/* ================================================
   MAYBANK → YNAB | Dark & Sleek Interface
   A cyberpunk-inspired financial tool aesthetic
   ================================================ */

/* Import JetBrains Mono for that terminal/hacker vibe */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ================================================
   CSS Custom Properties - Dark Theme (Default)
   ================================================ */
:root {
    /* Base colors - deep dark */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-elevated: #1a1a25;

    /* Accent - Electric cyan */
    --accent-primary: #00d4ff;
    --accent-secondary: #00ffcc;
    --accent-glow: rgba(0, 212, 255, 0.4);
    --accent-subtle: rgba(0, 212, 255, 0.1);

    /* Semantic colors */
    --success: #00ff88;
    --success-glow: rgba(0, 255, 136, 0.3);
    --error: #ff3366;
    --error-glow: rgba(255, 51, 102, 0.3);
    --warning: #ffaa00;
    --warning-glow: rgba(255, 170, 0, 0.3);
    --internal: #aa66ff;
    --internal-glow: rgba(170, 102, 255, 0.3);

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #555566;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Shadows & Glows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --glow-accent: 0 0 20px var(--accent-glow);
    --glow-success: 0 0 20px var(--success-glow);
    --glow-error: 0 0 20px var(--error-glow);

    /* Transaction colors */
    --inflow: var(--success);
    --outflow: var(--error);

    /* Timing */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ================================================
   Light Theme Override
   ================================================ */
[data-theme="light"] {
    --bg-primary: #f5f5f8;
    --bg-secondary: #eaeaef;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;

    --accent-primary: #0088cc;
    --accent-secondary: #00aa99;
    --accent-glow: rgba(0, 136, 204, 0.3);
    --accent-subtle: rgba(0, 136, 204, 0.08);

    --success: #00aa66;
    --success-glow: rgba(0, 170, 102, 0.2);
    --error: #dd2255;
    --error-glow: rgba(221, 34, 85, 0.2);
    --warning: #cc8800;
    --warning-glow: rgba(204, 136, 0, 0.2);
    --internal: #8844dd;
    --internal-glow: rgba(136, 68, 221, 0.2);

    --text-primary: #1a1a2e;
    --text-secondary: #555577;
    --text-muted: #8888aa;

    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
    --glow-accent: 0 0 15px var(--accent-glow);
}

/* ================================================
   Base Styles
   ================================================ */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

/* Subtle grid pattern overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--border-subtle) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

/* Gradient glow at top */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 300px;
    background: radial-gradient(ellipse at center top, var(--accent-subtle) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
    position: relative;
    z-index: 1;
}

/* ================================================
   Typography
   ================================================ */
h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* ================================================
   Header
   ================================================ */
header {
    padding: var(--space-xl) 0;
    margin-bottom: var(--space-md);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header-title {
    flex: 1;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
    font-weight: 400;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: var(--glow-accent);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.theme-toggle .toggle-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ================================================
   Sections (Cards)
   ================================================ */
section {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

/* Subtle top border accent */
section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.5;
}

section h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

section h2::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 2px;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* ================================================
   Settings Section
   ================================================ */
.token-input label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-group input {
    flex: 1;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--glow-accent);
    background: var(--bg-elevated);
}

.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

/* Connection status */
.connection-status {
    margin-top: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.connection-status.success {
    background: rgba(0, 255, 136, 0.08);
    border: 1px solid rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.connection-status.error {
    background: rgba(255, 51, 102, 0.08);
    border: 1px solid rgba(255, 51, 102, 0.2);
    color: var(--error);
}

.connection-status.info {
    background: var(--accent-subtle);
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: var(--accent-primary);
}

/* ================================================
   Buttons
   ================================================ */
.btn-primary,
.btn-secondary,
.btn-icon {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    border: none;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    box-shadow: var(--glow-accent);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    padding: var(--space-md);
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    min-width: 44px;
}

.btn-icon:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ================================================
   Drop Zone
   ================================================ */
.drop-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    background: var(--bg-secondary);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
    box-shadow: inset 0 0 30px var(--accent-subtle);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-md);
    background: var(--accent-subtle);
    border-radius: var(--radius-lg);
    color: var(--accent-primary);
}

.drop-icon svg {
    width: 32px;
    height: 32px;
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.drop-zone .hint {
    margin-top: 0;
}

/* ================================================
   File List
   ================================================ */
.file-list {
    margin-top: var(--space-md);
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: all var(--transition-fast);
}

.file-item:hover {
    border-color: var(--border-default);
}

.file-item .file-name {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.file-item .file-name svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.file-item .remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-item .remove-btn:hover {
    color: var(--error);
    background: rgba(255, 51, 102, 0.1);
}

.file-item .remove-btn svg {
    width: 18px;
    height: 18px;
}

/* ================================================
   Preview Stats
   ================================================ */
.preview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    text-align: center;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border-default);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--space-xs);
}

/* Stat variants */
.stat-warning {
    border-color: var(--warning);
    background: rgba(255, 170, 0, 0.08);
}

.stat-warning .stat-value {
    color: var(--warning);
}

.stat-internal {
    border-color: var(--internal);
    background: rgba(170, 102, 255, 0.08);
}

.stat-internal .stat-value {
    color: var(--internal);
}

.stat-preauth {
    border-color: var(--text-muted);
    background: rgba(85, 85, 102, 0.08);
}

.stat-preauth .stat-value {
    color: var(--text-muted);
}

.stat-selected {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
}

.stat-selected .stat-value {
    color: var(--accent-primary);
}

/* Inflow/Outflow stat cards */
.stat-inflow {
    border-color: var(--success);
    background: rgba(0, 255, 136, 0.05);
}

.stat-inflow .stat-value {
    color: var(--success);
    font-size: 1.25rem;
    font-family: var(--font-mono);
    font-weight: 600;
}

.stat-inflow .stat-prefix {
    font-size: 0.9rem;
    opacity: 0.7;
}

.stat-outflow {
    border-color: var(--error);
    background: rgba(255, 51, 102, 0.05);
}

.stat-outflow .stat-value {
    color: var(--error);
    font-size: 1.25rem;
    font-family: var(--font-mono);
    font-weight: 600;
}

.stat-outflow .stat-prefix {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Amount formatting in stat cards */
.stat-amount {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-amount .amount-sign {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.8;
}

.stat-amount .amount-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

/* ================================================
   Balance Summary
   ================================================ */
.balance-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
}

.balance-summary.balance-match {
    background: rgba(0, 255, 136, 0.05);
    border-color: rgba(0, 255, 136, 0.3);
}

.balance-summary.balance-mismatch-summary {
    background: rgba(255, 51, 102, 0.05);
    border-color: rgba(255, 51, 102, 0.3);
}

.balance-item {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.balance-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.balance-value {
    font-weight: 600;
    font-size: 0.9rem;
    font-family: var(--font-mono);
}

.balance-status {
    font-weight: 600;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.balance-ok {
    color: var(--success);
}

.balance-warning {
    color: var(--error);
}

/* ================================================
   Table
   ================================================ */
.table-container {
    overflow-x: auto;
    margin: var(--space-md) 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--bg-secondary);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Amount styling */
.amount-inflow {
    color: var(--inflow);
    font-weight: 600;
}

.amount-outflow {
    color: var(--outflow);
    font-weight: 600;
}

/* Balance columns */
.balance-cell {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

.balance-active {
    color: var(--text-primary);
    font-weight: 500;
}

.balance-inactive {
    opacity: 0.4;
}

.balance-mismatch-cell {
    color: var(--error);
    font-weight: 500;
}

.balance-mismatch {
    background: rgba(255, 51, 102, 0.05);
}

/* Row states */
.duplicate-row {
    background: rgba(85, 85, 102, 0.15);
}

.duplicate-row td {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.7;
}

.duplicate-row .info-cell {
    opacity: 1; /* Keep info cell fully visible for tooltip */
}

.duplicate-row .editable-field {
    text-decoration: line-through;
    opacity: 0.7;
}

.internal-row {
    background: rgba(170, 102, 255, 0.08);
    border-left: 3px solid var(--internal);
}

.internal-row td {
    color: var(--internal);
}

.internal-row td:first-child {
    padding-left: calc(var(--space-md) - 3px);
}

.internal-row .editable-field {
    color: var(--internal);
    opacity: 0.9;
}

/* Pre-auth: dashed border + orange/amber accent */
.preauth-row {
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(255, 170, 0, 0.03) 10px,
        rgba(255, 170, 0, 0.03) 20px
    );
    border-left: 3px dashed var(--warning);
}

.preauth-row td {
    color: var(--text-muted);
}

.preauth-row td:first-child {
    padding-left: calc(var(--space-md) - 3px);
}

.preauth-row .editable-field {
    color: var(--text-muted);
}

.unmatched-row {
    background: rgba(255, 170, 0, 0.08);
}

.unmatched-row .editable-field {
    border-color: var(--warning);
}

.excluded-row {
    background: rgba(85, 85, 102, 0.08);
}

.excluded-row td {
    color: var(--text-muted);
}

.excluded-row .editable-field {
    color: var(--text-muted);
}

/* ================================================
   Editable Fields
   ================================================ */
.editable-field {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    font-family: var(--font-mono);
    font-size: inherit;
    color: inherit;
    transition: all var(--transition-fast);
}

.editable-field:hover {
    border-color: var(--border-default);
    background: var(--bg-secondary);
}

.editable-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.editable-field::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.editable-field:disabled {
    color: var(--text-muted);
    background: transparent;
    cursor: not-allowed;
}

/* ================================================
   Info Cell & Tooltip
   ================================================ */
.info-cell {
    position: relative;
    width: 30px;
    min-width: 30px;
    text-align: center;
    padding: var(--space-xs) !important;
}

.info-icon {
    opacity: 0;
    cursor: help;
    transition: opacity var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.info-icon svg {
    width: 16px;
    height: 16px;
}

tr:hover .info-icon {
    opacity: 0.5;
}

.info-icon:hover {
    opacity: 1;
    color: var(--accent-primary);
}

.info-tooltip {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    max-width: 500px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    color: var(--text-primary) !important;
    opacity: 1 !important;
    /* Ensure tooltip is never affected by parent opacity */
    isolation: isolate;
}

.info-cell:hover .info-tooltip {
    display: block;
}

/* Ensure tooltip text is always readable regardless of row state */
.info-tooltip,
.duplicate-row .info-tooltip,
.internal-row .info-tooltip,
.preauth-row .info-tooltip,
.excluded-row .info-tooltip {
    opacity: 1 !important;
    color: var(--text-primary) !important;
    text-decoration: none !important;
}

/* ================================================
   Checkbox Column
   ================================================ */
.checkbox-col {
    width: 40px;
    min-width: 40px;
}

.checkbox-cell {
    text-align: center;
    padding: var(--space-sm) !important;
}

.transaction-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
    border-radius: var(--radius-sm);
}

.transaction-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

/* ================================================
   Edit Mode Controls
   ================================================ */
.edit-mode-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    justify-content: flex-end;
    grid-column: 1 / -1;
    margin-top: var(--space-sm);
}

.btn-edit-mode {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    border: none;
    transition: all var(--transition-base);
}

.btn-edit-mode:hover {
    box-shadow: var(--glow-accent);
}

.btn-select-all {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    transition: all var(--transition-base);
}

.btn-select-all:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ================================================
   Actions
   ================================================ */
.actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-lg);
}

/* ================================================
   Result Card
   ================================================ */
.result-card {
    text-align: center;
    padding: var(--space-2xl);
    border-radius: var(--radius-lg);
}

.result-card.success {
    background: rgba(0, 255, 136, 0.05);
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.result-card.error {
    background: rgba(255, 51, 102, 0.05);
    border: 1px solid rgba(255, 51, 102, 0.2);
}

.result-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-md);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-card.success .result-icon {
    background: rgba(0, 255, 136, 0.15);
    color: var(--success);
    box-shadow: var(--glow-success);
}

.result-card.error .result-icon {
    background: rgba(255, 51, 102, 0.15);
    color: var(--error);
    box-shadow: var(--glow-error);
}

.result-icon svg {
    width: 32px;
    height: 32px;
}

.result-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.result-details {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-details p {
    margin: var(--space-xs) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.result-details p svg {
    flex-shrink: 0;
}

.result-details .error-detail {
    font-size: 0.8rem;
    color: var(--error);
    padding: var(--space-sm);
    background: rgba(255, 51, 102, 0.1);
    border-radius: var(--radius-sm);
    margin-top: var(--space-sm);
}

/* ================================================
   Loading Overlay
   ================================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

[data-theme="light"] .loading-overlay {
    background: rgba(245, 245, 248, 0.95);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: var(--glow-accent);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-text {
    margin-top: var(--space-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ================================================
   Responsive Design
   ================================================ */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    header {
        padding: var(--space-lg) 0;
    }

    header h1 {
        font-size: 1.5rem;
    }

    section {
        padding: var(--space-md);
    }

    .input-group {
        flex-wrap: wrap;
    }

    .input-group input {
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

    .actions button {
        width: 100%;
    }

    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: var(--space-sm);
    }

    .preview-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .drop-zone {
        padding: var(--space-xl);
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: var(--space-md);
    }

    .theme-toggle {
        align-self: flex-start;
    }

    .preview-stats {
        grid-template-columns: 1fr;
    }
}

/* ================================================
   Scrollbar Styling
   ================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg-secondary);
}

/* ================================================
   Selection Styling
   ================================================ */
::selection {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

/* ================================================
   Focus Visible for Accessibility
   ================================================ */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--accent-primary);
}
