/* RegenInsight shell, layered on windows-ui.css. */
:root {
  --ink: #1b1f2a;
  --ink-soft: #5b6475;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --line: #e3e7ee;
  --brand: #0f6cbd;
  --brand-dark: #0b3d6e;
  --brand-tint: #e8f1fb;
  --good: #107c41;
  --bad: #c42b1c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
}

body { background: var(--canvas); color: var(--ink); font-size: 15px; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 600; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand-dark); color: #dbe7f5; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.1rem; color: #fff; padding: 0 8px 22px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #2b88d8, #0f6cbd); color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #dbe7f5; text-decoration: none; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: inset 3px 0 0 #6cb8f6; }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar form { display: flex; align-items: center; gap: 12px; }
.org { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.org i { color: var(--brand); }
.user { color: var(--ink-soft); font-size: .9rem; }
.btn-ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--ink); font: inherit; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-ghost:hover { background: var(--canvas); }
.content { padding: 28px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }

/* Shared components (cards and KPI tiles are used from Phase 5) */
.btn { border-radius: 8px; padding: 9px 16px; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi-label { color: var(--ink-soft); font-size: .85rem; }
.kpi-value { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.notice-danger { background: #fdf3f2; border-color: #f1c4bf; color: #8a1f14; }
.notice-info { background: var(--brand-tint); border-color: #bcd6f2; color: #0b3d6e; }

.empty-state { background: var(--surface); border: 1px dashed #c7d0dd; border-radius: var(--radius); text-align: center; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state p { max-width: 520px; }
.empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; font-size: 1.6rem; }

/* Login */
.login-page { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-hero { background: radial-gradient(circle at 20% 10%, #1d5fa3 0, var(--brand-dark) 55%, #082a4c 100%); color: #e6eef8; padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-hero .brand { padding: 0 0 24px; }
.login-hero h2 { font-size: 2rem; line-height: 1.25; color: #fff; max-width: 460px; }
.login-hero p { max-width: 460px; color: #c9d8ea; }
.hero-points { list-style: none; display: grid; gap: 12px; margin-top: 8px; }
.hero-points i { color: #6cb8f6; margin-right: 8px; }
.login-panel { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; display: flex; flex-direction: column; }
.login-card h1 { margin-bottom: 2px; }
.login-card > .muted { margin-bottom: 20px; }
.login-card .form-label { font-weight: 600; margin: 10px 0 6px; }
.login-card .form-control { padding: 10px 12px; border-radius: 8px; font-size: 15px; }
.btn-wide { width: 100%; margin-top: 22px; padding: 11px; font-size: 15px; }

/* Tablet and phone */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; display: flex; align-items: center; gap: 16px; padding: 10px 14px; overflow-x: auto; }
  .brand { padding: 0; }
  .sidebar nav { flex-direction: row; }
  .nav-item { white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 -3px 0 #6cb8f6; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .user { display: none; }
  .login-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-panel { place-items: start center; }
  .login-hero { padding: 32px 24px; }
  .login-hero h2 { font-size: 1.5rem; }
}
@media (max-width: 560px) {
  .login-hero p, .hero-points { display: none; }
}

/* Upload, review and history (Phase 2) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .85rem; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.upload-form { max-width: 820px; }
.upload-form .form-label { display: block; font-weight: 600; margin: 18px 0 6px; }
.upload-form textarea { border-radius: 8px; padding: 10px 12px; }
.drop-zone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 36px 20px; border: 2px dashed #b9c6d8; border-radius: var(--radius); background: #fafcff; cursor: pointer; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--brand); background: var(--brand-tint); }
.drop-zone:focus-within { outline: 3px solid var(--brand); outline-offset: 2px; }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { font-size: 2rem; color: var(--brand); }
.drop-title { font-weight: 600; font-size: 1.05rem; }
.drop-zone span.muted { max-width: 520px; }
.file-list { list-style: none; display: grid; gap: 4px; margin-top: 6px; font-size: .9rem; }
.file-list li::before { content: "\f15c"; font: var(--fa-font-regular); margin-right: 8px; color: var(--brand); }

.file-cards { display: grid; gap: 16px; }
.file-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.file-card-head h2 { margin-bottom: 6px; word-break: break-word; }
.file-card-head h2 i { color: var(--brand); margin-right: 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.facts dt { color: var(--ink-soft); font-size: .85rem; margin-bottom: 4px; }
.facts dd { font-weight: 600; }
.facts select.form-control { border-radius: 8px; padding: 8px 10px; font-weight: 400; max-width: 320px; }
.msg-list { list-style: none; display: grid; gap: 8px; margin: 6px 0 12px; }
.msg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; border: 1px solid; }
.msg i { margin-top: 3px; }
.msg-error { background: #fdf3f2; border-color: #f1c4bf; color: #8a1f14; }
.msg-warning { background: #fff8e6; border-color: #f3d58a; color: #6b4a00; }
.msg-info { background: #f5f8fc; border-color: #dbe4f0; color: #2c3a4f; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; margin-bottom: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.tech { margin-top: 6px; font-size: .88rem; }
.tech summary { cursor: pointer; color: var(--ink-soft); }
.tech dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin-top: 10px; }
.tech dt { color: var(--ink-soft); }
.tech dd { word-break: break-all; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--canvas) 30%); padding: 18px 0 8px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-uploaded { background: #fff4d6; color: #6b4a00; }
.status-loaded { background: #e3f4ea; color: #0b5a2f; }
.status-failed { background: #fde7e5; color: #8a1f14; }
.status-superseded, .status-rolled_back { background: #eceff4; color: #3d4757; }

.table-wrap { padding: 0; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th { text-align: left; font-weight: 600; color: var(--ink-soft); background: #f8fafc; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fbff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table a { color: var(--brand); font-weight: 600; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.warn-icon { color: #b07800; }
.crumbs { margin-bottom: 10px; }
.crumbs a { color: var(--brand); text-decoration: none; }
.section-title { font-size: 1rem; margin: 6px 0 8px; }

/* Phone: three nav items fit; tables become stacked cards */
@media (max-width: 560px) {
  .sidebar .brand-text { display: none; }
  .sidebar { gap: 10px; }
  .nav-item { padding: 9px 10px; gap: 8px; }
  .stack-on-phone thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack-on-phone tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .stack-on-phone td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .stack-on-phone td::before { content: attr(data-label); color: var(--ink-soft); font-weight: 600; text-align: left; }
  .stack-on-phone td:first-child { font-size: 1rem; padding-bottom: 8px; }
  .stack-on-phone td:first-child::before { content: none; }
}

/* Checks (Phase 4) */
.verdict { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.verdict h2 { margin-bottom: 2px; font-size: 1.3rem; }
.verdict-icon { font-size: 2rem; }
.verdict-ok { border-left: 5px solid var(--good); }
.verdict-ok .verdict-icon { color: var(--good); }
.verdict-warn { border-left: 5px solid #b07800; }
.verdict-warn .verdict-icon { color: #b07800; }
.check-cards { display: grid; gap: 16px; }
.check-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.check-head h2 { margin-bottom: 4px; }
.check-card .table-wrap { margin: 8px 0 10px; border: 1px solid var(--line); border-radius: 8px; }
.ok-icon { color: var(--good); }
.danger-zone { margin-top: 16px; }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--bad); }
.danger-zone p { margin: 12px 0; max-width: 760px; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Phone: four or more nav items become icons, labels kept for screen readers */
@media (max-width: 480px) {
  .sidebar nav { gap: 2px; }
  .nav-item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-item { padding: 10px 14px; }
  .nav-item i { font-size: 1.15rem; }
}

/* Overview dashboard (Phase 5) */
.trust-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font-weight: 600;
  text-decoration: none; font-size: .9rem; border: 1px solid; }
.trust-ok { background: #e9f6ee; color: #0b5a2f; border-color: #bfe3cc; }
.trust-warn { background: #fff4d6; color: #6b4a00; border-color: #f3d58a; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.filter-bar select, .filter-bar input { font: inherit; font-size: .92rem; color: var(--ink); padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; min-width: 170px; }
.custom-dates { display: flex; gap: 14px; }
.custom-dates[hidden] { display: none; }
.filter-note { margin-left: auto; align-self: center; }
.notice-warning { background: #fff8e6; border-color: #f3d58a; color: #6b4a00; }
.kpi-grid { margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 6px; text-align: left; font: inherit; color: inherit; }
button.kpi { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
button.kpi:hover { border-color: #b9cde6; box-shadow: 0 2px 4px rgba(16,24,40,.06), 0 8px 20px rgba(16,24,40,.08); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .88rem; font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: normal; }
.kpi-change { font-size: .82rem; display: flex; flex-wrap: wrap; gap: 4px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key-income { background: #257de0; } .key-expense { background: #f47230; } .key-net { background: #00b894; }
.delta-good { color: #006c10; font-weight: 600; } .delta-bad { color: #b42318; font-weight: 600; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card header h2 { font-size: 1.05rem; margin-bottom: 2px; }
.chart-card header { margin-bottom: 8px; }
.chart { width: 100%; }
.loading { opacity: .55; transition: opacity .2s; }
.table-view .data-table { margin-top: 8px; font-size: .86rem; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(920px, 100%); background: var(--surface); z-index: 50;
  box-shadow: -12px 0 32px rgba(15, 23, 42, .18); display: flex; flex-direction: column; }
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 1.15rem; margin-bottom: 4px; }
.drawer-total { font-size: .92rem; }
.drawer-body { overflow: auto; padding: 0 22px 22px; }
.drill-table { font-size: .86rem; }
.drill-table td { vertical-align: top; }
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .filter-note { margin-left: 0; width: 100%; }
  .filter-bar select, .filter-bar input { min-width: 0; }
  .filter-bar label { flex: 1 1 160px; }
}
.kpi-label [data-field="as-at"] { font-weight: 400; }
.drill-table td:last-child { min-width: 150px; }
@media (max-width: 700px) { .drill-table th:nth-child(4), .drill-table td:nth-child(4) { display: none; } }
.drawer-open .chart-tip { display: none !important; }

/* Phase 6: top-bar upload, demo banner, funds, reserves, where next */
.btn-sm-top { padding: 6px 12px; font-size: .9rem; text-decoration: none; }
.demo-banner { background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #f3d58a; padding: 8px 28px; font-size: .9rem; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.btn-csv { margin: 8px 0; font-size: .86rem; }
.key-violet { background: #6a4ce2; }
.illustrative { display: flex; gap: 8px; align-items: flex-start; background: #f5f3ff; color: #4c1d95; border: 1px solid #ddd6fe;
  border-radius: 8px; padding: 8px 10px; font-size: .85rem; margin-top: 6px; }
.reserves-figure { font-size: 2.6rem; font-weight: 650; letter-spacing: -.02em; margin: 4px 0 10px; }
.reserves-unit { font-size: 1rem; font-weight: 500; color: var(--ink-soft); letter-spacing: 0; }
.calc { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: .9rem; border-top: 1px solid var(--line); padding-top: 10px; }
.calc dt { color: var(--ink-soft); }
.calc dd { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pipeline { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; counter-reset: stage; }
.stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.stage-live { border-top: 4px solid var(--good); }
.stage-next { border-top: 4px dashed #b9c6d8; background: #fbfcfe; }
.stage:not(:last-child)::after { content: "\f061"; font: var(--fa-font-solid); position: absolute; right: -14px; top: 34px;
  color: #9aa8bd; background: var(--canvas); padding: 2px; z-index: 1; }
.stage-head { display: flex; gap: 10px; align-items: center; }
.stage-head .status { margin-left: auto; }
.stage-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); font-size: 1.1rem; flex: none; }
.stage-num { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 600; }
.stage h2 { margin: 0; }
.questions { padding-left: 18px; display: grid; gap: 6px; font-size: .9rem; color: var(--ink); }
.stage-link { margin-top: auto; color: var(--brand); font-weight: 600; text-decoration: none; }
@media (max-width: 1100px) { .pipeline { grid-template-columns: 1fr 1fr; } .stage:nth-child(2)::after { display: none; } }
@media (max-width: 640px) {
  .pipeline { grid-template-columns: 1fr; }
  .stage:not(:last-child)::after { content: "\f063"; right: auto; left: 50%; top: auto; bottom: -16px; transform: translateX(-50%); display: block; }
  .demo-banner { padding: 8px 16px; }
}
.chart-card, .chart-grid > *, .check-card, .file-card { min-width: 0; }
@media (max-width: 640px) { .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }

/* Phase 5a: plain-English answers and an eight-item phone nav */
.answer { border-left: 5px solid var(--good); margin-bottom: 18px; }
.answer h2 { font-size: 1.05rem; margin-bottom: 4px; }
.answer-text { font-size: 1.05rem; }
.answer-warn { border-left-color: #b07800; }
@media (max-width: 480px) {
  .sidebar { gap: 6px; padding: 8px 8px; }
  .brand-mark { width: 30px; height: 30px; }
  .nav-item { padding: 9px 9px; }
  .nav-item i { font-size: 1.05rem; }
}
.group-title { font-size: 1.15rem; margin: 18px 0 4px; }
