/* AT Studio Portal. Same tokens as the public site (www/theme.css), plus chart and status colours. Phone first. */
:root {
  --paper: #ffffff;
  --ink: #111111;
  --ink-soft: #5a564e;
  --ink-muted: #8a857b;
  --line: #e4dfd5;
  --line-soft: #efebe4;
  --wash: #f7f4ef;
  --gold: #b79b6a;
  --gold-deep: #8a6f3f;
  --display: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --body: "Jost", "Helvetica Neue", Arial, sans-serif;

  /* Chart series (validated pair: colourblind-safe against the light surface) */
  --collected: #2a78d6;
  --spent: #eb6834;
  /* Status: always paired with an icon and words */
  --danger: #b03a2e;
  --danger-bg: #fbecea;
  --warn: #8f5c00;
  --warn-bg: #fdf3df;
  --good: #2f6b45;
  --good-bg: #e8f3ec;

  --gutter: 16px;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--wash); color: var(--ink); font: 300 15px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 500; margin: 0; }
h1, h2 { font-family: var(--display); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }
.num { font-variant-numeric: tabular-nums lining-nums; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-danger { color: var(--danger); }
.ic-warn { color: var(--warn); }
.ic-good { color: var(--good); }
.ic-muted { color: var(--ink-muted); }

.brand { margin: 0; letter-spacing: .28em; font-size: 13px; font-weight: 400; text-decoration: none; white-space: nowrap; }
.brand .mark { font-family: var(--display); font-size: 22px; letter-spacing: .05em; margin-right: 3px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--ink); background: var(--paper); padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 400; white-space: nowrap; text-decoration: none; min-height: 40px; }
.btn:hover { background: var(--wash); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #333; }
.btn-small { padding: 5px 12px; font-size: 13px; min-height: 32px; }
.btn-ghost { border-color: var(--line); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--gold-deep); cursor: pointer; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 9px 12px; font-size: 16px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--ink-soft); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-actions.split { justify-content: space-between; }

/* Chips (filters and choice buttons) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { position: relative; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 13px; font-size: 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.chip.on, .chip:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip .count { color: var(--ink-muted); font-size: 12px; }
.chip.on .count { color: #cfcac0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); padding: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; cursor: pointer; font-size: 14px; border-radius: 999px; }
.seg button.on { background: var(--ink); color: var(--paper); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--wash); color: var(--ink-soft); white-space: nowrap; font-weight: 400; }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.dark { background: var(--ink); color: var(--paper); }
.t-danger { color: var(--danger); }
.t-warn { color: var(--warn); }
.t-good { color: var(--good); }

progress { width: 100%; height: 6px; border: 0; border-radius: 99px; background: var(--line-soft); overflow: hidden; -webkit-appearance: none; appearance: none; display: block; }
progress::-webkit-progress-bar { background: var(--line-soft); }
progress::-webkit-progress-value { background: var(--gold); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 99px; }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.login-card { width: min(380px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: grid; gap: 14px; }
.login-card h1 { font-size: 32px; }

/* Top bar and navigation */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px var(--gutter); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.2) blur(6px); }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { text-decoration: none; padding: 7px 14px; border-radius: 999px; font-size: 15px; color: var(--ink-soft); }
.topnav a.on { background: var(--ink); color: var(--paper); }
.topnav a:hover:not(.on) { background: var(--wash); }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who { font-size: 13px; color: var(--ink-soft); }
.bottomnav { display: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 18px var(--gutter) 110px; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 34px; line-height: 1.1; }
.fab { position: fixed; right: 22px; bottom: 24px; z-index: 6; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); font-size: 30px; font-weight: 300; line-height: 1; cursor: pointer; box-shadow: 0 6px 18px rgba(17,17,17,.22); }
.fab:hover { background: #333; }

/* Cards and grids */
.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 14px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-family: var(--body); font-size: 15px; font-weight: 500; }
.card-head .muted { font-size: 13px; }
.empty { color: var(--ink-soft); font-size: 14px; margin: 4px 0; }

