/* =========================================================
   SRR Analytics — design language mirrored from tools.ramazanov.kz/timesheet
   Slate-50 canvas, white surfaces, teal accent, Inter UI.
   ========================================================= */

:root {
    /* ── accent (teal — KPO) ── */
    --accent:        #0098b5;
    --accent-h:      #007a94;
    --accent-soft:   #e6f5f8;
    --accent-ring:   rgb(0 152 181 / 0.30);
    --accent-faint:  rgb(0 152 181 / 0.12);
    --accent-muted:  rgb(0 152 181 / 0.40);

    /* ── surfaces ── */
    --bg:            #f8fafc;     /* slate-50 — canvas */
    --surface:       #ffffff;     /* white — cards */
    --surface-2:     #f1f5f9;     /* slate-100 — hover/header bg */
    --surface-3:     #e2e8f0;     /* slate-200 — deeper bg */

    /* ── borders ── */
    --border:        #e2e8f0;     /* slate-200 */
    --border-2:      #cbd5e1;     /* slate-300 */

    /* ── text ── */
    --text:          #0f172a;     /* slate-900 */
    --text-2:        #475569;     /* slate-600 */
    --text-3:        #94a3b8;     /* slate-400 */

    /* ── semantic ── */
    --warn:          #f59e0b;
    --warn-soft:     #fef3c7;
    --warn-line:     #fde68a;
    --danger:        #dc2626;
    --danger-soft:   #fee2e2;
    --danger-line:   #fecaca;
    --success:       #10b981;
    --success-soft:  #d1fae5;
    --success-line:  #b7e4c7;
    --info:          #3b82f6;
    --info-soft:     #dbeafe;
    --info-line:     #bfdbfe;

    /* ── type scale ── */
    --fs-xs:    11px;
    --fs-sm:    12px;
    --fs-base:  13px;
    --fs-md:    14px;
    --fs-lg:    18px;
    --fs-xl:    24px;
    --fs-2xl:   32px;

    --fw-regular: 400;
    --fw-medium:  500;
    --fw-semi:    600;
    --fw-bold:    700;

    /* ── spacing ── */
    --sp-1:  4px;
    --sp-2:  8px;
    --sp-3:  12px;
    --sp-4:  16px;
    --sp-5:  20px;
    --sp-6:  24px;
    --sp-8:  32px;
    --sp-10: 40px;

    /* ── shape ── */
    --radius:    8px;
    --radius-lg: 12px;
    --radius-sm: 5px;

    /* ── shadow ── */
    --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.04);
    --shadow:    0 1px 3px rgb(15 23 42 / 0.06), 0 1px 2px rgb(15 23 42 / 0.04);
    --shadow-lg: 0 10px 24px rgb(15 23 42 / 0.10), 0 2px 6px rgb(15 23 42 / 0.05);

    /* ── motion ── */
    --t: 150ms cubic-bezier(.4, 0, .2, 1);

    /* ── layout ── */
    --sidebar-w: 240px;

    /* ── fonts ── */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

/* ─── reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* tabular numerics everywhere numeric data lives */
.mono, table td, table th, .metric-value, .stat-num, .num,
.step-meta, .tile-meta, .stage-meta {
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
}
.mono, .num { font-family: var(--font-mono); }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

::selection { background: var(--accent-soft); color: var(--text); }

/* headings */
h1 { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.2; letter-spacing: -0.02em; color: var(--text); }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-semi); line-height: 1.25; letter-spacing: -0.015em; color: var(--text); }
h3 { font-size: var(--fs-md); font-weight: var(--fw-semi); line-height: 1.3; color: var(--text); }
h4 { font-size: var(--fs-base); font-weight: var(--fw-semi); line-height: 1.3; color: var(--text); }

/* =========================================================
   APP SHELL — sidebar + main
   ========================================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* topbar in the index page is sticky at top of main; on settings/wps-review
   it sits as a banner. We unify with a "topbar" style. */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 52px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}
