/* CleanerStart design system.
   1. Tokens   2. Base   3. Shell   4. Type and page head   5. Components
   6. Floor plan   7. Money widgets   8. Auth pages   9. Utilities
   Brand follows the landing page: paper, ink, and one red. The app is quieter:
   red marks the brand and the active place. Ink carries primary actions. */

/* 1. Tokens ------------------------------------------------------------ */
:root {
  --paper: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --sunken: #eeebe4;
  --ink: #111111;
  --ink-2: #33312d;
  --muted: #6b675f;
  --faint: #9c978d;
  --line: #e5e1d8;
  --line-strong: #cfc9bc;

  --brand: #e8391d;
  --brand-strong: #c22e14;
  --brand-soft: #fdebe6;

  --ok: #157a3a;      --ok-soft: #e5f3e9;
  --warn: #a95c06;    --warn-soft: #fcf0de;
  --bad: #c22e14;     --bad-soft: #fdebe6;
  --info: #1f4fc4;    --info-soft: #e8eefb;
  --off: #6b675f;     --off-soft: #ecebe6;

  --focus: 0 0 0 3px rgba(232, 57, 29, .28);
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, .05);
  --shadow: 0 1px 2px rgba(17, 17, 17, .05), 0 6px 16px rgba(17, 17, 17, .05);
  --shadow-lg: 0 12px 40px rgba(17, 17, 17, .16);

  --sans: "Helvetica Neue", Helvetica, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --display: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --fs-xs: 11px; --fs-sm: 13px; --fs: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 34px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --sidebar: 248px;
  --content: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121110;
    --surface: #1a1918;
    --surface-2: #1f1e1c;
    --sunken: #0d0d0c;
    --ink: #f3f1ec;
    --ink-2: #d7d3ca;
    --muted: #a19c92;
    --faint: #6f6b63;
    --line: #2c2a27;
    --line-strong: #3d3a36;
    --brand: #ff5233;
    --brand-strong: #ff6e54;
    --brand-soft: #3a1a13;
    --ok: #4cc47a;   --ok-soft: #12291b;
    --warn: #f0a443; --warn-soft: #33240f;
    --bad: #ff6e54;  --bad-soft: #3a1a13;
    --info: #7fa5ff; --info-soft: #17213b;
    --off: #a19c92;  --off-soft: #262522;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 16px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

