:root {
  --brand: #29aae1; --navy: #1d4568; --navy-2: #2a5a85;
  --bg: #f3f5f9; --card: #ffffff; --well: #e9edf4;
  --text: #1c2430; --sub: #6b7689; --line: #e1e5ec;
  --ok: #e3f6ea; --ok-t: #176639; --warn: #fff1c9; --warn-t: #7a5a00;
  --bad: #fde2d6; --bad-t: #8a2d00; --info: #e1f1fb; --info-t: #16517a;
  --r: 16px; --r-sm: 12px; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(20,30,60,.05), 0 6px 20px rgba(20,30,60,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text);
  font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--navy-2); }

/* ---- top bar ---- */
header.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: #fff; padding: 0.55rem 1.25rem; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--text); }
.brand img { height: 30px; display: block; }
.brand-name { font-weight: 700; font-size: 0.98rem; letter-spacing: -0.01em; color: var(--text); text-decoration: none; margin-right: auto; }
nav { display: flex; align-items: center; gap: 0.25rem; font-size: 0.9rem; }
nav a { color: var(--sub); text-decoration: none; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: var(--r-pill); }
nav a:hover { color: var(--navy); background: var(--well); }
nav a.on { color: var(--navy); background: var(--well); }
nav .who { color: var(--sub); padding: 0 0.6rem 0 0.9rem; }