.topbar-brand { display: flex; align-items: center; gap: var(--sp-3); }
.topbar-mark {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), var(--accent-h));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700; font-size: 11px;
    letter-spacing: 0.4px;
    box-shadow: 0 2px 6px rgb(0 152 181 / 0.20);
}
.topbar-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    color: var(--text);
    letter-spacing: -0.01em;
}
.topbar-title-sub {
    font-size: var(--fs-xs);
    color: var(--text-3);
    font-weight: var(--fw-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 6px;
}
.topbar-center {
    display: flex; align-items: center; gap: var(--sp-3);
    flex: 1; justify-content: center;
    max-width: 720px; margin: 0 24px;
}
.topbar-search {
    width: 100%; max-width: 480px;
    height: 32px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px 0 32px;
    font-size: var(--fs-base);
    color: var(--text-2);
    cursor: pointer;
    position: relative;
    display: flex; align-items: center; justify-content: space-between;
    transition: background var(--t), border-color var(--t);
    user-select: none;
}
.topbar-search:hover { background: var(--surface); border-color: var(--border-2); }
.topbar-search::before {
    content: '⌕';
    position: absolute;
    left: 10px;
    color: var(--text-3);
    font-size: 15px;
}
.topbar-search-placeholder { color: var(--text-3); flex: 1; }

.kbd {
    display: inline-flex; align-items: center; gap: 2px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    line-height: 1.4;
    font-weight: var(--fw-medium);
}

.topbar-actions { display: flex; align-items: center; gap: 4px; }

/* ============================================================
   ROLE SWITCHER (topbar "View as")
   ============================================================ */
.role-switcher { position: relative; }
.role-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    height: 32px; padding: 0 10px 0 4px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    transition: all var(--t);
    font-family: inherit;
}
.role-trigger:hover { border-color: var(--border-2); background: var(--surface-2); }

/* tinted background per role */
.role-trigger.role-admin {
    background: var(--accent-soft);
    border-color: rgb(0 152 181 / 0.30);
}
.role-trigger.role-admin:hover { background: #d6f0f5; border-color: var(--accent); }
.role-trigger.role-expert {
    background: var(--warn-soft);
    border-color: var(--warn-line);
}
.role-trigger.role-expert:hover { background: #fce8c6; border-color: var(--warn); }
.role-trigger.role-spe {
    background: rgb(124 58 237 / 0.10);
    border-color: rgb(124 58 237 / 0.30);
}
.role-trigger.role-spe:hover { background: rgb(124 58 237 / 0.16); border-color: var(--purple); }

.role-badge {
    display: inline-flex; align-items: center; justify-content: center;
    height: 22px; padding: 0 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    color: #fff;
    flex-shrink: 0;
    line-height: 1;
}
.role-trigger.role-admin  .role-badge { background: var(--accent); }
.role-trigger.role-expert .role-badge { background: var(--warn); }
.role-trigger.role-spe    .role-badge { background: var(--purple); }

.role-dot {  /* legacy compat with markup that still uses dots */
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-3);
    flex-shrink: 0;
}
.role-dot.admin  { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.role-dot.expert { background: var(--warn);   box-shadow: 0 0 0 3px var(--warn-soft); }
.role-label { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.role-eyebrow {
    font-size: 9.5px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--fw-semi);
}
.role-name { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--text); }
.role-caret { color: var(--text-3); font-size: 10px; }

.role-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 100;
}
.role-section {
    font-size: 10.5px;
    text-transform: uppercase;
    color: var(--text-3);
    font-weight: var(--fw-semi);
    letter-spacing: 0.05em;
    padding: 8px 10px 4px;
}
.role-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--text);
    transition: background var(--t);
}
.role-item:hover { background: var(--surface-2); }
.role-item.active { background: var(--accent-soft); }
.ri-ic {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: var(--fw-bold);
    color: #fff;
    flex-shrink: 0;
}
.ri-ic.admin  { background: linear-gradient(135deg, var(--accent), var(--accent-h)); }
.ri-ic.expert { background: linear-gradient(135deg, #f59e0b, #b45309); }
.ri-ic.spe    { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.ri-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ri-name { font-size: var(--fs-base); font-weight: var(--fw-semi); color: var(--text); }
.ri-sub  { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-check { color: var(--accent); font-weight: var(--fw-bold); }
.role-empty {
    padding: 12px 14px;
    font-size: var(--fs-sm);
    color: var(--text-3);
    text-align: center;
    line-height: 1.45;
}
.role-empty a { font-weight: var(--fw-semi); }
.icon-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 16px;
    transition: all var(--t);
    text-decoration: none;
}
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}
.sb-head {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sb-head .topbar-mark { width: 34px; height: 34px; font-size: 12px; }
.sb-head-text { min-width: 0; line-height: 1.2; }
.sb-head-text .title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    letter-spacing: -0.01em;
    color: var(--text);
}
.sb-head-text .subtitle {
    font-size: var(--fs-xs);
    color: var(--text-3);
    font-weight: var(--fw-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 1px;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 8px;
}
.sidebar-group:first-of-type { padding-top: 14px; }
.sidebar-group + .sidebar-group { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; }
.sidebar-group-label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    padding: 4px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    padding-left: 14px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--t);
    width: 100%;
    text-align: left;
    position: relative;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: var(--fw-semi);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-muted);
    animation: nav-rail-pulse 2.6s ease-in-out infinite;
}
@keyframes nav-rail-pulse {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .nav-item.active::before { animation: none; opacity: 1; }
}
.nav-item .ic {
    display: inline-flex;
    width: 16px; height: 16px;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    flex-shrink: 0;
    color: var(--text-2);
}
.nav-item.active .ic { opacity: 1; color: var(--accent); }
.nav-item .nav-meta {
    margin-left: auto;
    font-size: var(--fs-xs);
    font-family: var(--font-mono);
    color: var(--text-3);
}
.nav-item.active .nav-meta { color: var(--accent); }
.nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    padding: 1px 6px;
    font-weight: var(--fw-semi);
    line-height: 1.4;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border);
    font-size: var(--fs-xs);
    color: var(--text-3);
    line-height: 1.5;
    text-align: center;
}
.sidebar-footer strong { color: var(--text-2); font-weight: var(--fw-semi); display: block; margin-bottom: 2px; }

