/* =============================================
   CONCOR V1.0 — DESIGN SYSTEM
   ============================================= */

/* CSS Variables */
:root {
    /* Backgrounds */
    --bg-primary: #08080f;
    --bg-secondary: #0d0d1a;
    --bg-tertiary: #141424;
    --bg-card: #10101e;
    --bg-card-hover: #161628;
    --bg-input: #0d0d1a;

    /* Text */
    --text-primary: #f0f2f8;
    --text-secondary: #8892aa;
    --text-muted: #525d75;
    --text-inverse: #08080f;

    /* Accent — Indigo */
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-light: rgba(99, 102, 241, 0.12);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    /* Semantic Colors */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.1);
    --processing: #a855f7;
    --processing-bg: rgba(168, 85, 247, 0.1);

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.07);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-accent: rgba(99, 102, 241, 0.4);

    /* Spacing */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-accent: 0 4px 20px rgba(99,102,241,0.3);

    /* Typography */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --sidebar-width: 248px;

    /* Legacy aliases for compatibility */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --bg-primary-compat: var(--bg-primary);
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* =============================================
   LAYOUT
   ============================================= */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: var(--sp-6) var(--sp-5);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    user-select: none;
}

.logo-icon-wrap {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-accent);
}

.logo-icon-wrap svg {
    width: 20px;
    height: 20px;
    color: white;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.logo-text-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo-version {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Nav */
.nav-menu {
    flex: 1;
    padding: var(--sp-4) var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: var(--sp-3) var(--sp-3) var(--sp-1);
    margin-top: var(--sp-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all 0.18s ease;
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent-secondary);
    border-left: 2px solid var(--accent-primary);
    padding-left: calc(var(--sp-3) - 2px);
}

.nav-item.active .nav-icon svg { color: var(--accent-secondary); }

.nav-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-label { flex: 1; }

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.queue-status {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
    animation: pulse-dot 2.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

.status-text { font-weight: 500; }

/* =============================================
   MAIN CONTENT
   ============================================= */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--sp-8) var(--sp-10);
    max-width: 1440px;
    min-height: 100vh;
}

.main-content.full-width {
    margin-left: 0;
}

body.no-sidebar .main-content {
    margin-left: 0;
}

/* =============================================
   PAGE HEADER
   ============================================= */

.page-header {
    margin-bottom: var(--sp-8);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-6);
    flex-wrap: wrap;
}

.page-header-content { flex: 1; min-width: 0; }

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: var(--sp-1);
    font-size: 0.9rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-shrink: 0;
}

/* =============================================
   KPI / STAT CARDS
   ============================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-8);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5) var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    transition: border-color 0.2s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.stat-icon svg {
    width: 22px; height: 22px;
    fill: none; stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
    color: var(--text-secondary);
}

.stat-content { display: flex; flex-direction: column; min-width: 0; }

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: var(--sp-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card.stat-success .stat-icon { background: var(--success-bg); }
.stat-card.stat-success .stat-icon svg { color: var(--success); }
.stat-card.stat-success .stat-value { color: var(--success); }

.stat-card.stat-warning .stat-icon { background: var(--warning-bg); }
.stat-card.stat-warning .stat-icon svg { color: var(--warning); }
.stat-card.stat-warning .stat-value { color: var(--warning); }

.stat-card.stat-danger .stat-icon { background: var(--error-bg); }
.stat-card.stat-danger .stat-icon svg { color: var(--error); }
.stat-card.stat-danger .stat-value { color: var(--error); }

.stat-card.stat-info .stat-icon { background: var(--info-bg); }
.stat-card.stat-info .stat-icon svg { color: var(--info); }
.stat-card.stat-info .stat-value { color: var(--info); }

.stat-card.stat-processing .stat-icon { background: var(--processing-bg); }
.stat-card.stat-processing .stat-icon svg { color: var(--processing); }

.stat-card.stat-clickable { cursor: pointer; }

/* =============================================
   ACTION CARDS
   ============================================= */

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-4);
}