/* Money tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile .label { font-size: 13px; color: var(--ink-soft); }
.tile .value { font-family: var(--display); font-size: 36px; font-weight: 500; line-height: 1.15; font-variant-numeric: tabular-nums lining-nums; overflow-wrap: anywhere; }
.tile .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.tile.hero { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tile.hero .label, .tile.hero .sub { color: #cfcac0; }

/* Chart */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw-collected { background: var(--collected); }
.sw-spent { background: var(--spent); }
.chart { width: 100%; min-height: 190px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: #ece7de; stroke-width: 1; }
.chart .baseline { stroke: #cfc8bb; stroke-width: 1; }
.chart text { fill: var(--ink-muted); font-size: 12px; font-family: var(--body); }
.chart .bar-c { fill: var(--collected); }
.chart .bar-s { fill: var(--spent); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.on { fill: rgba(17,17,17,.04); }
.chart-note { font-size: 13px; color: var(--ink-soft); margin: 10px 0 0; }
.tip { position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 8px 11px; font-size: 13px; line-height: 1.45; max-width: 240px; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.tip b { font-weight: 500; }
.tip .sw { margin-right: 6px; }

/* Lists (attention, clients, ledger, agenda) */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line-soft); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 2px; background: none; border: 0; text-align: left; cursor: pointer; text-decoration: none; min-height: 52px; }
.row:hover { background: var(--wash); }
.row .main { flex: 1; min-width: 0; }
.row .title { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 15px; flex-wrap: wrap; }
.row .sub { font-size: 13px; color: var(--ink-soft); }
.row .end { text-align: right; font-size: 13px; white-space: nowrap; }
.row .end b { display: block; font-weight: 400; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.row .mini { width: 70px; margin-top: 5px; }
.list.card-list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; }
.group-label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin: 18px 2px 6px; font-weight: 500; }
.group-label:first-child { margin-top: 0; }

/* Pipeline */
.pipe svg { display: block; width: 100%; height: 26px; border-radius: 8px; }
.pipe-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pipe-legend button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; min-height: 34px; }
.pipe-legend button:hover { border-color: var(--gold); }
.pipe-legend b { font-weight: 500; }
.p0 { fill: #e8dcc4; background: #e8dcc4; }
.p1 { fill: #d6bf93; background: #d6bf93; }
.p2 { fill: #b79b6a; background: #b79b6a; }
.p3 { fill: #8a6f3f; background: #8a6f3f; }
.p4 { fill: #5c4824; background: #5c4824; }

/* Client page */
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--ink-soft); font-size: 14px; margin-bottom: 8px; }
.client-head h1 { font-size: 38px; line-height: 1.05; }
.client-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 14px; color: var(--ink-soft); }
.stepper { list-style: none; display: flex; padding: 0; margin: 18px 0 14px; gap: 4px; }
.stepper li { flex: 1; text-align: center; font-size: 12px; color: var(--ink-muted); min-width: 0; }
.stepper li::before { content: ""; display: block; height: 5px; border-radius: 9px; background: var(--line); margin-bottom: 6px; }
.stepper li.done::before { background: var(--gold); }
.stepper li.now::before { background: var(--ink); }
.stepper li.now { color: var(--ink); font-weight: 500; }
.next-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.next-bar .grow { flex: 1; min-width: 180px; font-size: 14px; color: var(--ink-soft); }
.next-bar .grow b { color: var(--ink); font-weight: 500; }
.next-bar.rush { border-color: #efc9c4; background: var(--danger-bg); }
.mini-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini-tiles .tile { padding: 10px 12px; }
.mini-tiles .tile .value { font-size: 26px; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ck { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; min-height: 52px; }
.ck:hover { border-color: var(--gold); }
.ck .lbl { flex: 1; font-size: 14px; }
.ck .state { font-size: 12px; color: var(--ink-muted); }
.ck.complete { background: var(--good-bg); border-color: #cfe5d6; }
.ck.complete .state { color: var(--good); }
.ck.will_follow { background: var(--warn-bg); border-color: #f2dfb6; }
.ck.will_follow .state { color: var(--warn); }
.ck.na .lbl { color: var(--ink-muted); text-decoration: line-through; }
.box { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line); display: grid; place-items: center; flex: none; background: var(--paper); }
.ck.complete .box { background: var(--good); border-color: var(--good); color: #fff; }
.ck.will_follow .box { border-color: var(--warn); color: var(--warn); }
.ck.na .box { color: var(--ink-muted); }
.hint { font-size: 13px; color: var(--ink-soft); margin: 10px 0 0; }

.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.money-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 8px 0; align-items: center; }
.money-row + .money-row { border-top: 1px solid var(--line-soft); }
details.more { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
details.more > summary { cursor: pointer; padding: 14px 16px; font-weight: 400; list-style: none; display: flex; justify-content: space-between; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "Show"; color: var(--gold-deep); font-size: 14px; }
details.more[open] > summary::after { content: "Hide"; }
details.more > .inner { padding: 0 16px 16px; }
details.sub { margin-top: 10px; }
details.sub > summary { cursor: pointer; font-size: 14px; color: var(--gold-deep); }
.note { border-top: 1px solid var(--line-soft); padding: 10px 0; }
.note-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; align-items: center; }
.note-body { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.break { overflow-wrap: anywhere; }

/* Category bars on Money */
.cat { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; font-size: 14px; padding: 6px 0; }
.cat progress { height: 10px; }
.cat progress::-webkit-progress-value { background: var(--spent); }
.cat progress::-moz-progress-bar { background: var(--spent); }

/* Sheet (bottom sheet on phones, dialog on desktop) */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(17,17,17,.32); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { background: var(--paper); border-radius: 20px; width: min(500px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 20px 22px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 26px; }
.action-list { display: grid; gap: 8px; }
.action-list button { display: flex; align-items: center; gap: 12px; width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 14px; padding: 14px; cursor: pointer; text-align: left; font-size: 16px; }
.action-list button:hover { border-color: var(--gold); }
.action-list small { display: block; color: var(--ink-soft); font-size: 13px; }

.toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 40; max-width: calc(100% - 32px); text-align: center; }
.toast.bad { background: var(--danger); }

/* Tablet */
@media (max-width: 960px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles > .tile:nth-child(3):last-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Phone */
@media (max-width: 720px) {
  .topnav, .who { display: none; }
  .topbar { padding: 10px var(--gutter); }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; text-decoration: none; color: var(--ink-muted); padding: 4px 0; }
  .bottomnav a.on { color: var(--ink); font-weight: 500; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; width: 54px; height: 54px; }
  .page { padding-bottom: 150px; }
  .page-head h1 { font-size: 30px; }
  .tile .value { font-size: 28px; }
  .client-head h1 { font-size: 32px; }
  .checklist { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .cat { grid-template-columns: 96px 1fr auto; }
  .sheet-wrap { align-items: flex-end; padding: 0; }
  .sheet { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
  .stepper li { font-size: 11px; }
  .card { padding: 14px; }
}