/* =========================================================
   MAIN
   ========================================================= */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 1000px 500px at top right, var(--accent-soft) 0%, transparent 65%),
        var(--bg);
}

/* status bar — sits just below sticky topbar */
.status-bar {
    position: sticky;
    top: 52px;
    z-index: 20;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 18px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}
.status-bar-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--text);
    letter-spacing: -0.025em;
    line-height: 1.2;
}
.status-bar-sub {
    font-size: var(--fs-base);
    color: var(--text-2);
    margin-top: 2px;
}
.status-bar-right {
    display: flex; align-items: center; gap: var(--sp-2);
    flex-wrap: wrap;
}

.main-content {
    padding: 24px 32px 80px;
    width: 100%;
}

/* container used by settings.html / wps_review.html */
.container {
    width: 100%;
    padding: 24px 32px 80px;
}

/* old app-container (index used to use it; safe fallback) */
.app-container {
    width: 100%;
    padding: 24px 32px 80px;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-2);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--t);
    white-space: nowrap;
    font-family: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary,
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgb(0 152 181 / 0.20);
}
.btn.primary:hover,
.btn-primary:hover {
    background: var(--accent-h);
    border-color: var(--accent-h);
    color: #fff;
}

.btn.green,
.btn-green {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn.green:hover,
.btn-green:hover { background: #0d9668; border-color: #0d9668; color: #fff; }

.btn.danger,
.btn-danger {
    color: var(--danger);
    border-color: var(--danger-line);
    background: var(--surface);
}
.btn.danger:hover,
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.btn.ghost,
.btn-outline {
    background: transparent;
    border-color: transparent;
    color: var(--text-2);
}
.btn.ghost:hover,
.btn-outline:hover { background: var(--surface-2); color: var(--text); }

.btn.sm,
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }

.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.icon.sm { width: 28px; }

.btn.xs {
    height: 22px; padding: 0 8px;
    font-size: 11px;
}

.btn-save {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-save:hover { background: var(--accent-h); color: #fff; border-color: var(--accent-h); }

/* =========================================================
   TABS (legacy on index workflow + settings)
   ========================================================= */
.tab-bar {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    padding: 0 2px;
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab-btn {
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: color var(--t), border-color var(--t);
    position: relative;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    font-family: inherit;
}
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: var(--fw-semi);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* settings.html uses .tabs / .tab / .section */
.tabs {
    display: flex; flex-wrap: wrap; gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    padding: 9px 13px;
    color: var(--text-2);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--t), border-color var(--t);
    white-space: nowrap;
}
.tab:hover:not(.active) { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: var(--fw-semi);
}
.section { display: none; }
.section.active { display: block; }

/* =========================================================
   PIPELINE — STAGE STEPPER
   ========================================================= */
.stage-stepper {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--sp-2);
    margin-bottom: var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
}
.stage-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    padding: 2px 4px;
}
.stage-cell:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -4px; top: 8px;
    width: 4px; height: 2px;
    background: var(--border);
    border-radius: 2px;
}
.stage-bar {
    height: 4px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
    position: relative;
}
.stage-bar > i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--text-3);
    border-radius: 999px;
    transition: width 220ms ease;
}
.stage-cell.done    .stage-bar > i { width: 100%; background: var(--success); }
.stage-cell.active  .stage-bar > i { width: 55%;  background: var(--accent);  animation: stagePulse 1.6s ease-in-out infinite; }
.stage-cell.pending .stage-bar > i { width: 0; }
@keyframes stagePulse { 0%,100%{opacity:1} 50%{opacity:.55} }

.stage-cell .stage-no {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-3);
    font-weight: var(--fw-semi);
    letter-spacing: 0.4px;
}
.stage-cell.done   .stage-no { color: var(--success); }
.stage-cell.active .stage-no { color: var(--accent); }
.stage-cell .stage-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    color: var(--text-2);
    letter-spacing: -0.01em;
}
.stage-cell.active .stage-title { color: var(--text); }
.stage-cell.pending .stage-title { color: var(--text-3); }
.stage-cell .stage-meta {
    font-size: var(--fs-xs);
    color: var(--text-3);
    font-family: var(--font-mono);
    margin-top: -2px;
}