.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-6) var(--sp-5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

.action-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-card.action-primary {
    border-color: var(--border-accent);
    background: var(--accent-light);
    color: var(--accent-secondary);
}

.action-card.action-primary:hover {
    background: rgba(99,102,241,0.18);
    box-shadow: var(--shadow-accent);
}

.action-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.action-icon svg {
    width: 22px; height: 22px;
    fill: none; stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
}

.action-card.action-primary .action-icon {
    background: var(--accent-light);
}

.action-label { font-size: 0.82rem; line-height: 1.3; }

/* =============================================
   SECTION
   ============================================= */

.section { margin-bottom: var(--sp-10); }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
    gap: var(--sp-4);
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}

.btn svg {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.12);
}

.btn-outline {
    background: transparent;
    color: var(--accent-secondary);
    border-color: var(--border-accent);
}
.btn-outline:hover {
    background: var(--accent-light);
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(34,197,94,0.3);
}
.btn-success:hover {
    background: rgba(34,197,94,0.18);
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(245,158,11,0.3);
}
.btn-warning:hover { background: rgba(245,158,11,0.18); }

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.18); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.78rem; }
.btn-lg { padding: 0.65rem 1.4rem; font-size: 0.9rem; }

.btn-back {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    padding: var(--sp-1) 0;
}
.btn-back:hover { color: var(--accent-secondary); }

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

/* =============================================
   BADGES
   ============================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-info    { background: var(--info-bg);     color: var(--info); }
.badge-processing { background: var(--processing-bg); color: var(--processing); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

.badge-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* =============================================
   TABLES
   ============================================= */

.data-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

.data-table td { font-size: 0.875rem; vertical-align: middle; }

.doc-link {
    color: var(--text-primary);
    font-weight: 600;
    transition: color 0.15s;
}
.doc-link:hover { color: var(--accent-secondary); }

/* Legacy table compat */
.documents-table { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.documents-table table { width: 100%; border-collapse: collapse; }
.documents-table th, .documents-table td { padding: 0.75rem 1rem; text-align: left; }
.documents-table th { background: var(--bg-tertiary); font-weight: 600; color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; }
.documents-table tr:not(:last-child) td { border-bottom: 1px solid var(--border-subtle); }

/* =============================================
   PROGRESS BAR
   ============================================= */

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.progress-fill.progress-animated {
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #6366f1);
    background-size: 200% 100%;
    animation: progress-shimmer 2s linear infinite;
}

@keyframes progress-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.progress-bar-wrapper {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

/* =============================================
   DOCUMENT CARDS (GRID)
   ============================================= */

.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-5);
}

.document-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    position: relative;
}

.document-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.document-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-3);
}

.document-card-header .badge {
    flex-shrink: 0;
    margin-top: 2px;
}

.document-title { font-size: 0.95rem; }
.document-title a { color: var(--text-primary); font-weight: 600; }
.document-title a:hover { color: var(--accent-secondary); }

.document-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.document-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.document-stats {
    display: flex;
    gap: var(--sp-4);
}

.doc-stat {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.doc-stat svg {
    width: 14px; height: 14px;
    fill: none; stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    opacity: 0.6;
}

.doc-stat-value { font-weight: 700; color: var(--text-primary); }

.document-progress { margin-top: var(--sp-1); }

.progress-percent {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: block;
    text-align: right;
    margin-top: 4px;
}

.document-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    padding-top: var(--sp-2);
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

/* Document Menu (3-dot) */
.document-menu { position: relative; }

.menu-trigger {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: all 0.15s;
    line-height: 1;
}

.menu-trigger:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 170px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    overflow: hidden;
    animation: dropdown-appear 0.12s ease;
}

@keyframes dropdown-appear {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.menu-dropdown.show { display: block; }

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: 0.6rem 1rem;
    text-align: left;
    background: transparent;
    border: none;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease;
}

.menu-item svg {
    width: 14px; height: 14px;
    fill: none; stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    color: var(--text-muted);
    flex-shrink: 0;
}

.menu-item:hover { background: var(--bg-tertiary); }
.menu-item-danger { color: var(--error); }
.menu-item-danger svg { color: var(--error); }
.menu-item-danger:hover { background: var(--error-bg); }