/* 2. Base -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: var(--fs)/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0 0 var(--s3); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s6) 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--brand-soft); }

/* 3. Shell ------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: var(--s4) var(--s3);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; background: var(--brand); border-radius: 4px; position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 2.5px solid #fff; }
.brand-word { font-family: var(--display); font-size: 14px; letter-spacing: .02em; text-transform: uppercase; }

.scope { margin: 0 0 var(--s4); position: relative; }
.scope summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
}
.scope summary::-webkit-details-marker { display: none; }
.scope summary:hover { border-color: var(--line-strong); }
.scope-text { min-width: 0; flex: 1; }
.scope-org { display: block; font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-caret { color: var(--muted); font-size: 11px; }
.scope-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 6px; max-height: 60vh; overflow-y: auto;
}
.scope-menu a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; }
.scope-menu a:hover { background: var(--sunken); }
.scope-menu a[aria-current="true"] { font-weight: 600; }
.scope-menu a[aria-current="true"]::after { content: "✓"; color: var(--brand); }
.scope-menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.scope-menu .label { padding: 6px 10px 2px; font-size: var(--fs-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { margin-top: var(--s4); padding: 0 10px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }
.nav a, .nav .soon {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  text-decoration: none; color: var(--ink-2); position: relative;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--sunken); color: var(--ink); font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav .soon { color: var(--faint); cursor: default; }
.nav .soon em { margin-left: auto; font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; border: 1px solid var(--line); border-radius: 99px; padding: 1px 6px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }

.me { border-top: 1px solid var(--line); margin-top: var(--s4); padding-top: var(--s3); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.me-text { min-width: 0; flex: 1; line-height: 1.25; }
.me-text a { text-decoration: none; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text span { font-size: var(--fs-xs); color: var(--muted); }
.me form { margin: 0; }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: var(--content); margin: 0 auto; padding: var(--s7) var(--s7) var(--s8); }

#nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(86vw, 300px); height: auto;
    transform: translateX(-102%); transition: transform .2s ease, visibility .2s; visibility: hidden;
  }
  #nav-toggle:checked ~ .shell .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  #nav-toggle:checked ~ .shell .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  }
  .topbar .burger { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
  .topbar .burger svg { width: 18px; height: 18px; stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; }
  .topbar .t { font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .t small { display: block; font-weight: 400; font-size: var(--fs-xs); color: var(--muted); }
  .content { padding: var(--s5) var(--s4) var(--s8); }
}

/* 4. Type and page head ------------------------------------------------ */
.kicker { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s6); }
.page-head h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; margin-top: 4px; }
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 60ch; }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.section { margin-top: var(--s7); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.section-head h2 { font-size: var(--fs-md); font-weight: 700; }
.section-head .meta { color: var(--muted); font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* 5. Components -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: var(--fs-md); font-weight: 700; }
.card-body { padding: var(--s5); }
.card + .card { margin-top: var(--s4); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: var(--s3); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) var(--s5); box-shadow: var(--shadow-sm); min-width: 0; }
.stat-label { font-size: var(--fs-sm); color: var(--muted); }
.stat-value { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.stat.hero { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.stat.hero .stat-label, .stat.hero .stat-sub { color: color-mix(in srgb, var(--paper) 70%, transparent); }
.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); } .tone-off { color: var(--off); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 var(--fs)/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink-2); }
.btn-accent { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-accent:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--sunken); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-size: var(--fs-sm); color: var(--ink-2);
}
.chip:hover { border-color: var(--line-strong); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip b { font-weight: 600; opacity: .7; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 2px; }
.segmented a { padding: 5px 12px; border-radius: 4px; text-decoration: none; font-size: var(--fs-sm); color: var(--muted); }
.segmented a[aria-current="true"] { background: var(--sunken); color: var(--ink); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-operational, .b-ok { color: var(--ok); background: var(--ok-soft); }
.b-broken, .b-bad { color: var(--bad); background: var(--bad-soft); }
.b-maintenance, .b-warn { color: var(--warn); background: var(--warn-soft); }
.b-offline, .b-off { color: var(--off); background: var(--off-soft); }
.b-info { color: var(--info); background: var(--info-soft); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid; margin-bottom: var(--s5); }
.alert-error { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-info { color: var(--ink-2); background: var(--surface); border-color: var(--line); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:hover td { background: var(--surface-2); }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); border-bottom: 0; }
.table .num { text-align: right; }
.table td a { text-decoration: none; font-weight: 600; }
.table td a:hover { text-decoration: underline; }
.table tr.current td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }

.form { display: grid; gap: var(--s4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.hint { font-size: var(--fs-sm); color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: var(--fs-md)/1.2 var(--sans);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.money-input { position: relative; }
.money-input::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-input .input { padding-left: 24px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.form-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; padding-top: var(--s2); }

.empty { text-align: center; padding: var(--s8) var(--s5); color: var(--muted); }
.empty h3 { color: var(--ink); font-size: var(--fs-md); margin-bottom: 6px; }
.empty .btn { margin-top: var(--s4); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 99px; font-weight: 600; font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg); transition: opacity .18s, transform .18s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }

.copy-row { display: flex; gap: var(--s2); }
.copy-row .input { font-family: var(--mono); font-size: var(--fs-sm); }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 92px; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.bar-track { height: 10px; background: var(--sunken); border-radius: 99px; overflow: hidden; position: relative; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 99px; }
.bar-proj { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(45deg, var(--line-strong) 0 4px, transparent 4px 8px); border-radius: 99px; }
.bar-row.current .bar-fill { background: var(--brand); }

/* 6. Floor plan -------------------------------------------------------- */
.floor-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.floor { display: flex; gap: var(--s5); align-items: flex-start; min-width: min-content; }
.floor-col { display: flex; flex-direction: column; gap: var(--s4); }
.zone { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 12px 12px; }
.zone-name { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 2px 8px; }
.zone-rows { display: flex; flex-direction: column; gap: 6px; }
.zone-row { display: flex; gap: 6px; }
.zone-row + .zone-row.gap { margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.cell { display: flex; gap: 0; }
.cell.stacked .tile:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cell.stacked .tile + .tile { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }

.tile {
  --tone: var(--ok); --tone-soft: var(--ok-soft);
  position: relative; width: 78px; height: 58px; padding: 6px 7px 5px 9px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  transition: border-color .12s, transform .06s, box-shadow .12s, opacity .12s;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone); }
.tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.tile-id { font: 700 12px/1 var(--mono); letter-spacing: -.02em; }
.tile-meta { font-size: 10.5px; color: var(--muted); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-flag { position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--surface); }
.tile.s-broken { --tone: var(--bad); --tone-soft: var(--bad-soft); background: var(--bad-soft); }
.tile.s-maintenance { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.tile.s-offline { --tone: var(--off); --tone-soft: var(--off-soft); background: var(--off-soft); color: var(--muted); }
.tile.dim { opacity: .22; }

/* Coin entry tiles */
.coin .tile { cursor: pointer; }
.coin .tile::before { background: var(--line-strong); }
.coin .tile.has::before { background: var(--info); }
.coin .tile.high::before { background: var(--ok); }
.coin .tile.down { background: var(--off-soft); }
.coin .tile .amt { font: 700 13px/1 var(--sans); color: var(--faint); }
.coin .tile.has .amt { color: var(--info); }
.coin .tile.high .amt { color: var(--ok); }
.coin .tile .units { font-size: 10px; color: var(--muted); }
.coin .tile.editing { border-color: var(--brand); box-shadow: var(--focus); }
.coin .tile input { width: 100%; border: 0; background: transparent; font: 700 16px/1 var(--sans); color: var(--ink); padding: 0; outline: none; }
.coin .tile.saving { opacity: .6; }
.coin .tile.err { border-color: var(--bad); }

.legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 7. Money widgets ----------------------------------------------------- */
.daybar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.daybar .input { width: auto; height: 38px; }
.day-title { font-size: var(--fs-lg); font-weight: 700; }
.denoms { display: grid; grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); gap: var(--s2); }
.denom { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 8px 8px; display: grid; gap: 4px; }
.denom-head { display: flex; justify-content: space-between; align-items: baseline; }
.denom-face { font: 700 var(--fs-sm)/1 var(--mono); }
.denom-sub { font-size: var(--fs-xs); color: var(--faint); }
.denom-sub.has { color: var(--ok); font-weight: 600; }
.denom .input { height: 36px; text-align: center; font-weight: 600; padding: 0 6px; }
.denom .par { font-size: var(--fs-xs); color: var(--muted); text-align: center; }

.summary { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.summary div { display: grid; gap: 2px; }
.summary span { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.summary b { font-size: var(--fs-md); }
.save-state { margin-left: auto; align-self: center; font-size: var(--fs-sm); color: var(--muted); }
.htmx-request .save-state, .save-state.htmx-request { color: var(--info); }

.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (max-width: 1050px) { .split { grid-template-columns: 1fr; } }

/* 8. Auth pages -------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--ink); color: #f4f1ea; padding: var(--s8); display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .brand-word { color: #f4f1ea; }
.auth-side h2 { font-family: var(--display); font-size: clamp(30px, 3.6vw, 52px); line-height: .95; text-transform: uppercase; letter-spacing: -.01em; max-width: 12ch; }
.auth-side h2 em { font-style: normal; color: var(--brand); }
.auth-side p { color: #a9a49a; max-width: 40ch; margin-top: var(--s4); }
.auth-side .stripe { position: absolute; right: -60px; bottom: -60px; width: 260px; height: 260px; border-radius: 50%; border: 28px solid var(--brand); opacity: .9; }
.auth-main { display: grid; place-items: center; padding: var(--s7) var(--s5); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: var(--s6); }
.auth-foot { margin-top: var(--s5); font-size: var(--fs-sm); color: var(--muted); }
.auth-foot a { color: var(--ink); font-weight: 600; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: var(--s5); min-height: 0; }
  .auth-side h2, .auth-side p, .auth-side .stripe { display: none; }
}

/* 9. Utilities --------------------------------------------------------- */
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: var(--s4); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s2); } .mt-4 { margin-top: var(--s4); } .mt-6 { margin-top: var(--s6); }
.inline { display: inline; margin: 0; }
.hide-sm { }
@media (max-width: 700px) { .hide-sm { display: none; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Floor view options. Rotate turns the plan 90 degrees: zones in a column sit in a row,
   and each zone's rows become columns. Tiles stay upright. Compact shrinks tiles. */
.view-tools { display: inline-flex; gap: 6px; }
.view-tools button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.floor.rot { flex-direction: column; }
.floor.rot .floor-col { flex-direction: row; align-items: flex-start; }
.floor.rot .zone-rows { flex-direction: row; }
.floor.rot .zone-row { flex-direction: column; }
.floor.rot .cell { flex-direction: column; }
.floor.rot .cell.stacked .tile:first-child { border-radius: 8px 8px 0 0; }
.floor.rot .cell.stacked .tile + .tile { border-radius: 0 0 8px 8px; border-left-style: solid; border-top-style: dashed; }
.floor.compact .tile { width: 56px; height: 44px; padding: 4px 5px 3px 7px; }
.floor.compact .tile-meta, .floor.compact .tile .units { display: none; }
.floor.compact .tile-id { font-size: 11px; }
.floor.compact .zone { padding: 8px; }
.floor.compact .zone-name { margin-bottom: 6px; }
.floor.compact, .floor.compact .floor-col { gap: var(--s3); }
.floor.compact .zone-rows, .floor.compact .zone-row { gap: 4px; }

/* Layout editor ------------------------------------------------------- */
.editor { display: grid; gap: var(--s4); }
.tray { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); padding: 10px 12px 12px; position: sticky; top: 8px; z-index: 5; }
.tray-head { display: flex; gap: var(--s3); align-items: baseline; margin-bottom: 8px; }
.tray-tiles { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; align-items: center; }
.tray.over { border-color: var(--brand); background: var(--brand-soft); }
.zone-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.zone-head form { margin: 0; flex: 1; min-width: 0; }
.zone-title { width: 100%; min-width: 80px; border: 1px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 3px 6px; margin-left: -6px;
  font: 600 var(--fs-xs)/1.3 var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.zone-title:hover { border-color: var(--line); }
.zone-title:focus { outline: none; border-color: var(--brand); color: var(--ink); background: var(--surface); }
.zone-tools { display: flex; gap: 2px; flex: none; }
.zone-tools button { width: 26px; height: 26px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.zone-tools button:hover { border-color: var(--line); color: var(--ink); background: var(--surface); }
.slot { display: flex; min-width: 78px; min-height: 58px; border-radius: 8px; }
.slot:not(.filled) { border: 1px dashed var(--line-strong); opacity: .55; }
.slot.over { outline: 2px solid var(--brand); outline-offset: 1px; opacity: 1; background: var(--brand-soft); }
.slot.stacked .tile:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.slot.stacked .tile + .tile { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.editor [data-drag] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); transform: rotate(-3deg) scale(1.04); opacity: .95; }
.editor [data-drag].lifted { opacity: .3; }
body.dragging, body.dragging * { cursor: grabbing !important; }
.add-zone { display: flex; gap: 6px; align-items: center; }
.add-zone .input { height: 32px; font-size: var(--fs-sm); width: 160px; }
.add-col { padding-top: 2px; }
.floor.rot .slot { flex-direction: column; }
.floor.rot .slot.stacked .tile:first-child { border-radius: 8px 8px 0 0; }
.floor.rot .slot.stacked .tile + .tile { border-radius: 0 0 8px 8px; border-left-style: solid; border-top-style: dashed; }
.floor.rot .floor-col { flex-wrap: wrap; }
.floor.compact .slot { min-width: 56px; min-height: 44px; }

/* Overview strip and history bars */
.strip { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); margin-top: var(--s3); padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--muted); font-size: var(--fs-sm); }
.strip b { color: var(--ink); font-size: var(--fs); }
.table.history .bar-cell { display: flex; align-items: center; gap: 12px; }
.table.history th:nth-child(2) { width: 60%; }
.table.history .bar-cell .bar-track { flex: 1; }
.table.history .bar-cell .num { width: 84px; flex: none; }
.table.history tr.current .bar-fill { background: var(--brand); }

/* Phone tab bar */
.tabbar { display: none; }
@media (max-width: 900px) {
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar label { display: grid; justify-items: center; gap: 2px; padding: 4px 0; text-decoration: none; color: var(--muted); font-size: 11px; cursor: pointer; }
  .tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="page"] { color: var(--brand); font-weight: 600; }
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: var(--s5); }
  .page-head h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 22px; }
  .card-body, .card-head { padding-left: var(--s4); padding-right: var(--s4); }
  .summary { padding: var(--s3) var(--s4); gap: var(--s2) var(--s4); }
  .daybar { width: 100%; }
  .daybar .input { flex: 1; min-width: 0; }
  .section-head .meta { display: none; }
  .table th, .table td { padding: 10px 12px; }
}
.slot.spare { visibility: hidden; }
body.dragging .slot.spare { visibility: visible; }
.tray { padding: 8px 12px; }
.tray-head { margin-bottom: 4px; }
.tray-tiles { min-height: 30px; }
@media (max-width: 600px) {
  .table.history .bar-cell { gap: 8px; }
  .table.history .bar-cell .num { width: 66px; }
  .table.history th, .table.history td { padding-left: 10px; padding-right: 10px; }
}