/* =========================================================
   PIPELINE — ZONES (re-themed)
   ========================================================= */
.zone {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--sp-3);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.zone-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.zone-head.no-border { border-bottom: none; }
.zone-no {
    width: 26px; height: 26px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: var(--fw-bold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.zone.done   .zone-no { background: var(--success-soft); color: #047857; border-color: var(--success-line); }
.zone.active .zone-no { background: var(--accent-soft);  color: var(--accent); border-color: rgb(0 152 181 / 0.20); }

.zone-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    color: var(--text);
    flex: 1;
    display: flex; align-items: baseline; gap: 10px;
    letter-spacing: -0.01em;
}
.zone-title .zone-sub {
    font-size: var(--fs-sm);
    font-weight: var(--fw-regular);
    color: var(--text-3);
}
.zone-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.zone-body {
    padding: 16px 18px;
}
.zone-body.empty {
    text-align: center;
    color: var(--text-3);
    padding: 28px 18px;
}

/* =========================================================
   FILE TILES (loaded / waiting / required)
   ========================================================= */
.file-grid {
    display: grid;
    gap: var(--sp-2);
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.file-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color var(--t), background var(--t), transform var(--t);
    position: relative;
}
.file-tile:hover { border-color: var(--border-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.file-tile.loaded {
    border-color: var(--success-line);
    background: var(--success-soft);
}
.file-tile.loaded:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.file-tile.waiting { border-style: dashed; background: var(--surface-2); }
.file-tile.required { border-color: var(--warn-line); background: var(--warn-soft); }
.file-tile .tile-icon {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-3);
}
.file-tile.loaded .tile-icon { color: #047857; border-color: var(--success-line); background: #fff; }
.file-tile.required .tile-icon { color: #b45309; border-color: var(--warn-line); background: #fff; }
.file-tile .tile-body { flex: 1; min-width: 0; }
.file-tile .tile-label {
    font-size: var(--fs-xs);
    color: var(--text-3);
    font-weight: var(--fw-medium);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.file-tile.loaded .tile-label { color: #047857; }
.file-tile .tile-name {
    font-size: var(--fs-base);
    font-weight: var(--fw-semi);
    color: var(--text);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-tile .tile-meta {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-2);
}
.file-tile.loaded .tile-meta { color: #047857; }
.file-tile .tile-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.file-tile .tile-x {
    color: var(--text-3);
    background: transparent;
    border: none;
    cursor: pointer;
    width: 22px; height: 22px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: all var(--t);
}
.file-tile .tile-x:hover { color: var(--danger); background: var(--surface); }

/* =========================================================
   DROPZONES
   ========================================================= */
.dropzone-mini {
    border: 1.5px dashed var(--border-2);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    text-align: center;
    cursor: pointer;
    color: var(--text-2);
    font-size: var(--fs-sm);
    background: var(--surface);
    transition: all var(--t);
    flex: 1;
}
.dropzone-mini:hover, .dropzone-mini.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}
.dropzone-mini strong { font-weight: var(--fw-semi); color: var(--text-2); }
.dropzone-mini input[type="file"] { display: none; }

.dropzone-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: 32px 20px;
    border: 1.5px dashed var(--border-2);
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
    cursor: pointer;
    transition: all var(--t);
}
.dropzone-hero:hover, .dropzone-hero.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dropzone-hero .hero-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    border: 1px solid rgb(0 152 181 / 0.20);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.dropzone-hero .hero-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    color: var(--text);
    letter-spacing: -0.01em;
}
.dropzone-hero .hero-sub {
    font-size: var(--fs-sm);
    color: var(--text-3);
}
.dropzone-hero input[type="file"] { display: none; }

/* legacy upload zone (kept for safety) */
.upload-zone {
    border: 1.5px dashed var(--border-2);
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
    cursor: pointer;
    transition: all var(--t);
    background: var(--surface);
    margin-top: 8px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.upload-zone input[type="file"] { display: none; }
.upload-zone-text { font-size: var(--fs-sm); color: var(--text-2); }
.upload-zone-text strong { color: var(--accent); font-weight: var(--fw-semi); }

/* =========================================================
   CTA / READY CHIPS
   ========================================================= */
.cta-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.cta-block .cta-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    color: var(--text);
    margin-bottom: 4px;
}
.cta-block .cta-sub {
    font-size: var(--fs-sm);
    color: var(--text-3);
    margin-bottom: 18px;
}
.ready-chips {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 6px; margin-bottom: 14px;
}
.ready-chip {
    font-size: var(--fs-xs);
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-3);
    display: inline-flex; align-items: center; gap: 5px;
    font-weight: var(--fw-medium);
}
.ready-chip.ok { background: var(--success-soft); color: #047857; border-color: var(--success-line); }
.ready-chip .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-3);
}
.ready-chip.ok .dot { background: var(--success); }

/* =========================================================
   STATUS PILL
   ========================================================= */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px 3px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: var(--fs-xs);
    color: var(--text-2);
    font-weight: var(--fw-medium);
}
.status-pill .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-3);
}
.status-pill.ok    { color: #047857; border-color: var(--success-line); background: var(--success-soft); }
.status-pill.ok    .dot { background: var(--success); }
.status-pill.warn  { color: #b45309; border-color: var(--warn-line);   background: var(--warn-soft); }
.status-pill.warn  .dot { background: var(--warn); }
.status-pill.empty .dot { background: var(--text-3); }

/* =========================================================
   PANELS, METRICS  (legacy analysis-panel + metric-box)
   ========================================================= */
.analysis-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: var(--sp-5);
    box-shadow: var(--shadow-sm);
}
.analysis-panel.ready { border-color: var(--success-line); }

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-2);
    margin: var(--sp-3) 0;
}
.metric-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    text-align: center;
}
.metric-value {
    font-family: var(--font-mono);
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--text);
    letter-spacing: -0.025em;
}
.metric-label {
    font-size: var(--fs-xs);
    color: var(--text-3);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: var(--fw-semi);
}