.menu-divider {
    margin: 0.25rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.menu-form { margin: 0; }

/* =============================================
   ALERTS
   ============================================= */

.alert {
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-5);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    border: 1px solid transparent;
}

.alert svg {
    width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(34,197,94,0.2); }
.alert-error   { background: var(--error-bg);   color: var(--error);   border-color: rgba(239,68,68,0.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(245,158,11,0.2); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: rgba(56,189,248,0.2); }

/* =============================================
   EMPTY STATE
   ============================================= */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-12) var(--sp-8);
    text-align: center;
    gap: var(--sp-4);
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-xl);
}

.empty-icon {
    width: 64px; height: 64px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
}

.empty-icon svg {
    width: 30px; height: 30px;
    fill: none; stroke: var(--text-muted);
    stroke-width: 1.5;
    stroke-linecap: round; stroke-linejoin: round;
}

.empty-state h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    max-width: 340px;
    line-height: 1.6;
}

/* =============================================
   FORMS
   ============================================= */

.form-group {
    margin-bottom: var(--sp-5);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}

.form-control {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.18s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 100px; }

/* =============================================
   STATS DASHBOARD (Document Detail)
   ============================================= */

.stats-dashboard {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5) var(--sp-6);
    margin-bottom: var(--sp-6);
}

.stats-row {
    display: flex;
    gap: var(--sp-6);
    flex-wrap: wrap;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    text-align: center;
    cursor: default;
}

.stat-item .stat-icon { font-size: 1.25rem; }
.stat-item .stat-value { font-size: 1.4rem; font-weight: 700; font-family: var(--font-mono); }
.stat-item .stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.stat-item.stat-success .stat-value { color: var(--success); }
.stat-item.stat-warning .stat-value { color: var(--warning); }
.stat-item.stat-danger  .stat-value { color: var(--error); }
.stat-item.stat-info    .stat-value { color: var(--info); }

.stat-item.stat-clickable:hover .stat-value { text-decoration: underline; }

/* =============================================
   QUICK ACTIONS BAR
   ============================================= */

.quick-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

/* =============================================
   PROCESSING PANEL
   ============================================= */

.processing-section .section-header {
    margin-bottom: var(--sp-4);
}

.processing-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
}

.auto-processing-notice {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4);
    background: var(--accent-light);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-5);
    font-size: 0.875rem;
    color: var(--accent-secondary);
}

.notice-icon { font-size: 1rem; flex-shrink: 0; }
.notice-text { line-height: 1.5; }

.processing-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.processing-log-wrap {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.processing-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
}

.processing-log {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: var(--sp-4);
    max-height: 260px;
    overflow-y: auto;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.processing-log::-webkit-scrollbar { width: 6px; }
.processing-log::-webkit-scrollbar-track { background: transparent; }
.processing-log::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
}

.status-processing {
    background: var(--processing-bg);
    color: var(--processing);
}

.status-idle {
    background: var(--success-bg);
    color: var(--success);
}

.status-error {
    background: var(--error-bg);
    color: var(--error);
}

/* Time estimate / batch info */
#time-estimate, #batch-info, #elapsed-time {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

#time-estimate strong, #batch-info strong {
    color: var(--text-primary);
}

/* =============================================
   IMAGES GALLERY
   ============================================= */

.images-section { margin-top: var(--sp-8); }

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--sp-4);
}

.image-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s ease;
}

.image-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.image-card.processed { border-color: rgba(34,197,94,0.3); }
.image-card.error     { border-color: rgba(239,68,68,0.3); }
.image-card.duplicate { border-color: rgba(245,158,11,0.3); }
.image-card.pending   { border-color: var(--border-color); }

.image-thumb {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    display: block;
    background: var(--bg-tertiary);
}

.image-info {
    padding: var(--sp-2) var(--sp-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.image-page {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* =============================================
   PROBLEMS PANEL
   ============================================= */

.problems-panel {
    position: fixed;
    top: 0; right: 0;
    width: 480px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.problems-panel.show { transform: translateX(0); }

.problems-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.problems-panel-title {
    font-size: 1rem;
    font-weight: 600;
}

.problems-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-5) var(--sp-6);
}

.problem-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    margin-bottom: var(--sp-3);
}

.problem-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-2);
}

