:root {
  --navy: #0B2545; --navy-2: #13325B; --blue: #1D4E89;
  --pink: #E8457C; --pink-hover: #D6336B; --blush: #FDECF2;
  --cloud: #F5F7FA; --white: #FFFFFF; --ink: #0B2545; --text: #2B3A52; --muted: #55627A; --line: #E3E8EF;
  --green: #1E7B4F; --green-soft: #E6F4EC; --amber: #9A6400; --amber-soft: #FFF4DC; --red: #B4232A; --red-soft: #FDECEC;
  --blue-soft: #E8F0FA;
  --radius: 14px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--cloud); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 800; }
h3 { font-size: .95rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell */
.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 12px; }
.topbar .brand { display: flex; flex-direction: column; min-width: 0; }
.topbar .brand b { font-size: 1rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand span { font-size: .75rem; color: #C9D6E8; }
.topbar .spacer { flex: 1; }
.badge-demo { background: var(--pink); color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #3DDC97; box-shadow: 0 0 0 0 rgba(61,220,151,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,151,.6); } 70% { box-shadow: 0 0 0 8px rgba(61,220,151,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); } }

.main { padding: 16px 16px calc(var(--nav-h) + 24px); max-width: 980px; margin: 0 auto; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-h); font-size: .72rem; font-weight: 600; color: var(--muted); }
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--pink); }
.nav .wide-only { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .nav { position: sticky; top: 64px; height: calc(100vh - 64px); flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 12px 10px; gap: 2px; align-self: start; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; font-size: .92rem; }
  .nav a.on { background: var(--blush); }
  .nav .wide-only { display: flex; }
  .nav .narrow-only { display: none; }
  .main { padding: 24px 28px 48px; width: 100%; }
}

/* ---------- blocks */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card, .section + .section { margin-top: 14px; }
.section { margin-top: 22px; }
.section > h2 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section > h2 .count { background: var(--pink); color: #fff; font-size: .72rem; border-radius: 999px; padding: 1px 8px; }
.grid { display: grid; gap: 12px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.tile .label { font-size: .76rem; color: var(--muted); font-weight: 600; }
.tile .value { font-size: 1.45rem; font-weight: 800; color: var(--ink); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.tile.navy { background: var(--navy); border-color: var(--navy); }
.tile.navy .label, .tile.navy .sub { color: #C9D6E8; }
.tile.navy .value { color: #fff; }

.list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; gap: 12px; align-items: center; padding: 13px 14px; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
a.row:hover { background: #FAFBFD; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .right { text-align: right; flex-shrink: 0; }
.row .amount { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.empty { padding: 18px 14px; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.pink { background: var(--blush); color: var(--pink-hover); }
.chip.grey { background: var(--cloud); color: var(--muted); }

/* timeline of today's jobs */
.job { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 14px; border-top: 1px solid var(--line); }
.job:first-child { border-top: 0; }
.job .when { font-weight: 800; color: var(--ink); font-size: .9rem; line-height: 1.2; }
.job .when span { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; }
.job .what { min-width: 0; }
.job .what .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.job .what .name { font-weight: 800; color: var(--ink); }
.job .what .problem { margin-top: 2px; }
.job .what .addr { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.job.now { background: var(--blush); }
.job.new { animation: flash 2.4s ease-out; }
@keyframes flash { 0% { background: #FFE2EC; } 100% { background: transparent; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; background: var(--pink); color: #fff; }
.btn:hover { background: var(--pink-hover); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--cloud); }
.btn.navy { background: var(--navy); }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* tabs and inputs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex-shrink: 0; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 12px; text-align: center; color: var(--ink); min-width: 62px; }
.tab b { display: block; font-size: 1.05rem; }
.tab span { font-size: .72rem; color: var(--muted); }
.tab.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tab.on span { color: #C9D6E8; }
.tab .dots { font-size: .68rem; color: var(--pink); font-weight: 800; }
.search { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; background: #fff; margin-bottom: 12px; }
.search:focus, .field input:focus { outline: 2px solid var(--pink); outline-offset: 1px; }

/* detail pages */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.two { display: grid; gap: 14px; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }
.options { display: grid; gap: 10px; }
@media (min-width: 640px) { .options { grid-template-columns: repeat(3, 1fr); } }
.option { border: 1px solid var(--line); border-radius: 12px; padding: 12px; position: relative; }
.option .tier { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.option .price { font-size: 1.3rem; font-weight: 800; color: var(--ink); margin: 4px 0; }
.option.chosen { border: 2px solid var(--pink); background: var(--blush); }
.option .margin { font-size: .76rem; color: var(--green); font-weight: 700; }
.transcript { white-space: pre-wrap; font-size: .85rem; background: var(--cloud); border-radius: 10px; padding: 12px; margin-top: 10px; color: var(--text); }
details summary { cursor: pointer; font-weight: 700; color: var(--blue); margin-top: 8px; }
.quote-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: .9rem; }
.quote-line:first-child { border-top: 0; }
.total-line { display: flex; justify-content: space-between; font-weight: 800; color: var(--ink); padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line); }
.debrief { border-left: 3px solid var(--pink); padding: 2px 0 2px 12px; }
.rec { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 34px; background: var(--navy); border-radius: 6px 6px 2px 2px; }
.bars .b.cur i { background: var(--pink); }
.bars .b span { font-size: .66rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.meter { height: 8px; background: var(--cloud); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.meter i.low { background: var(--amber); }

/* scorecard table */
.score { width: 100%; border-collapse: collapse; font-size: .86rem; font-variant-numeric: tabular-nums; }
.score th, .score td { padding: 9px 8px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.score th:first-child, .score td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.score thead th { color: var(--muted); font-weight: 700; font-size: .74rem; border-top: 0; }
.score td.cur { background: var(--blush); font-weight: 800; color: var(--ink); }
.score .good { color: var(--green); font-weight: 700; }
.score .low { color: var(--amber); font-weight: 700; }
.scroll-x { overflow-x: auto; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--navy); }
.login .box { background: #fff; border-radius: 18px; padding: 28px 22px; width: 100%; max-width: 400px; }
.login .logo { font-weight: 800; color: var(--ink); font-size: 1.15rem; }
.login .logo span { color: var(--pink); }
.login p { color: var(--muted); }
.field { display: grid; gap: 6px; margin: 18px 0 14px; }
.field label { font-weight: 700; color: var(--ink); font-size: .9rem; }
.field input { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font: inherit; }
.error { color: var(--red); font-size: .88rem; min-height: 1.2em; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); z-index: 50; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 10px 30px rgba(11,37,69,.3); max-width: calc(100% - 32px); }
#toast b { color: var(--pink); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.note { background: var(--blue-soft); color: var(--navy); border-radius: 12px; padding: 12px 14px; font-size: .88rem; }
