:root {
    --primary: #2563EB;
    --primary-600: #1D4ED8;
    --primary-50: #EFF6FF;
    --selected: #DBEAFE;
    --secondary: #0F172A;
    --accent: #14B8A6;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --success: #22C55E;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --text: #0F172A;
    --muted: #64748B;
    --subtle: #CBD5E1;
    --hover: #EFF6FF;
    --dark-bg: #020617;
    --dark-surface: #0F172A;
    --dark-border: #334155;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, .10);
    --shadow-lg: 0 30px 70px rgba(15, 23, 42, .16);
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 28px;
    --sidebar: 280px;
    --topbar: 78px;
}

[data-theme="dark"] {
    --bg: #020617;
    --surface: #0F172A;
    --surface-2: #111C2F;
    --border: #334155;
    --border-strong: #475569;
    --text: #E2E8F0;
    --muted: #94A3B8;
    --subtle: #475569;
    --hover: rgba(37, 99, 235, .16);
    --selected: rgba(37, 99, 235, .24);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.30);
    --shadow-sm: 0 10px 26px rgba(0,0,0,.30);
    --shadow-md: 0 18px 42px rgba(0,0,0,.36);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 10% -10%, rgba(37,99,235,.16), transparent 34rem),
        radial-gradient(circle at 100% 0%, rgba(20,184,166,.12), transparent 30rem),
        linear-gradient(180deg, #F8FAFC 0%, #EEF4FF 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.45;
}
[data-theme="dark"] body,
body[data-theme="dark"] {
    background:
        radial-gradient(circle at 10% -10%, rgba(37,99,235,.22), transparent 34rem),
        radial-gradient(circle at 100% 0%, rgba(20,184,166,.13), transparent 30rem),
        #020617;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
svg, svg.ui-icon { width: 1em; height: 1em; fill: currentColor; flex: 0 0 auto; vertical-align: -.14em; }
img, video { max-width: 100%; height: auto; }

h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -.035em; }
h1 { font-size: clamp(30px, 4vw, 46px); line-height: 1.05; }
h2 { font-size: clamp(20px, 2vw, 25px); line-height: 1.15; margin-bottom: 12px; }
h3 { font-size: 16px; line-height: 1.25; margin-bottom: 6px; }
p { margin: 0; }
.muted { color: var(--muted); margin-top: 7px; }
.kicker { color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 900; margin-bottom: 8px; }
.help { font-size: 12px; color: var(--muted); font-weight: 550; line-height: 1.45; }

