:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #f97316;
  --brand-dark: #c2410c;
  --good: #16a34a;
  --bad: #dc2626;
  --soft: #f8fafc;
  --shadow: 0 18px 45px rgba(15, 23, 42, .12);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f3f4f6; color: var(--ink); }
.hero { background: linear-gradient(135deg, #111827, #1f2937); color: white; padding: 44px clamp(18px, 4vw, 56px); display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.eyebrow { color: #fed7aa; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; margin: 0 0 8px; }
h1 { margin: 0; font-size: clamp(32px, 5vw, 56px); line-height: 1; }
.subhead { max-width: 760px; color: #d1d5db; font-size: 18px; line-height: 1.5; }
.hero-card { min-width: 230px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 22px; padding: 22px; backdrop-filter: blur(10px); }
.hero-card strong { display: block; font-size: 30px; margin: 6px 0; }
.label { color: #fed7aa; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.layout { max-width: 1220px; margin: -28px auto 40px; padding: 0 18px; display: grid; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); }
.section-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
h2 { margin: 0 0 6px; font-size: 21px; }
p { color: var(--muted); line-height: 1.5; }
.badge { border-radius: 999px; padding: 8px 12px; background: #fef3c7; color: #92400e; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.error { background: #fee2e2; color: #991b1b; }
.dropzone { display: grid; place-items: center; text-align: center; min-height: 170px; border: 2px dashed #cbd5e1; background: var(--soft); border-radius: 20px; cursor: pointer; transition: .2s ease; }
.dropzone:hover { border-color: var(--brand); background: #fff7ed; }
.dropzone input { display: none; }
.drop-icon { width: 54px; height: 54px; display: grid; place-items: center; background: var(--brand); color: white; border-radius: 18px; font-size: 26px; margin-bottom: 10px; }
.upload-options { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
button { border: 0; border-radius: 12px; padding: 11px 15px; font-weight: 800; cursor: pointer; background: var(--brand); color: white; }
button.secondary { background: #111827; }
.status { min-height: 22px; font-weight: 700; }
.status.error { color: var(--bad); }
.status.success { color: var(--good); }
.filters-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 12px; }
label { display: grid; gap: 7px; color: #374151; font-size: 13px; font-weight: 800; }
select, input[type="date"] { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid #cbd5e1; background: white; color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 14px; }
.kpi-card { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.kpi-card small { display: block; color: var(--muted); font-weight: 800; min-height: 34px; }
.kpi-card strong { display: block; font-size: 28px; margin: 8px 0; }
.delta { font-size: 13px; font-weight: 900; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.neutral { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-panel canvas { max-height: 360px; }
.insight { padding: 14px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); margin-bottom: 10px; }
.insight strong { display: block; margin-bottom: 4px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { background: #f8fafc; color: #334155; position: sticky; top: 0; }
tr:hover td { background: #fff7ed; }
.note { background: #fff7ed; border-left: 4px solid var(--brand); padding: 12px; border-radius: 10px; }
footer { max-width: 1220px; margin: 0 auto 36px; padding: 0 18px; color: var(--muted); display: flex; justify-content: space-between; }
@media (max-width: 980px) { .hero, .grid-2 { grid-template-columns: 1fr; display: grid; } .filters-grid, .kpis { grid-template-columns: repeat(2, minmax(140px, 1fr)); } }
@media (max-width: 640px) { .hero { padding: 30px 18px 56px; } .filters-grid, .kpis { grid-template-columns: 1fr; } .section-title, footer { flex-direction: column; } }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 22px; padding: 10px; box-shadow: var(--shadow); }
.tab { background: #e5e7eb; color: #111827; }
.tab.active { background: var(--brand); color: #fff; }
.tab-page { display: none; gap: 18px; }
.tab-page.active { display: grid; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
button.danger { background: var(--bad); }
.manage-panel .filters-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.small-note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.table-panel h2, .chart-panel h2, .insight-panel h2 { margin-bottom: 10px; }
.chart-panel { min-height: 430px; }
.chart-panel canvas { width: 100% !important; height: 330px !important; max-height: 330px; }
ul { color: var(--muted); line-height: 1.6; }
@media (max-width: 760px) { .upload-grid { grid-template-columns: 1fr; } .tabs { display: grid; grid-template-columns: 1fr; } }

/* v8 layout fix: prevent wide AI tables from forcing horizontal overflow */
html, body { max-width: 100%; overflow-x: hidden; }
.layout, .panel, .tab-page, .grid-2, .table-panel, .chart-panel, .insight-panel { min-width: 0; }
.layout { width: min(1220px, calc(100% - 36px)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.upload-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dropzone { min-width: 0; overflow: hidden; }
.dropzone strong, .dropzone small { max-width: 100%; overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; overflow-x: auto; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .upload-grid { grid-template-columns: 1fr; } }
