:root {
  --ink: #16202a;
  --navy: #17324d;
  --navy2: #25455f;
  --red: #c8102e;
  --cream: #faf7f2;
  --paper: #ffffff;
  --line: #e6dfd5;
  --muted: #6f6862;
  --gold: #c9a227;
  --green: #2e7d5b;
  --amber: #b7791f;
  --soft: #f4ede4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy2); text-decoration: none; }
a:hover { text-decoration: underline; }

.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }
.mb { margin-bottom: 14px; }

/* ---------- rail ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: 232px;
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column;
  padding: 20px 12px 14px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--red);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; flex: none;
}
.brand .name { font-size: 14px; font-weight: 700; line-height: 1.15; }
.brand .name span { display: block; font-size: 9.5px; font-weight: 500; color: #9fb1c2; letter-spacing: 1.6px; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  color: #afc0cf; padding: 9px 11px; border-radius: 8px;
  font-size: 13px; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.10); color: #fff; font-weight: 600; }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px;
  width: 3px; background: var(--gold); border-radius: 0 3px 3px 0;
}
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.rail .foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; color: #8fa3b5; line-height: 1.6; }
.rail .foot b { color: #dce6ee; font-weight: 600; }
.rail .foot form { margin-top: 8px; }

/* ---------- shell ---------- */
.main { margin-left: 232px; min-height: 100vh; }
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--line);
  background: rgba(250,247,242,.94); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(6px);
}
.topbar h1 { font-size: 17.5px; font-weight: 700; letter-spacing: -.2px; }
.topbar .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tools { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--navy2); color: #fff;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
}
.content { padding: 22px 26px 60px; max-width: 1200px; }
.main-auth { margin-left: 0; display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-content { width: 100%; max-width: 400px; padding: 24px 16px 60px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand .mark { width: 36px; height: 36px; border-radius: 10px; background: var(--red); display: grid; place-items: center; color: #fff; font-weight: 800; }
.auth-brand .name { font-size: 16px; font-weight: 700; line-height: 1.1; }
.auth-brand .name span { display: block; font-size: 9.5px; letter-spacing: 1.6px; color: var(--muted); font-weight: 600; margin-top: 3px; }

.tabs { display: none; }

/* ---------- primitives ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.card h3 {
  font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.card h3 .r { letter-spacing: 0; text-transform: none; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.grid { display: grid; gap: 13px; }
.g2 { grid-template-columns: 1.5fr 1fr; }
.g2e { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.stack { display: flex; flex-direction: column; gap: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.big { font-size: 29px; font-weight: 650; letter-spacing: -.9px; line-height: 1.05; }
.label { font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
.up { color: var(--green); }
.dn { color: var(--red); }

.hero {
  background: var(--navy); color: #fff; border-radius: 12px;
  padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 22px;
}
.hero .eyebrow { font-size: 9.5px; letter-spacing: 2px; color: var(--gold); font-weight: 700; text-transform: uppercase; }
.hero h2 { font-size: 20px; font-weight: 600; letter-spacing: -.3px; margin-top: 6px; line-height: 1.32; }
.hero p { font-size: 12.5px; color: #b9c6d3; margin-top: 7px; max-width: 660px; }
.hero .right { text-align: right; flex: none; }
.hero .right .v { font-size: 32px; font-weight: 650; letter-spacing: -1px; }
.hero .right .k { font-size: 9.5px; letter-spacing: 1.4px; color: #9fb1c2; text-transform: uppercase; }

.tile { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.tile .k { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.tile .v { font-size: 26px; font-weight: 650; letter-spacing: -.8px; margin-top: 5px; }
.tile .d { font-size: 11.5px; margin-top: 3px; color: var(--muted); }
.tile.warn { border-color: #e9c9a8; background: #fffbf4; }
.tile.bad { border-color: #e9b9bf; background: #fff8f8; }
.tile.good { border-color: #bcd9c9; background: #f8fcf9; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .3px; padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.pill.red { background: #fbe7e9; color: #9b1226; }
.pill.amber { background: #fbf0dc; color: #8a5a12; }
.pill.green { background: #e4f1ea; color: #1f6047; }
.pill.grey { background: #eeeae4; color: #5f5952; }
.pill.blue { background: #e6edf4; color: #274a6b; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: flex-start; gap: 11px; padding: 9px 0; border-bottom: 1px solid #f1ece4; }
.li:last-child { border-bottom: 0; }
.li .ic { width: 26px; height: 26px; border-radius: 7px; background: var(--soft); display: grid; place-items: center; font-size: 12px; flex: none; margin-top: 1px; }
.li .tx { flex: 1; min-width: 0; }
.li .tx b { font-weight: 600; font-size: 12.8px; display: block; }
.li .tx span { font-size: 11.5px; color: var(--muted); }
.li .rt { flex: none; text-align: right; font-size: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: right; font-size: 9.5px; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 0 0 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
th:first-child { text-align: left; }
td { padding: 8px 0; border-bottom: 1px solid #f4f0e9; text-align: right; vertical-align: middle; }
td:first-child { text-align: left; }
tr.total td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; padding-top: 9px; }
tr.sub td { font-weight: 600; background: #fcfaf6; }
tr.neg td { color: var(--red); }
tr.muted-row td { color: var(--muted); }
.ind { color: var(--muted); padding-left: 16px !important; }

/* ---------- forms ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: #3c4650; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d8d1c6; border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23,50,77,.18); border-color: var(--navy2); }
textarea { resize: vertical; min-height: 64px; }
input.money { font-size: 22px; font-weight: 650; letter-spacing: -.5px; padding: 12px 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 8px; padding: 9px 14px;
  background: var(--navy); color: #fff; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--navy2); text-decoration: none; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 18px; font-size: 15px; }
.btn.ghost { background: #fff; color: var(--navy); border-color: #d8d1c6; }
.btn.ghost:hover { background: #f7f3ec; }
.btn.danger { background: #fff; color: var(--red); border-color: #e9b9bf; }
.btn.small { padding: 5px 9px; font-size: 11.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.check input { width: auto; }

/* ---------- flash ---------- */
.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 12.8px; border: 1px solid; }
.flash.ok { background: #eef7f1; border-color: #bcd9c9; color: #1f6047; }
.flash.warn { background: #fdf6e9; border-color: #e9cfa6; color: #8a5a12; }
.flash.error { background: #fdf0f1; border-color: #e9b9bf; color: #9b1226; }

/* ---------- data ---------- */
.src { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid #f1ece4; }
.src:last-child { border: 0; }
.src .st { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.src .tx { flex: 1; min-width: 0; }
.src .tx b { font-size: 12.8px; display: block; }
.src .tx span { font-size: 11.5px; color: var(--muted); }
.st.live { background: var(--green); }
.st.connected { background: var(--navy2); }
.st.stale { background: var(--amber); }
.st.planned { background: #8a8178; }
.st.missing, .st.error { background: var(--red); }

.drop {
  border: 1.5px dashed #c9c2b7; border-radius: 12px; padding: 20px;
  text-align: center; background: #fcfaf6;
}
.drop b { font-size: 13px; }
.drop p { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.drop input[type=file] { margin: 10px auto 0; font-size: 11.5px; }

/* ---------- cash ---------- */
.cash-hero { max-width: 520px; }
.cash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.secret td { color: var(--muted); }
.reveal {
  background: var(--navy); color: #fff; border-radius: 12px; padding: 16px 18px;
}
.reveal .v { font-size: 26px; font-weight: 650; letter-spacing: -.6px; }
.reveal .k { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: #9fb1c2; }
.reveal .grid { gap: 12px; }

/* ---------- targets ---------- */
.progress { height: 6px; border-radius: 3px; background: #ede8e0; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--navy2); border-radius: 3px; }
.progress i.warn { background: var(--amber); }
.progress i.bad { background: var(--red); }
.progress i.good { background: var(--green); }

/* ---------- misc ---------- */
.kpi-inline { display: flex; gap: 18px; flex-wrap: wrap; }
.kpi-inline > div { min-width: 90px; }
.kpi-inline .k { font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kpi-inline .v { font-size: 19px; font-weight: 650; letter-spacing: -.4px; }
.empty { padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }
.banner-warn { background: #fdf6e9; border: 1px solid #e9cfa6; color: #8a5a12; border-radius: 9px; padding: 10px 13px; font-size: 12.5px; }
.tag { font-size: 10px; letter-spacing: .3px; background: var(--soft); color: #5a5148; border-radius: 4px; padding: 2px 6px; font-weight: 600; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 20px;
  padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: inherit; color: #3c4650;
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; background: #f4efe8; padding: 1px 5px; border-radius: 4px; }

/* ---------- mobile ---------- */
@media (max-width: 980px) {
  .g2, .g2e, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero .right { text-align: left; }
}

@media (max-width: 760px) {
  body { font-size: 14px; }
  .rail { display: none; }
  .main { margin-left: 0; padding-bottom: 64px; }
  .topbar { height: 54px; padding: 0 14px; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 14px 14px 40px; }
  .g2, .g2e, .g3, .g4, .form-grid, .cash-actions { grid-template-columns: 1fr; }
  .tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 58px;
    background: #fff; border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 10px; color: var(--muted); font-weight: 600;
  }
  .tabs a.active { color: var(--navy); }
  .tabs svg { width: 19px; height: 19px; }
  .big { font-size: 25px; }
  .tile .v { font-size: 22px; }
  input, select, textarea, .btn { font-size: 16px; } /* stops iOS zooming on focus */
  .btn.lg { width: 100%; }
}

@media print {
  .rail, .topbar, .tabs, .btn, form { display: none !important; }
  .main { margin: 0; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; font-size: 11px; }
}