/* legacy section-header */
.section-header {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 10px;
    padding-left: 2px;
}

/* legacy step-card / step-full (still referenced by partials before redesign;
   keep visual minimal in case any code still emits them) */
.step-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}
.step-card.loaded { border-color: var(--success-line); }
.step-full {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}
.step-full.loaded { border-color: var(--success-line); }
.step-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.step-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.step-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.step-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.step-status {
    font-size: 10.5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: var(--fw-semi);
}
.status-ready   { background: var(--success-soft); color: #047857; border: 1px solid var(--success-line); }
.status-waiting { background: var(--warn-soft);    color: #b45309; border: 1px solid var(--warn-line); }
.status-empty   { background: var(--surface-2);    color: var(--text-3); border: 1px solid var(--border); }
.step-name { font-size: 14.5px; font-weight: var(--fw-semi); color: var(--text); margin-bottom: 2px; }
.step-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); }
.step-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 4px 0 16px; }
.pipeline-section { margin-bottom: var(--sp-5); }

/* =========================================================
   DOWNLOADS
   ========================================================= */
.downloads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-2);
    margin-top: var(--sp-3);
}
.download-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--t);
    cursor: pointer;
    color: var(--text);
}
.download-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.download-icon { font-size: 24px; line-height: 1; color: var(--accent); }
.download-label {
    font-size: var(--fs-sm);
    color: var(--text);
    text-align: center;
    font-weight: var(--fw-semi);
}
.download-desc {
    font-size: var(--fs-xs);
    color: var(--text-3);
    text-align: center;
}

/* =========================================================
   COPY BOX  (textarea + COPY button overlay)
   ========================================================= */
.copy-box { position: relative; margin-top: 8px; }
.copy-box textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}
.copy-box textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.copy-btn {
    position: absolute;
    top: 6px; right: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 9px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    color: var(--accent);
    cursor: pointer;
    transition: all var(--t);
}
.copy-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

/* =========================================================
   TOAST
   ========================================================= */
.toast {
    position: fixed;
    top: 18px; right: 18px;
    padding: 11px 18px;
    border-radius: var(--radius);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    z-index: 9999;
    animation: slideIn 0.25s ease, fadeOut 0.4s ease 3.5s forwards;
    box-shadow: var(--shadow-lg);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
}
.toast.success, .toast-success { background: var(--success-soft); color: #047857; border-color: var(--success-line); }
.toast.danger, .toast.error, .toast-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.toast.warn { background: var(--warn-soft); color: #b45309; border-color: var(--warn-line); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-6px) } }

.toast-ok  { background: var(--success-soft); color: #047857; border: 1px solid var(--success-line); }
.toast-err { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); }

/* =========================================================
   LOADING
   ========================================================= */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request .hide-on-request { display: none; }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.processing-overlay {
    position: fixed; inset: 0;
    background: rgba(248, 250, 252, 0.78);
    display: flex; align-items: center; justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.processing-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.processing-box .spinner {
    width: 28px; height: 28px;
    border-width: 3px;
    margin-bottom: 12px;
}
.processing-text {
    font-size: var(--fs-md);
    color: var(--text-2);
    font-weight: var(--fw-medium);
}

/* =========================================================
   COMMAND PALETTE
   ========================================================= */
.palette-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.40);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
}
.palette {
    width: 100%;
    max-width: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.palette-input {
    width: 100%;
    border: none !important;
    box-shadow: none !important;
    font-size: var(--fs-md);
    padding: 14px 16px;
    background: transparent;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    height: auto !important;
    color: var(--text);
}
.palette-input:focus { outline: none; box-shadow: none !important; border-color: var(--border) !important; }
.palette-list {
    max-height: 56vh;
    overflow-y: auto;
    padding: 6px;
}
.palette-section {
    font-size: 10.5px;
    text-transform: uppercase;
    color: var(--text-3);
    font-weight: var(--fw-semi);
    letter-spacing: 0.05em;
    padding: 10px 10px 4px;
}
.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--fs-md);
    color: var(--text);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: background var(--t);
}
.palette-item:hover, .palette-item.focused {
    background: var(--accent-soft);
    color: var(--accent);
}
.palette-item .pi-ic {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-3);
    font-size: 14px;
    flex-shrink: 0;
}
.palette-item.focused .pi-ic, .palette-item:hover .pi-ic { color: var(--accent); }
.palette-item .pi-sub {
    margin-left: auto;
    font-size: var(--fs-xs);
    color: var(--text-3);
    font-family: var(--font-mono);
}

