:root {
  --ford: #1d4ed8;
  --ford-hover: #1e40af;
  --ford-light: #2563eb;
  --bg0: #f6f7f9;
  --bg1: #eef1f4;
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #3f4654;
  --text-strong: #12141a;
  --muted: #6b7280;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.06);
  --sidebar-bg: rgba(255, 255, 255, 0.92);
  --input-bg: #f8f9fb;
  --metric-bg: #ffffff;
  --kpi-accent: #1d4ed8;
  --grad-mark: #12141a;
  --pro-bg: #f4f7ff;
  --pro-border: rgba(29, 78, 216, 0.25);
  --link: #1d4ed8;
  --accent: #1d4ed8;
  --radius: 16px;
  --table-header-bg: transparent;
  --table-header-fg: #6b7280;
  --table-zebra: transparent;
  --chart-bg: #ffffff;
  --code-bg: #f3f4f6;
  --expander: #f3f4f6;
  --pos: #047857;
  --neg: #b91c1c;
}
html[data-theme="dark"] {
  --bg0: #090a0d;
  --bg1: #101218;
  --card: #14161c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #c8cdd6;
  --text-strong: #f4f6fb;
  --muted: #8b93a1;
  --shadow: none;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.35);
  --sidebar-bg: rgba(16, 18, 24, 0.92);
  --input-bg: #0e1015;
  --metric-bg: #181b22;
  --kpi-accent: #8ea2ff;
  --grad-mark: linear-gradient(160deg, #eef2ff, #c7d2fe);
  --pro-bg: #1a1e2a;
  --pro-border: rgba(142, 162, 255, 0.35);
  --link: #a5b4fc;
  --accent: #a5b4fc;
  --table-header-bg: transparent;
  --table-header-fg: #8b93a1;
  --table-zebra: transparent;
  --chart-bg: #14161c;
  --code-bg: #0e1015;
  --expander: #1c2029;
  --pos: #6ee7b7;
  --neg: #fca5a5;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg0);
  color: var(--text);
  font-weight: 450;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
html[data-theme="dark"] body {
  background:
    radial-gradient(720px 280px at 0% -10%, rgba(99, 102, 241, 0.08), transparent 60%),
    var(--bg0);
  background-attachment: fixed;
}
a { color: var(--link); }
strong, b, h1, h2, h3, h4 { color: var(--text-strong); font-weight: 600; }
code, pre {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  background: var(--code-bg);
  color: var(--ford);
  border-radius: 6px;
  padding: .05rem .3rem;
  font-size: .85em;
}
html[data-theme="dark"] code { color: #c7d2fe; }

.wrap { max-width: 52rem; margin: 0 auto; padding: 1.25rem 1.25rem 3.5rem; }
.wrap.dash { max-width: 1240px; padding: 1rem 1.25rem 3rem; }

.hero { text-align: center; margin: .4rem auto 1rem; }
.pill {
  display: inline-block; font-size: .72rem; font-weight: 600;
  padding: .28rem .75rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--link);
}
h1 { font-size: clamp(1.45rem, 3vw, 1.85rem); letter-spacing: -.035em; margin: .35rem 0 .3rem; font-weight: 600; }
.section-title {
  font-size: .95rem; font-weight: 600; letter-spacing: -.02em;
  margin: 1.35rem 0 .65rem; color: var(--text-strong);
}
.section-title span { font-weight: 450; color: var(--muted); font-size: .8rem; margin-left: .35rem; }
.sub, .trust, .muted { color: var(--muted); }
.trust { font-size: .8rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  box-shadow: var(--shadow);
  margin: 0 auto 1rem;
  max-width: 28rem;
}
.wide { max-width: 52rem; }
.dash .card.wide {
  max-width: none;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}
.charts > .card {
  background: var(--chart-bg);
}

label { display: block; font-size: .78rem; font-weight: 550; margin: .55rem 0 .25rem; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text-strong);
  font: inherit; font-weight: 500;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(6, 111, 239, .28);
  border-color: var(--ford-light);
}
.row { display: flex; gap: .6rem; flex-wrap: wrap; }
.row > * { flex: 1 1 8rem; }