.problem-page {
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.problem-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =============================================
   TRANSCRIPTION
   ============================================= */

.transcription-section { margin-top: var(--sp-8); }

.transcription-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-6) var(--sp-8);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow-y: auto;
}

.transcription-content h2,
.transcription-content h3 {
    font-family: var(--font-sans);
    color: var(--text-primary);
    margin: var(--sp-5) 0 var(--sp-2);
}

/* =============================================
   SEARCH
   ============================================= */

.search-bar {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
}

.search-input-wrap {
    flex: 1;
    position: relative;
}

.search-input-icon {
    position: absolute;
    left: var(--sp-4);
    top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-icon svg {
    width: 16px; height: 16px;
    fill: none; stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

.search-input {
    width: 100%;
    padding: var(--sp-3) var(--sp-4) var(--sp-3) 2.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.search-result {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--sp-4) var(--sp-5);
    margin-bottom: var(--sp-3);
    transition: border-color 0.15s;
}

.search-result:hover { border-color: var(--border-accent); }

.search-result-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: var(--sp-2);
}

.search-result-snippet {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.search-result-snippet mark {
    background: rgba(99,102,241,0.3);
    color: var(--accent-secondary);
    border-radius: 3px;
    padding: 0 2px;
}

/* =============================================
   UPLOAD ZONE
   ============================================= */

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--sp-12) var(--sp-8);
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.upload-icon {
    width: 60px; height: 60px;
    margin: 0 auto var(--sp-4);
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
}

.upload-icon svg {
    width: 28px; height: 28px;
    fill: none; stroke: var(--text-muted);
    stroke-width: 1.5;
    stroke-linecap: round; stroke-linejoin: round;
}

.upload-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: var(--sp-2);
}

.upload-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--sp-5);
}

/* =============================================
   CATEGORIES / PROJECTS
   ============================================= */

.categories-grid, .projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-5);
}

.category-card, .project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    transition: all 0.2s ease;
}

.category-card:hover, .project-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* =============================================
   MODALS
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--sp-8);
    max-width: 560px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modal-appear 0.2s ease;
}

@keyframes modal-appear {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* =============================================
   SCROLLBAR
   ============================================= */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-color); }

/* =============================================
   UTILITIES
   ============================================= */

.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error   { color: var(--error); }
.text-accent  { color: var(--accent-secondary); }
.text-mono    { font-family: var(--font-mono); }

.font-mono    { font-family: var(--font-mono); }
.font-bold    { font-weight: 700; }
.font-semibold { font-weight: 600; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }

.w-full { width: 100%; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* =============================================
   WELCOME SCREEN (sin DB)
   ============================================= */

body.no-sidebar {
    background: radial-gradient(ellipse at 60% 0%, rgba(99,102,241,0.08) 0%, transparent 60%),
                var(--bg-primary);
}

.welcome-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--sp-12) var(--sp-8);
}

.welcome-hero {
    text-align: center;
    padding: var(--sp-12) 0 var(--sp-10);
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 16px;
    background: var(--accent-light);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-secondary);
    margin-bottom: var(--sp-6);
    letter-spacing: 0.05em;
}

.welcome-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: var(--sp-5);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto var(--sp-8);
    line-height: 1.7;
}

.setup-steps {
    display: grid;
    gap: var(--sp-4);
    margin-top: var(--sp-8);
}

.setup-step {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5) var(--sp-6);
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
}

.setup-step-num {
    width: 32px; height: 32px;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.setup-step-title { font-weight: 600; margin-bottom: 4px; }
.setup-step-desc { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

code, .code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--accent-secondary);
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 1024px) {
    .main-content { padding: var(--sp-6) var(--sp-6); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; padding: var(--sp-5) var(--sp-4); }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .documents-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .problems-panel { width: 100%; }
}

/* =============================================
   CHECKPOINT INFO
   ============================================= */

.checkpoint-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* =============================================
   PROCESSING STATS
   ============================================= */

.processing-stats {
    display: flex;
    gap: var(--sp-6);
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.processing-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.processing-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.processing-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