/* =========================================================
   EXCLUSION TAGS
   ========================================================= */
.excl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.excl-tag {
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--info-soft);
    border: 1px solid var(--info-line);
    color: #1d4ed8;
    font-weight: var(--fw-medium);
}

/* =========================================================
   COLLAPSIBLE DETAILS
   ========================================================= */
details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    transition: background var(--t);
}
details[open] { background: var(--surface); border-color: var(--border-2); }
details > summary {
    cursor: pointer;
    list-style: none;
    font-size: var(--fs-base);
    color: var(--text-2);
    font-weight: var(--fw-medium);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
    content: '›';
    display: inline-block;
    color: var(--text-3);
    font-size: 16px;
    line-height: 1;
    transform: translateY(-1px);
    transition: transform var(--t);
}
details[open] > summary::before { transform: rotate(90deg) translateX(-1px); }

/* =========================================================
   FORMS
   ========================================================= */
input[type="text"], input[type="number"], input[type="email"], input[type="search"],
input[type="date"], input[type="time"], input[type="url"], input[type="password"],
select, textarea, .input, .select {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    color: var(--text);
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
    width: 100%;
    line-height: 1.4;
}
input:focus, select:focus, textarea:focus, .input:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }

label {
    font-size: var(--fs-sm);
    color: var(--text-2);
    font-weight: var(--fw-medium);
}

/* =========================================================
   TABLES
   ========================================================= */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
    background: var(--surface);
}
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th {
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: var(--fw-semi);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.num, th.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* =========================================================
   SETTINGS PAGE: .card, .card-title, etc.
   ========================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.card-title {
    font-size: var(--fs-sm);
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    font-weight: var(--fw-semi);
}
.card-desc {
    font-size: var(--fs-base);
    color: var(--text-2);
    margin-bottom: 14px;
    line-height: 1.55;
}

.tags-input {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    min-height: 38px;
}
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 11px;
    font-size: 11.5px;
    color: var(--text-2);
    font-weight: var(--fw-medium);
}
.tag.success { background: var(--success-soft); color: #047857; border-color: var(--success-line); }
.tag.warn { background: var(--warn-soft); color: #b45309; border-color: var(--warn-line); }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: rgb(0 152 181 / 0.20); }

.tag .remove {
    cursor: pointer;
    color: var(--text-3);
    font-size: 14px;
    line-height: 1;
}
.tag .remove:hover { color: var(--danger); }
.tag-add {
    border: none; background: transparent; color: var(--text-2);
    font-family: var(--font-sans); font-size: 12px;
    outline: none; min-width: 80px;
    padding: 2px 4px;
}

.criteria-row {
    display: grid;
    grid-template-columns: 40px 1fr 280px;
    gap: 12px; align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.criteria-row:last-child { border-bottom: none; }
.criteria-num {
    font-family: var(--font-mono);
    font-size: 18px; font-weight: var(--fw-bold);
    color: var(--accent);
    text-align: center;
    padding-top: 4px;
}

.fwa-row {
    display: grid;
    grid-template-columns: 120px 120px 80px 40px;
    gap: 6px; align-items: center;
    margin-bottom: 6px;
}

.col-list { counter-reset: col; max-height: 500px; overflow-y: auto; }
.col-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11.5px;
    counter-increment: col;
}
.col-item::before {
    content: counter(col);
    color: var(--text-3);
    min-width: 24px;
    text-align: right;
}
.col-item .col-name { flex: 1; color: var(--text); }
.col-item .col-remove { cursor: pointer; color: var(--text-3); font-size: 14px; }
.col-item .col-remove:hover { color: var(--danger); }
.col-item .drag-handle { cursor: grab; color: var(--text-3); }

.actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 20px; padding-top: 14px;
    border-top: 1px solid var(--border);
}

.inline-row { display: flex; gap: 12px; align-items: end; margin-bottom: 10px; }
.inline-row > div { flex: 1; }

.var-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px;
    background: var(--accent-soft);
    border: 1px solid rgb(0 152 181 / 0.20);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    margin: 3px 0;
}
.var-badge .var-name { color: var(--accent); font-weight: var(--fw-semi); }
.var-badge .var-arrow { color: var(--text-3); }
.var-badge .var-col { color: var(--info); font-size: 10.5px; }
.var-badge .var-label { color: var(--text-3); font-size: 10.5px; }