/* Holy Grail application shell */
.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    overflow-y: auto;
    color: #E2E8F0;
    background:
        radial-gradient(circle at 20% 0%, rgba(37,99,235,.26), transparent 18rem),
        linear-gradient(180deg, #020617, #0F172A 52%, #020617);
    border-right: 1px solid rgba(148,163,184,.16);
    box-shadow: 18px 0 50px rgba(15,23,42,.18);
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 4px 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; font-weight: 900; }
.brand:hover { color: inherit; }
.brand small { display: block; margin-top: 1px; color: #94A3B8; font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 16px 34px rgba(37,99,235,.32);
    font-size: 22px;
}
.brand-mark svg { display: block; }
.sidebar-close {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(226,232,240,.16);
    border-radius: 12px;
    color: #E2E8F0;
    background: rgba(255,255,255,.05);
}
.sidebar-section-label { margin: 18px 12px 8px; color: #94A3B8; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; font-weight: 900; }
.sidebar-nav { display: grid; gap: 4px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 44px;
    padding: 11px 12px;
    border-radius: 13px;
    color: #CBD5E1;
    font-weight: 780;
    border: 1px solid transparent;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.nav-link svg { font-size: 19px; }
.nav-link:hover { color: #FFFFFF; background: rgba(255,255,255,.06); transform: translateX(2px); }
.nav-link.active { color: #FFFFFF; background: rgba(37,99,235,.22); border-color: rgba(96,165,250,.26); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-card {
    margin: auto 4px 14px;
    padding: 15px;
    border: 1px solid rgba(226,232,240,.14);
    border-radius: 18px;
    background: rgba(255,255,255,.06);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.sidebar-card-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: white; background: rgba(37,99,235,.28); margin-bottom: 10px; }
.sidebar-card strong { display: block; color: #F8FAFC; }
.sidebar-card p { margin-top: 5px; color: #94A3B8; font-size: 12px; }
.logout-link { display: flex; align-items: center; gap: 9px; margin: 0 4px; padding: 11px 12px; color: #CBD5E1; border-radius: 13px; font-weight: 800; }
.logout-link:hover { color: white; background: rgba(239,68,68,.16); }
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.52); backdrop-filter: blur(3px); }
.sidebar-overlay.open { display: block; }
.shell-main { min-height: 100vh; margin-left: var(--sidebar); display: flex; flex-direction: column; }

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: var(--topbar);
    background: rgba(248,250,252,.86);
    backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid rgba(226,232,240,.88);
}
[data-theme="dark"] .app-topbar { background: rgba(2,6,23,.82); border-color: rgba(51,65,85,.86); }
.topbar-inner {
    min-height: var(--topbar);
    max-width: 1540px;
    margin: 0 auto;
    padding: 12px 28px;
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(260px, 520px) auto;
    align-items: center;
    gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 13px; min-width: 0; }
.crumb { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }
.topbar-title { font-size: 19px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle, .icon-button {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
}
.nav-toggle { display: none; }
.global-search {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    color: var(--muted);
}
.global-search input { border: 0; box-shadow: none; padding: 0; min-height: 0; background: transparent; }
.global-search input:focus { box-shadow: none; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}
.status-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(34,197,94,.14); }
.user-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    max-width: 240px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.user-chip span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip strong { color: var(--text); font-size: 12px; }
.container { width: 100%; max-width: 1540px; margin: 0 auto; padding: 28px; }
.footer { color: var(--muted); text-align: center; padding: 18px 28px 30px; font-size: 13px; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.auth-footer { margin-left: 0; }

/* Authentication / hero landing */
.auth-body { background: radial-gradient(circle at 20% -10%, rgba(37,99,235,.20), transparent 34rem), linear-gradient(135deg, #020617 0%, #0F172A 42%, #F8FAFC 42%); }
.landing-topbar { display: flex; align-items: center; justify-content: space-between; padding: 22px clamp(16px, 4vw, 48px); color: white; }
.auth-container { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth-shell { width: min(1040px, 100%); min-height: auto; display: grid; grid-template-columns: 1.1fr .9fr; align-items: stretch; border: 1px solid rgba(226,232,240,.55); border-radius: 32px; overflow: hidden; background: rgba(255,255,255,.92); box-shadow: var(--shadow-lg); }
.auth-hero { display: grid; align-content: end; gap: 18px; min-height: 620px; padding: 34px; color: white; background: radial-gradient(circle at 0% 10%, rgba(20,184,166,.35), transparent 22rem), linear-gradient(160deg, #020617, #0F172A 72%, #1D4ED8); }
.auth-hero h1 { color: white; max-width: 520px; }
.auth-hero p { color: #CBD5E1; max-width: 540px; }
.auth-card { width: 100%; margin: 0; padding: 44px; border: 0; border-radius: 0; background: var(--surface); box-shadow: none; display: grid; align-content: center; }
.auth-card .form-grid { grid-template-columns: 1fr; }
.empty-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--selected); color: var(--primary); margin: 0 0 18px; font-size: 30px; }

/* Page layouts */
.hero, .page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
.hero {
    position: relative;
    overflow: hidden;
    min-height: 210px;
    padding: clamp(22px, 3vw, 34px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 100% 0%, rgba(20,184,166,.18), transparent 26rem),
        linear-gradient(135deg, rgba(255,255,255,.96), rgba(239,246,255,.90));
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .hero { background: radial-gradient(circle at 100% 0%, rgba(20,184,166,.13), transparent 26rem), linear-gradient(135deg, rgba(15,23,42,.96), rgba(17,24,39,.92)); }
.hero::after { content: ''; position: absolute; width: 220px; height: 220px; right: -80px; bottom: -100px; border-radius: 999px; background: rgba(37,99,235,.10); }
.hero > * { position: relative; z-index: 1; }
.hero p { max-width: 720px; }
.actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

.card, .auth-card, .empty-state {
    background: rgba(255,255,255,.96);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
[data-theme="dark"] .card, [data-theme="dark"] .auth-card, [data-theme="dark"] .empty-state, [data-theme="dark"] .stat { background: rgba(15,23,42,.95); }
.card > h2 { display: flex; align-items: center; gap: 10px; }
.empty-state { text-align: center; padding: 46px 20px; }
.empty-state .empty-icon { margin-left: auto; margin-right: auto; }

/* Grids / analytics cards */
.stats-grid, .metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat, .metric-card {
    position: relative;
    overflow: hidden;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow-sm);
}
.stat::after, .metric-card::after { content: ''; position: absolute; inset: auto -24px -34px auto; width: 104px; height: 104px; border-radius: 999px; background: rgba(37,99,235,.08); }
.stat span, .metric-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.stat strong, .metric-card strong { position: relative; z-index: 1; display: block; margin-top: 8px; font-size: clamp(23px, 2.4vw, 34px); letter-spacing: -.05em; overflow-wrap: anywhere; }
.stat .trend, .metric-card .trend { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; padding: 4px 8px; border-radius: 999px; background: var(--primary-50); color: var(--primary-600); font-size: 12px; font-weight: 850; }

.asym-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .85fr); gap: 18px; align-items: stretch; margin-bottom: 20px; }
.executive-panel { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; min-height: 280px; }
.report-card { min-height: 100%; display: grid; gap: 14px; }
.chart-bars { display: grid; gap: 12px; margin-top: 14px; }
.bar-row { display: grid; gap: 7px; }
.bar-label { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 800; }
.bar-track { height: 11px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; min-width: 4px; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.workflow-list { display: grid; gap: 10px; }
.workflow-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); }
.workflow-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px rgba(37,99,235,.10); }
.workflow-item strong { display: block; }
.workflow-item span { color: var(--muted); font-size: 12px; font-weight: 700; }

/* Forms */
.form-grid, .dispute-form, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 16px; align-items: end; width: 100%; }
.settings-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
label { display: grid; gap: 7px; color: #334155; font-size: 14px; font-weight: 820; }
[data-theme="dark"] label { color: #CBD5E1; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
input, select, textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    font-weight: 650;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.13); }
textarea { resize: vertical; min-height: 118px; }
input[type="file"] { padding: 10px; background: var(--surface-2); cursor: pointer; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.readonly-box { border: 1px solid var(--border); border-radius: 15px; padding: 13px 14px; background: var(--surface-2); }
.readonly-box span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; }
.readonly-box strong { display: block; margin-top: 5px; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 11px 16px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    color: var(--text);
    background: var(--surface);
    font: inherit;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.button.primary { color: white; background: linear-gradient(135deg, var(--primary), var(--primary-600)); border-color: var(--primary); box-shadow: 0 14px 30px rgba(37,99,235,.20); }
.button.secondary { color: #475569; background: var(--surface-2); }
[data-theme="dark"] .button.secondary { color: #CBD5E1; }
.button.danger { color: #B91C1C; border-color: #FECACA; background: #FEF2F2; }
.button.full { width: 100%; }
.button[disabled] { opacity: .65; pointer-events: none; }

/* CRUD UX and feedback */
.toast-stack { position: fixed; top: 92px; right: 18px; z-index: 90; display: grid; gap: 10px; width: min(430px, calc(100vw - 36px)); }
.flash { padding: 13px 14px; border-radius: 15px; font-weight: 760; border: 1px solid transparent; }
.toast { display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-md); background: var(--surface); }
.toast span { flex: 1; }
.toast-close { border: 0; background: transparent; color: currentColor; font-size: 22px; line-height: 1; cursor: pointer; opacity: .72; }
.flash.success { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.flash.error { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.flash.info { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.flash.warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.progress-panel { display: none; margin-top: 16px; }
.progress-panel.active { display: block; }
.progress-track { height: 12px; overflow: hidden; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .25s ease; }
.progress-text { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 13px; margin-top: 8px; }
.is-loading { cursor: progress; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 12px; min-height: 18px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.autosave-note { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* F-pattern tables */
.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(220px, 320px) auto auto; gap: 12px; align-items: center; width: 100%; margin-bottom: 16px; }
.toolbar input[type="search"], .toolbar select { max-width: none; min-height: 48px; }
.toolbar .button { white-space: nowrap; }
.table-card { padding: 0; overflow: hidden; }
.table-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.table-header .muted { max-width: 620px; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); scrollbar-gutter: stable; }
.table-card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.table-wrap.wide { max-height: 66vh; overflow: auto; }
.table-wrap.compact table { min-width: 820px; }
table { width: 100%; min-width: 1120px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
.enterprise-table th, .enterprise-table td { white-space: nowrap; }
th, td { padding: 12px 12px; border-bottom: 1px solid rgba(226,232,240,.78); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; color: #334155; background: #F8FAFC; font-size: 10.5px; text-transform: uppercase; letter-spacing: .075em; font-weight: 950; line-height: 1.2; white-space: nowrap; }
[data-theme="dark"] th { color: #CBD5E1; background: #111827; }
tr:hover td { background: var(--hover); }
.num { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px; white-space: normal; }
.text-clip, .remarks-cell, .file-cell, .email-cell, .record-cell { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remarks-cell { max-width: 220px; color: var(--muted); }
.file-cell { max-width: 340px; }
.email-cell { max-width: 300px; }
.record-cell { max-width: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }
.date-cell { white-space: nowrap; color: #475569; font-variant-numeric: tabular-nums; }
[data-theme="dark"] .date-cell { color: #CBD5E1; }
.money-cell { font-variant-numeric: tabular-nums; }
.po-link { font-weight: 950; white-space: nowrap; }
.table-actions { min-width: 112px; white-space: nowrap; }
.table-actions-inner { display: inline-flex; gap: 7px; align-items: center; flex-wrap: nowrap; }
.table-actions .button, .table-form .button, .inline-row .button { min-height: 34px; padding: 8px 10px; font-size: 12px; border-radius: 11px; }
.table-form, .inline-row { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.table-form select, .table-form input, .inline-row select, .inline-row input { min-height: 38px; padding: 8px 10px; border-radius: 11px; font-size: 13px; }
.table-form input[type="password"] { min-width: 180px; }
.table-dashboard { min-width: 1260px; }
.table-dashboard col.c-date { width: 96px; }
.table-dashboard col.c-type { width: 98px; }
.table-dashboard col.c-po { width: 112px; }
.table-dashboard col.c-money { width: 116px; }
.table-dashboard col.c-case { width: 90px; }
.table-dashboard col.c-status { width: 128px; }
.table-dashboard col.c-note { width: 190px; }
.table-dashboard col.c-small { width: 70px; }
.table-dashboard col.c-action { width: 116px; }
.table-lines { min-width: 1500px; }
.table-lines col.c-asin { width: 112px; }
.table-lines col.c-record { width: 140px; }
.table-lines col.c-date { width: 96px; }
.table-lines col.c-money { width: 110px; }
.table-lines col.c-short { width: 86px; }
.table-lines col.c-med { width: 118px; }
.table-lines col.c-qty { width: 82px; }
.table-lines col.c-action { width: 94px; }

.badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 5px 10px; border-radius: 999px; background: var(--selected); color: #3730A3; font-size: 12px; font-weight: 900; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-approved { background: #ECFDF5; color: #047857; }
.badge-rejected, .badge-high { background: #FEF2F2; color: #B91C1C; }
.badge-under-review, .badge-re-dispute, .badge-medium { background: #FFFBEB; color: #92400E; }
.badge-low, .role-pill { background: #F1F5F9; color: #475569; }

/* Split screen details + timeline */
.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.split-main { min-width: 0; }
.activity-panel { position: sticky; top: calc(var(--topbar) + 22px); display: grid; gap: 16px; }
.timeline { display: grid; gap: 0; padding-top: 4px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: 15px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-node { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: white; background: var(--primary); box-shadow: 0 0 0 5px rgba(37,99,235,.12); }
.timeline-content strong { display: block; }
.timeline-content span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.dispute-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dispute-form .span-2, .dispute-form .progress-panel.span-2 { grid-column: span 3; }

/* Evidence masonry / upload */
.evidence-search-form { grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto; align-items: start; }
.evidence-search-form .button { margin-top: 25px; min-width: 190px; }
.evidence-upload-form { align-items: start; }
.evidence-upload-form .button { min-width: 190px; }
.upload-dropzone { padding: 18px; border: 1px dashed var(--border-strong); border-radius: 18px; background: var(--surface-2); }
.evidence-grid { column-count: 3; column-gap: 16px; }
.evidence-card { display: inline-block; width: 100%; break-inside: avoid; margin: 0 0 16px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.evidence-card.important-high { border-color: #FECACA; background: linear-gradient(180deg, var(--surface), rgba(254,242,242,.72)); }
.evidence-card.important-medium { border-color: #FDE68A; background: linear-gradient(180deg, var(--surface), rgba(255,251,235,.72)); }
.evidence-title { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.file-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--selected); color: var(--primary); font-size: 20px; }
.evidence-title h3 { margin: 0; line-height: 1.25; }
.file-meta, .evidence-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.snippet { margin-top: 8px; padding: 10px; color: #334155; border: 1px solid var(--border); border-radius: 13px; background: #F8FAFC; font-size: 13px; }
[data-theme="dark"] .snippet { color: #CBD5E1; background: #111827; }
.inline-form { margin: 0; display: inline-flex; }
.evidence-actions .button { min-height: 38px; padding: 9px 12px; font-size: 13px; }
.analysis-box { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); gap: 18px; }
.template-box textarea { min-height: 360px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; }
.checklist { margin: 0; padding-left: 20px; color: #334155; }
.checklist li { margin: 7px 0; }

/* Settings / profile two column */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px; font-weight: 900; color: #334155; background: var(--surface); }
.tab.active { color: white; background: var(--primary); border-color: var(--primary); }
.settings-layout { display: grid; grid-template-columns: 320px minmax(0,1fr); gap: 20px; align-items: start; }
.settings-aside { position: sticky; top: calc(var(--topbar) + 22px); }
.secret-configured { color: #047857; font-weight: 900; }

/* Code and highlights */
pre { max-width: 620px; max-height: 340px; overflow: auto; padding: 14px; border-radius: 13px; background: #0F172A; color: #E5E7EB; font-size: 12px; white-space: pre-wrap; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 7px; }
mark { background: #FEF08A; color: #713F12; padding: 0 2px; border-radius: 4px; }

.fab { position: fixed; right: 22px; bottom: 22px; z-index: 45; display: none; place-items: center; width: 58px; height: 58px; border-radius: 999px; color: white; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 24px 50px rgba(37,99,235,.32); font-size: 24px; }

@media (max-width: 1280px) {
    .topbar-inner { grid-template-columns: minmax(220px,.7fr) minmax(220px,420px) auto; }
    .stats-grid.five { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .evidence-grid { column-count: 2; }
}
@media (max-width: 1180px) {
    .stats-grid, .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .asym-grid, .split-layout, .executive-panel, .analysis-box, .settings-layout { grid-template-columns: 1fr; }
    .activity-panel, .settings-aside { position: static; }
    .toolbar { grid-template-columns: minmax(220px, 1fr) minmax(200px, 320px) auto; }
    .toolbar .button.secondary { grid-column: 1 / -1; width: fit-content; }
    .dispute-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dispute-form .span-2, .dispute-form .progress-panel.span-2 { grid-column: span 2; }
    .evidence-search-form { grid-template-columns: 1fr 1fr; }
    .evidence-search-form .button { grid-column: 1 / -1; margin-top: 0; width: fit-content; }
}
@media (max-width: 1024px) {
    :root { --topbar: 72px; }
    .sidebar { transform: translateX(-105%); transition: transform .22s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-grid; place-items: center; }
    .shell-main { margin-left: 0; }
    .nav-toggle { display: inline-grid; }
    .topbar-inner { grid-template-columns: 1fr auto; padding: 10px 16px; }
    .global-search { grid-column: 1 / -1; order: 4; }
    .user-chip, .status-chip { display: none; }
    .stats-grid, .metric-grid, .stats-grid.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .container { padding: 20px 14px; }
    .fab { display: grid; }
}
@media (max-width: 860px) {
    .hero, .page-head, .table-header { flex-direction: column; }
    .actions, .actions .button { width: 100%; }
    .form-grid, .settings-grid, .dispute-form, .evidence-search-form, .stats-grid, .metric-grid, .stats-grid.five { grid-template-columns: 1fr; }
    .span-2, .span-3, .dispute-form .span-2, .dispute-form .progress-panel.span-2 { grid-column: span 1; }
    .toolbar { grid-template-columns: 1fr; }
    .toolbar .button, .toolbar .button.secondary, .evidence-search-form .button, .evidence-upload-form .button, .button { width: 100%; }
    .table-actions-inner { flex-direction: row; align-items: center; width: auto; }
    .table-actions .button { width: auto; }
    .evidence-grid { column-count: 1; }
    .toast-stack { top: 86px; right: 10px; width: calc(100vw - 20px); }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { min-height: 360px; }
}
@media (max-width: 640px) {
    .brand-word { display: none; }
    .card, .auth-card, .hero { padding: 17px; border-radius: 18px; }
    .auth-card { padding: 28px 20px; }
    .auth-hero { padding: 28px 20px; min-height: 330px; }
    table { min-width: 940px; }
    .table-dashboard { min-width: 1180px; }
    .table-lines { min-width: 1450px; }
    th, td { padding: 10px 10px; }
    .badge { padding: 4px 8px; }
    .footer { flex-direction: column; gap: 4px; padding-bottom: 90px; }
    .topbar-title { max-width: 190px; }
}

@media print {
    .sidebar, .app-topbar, .footer, .actions, .toolbar, .fab, .toast-stack { display: none !important; }
    .shell-main { margin-left: 0 !important; }
    .container { max-width: none; padding: 0; }
    .card, .stat, .hero, .table-wrap { box-shadow: none; break-inside: avoid; }
    body { background: white !important; color: #000; }
}
body.no-scroll { overflow: hidden; }

/* Table polish pass: compact labels, no awkward wrapping */
.compact-table { min-width: 900px; }
.enterprise-table td .button svg { font-size: 14px; }
.enterprise-table details { width: max-content; }
.enterprise-table summary { cursor: pointer; font-weight: 900; color: var(--primary); }
.enterprise-table pre { max-width: 540px; white-space: pre; }
@media (max-width: 860px) {
    .table-header .toolbar { width: 100%; }
    .table-form, .inline-row { min-width: 260px; }
}
.table-form-hidden { display: none; }
.compact-table input[type="text"], .compact-table input[type="number"], .compact-table input[type="password"], .compact-table select { min-height: 38px; padding: 8px 10px; border-radius: 11px; font-size: 13px; }
.compact-table input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; }

/* Live tables, cleaner grid, ASIN details */
.live-toolbar { margin-bottom: 0; }
.live-toolbar.compact-toolbar { grid-template-columns: minmax(220px, 1fr) auto; max-width: 520px; }
.table-header .live-toolbar { width: min(760px, 100%); }
.table-header .live-toolbar .button { min-height: 44px; }
.enterprise-table th, .enterprise-table td { border-left: 0 !important; border-right: 0 !important; }
.enterprise-table tbody tr:last-child td { border-bottom: 0; }
.enterprise-table tr[hidden] { display: none !important; }
.table-wrap { border-color: rgba(226,232,240,.64); }
.table-card .table-wrap { border-top: 1px solid rgba(226,232,240,.64); }
.table-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid rgba(226,232,240,.64); color: var(--muted); font-size: 13px; background: var(--surface); }
.table-page-controls { display: inline-flex; align-items: center; gap: 10px; }
.table-page-index { min-width: 90px; text-align: center; font-weight: 850; color: var(--text); }
.table-pager .button { min-height: 34px; padding: 8px 12px; font-size: 12px; border-radius: 11px; }
.table-pager .button[disabled] { opacity: .45; }
.table-lines { min-width: 1270px; }
.table-lines col.c-asin { width: 112px; }
.table-lines col.c-record { width: 132px; }
.table-lines col.c-date { width: 92px; }
.table-lines col.c-money { width: 110px; }
.table-lines col.c-short { width: 84px; }
.table-lines col.c-med { width: 116px; }
.table-lines col.c-qty { width: 76px; }
.table-lines col.c-action { width: 142px; }
.missing-value { color: var(--danger); font-weight: 950; }
.asin-detail-card { scroll-margin-top: calc(var(--topbar) + 16px); }
.compact-head { margin-bottom: 16px; }
.asin-detail-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.detail-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.detail-lists > div { padding: 13px 14px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); min-width: 0; }
.detail-lists span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.detail-lists strong { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
@media (max-width: 1180px) {
    .asin-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .table-header .live-toolbar { width: 100%; }
}
@media (max-width: 860px) {
    .live-toolbar, .live-toolbar.compact-toolbar { grid-template-columns: 1fr; max-width: none; }
    .table-pager { align-items: stretch; flex-direction: column; }
    .table-page-controls { justify-content: space-between; width: 100%; }
    .table-page-controls .button { width: auto; }
    .asin-detail-grid, .detail-lists { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .table-lines { min-width: 1180px; }
    .table-dashboard { min-width: 1080px; }
}

/* Final layout/export polish */
html, body { max-width: 100%; overflow-x: hidden; }
.app-shell, .shell-main, .container, .split-layout, .split-main, .card, .hero, .topbar-inner { min-width: 0; max-width: 100%; }
.shell-main { overflow-x: hidden; }
.table-wrap { max-width: 100%; overscroll-behavior-x: contain; }
.table-wrap.wide { max-height: none; overflow-x: auto; overflow-y: visible; }
.enterprise-table { border-collapse: separate; }
.enterprise-table th, .enterprise-table td { border-left: 0 !important; border-right: 0 !important; }
.enterprise-table tr { border-left: 0; border-right: 0; }
.enterprise-table tbody tr:hover { background: var(--hover); }
.actions .button { white-space: nowrap; }

/* Cleaner dashboard and ASIN summary tables */
.table-dashboard { min-width: 1060px; }
.table-dashboard col.c-action-wide { width: 150px; }
.table-asin-summary { min-width: 1060px; }
.table-lines.table-asin-summary col.c-asin { width: 132px; }
.table-lines.table-asin-summary col.c-med { width: 138px; }
.table-lines.table-asin-summary col.c-money { width: 120px; }
.table-lines.table-asin-summary col.c-date-range { width: 160px; }
.table-lines.table-asin-summary col.c-qty-wide { width: 280px; }
.table-lines.table-asin-summary col.c-action-wide { width: 156px; }
.qty-line { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 750; }
.date-cell .text-clip { max-width: 150px; }
.table-actions-inner { justify-content: flex-end; }
.table-actions .button { min-width: 0; }

/* Evidence upload and file explorer */
.evidence-hero { min-height: 170px; }
.evidence-control-card { padding: 20px; }
.evidence-control-grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); gap: 22px; align-items: start; }
.compact-evidence-search { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto; gap: 12px; align-items: end; }
.compact-evidence-search .button { min-width: 140px; }
.upload-panel { padding: 18px; border: 1px solid var(--border); border-radius: 20px; background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.upload-fields { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.2fr); gap: 12px; margin-bottom: 12px; }
.evidence-upload-form { display: grid; gap: 12px; }
.upload-dropzone { position: relative; display: grid; place-items: center; gap: 6px; min-height: 148px; padding: 22px; border: 1.5px dashed var(--border-strong); border-radius: 20px; background: var(--surface); text-align: center; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.upload-dropzone:hover { border-color: var(--primary); background: var(--hover); transform: translateY(-1px); }
.upload-dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 100%; }
.upload-dropzone strong { font-size: 16px; color: var(--text); }
.upload-dropzone small { color: var(--muted); font-weight: 650; }
.dropzone-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--selected); color: var(--primary); font-size: 24px; }
.file-count-note { display: inline-flex; margin-top: 4px; color: var(--primary); font-weight: 850; }

.file-explorer-card { padding: 0; overflow: hidden; }
.explorer-header { align-items: center; }
.explorer-search { min-height: 42px; min-width: 220px; border-radius: 999px; }
.file-explorer { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 420px; }
.folder-pane { padding: 14px; border-right: 1px solid var(--border); background: var(--surface-2); display: grid; align-content: start; gap: 7px; }
.folder-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 40px; padding: 9px 10px; border-radius: 12px; color: var(--muted); font-weight: 850; }
.folder-item.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-xs); }
.folder-item.subfolder { grid-template-columns: minmax(0, 1fr) auto; padding-left: 16px; }
.folder-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item strong { color: var(--primary); font-size: 12px; }
.explorer-table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.evidence-file-table { min-width: 1040px; }
.evidence-file-table col.c-file { width: 270px; }
.evidence-file-table col.c-asin { width: 110px; }
.evidence-file-table col.c-priority { width: 128px; }
.evidence-file-table col.c-size { width: 88px; }
.evidence-file-table col.c-date { width: 100px; }
.evidence-file-table col.c-note { width: 230px; }
.evidence-file-table col.c-action-wide { width: 180px; }
.file-name-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.file-name-cell strong { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-icon.small { width: 30px; height: 30px; border-radius: 10px; font-size: 15px; }
.compact-evidence-grid .evidence-card { padding: 14px; }
.compact-evidence-grid .evidence-card .snippet { display: none; }

/* Detailed report */
.report-detail-card { overflow: hidden; }
.report-summary-grid { display: grid; grid-template-columns: 1.5fr .7fr .7fr; gap: 12px; margin-bottom: 18px; }
.polished-analysis { align-items: start; }
.polished-analysis h3 { margin-top: 14px; }
.polished-analysis h3:first-child { margin-top: 0; }
.polished-analysis p { color: var(--muted); line-height: 1.7; }
.template-box textarea { min-height: 420px; }

@media (max-width: 1280px) {
    .topbar-inner { grid-template-columns: minmax(180px,.55fr) minmax(220px,380px) auto; }
    .evidence-control-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    .shell-main { margin-left: 0; }
    .topbar-inner { overflow: hidden; }
    .actions { justify-content: flex-start; }
    .file-explorer { grid-template-columns: 1fr; }
    .folder-pane { border-right: 0; border-bottom: 1px solid var(--border); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 860px) {
    .compact-evidence-search, .upload-fields, .report-summary-grid { grid-template-columns: 1fr; }
    .compact-evidence-search .button { width: 100%; }
    .explorer-header .actions { width: 100%; }
    .explorer-search { width: 100%; min-width: 0; }
    .actions .button { white-space: normal; }
}
@media (max-width: 640px) {
    .table-dashboard { min-width: 980px; }
    .table-asin-summary, .evidence-file-table { min-width: 980px; }
    .table-lines.table-asin-summary col.c-qty-wide { width: 230px; }
    .file-explorer { min-height: 0; }
    .folder-pane { display: none; }
}
.upload-dropzone .file-count-note { position: relative; z-index: 2; }
.file-explorer > .table-pager { grid-column: 2; margin: 0; border-left: 0; }
@media (max-width: 1024px) { .file-explorer > .table-pager { grid-column: 1; } }