main { max-width: 1200px; margin: 1.25rem auto; padding: 0 1.25rem 2rem; }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; display: flex; align-items: center; gap: 0.6rem; }
h2 { font-size: 1.02rem; font-weight: 700; margin: 0 0 0.7rem; display: flex; align-items: center; gap: 0.5rem; }
p { margin: 0.4rem 0; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---- surfaces ---- */
.card { background: var(--card); border-radius: var(--r); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.tight { padding: 0.35rem 0.5rem; overflow-x: auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.login-card { max-width: 400px; margin: 12vh auto; text-align: center; padding: 2rem 1.6rem; }
.login-card h1 { justify-content: center; margin-bottom: 1rem; }
.login-logo { height: 56px; margin-bottom: 0.6rem; }
details.card summary { cursor: pointer; font-weight: 700; color: var(--navy); font-size: 1.02rem; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.6rem 1.15rem; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: #fff; color: var(--text); text-decoration: none; font: inherit; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.btn:hover { border-color: var(--navy-2); color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.btn.small { padding: 0.36rem 0.85rem; font-size: 0.82rem; }
.btn.ghost { border-color: transparent; color: var(--sub); }
.btn.ghost:hover { background: var(--well); color: var(--navy); }
.btn.danger { color: var(--bad-t); border-color: #f0c2ae; }
.btn.danger:hover { background: var(--bad); border-color: var(--bad-t); color: var(--bad-t); }
input, select { font: inherit; color: var(--text); }
input[type=search], input[type=text], input[type=email], select {
  padding: 0.55rem 0.95rem; border: 1px solid var(--line); border-radius: var(--r-pill); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(41,170,225,.18); }
select { padding-right: 2rem; appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7689' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.8rem center; }
form.inline { display: inline-flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
label.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem; border-radius: var(--r-pill);
  background: #fff; border: 1px solid var(--line); font-size: 0.85rem; font-weight: 600; color: var(--sub); cursor: pointer; }
label.chip:has(input:checked) { background: var(--navy); border-color: var(--navy); color: #fff; }
label.chip input { position: absolute; opacity: 0; width: 0; height: 0; }

/* ---- pills ---- */
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.16rem 0.6rem; border-radius: var(--r-pill);
  font-size: 0.74rem; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.pill.soft { background: var(--well); color: var(--sub); }
.pill.ok, .pill.w2 { background: var(--ok); color: var(--ok-t); }
.pill.warn, .pill.future { background: var(--warn); color: var(--warn-t); }
.pill.bad, .pill.terminated { background: var(--bad); color: var(--bad-t); }
.pill.contractor { background: var(--info); color: var(--info-t); }
.pill.unmapped { background: var(--well); color: var(--sub); }
.pill.dept-sales { background: #ede7fb; color: #4b2f9e; }
.pill.dept-production { background: #fdebd3; color: #8a4b00; }
.pill.dept-office { background: var(--well); color: #3c4860; }
.pill.tool { background: var(--well); color: var(--text); font-weight: 500; }
.pill.tool b { font-weight: 700; color: var(--navy); }
.banner { padding: 0.6rem 1rem; border-radius: var(--r-sm); font-weight: 600; margin-bottom: 1rem; }
.banner.ok { background: var(--ok); color: var(--ok-t); }
.error { background: var(--bad); color: var(--bad-t); padding: 0.6rem 0.9rem; border-radius: var(--r-sm); margin: 0.8rem 0; }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 0.82rem; }

/* ---- tables ---- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sub);
  padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); font-weight: 700; }
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ---- toolbar + tabs ---- */
.toolbar { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar .search { flex: 1 1 240px; }
.toolbar .search input { width: 100%; }
.toolbar-right { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 0.25rem; padding: 0.25rem; background: var(--well); border-radius: var(--r-pill); }

/* ---- cash dashboard ---- */
.sub { color: var(--sub); font-size: 0.85rem; }
.src { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid4 { grid-template-columns: 1fr; } }
.block h2 { margin-bottom: 0.9rem; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 0 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.kv:last-of-type { border-bottom: none; }
.kv span { color: var(--sub); font-size: 0.88rem; }
.kv b { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.kv small { grid-column: 1 / -1; color: var(--sub); font-size: 0.76rem; }
.kv.big b { font-size: 1.35rem; color: var(--navy); }
.kv.bad b { color: var(--bad-t); }
.callout { margin-top: 0.8rem; padding: 0.7rem 0.9rem; border-radius: var(--r-sm); background: var(--info); color: var(--info-t); font-size: 0.88rem; }
.callout b { font-variant-numeric: tabular-nums; }
table.mini { font-size: 0.8rem; }
table.mini td, table.mini th { padding: 0.3rem 0.5rem; }
table.mini td.num, table.mini th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td:first-child { font-weight: 600; }
details.sub-detail { margin-top: 0.6rem; }
details.sub-detail summary { cursor: pointer; color: var(--navy-2); font-size: 0.85rem; font-weight: 600; }
details.notes summary { cursor: pointer; font-weight: 700; color: var(--navy); }
details.notes li { font-size: 0.85rem; color: var(--sub); margin: 0.3rem 0; }
.chart { width: 100%; height: auto; margin: 0.3rem 0 0.6rem; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.chart .dot { fill: var(--navy); }
.chart .lbl { font-size: 11px; fill: var(--sub); }
.form label { display: block; margin: 0.5rem 0; font-size: 0.85rem; color: var(--sub); font-weight: 600; }
.form input, .form textarea { display: block; width: 100%; margin-top: 0.2rem; padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; color: var(--text); }
.form textarea { font-family: Consolas, "SF Mono", monospace; font-size: 0.78rem; }
.form button { margin-top: 0.8rem; }
.banner.warn { background: var(--warn); color: var(--warn-t); }
code { background: var(--well); padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.82rem; }
.chart.trend .line.rloc { stroke: #d9603a; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.3rem; vertical-align: -1px; }
.key.cash { background: var(--brand); } .key.rloc { background: #d9603a; }
.legal { max-width: 760px; margin: 1rem auto; }
.legal h2 { margin-top: 1.2rem; }
footer.legal-links { text-align: center; color: var(--sub); font-size: 0.8rem; padding: 0 0 1.5rem; }
footer.legal-links a { color: var(--sub); }

/* ---- dashboard rebuild (James 10/13): 2x2 + sensitivity, QuickBooks-style tiles ---- */
.dash { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin-bottom: 0.9rem; }
@media (max-width: 900px) { .dash { grid-template-columns: 1fr; } }
.blk { margin: 0; padding: 1rem 1.15rem 0.95rem; display: flex; flex-direction: column; }
.blk h2 { margin-bottom: 0.7rem; }
.blk .lab { display: block; color: var(--sub); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.01em; }
.blk .lab2 { display: block; color: var(--sub); font-size: 0.74rem; margin-top: 0.1rem; }
.hero { padding: 0.1rem 0 0.75rem; border-bottom: 1px solid var(--line); margin-bottom: 0.75rem; }
.hero .val { display: block; font-size: 2.05rem; font-weight: 700; letter-spacing: -0.02em; color: var(--navy); line-height: 1.15; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.tiles.three { grid-template-columns: 1fr 1fr 1fr; }
.tile { background: var(--bg); border-radius: var(--r-sm); padding: 0.55rem 0.75rem; min-width: 0; }
.tile b { display: block; font-size: 1.12rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.tile.good { background: var(--ok); } .tile.good .lab, .tile.good .lab2 { color: var(--ok-t); } .tile.good b { color: var(--ok-t); }
.tile.bad { background: var(--bad); } .tile.bad .lab, .tile.bad .lab2 { color: var(--bad-t); } .tile.bad b { color: var(--bad-t); }
.rows { margin-top: 0.6rem; }
.rows .kv { padding: 0.32rem 0; }
.rows .kv span { font-size: 0.86rem; }
.rows .kv.total { border-top: 2px solid var(--line); margin-top: 0.1rem; }
.rows .kv.total span { color: var(--text); font-weight: 600; }
.rows .kv.total b { color: var(--navy); font-size: 1.02rem; }
.blk .callout { margin-top: 0.7rem; font-size: 0.84rem; }
details.accts { margin-top: 0.65rem; }
details.accts summary { cursor: pointer; color: var(--navy-2); font-size: 0.82rem; font-weight: 600; list-style: none; }
details.accts summary::-webkit-details-marker { display: none; }
details.accts summary::before { content: "▸ "; } details.accts[open] summary::before { content: "▾ "; }
details.accts table { margin-top: 0.3rem; max-height: 180px; display: block; overflow-y: auto; }
/* chart */
.charthead { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.charthead h2 { margin-bottom: 0.4rem; }
.legend { display: flex; align-items: center; gap: 0.9rem; font-size: 0.8rem; color: var(--sub); font-weight: 600; }
.sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 0.35rem; vertical-align: 3px; }
.sw.cash { background: var(--brand); } .sw.rloc { background: #d9603a; }
.chartblk { position: relative; }
.trend { flex: 1; min-height: 200px; }
.trendsvg { width: 100%; height: auto; display: block; }
.trendsvg .grid { stroke: var(--line); stroke-width: 1; }
.trendsvg .tick { font-size: 10.5px; fill: var(--sub); font-family: Inter, system-ui, sans-serif; }
.trendsvg .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trendsvg .ln.cash, .trendsvg .end.cash, .trendsvg .hov.cash { stroke: var(--brand); }
.trendsvg .ln.rloc, .trendsvg .end.rloc, .trendsvg .hov.rloc { stroke: #d9603a; }
.trendsvg .end.cash, .trendsvg .hov.cash { fill: var(--brand); }
.trendsvg .end.rloc, .trendsvg .hov.rloc { fill: #d9603a; }
.trendsvg .end, .trendsvg .hov { stroke: #fff; stroke-width: 2; }
.trendsvg .xhair { stroke: var(--sub); stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow);
  padding: 0.45rem 0.65rem; font-size: 0.8rem; pointer-events: none; z-index: 2; display: flex; flex-direction: column; gap: 0.1rem; }
.tip b { font-weight: 700; }
.tip span { color: var(--text); font-variant-numeric: tabular-nums; }
.trendtable { margin-top: 0.3rem; max-height: 220px; display: block; overflow-y: auto; }
/* sensitivity */
.sens { padding: 0.9rem 1.15rem; }
.sens table.grid th:first-child, .sens table.grid td:first-child { padding-left: 0.5rem; }
.sens table.grid tr.here td { background: var(--info); color: var(--info-t); font-weight: 700; }
.sens table.grid tr.here td:first-child::after { content: "  ◂ today"; font-size: 0.7rem; font-weight: 700; color: var(--info-t); }
.legend .lg { display: inline-flex; align-items: center; }
.trendtable[hidden], .trend[hidden], details.accts table[hidden] { display: none; }
/* compact pass (James 10/13: less scrolling) */
.blk { padding: 0.85rem 1.05rem 0.8rem; }
.blk h2 { margin-bottom: 0.55rem; font-size: 0.98rem; }
.hero { padding-bottom: 0.55rem; margin-bottom: 0.55rem; }
.hero .val { font-size: 1.9rem; }
.tiles { gap: 0.45rem; }
.tile { padding: 0.42rem 0.65rem; }
.tile b { font-size: 1.05rem; }
.rows { margin-top: 0.45rem; }
.rows .kv { padding: 0.24rem 0; }
.rows.two { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.3rem; }
.rows.two .kv.total { grid-column: 1 / -1; }
@media (max-width: 600px) { .rows.two { grid-template-columns: 1fr; } }
.blk .callout { margin-top: 0.5rem; padding: 0.5rem 0.75rem; }
.dash { gap: 0.75rem; margin-bottom: 0.75rem; }
.sens { padding: 0.75rem 1.05rem 0.6rem; }
.sens table.mini td, .sens table.mini th { padding: 0.28rem 0.5rem; }
.pagehead { margin-bottom: 0.7rem; }
main { margin-top: 0.9rem; }
.sens table.grid { width: 100%; display: table; table-layout: fixed; }
.sens table.grid td:first-child { width: 20%; }
.tip[hidden] { display: none; }