.rule-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
}
.rule-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.grid-5 { display: grid; grid-template-columns: 180px 220px 100px 1fr 30px; gap: 8px; align-items: center; }
.grid-6 { display: grid; grid-template-columns: 180px 180px 80px 80px 1fr 30px; gap: 8px; align-items: center; }

.del-btn { cursor: pointer; color: var(--text-3); text-align: center; font-size: 16px; }
.del-btn:hover { color: var(--danger); }

code {
    color: var(--accent);
    background: var(--accent-soft);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11.5px;
    font-family: var(--font-mono);
}

.chip-active      { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; font-weight: var(--fw-semi); }
.chip-active-all  { background: var(--success) !important; color: #fff !important; border-color: var(--success) !important; font-weight: var(--fw-semi); }
.chip-active-none { background: var(--text-3) !important; color: #fff !important; border-color: var(--text-3) !important; font-weight: var(--fw-semi); }
[style*="border-radius:4px"][style*="cursor:pointer"]:hover { opacity: 0.85; }

/* =========================================================
   WPS REVIEW PAGE
   ========================================================= */
.stats { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 22px;
    flex: 1; text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
    opacity: 0.6;
}
.stat-num {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: var(--fw-bold);
    color: var(--text);
    letter-spacing: -0.025em;
}
.stat-label {
    font-size: var(--fs-xs);
    color: var(--text-3);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: var(--fw-semi);
}

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.filter-bar input { flex: 1; }

.review-table { width: 100%; border-collapse: collapse; }
.review-table th {
    background: var(--surface-2);
    padding: 10px 12px;
    text-align: left;
    font-size: 11.5px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: var(--fw-semi);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1;
    white-space: nowrap;
}
.review-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    vertical-align: middle;
}
.review-table tr:hover td { background: var(--surface-2); }

.mat-id {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent);
    font-weight: var(--fw-medium);
}
.desc {
    color: var(--text-2);
    font-size: 11.5px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-input {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    width: 100%;
    outline: none;
    min-width: 160px;
    transition: all var(--t);
}
.comment-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.comment-input.changed {
    border-color: var(--success);
    background: var(--success-soft);
}

.quick-btn {
    padding: 2px 8px;
    font-size: 10.5px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: var(--fw-medium);
    margin-right: 4px;
    transition: all var(--t);
}
.quick-btn:hover { border-color: var(--accent); color: var(--accent); }
.quick-btn.yes { border-color: var(--success-line); color: #047857; }
.quick-btn.yes:hover { background: var(--success-soft); }
.quick-btn.no  { border-color: var(--danger-line); color: var(--danger); }
.quick-btn.no:hover { background: var(--danger-soft); }

.empty-state, .empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-3);
    font-size: var(--fs-base);
}

/* === Submission banner + action bar (WPS Review) === */
.submission-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--success-soft);
    border: 1px solid var(--success-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.submission-banner .sb-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
    color: #047857;
}
.submission-banner .sb-meta {
    font-size: var(--fs-sm);
    color: var(--text-2);
    margin-top: 2px;
}
.submission-banner .sb-meta b { color: var(--text); }

.wps-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 52px;
    z-index: 5;
}
.wps-action-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.period-tag {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 10px;
    background: var(--accent-soft);
    border: 1px solid rgb(0 152 181 / 0.20);
    border-radius: var(--radius-sm);
    color: var(--text);
    line-height: 1;
}
.period-tag-eyebrow {
    font-size: 9.5px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--fw-semi);
}
.period-tag-value {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    color: var(--text);
    font-family: var(--font-mono);
}
.wps-action-buttons { display: flex; align-items: center; gap: 8px; }

/* === Past-answer button === */
.past-answer-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--info-line);
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--fs-sm);
    transition: all var(--t);
    text-align: left;
    max-width: 100%;
    overflow: hidden;
}
.past-answer-btn:hover {
    border-color: #1d4ed8;
    background: #dbeafe;
}
.past-answer-btn .pa-tag {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #fff;
    border: 1px solid var(--info-line);
    color: #1d4ed8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: var(--fw-semi);
    line-height: 1.4;
}
.past-answer-btn .pa-text {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: var(--fw-medium);
}
.past-answer-btn .pa-cta {
    flex: 0 0 auto;
    font-size: 13px;
    color: #1d4ed8;
    font-weight: var(--fw-bold);
}