.btn {
  display: inline-block; width: 100%; text-align: center; text-decoration: none;
  background: var(--text-strong); color: var(--bg0) !important; border: 0; border-radius: 10px;
  font-weight: 600; padding: .65rem .9rem; cursor: pointer; font-size: .9rem;
  margin-top: .75rem;
  transition: opacity .15s ease, transform .12s ease;
}
html[data-theme="dark"] .btn { color: #090a0d !important; }
html[data-theme="dark"] .btn.secondary {
  background: var(--expander);
  color: var(--text-strong) !important;
}
html[data-theme="dark"] .btn.ghost { color: var(--muted) !important; }
.btn:hover { opacity: .88; }
.btn.secondary {
  background: var(--card); color: var(--text-strong) !important;
  border: 1px solid var(--border-strong); box-shadow: none;
}
.btn.secondary:hover { background: var(--expander); }
.btn.ghost {
  background: transparent; color: var(--muted) !important; border: 1px solid var(--border);
  width: auto; margin: 0; padding: .35rem .7rem; font-size: .78rem; box-shadow: none;
}
.btn.small { width: auto; margin: .4rem 0 0; padding: .4rem .75rem; font-size: .82rem; }
form.inline { display: inline; margin: 0; }
.btn.danger { background: #991b1b; box-shadow: none; }

.tabs { display: flex; gap: .4rem; margin-bottom: .6rem; }
.tabs a {
  padding: .35rem .55rem; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-size: .85rem; font-weight: 600;
}
.tabs a.on { background: var(--ford); color: #fff; }

.err { background: #fef2f2; color: #991b1b; padding: .6rem .7rem; border-radius: 10px; font-size: .85rem; }
.ok {
  background: linear-gradient(145deg, #ecfdf5, #d1fae5);
  color: #065f46; padding: .65rem .85rem; border-radius: 12px; font-size: .88rem;
  border: 1px solid #a7f3d0; margin-bottom: .8rem;
}
.warn {
  background: linear-gradient(145deg, #fff7ed, #ffedd5);
  color: #9a3412; padding: .65rem .85rem; border-radius: 12px; font-size: .88rem;
  border: 1px solid #fed7aa; margin-bottom: .8rem;
}
html[data-theme="dark"] .ok { background: rgba(6, 95, 70, .28); color: #6ee7b7; border-color: rgba(52, 211, 153, .3); }
html[data-theme="dark"] .warn { background: rgba(154, 52, 18, .28); color: #fdba74; border-color: rgba(251, 146, 60, .3); }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: .65rem;
  margin: .2rem 0 1.1rem;
}
.kpi {
  background: var(--metric-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .9rem 1rem .85rem;
  text-align: left;
  box-shadow: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.kpi .l {
  font-size: .68rem; color: var(--muted); font-weight: 550;
  letter-spacing: .06em; text-transform: uppercase;
}
.kpi .v {
  font-size: clamp(1.2rem, 1.6vw, 1.45rem);
  font-weight: 600; margin-top: .35rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--text-strong); letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.kpi .d { font-size: .72rem; color: var(--muted); margin-top: .28rem; font-weight: 500; }

.nav {
  display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; margin-bottom: 1.1rem; flex-wrap: wrap;
  position: sticky; top: .55rem; z-index: 30;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .45rem .7rem .45rem .85rem;
  box-shadow: var(--shadow);
}
.nav a { font-size: .84rem; font-weight: 550; text-decoration: none; color: var(--muted); }
.nav a.on { color: var(--text-strong); }
html[data-theme="dark"] .nav a.on { color: #f4f6fb; }
.nav .brand {
  color: var(--text-strong); font-size: 1.02rem; display: inline-flex; align-items: center; gap: .45rem;
}
.brand-mark {
  width: 1.65rem; height: 1.65rem; border-radius: 8px;
  background: var(--text-strong); color: var(--bg0);
  display: grid; place-items: center; font-size: .75rem; font-weight: 650;
  box-shadow: none;
}
html[data-theme="dark"] .brand-mark { color: #090a0d; }
.nav-links { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.nav .btn { width: auto; margin: 0; padding: .35rem .7rem; font-size: .8rem; }

.hero-dash {
  display: flex; gap: .75rem; align-items: flex-end;
  margin: .1rem 0 1rem; padding: 0 0 .15rem;
  border-bottom: 0;
}
.hero-dash .mark { display: none; }
.hero-dash h1 { margin: 0; font-size: clamp(1.35rem, 2vw, 1.7rem); line-height: 1.15; font-weight: 600; }
.hero-dash p { margin: .28rem 0 0; font-size: .84rem; color: var(--muted); font-weight: 450; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .7rem; }
.charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 0 0 1rem;
  align-items: stretch;
}
@media (min-width: 900px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1320px) {
  .charts.trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.charts > .card {
  min-width: 0;
  overflow: hidden;
  margin-bottom: 0;
  padding: .85rem .9rem .55rem;
  border-radius: 16px;
}
.chart { width: 100%; min-width: 0; overflow: hidden; }
.chart .js-plotly-plot,
.chart .plot-container,
.chart .svg-container { width: 100% !important; max-width: 100%; }

.action {
  border: 1px solid var(--border); border-radius: 12px; padding: .75rem .85rem;
  background: var(--card); box-shadow: var(--shadow);
}
.action .pri { font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.pri-high { color: #b45309; }
.pri-medium { color: #1d4ed8; }
.pri-low { color: var(--muted); }

.progress { height: 8px; background: rgba(148, 163, 184, .25); border-radius: 99px; overflow: hidden; margin: .35rem 0; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #003478, #066fef); }

details.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem 1rem; margin: 0 0 1rem; box-shadow: var(--shadow);
}
details.panel summary { cursor: pointer; font-weight: 600; color: var(--text-strong); letter-spacing: -.01em; }
details.panel .inner { margin-top: .7rem; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
}
.cmd { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.cmd input { flex: 1 1 14rem; }
.chip-line { font-size: .8rem; color: var(--muted); margin: .2rem 0 .8rem; font-weight: 450; }
.locked .btn { max-width: 16rem; }
.hustle { border: 1px solid var(--border); border-radius: 12px; padding: .7rem; background: var(--expander); }
.month-list { font-variant-numeric: tabular-nums; }
.check.inline { display: inline-flex; align-items: center; gap: .35rem; margin: .4rem .8rem .4rem 0; }
.check.inline input { width: auto; margin: 0; }
.inline-details { display: inline-block; }
.inline-details summary { cursor: pointer; }
.notes { max-width: 40rem; text-align: left; margin-top: .5rem; }
.notes-body { white-space: pre-wrap; font: inherit; font-weight: 500; font-size: .8rem; }
.tabs-row { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.tabs-row a, .tabs-row span {
  padding: .3rem .55rem; border-radius: 8px; font-size: .8rem; font-weight: 550;
  border: 1px solid var(--border); text-decoration: none; color: var(--muted);
}
.tabs-row a.on, .tabs-row span.on { background: var(--ford); color: #fff; border-color: var(--ford); }
.bar { height: 6px; background: rgba(148, 163, 184, .2); border-radius: 99px; overflow: hidden; margin: .4rem 0 1rem; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #003478, #066fef); }

table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td {
  text-align: left; padding: .62rem .55rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
th {
  background: var(--table-header-bg);
  color: var(--table-header-fg);
  font-weight: 550;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.table-wrap th:not(:first-child),
.table-wrap td:not(:first-child) { text-align: right; }
tr:nth-child(even) td { background: var(--table-zebra); }
tr:hover td { background: color-mix(in srgb, var(--expander) 70%, transparent); }
tr:last-child td { border-bottom: 0; }

footer { margin-top: 1.5rem; font-size: .78rem; color: var(--muted); }
.check { display: flex; gap: .45rem; align-items: flex-start; margin: .7rem 0; }
.check input { width: auto; margin-top: .2rem; }
.chips { display: flex; gap: .45rem; flex-wrap: wrap; max-width: 28rem; margin: .7rem auto; }
.chip {
  flex: 1 1 7rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: .7rem .55rem; text-align: center; box-shadow: var(--shadow);
}
.chip .n { font-weight: 600; color: var(--text-strong); }
.chip .l { font-size: .68rem; color: var(--muted); }

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
  align-items: start;
}
.side { min-width: 0; }
.side-fold { border: 0; padding: 0; margin: 0; }
.side-toggle {
  cursor: pointer; font-weight: 600; font-size: .85rem;
  padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); list-style: none;
}
.side-toggle::-webkit-details-marker { display: none; }
.side-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .7rem .8rem .85rem;
  margin: .55rem 0 0;
  box-shadow: var(--shadow);
}
.side-h {
  font-size: .68rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 .4rem;
}
.side label { font-size: .75rem; margin: .4rem 0 .12rem; }
.side input, .side select, .side textarea { padding: .4rem .5rem; font-size: .82rem; }
.side .btn { width: 100%; margin-top: .45rem; }
.side .btn.small { width: 100%; }
.main { min-width: 0; }

@media (min-width: 960px) {
  .app-shell { grid-template-columns: 17.25rem minmax(0, 1fr); gap: 1.35rem; }
  .side {
    position: sticky;
    top: 4.2rem;
    max-height: calc(100vh - 4.8rem);
    overflow-y: auto;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: .85rem .9rem 1rem;
    box-shadow: none;
    backdrop-filter: blur(12px);
  }
  .side-toggle { display: none; }
  .side-fold { display: block; }
  .side-block {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    padding: .75rem 0 .9rem;
  }
  .side-block:first-child { padding-top: 0; }
  .side-block:last-child { border-bottom: 0; padding-bottom: 0; }
}
@media (max-width: 640px) {
  .wrap { padding: .5rem .7rem 2rem; }
  .kpi { min-height: 5.4rem; }
}