/* === Expandable row + history panel inside WPS Review === */
.expand-btn {
    width: 24px; height: 24px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: all var(--t);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.expand-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.expand-btn.open { color: var(--accent); transform: rotate(90deg); }

.review-table tr.row-expanded td { background: var(--accent-soft); }
.review-table tr.row-expanded td:first-child + td,
.review-table tr.row-expanded td { border-bottom-color: rgb(0 152 181 / 0.15); }

.history-pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-3);
    font-size: 11px;
    font-weight: var(--fw-semi);
    cursor: pointer;
    transition: all var(--t);
    font-family: var(--font-mono);
}
.history-pill:hover { border-color: var(--border-2); color: var(--text); }
.history-pill.has { background: var(--info-soft); color: #1d4ed8; border-color: var(--info-line); }
.history-pill.has:hover { background: #c7dbfe; }
.history-pill.none { color: var(--text-3); }

.history-cell {
    background: var(--surface-2);
    padding: 14px 16px 16px !important;
}
.history-loading {
    color: var(--text-3);
    font-size: var(--fs-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.history-empty {
    color: var(--text-3);
    font-size: var(--fs-sm);
    padding: 12px 4px;
    font-style: italic;
}
.history-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}
.history-head-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    color: var(--text);
}
.history-head-title b { color: var(--accent); font-family: var(--font-mono); }
.history-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
}
.history-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 6px;
}
.history-month {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    color: var(--text);
}
.history-comments {
    font-size: 10.5px;
    color: var(--text-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 999px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-comments.expert {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgb(0 152 181 / 0.20);
}
.history-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 10px;
    font-size: 11px;
    color: var(--text-2);
    margin-bottom: 4px;
}
.history-fields > div { display: flex; gap: 6px; min-width: 0; }
.hf-key {
    color: var(--text-3);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: var(--fw-semi);
    min-width: 48px;
}
.hf-val {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.history-wps {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
    font-size: 11.5px;
    color: var(--text);
    display: flex;
    gap: 8px;
}
.history-wps .hf-val {
    color: var(--text);
    white-space: normal;
    line-height: 1.4;
}
.table-wrap {
    max-height: calc(100vh - 280px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* =========================================================
   SCROLLBARS
   ========================================================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* =========================================================
   UTILITIES
   ========================================================= */
.muted, .u-text-3 { color: var(--text-3); }
.u-text-2 { color: var(--text-2); }
.faint { color: var(--text-3); }
.text-ok, .text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.text-err, .text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }

/* Reference's utility scale, for inline composition */
.u-flex { display: flex; }
.u-flex-1 { flex: 1 1 0; min-width: 0; }
.u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-1 { gap: var(--sp-1); }
.u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); }
.u-gap-4 { gap: var(--sp-4); }
.u-mt-1 { margin-top: var(--sp-1); }
.u-mt-2 { margin-top: var(--sp-2); }
.u-mt-3 { margin-top: var(--sp-3); }
.u-mt-4 { margin-top: var(--sp-4); }
.u-fs-xs { font-size: var(--fs-xs); }
.u-fs-sm { font-size: var(--fs-sm); }
.u-fs-base { font-size: var(--fs-base); }
.u-fs-md { font-size: var(--fs-md); }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-min-w-0 { min-width: 0; }

/* =========================================================
   LEGACY ALIASES — inline style="var(--*)" backward-compat
   ========================================================= */
:root {
    /* old palette tokens used by inline styles in templates */
    --bg-primary:     var(--bg);
    --bg-secondary:   var(--surface-2);
    --bg-card:        var(--surface);
    --bg-card-hover:  var(--surface-2);
    --bg-input:       var(--surface-2);
    --border-active:  var(--border-2);
    --border-dim:     var(--border);
    --text-primary:   var(--text);
    --text-secondary: var(--text-2);
    --text-muted:     var(--text-3);
    --amber:          var(--accent);
    --amber-dim:      var(--accent-h);
    --amber-glow:     var(--accent-soft);
    --green:          var(--success);
    --green-dim:      var(--success-line);
    --green-glow:     var(--success-soft);
    --red:            var(--danger);
    --red-dim:        var(--danger-line);
    --blue:           var(--info);
    --blue-dim:       var(--info-line);
    --cyan:           var(--accent);
    --cyan-dim:       var(--accent-soft);
    --purple:         #7c3aed;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: relative; width: 100%; height: auto; max-height: 200px; }
    .main { min-height: auto; }
    .main-content, .container, .app-container { padding: 16px; }
    .topbar { padding: 0 12px; }
    .topbar-center { display: none; }
    .stage-stepper { grid-template-columns: repeat(5, minmax(60px, 1fr)); padding: 10px; }
    .stage-cell .stage-meta { display: none; }
    .stage-cell .stage-title { font-size: var(--fs-sm); }
    .file-grid, .step-grid { grid-template-columns: 1fr; }
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .downloads-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-bar, .tabs { overflow-x: auto; flex-wrap: nowrap; }
}
