/* =========================================================================
   SpaceLedger — UI tokens & components
   Type: Barlow (UI) + Barlow Condensed (headings, figures, bay codes)
   Status colours are reserved for occupancy only.
   ========================================================================= */
:root {
  --ink: #17212b;
  --ink-2: #4a5663;
  --ink-3: #75808b;
  --bg: #eef0ec;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --line: #d9ddd6;
  --line-2: #e7eae4;
  --steel: #3d5a6c;
  --steel-2: #2e4757;
  --steel-tint: #e3eaee;
  --side: #17212b;
  --side-ink: #c5ced6;
  --side-mute: #7d8995;

  --available: #2e9d5b;  --available-tint: #e2f3e8;
  --partial:   #e0a21b;  --partial-tint:   #fbf0d3;
  --full:      #d1453b;  --full-tint:      #f9e1df;
  --reserved:  #3b6fd8;  --reserved-tint:  #e1e9fa;
  --blocked:   #8a9096;  --blocked-tint:   #eceded;

  --danger: #b3372e;
  --ok: #2e7d4f;
  --warn: #9a6b00;

  --r-sm: 3px; --r: 6px; --r-lg: 10px;
  --shadow-pop: 0 12px 32px rgba(23, 33, 43, .16), 0 2px 6px rgba(23, 33, 43, .08);
  --font: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-c: "Barlow Condensed", "Arial Narrow", "Barlow", sans-serif;
  --side-w: 236px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #e6ebef; --ink-2: #b2bcc5; --ink-3: #8894a0;
  --bg: #12181e; --surface: #1a222a; --surface-2: #151c23;
  --line: #2c3742; --line-2: #243039;
  --steel: #7fa3b8; --steel-2: #a3c1d2; --steel-tint: #22313c;
  --side: #0d1318; --side-ink: #c5ced6; --side-mute: #6d7a86;
  --available-tint: #173427; --partial-tint: #3a2f14; --full-tint: #3b1d1b; --reserved-tint: #1b2a4a; --blocked-tint: #262b30;
  --danger: #e36b61; --ok: #5cc38a; --warn: #e3b64c;
  --shadow-pop: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--steel); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-c); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: .005em; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--font-c); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand-mark { width: 30px; height: 30px; border-radius: 5px; background: var(--partial); display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 5px; }
.brand-mark i { background: var(--side); border-radius: 1px; }
.brand-mark i:nth-child(2) { background: #fff3; }
.brand-name { font: 600 19px/1 var(--font-c); letter-spacing: .01em; }
.brand-co { font-size: 12px; color: var(--side-mute); margin-top: 3px; }
.nav { padding: 6px 10px 20px; }
.nav-group { margin-top: 16px; }
.nav-title { font-size: 12px; color: var(--side-mute); padding: 0 10px 6px; }
.nav a, .nav span.nav-soon { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: #ffffff10; text-decoration: none; color: #fff; }
.nav a[aria-current="page"] { background: #ffffff16; color: #fff; box-shadow: inset 3px 0 0 var(--partial); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav span.nav-soon { color: var(--side-mute); cursor: default; }
.nav span.nav-soon em { margin-left: auto; font-style: normal; font-size: 11px; border: 1px solid #ffffff22; border-radius: 99px; padding: 0 7px; }
.side-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid #ffffff12; font-size: 13px; }
.side-foot b { display: block; color: #fff; font-weight: 500; }
.side-foot form { margin-top: 8px; }
.side-foot button { background: none; border: 0; color: var(--side-mute); padding: 0; font: inherit; cursor: pointer; }
.side-foot button:hover { color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink-3); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--ink-2); }
.crumbs span[aria-current] { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: var(--line); }
.topbar .search { margin-left: auto; position: relative; }
.topbar .search input { width: 260px; padding-left: 32px; background: var(--surface-2); }
.topbar .search svg { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 16px; color: var(--ink-3); }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.page { padding: 26px 28px 60px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .lead { color: var(--ink-2); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 500 14px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--steel); border-color: var(--steel); color: #fff; }
.btn-primary:hover { background: var(--steel-2); border-color: var(--steel-2); }
:root[data-theme="dark"] .btn-primary { color: #0d1318; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--full-tint); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--steel-tint); border-color: var(--steel); color: var(--steel-2); }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: var(--r) 0 0 var(--r); }
.seg .btn:last-child { border-radius: 0 var(--r) var(--r) 0; margin-left: -1px; }

input, select, textarea { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 15px var(--font); }
textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--steel); box-shadow: 0 0 0 3px var(--steel-tint); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--steel); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.field-error { color: var(--danger); font-size: 13px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.req::after { content: " *"; color: var(--danger); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 56px; }
.input-suffix span { position: absolute; right: 11px; top: 50%; translate: 0 -50%; font-size: 13px; color: var(--ink-3); pointer-events: none; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { font-size: 18px; }
.panel-head .muted { font-size: 13px; }
.panel-head .tools { margin-left: auto; display: flex; gap: 8px; }
.panel-body { padding: 18px; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 18px; }

/* KPI rail: one continuous strip, not a pile of cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.kpi { padding: 14px 18px; border-left: 1px solid var(--line-2); }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 13px; color: var(--ink-3); }
.kpi-value { font: 600 27px/1.15 var(--font-c); font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi-sub { font-size: 12.5px; color: var(--ink-3); }
.kpi-value .unit { font-size: 15px; color: var(--ink-3); font-weight: 500; margin-left: 2px; }

/* ---------------------------------------------------------------- occupancy bars */
.occbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--available-tint); }
.occbar i { display: block; height: 100%; }
.occbar .o { background: var(--full); }
.occbar .r { background: var(--reserved); }
.occbar .b { background: var(--blocked); }
.occbar .a { background: var(--available); opacity: .35; }
.occbar.lg { height: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.dot-available { background: var(--available); } .dot-partial { background: var(--partial); } .dot-full { background: var(--full); }
.dot-reserved { background: var(--reserved); } .dot-blocked { background: var(--blocked); }

/* ---------------------------------------------------------------- dashboard hero: the shed strip */
.hero { padding: 22px 22px 18px; }
.hero-top { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.hero-figure { font: 600 64px/0.9 var(--font-c); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.hero-figure small { font-size: 28px; color: var(--ink-3); }
.hero-caption { color: var(--ink-2); max-width: 36ch; }
.hero-split { display: flex; gap: 26px; margin-left: auto; flex-wrap: wrap; }
.hero-split div b { display: block; font: 600 22px/1.1 var(--font-c); font-variant-numeric: tabular-nums; }
.hero-split div span { font-size: 13px; color: var(--ink-3); }
.shed { display: flex; gap: 4px; margin-top: 20px; height: 74px; }
.shed-wh { position: relative; display: flex; flex-direction: column; min-width: 60px; border-radius: var(--r-sm); overflow: hidden; background: var(--available-tint); color: inherit; }
.shed-wh:hover { text-decoration: none; outline: 2px solid var(--steel); outline-offset: 1px; }
.shed-fill { display: flex; flex: 1; }
.shed-fill i { display: block; height: 100%; }
.shed-fill .o { background: var(--full); } .shed-fill .r { background: var(--reserved); } .shed-fill .b { background: repeating-linear-gradient(135deg, var(--blocked) 0 5px, var(--blocked-tint) 5px 9px); }
.shed-label { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line-2); border-top: 0; border-radius: 0 0 var(--r-sm) var(--r-sm); white-space: nowrap; overflow: hidden; }
.shed-label b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.shed-wh { border: 0; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
.data th { text-align: left; font-weight: 500; font-size: 13px; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.data tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--surface-2); }
.data .r { text-align: right; }
.data .code { font: 600 15px var(--font-c); letter-spacing: .02em; }
.data .occ-cell { width: 180px; }
.occ-cell .occbar { margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--available-tint); }
.badge-warn { color: var(--warn); background: var(--partial-tint); }
.badge-bad { color: var(--danger); background: var(--full-tint); }
.badge-mute { color: var(--ink-3); background: var(--blocked-tint); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.state i { width: 9px; height: 9px; border-radius: 2px; }

/* ---------------------------------------------------------------- filters + pagination */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.filters .field { width: 190px; }
.filters .field.grow { flex: 1; min-width: 200px; width: auto; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--ink-3); }
.pager .pages { margin-left: auto; display: flex; gap: 4px; }
.pager a, .pager span.cur { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink-2); }
.pager span.cur { background: var(--steel); border-color: var(--steel); color: #fff; }
.pager a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------------------------------------------------------------- cards (warehouses/locations) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; color: inherit; }
a.card:hover { border-color: var(--steel); text-decoration: none; }
.card-top { display: flex; gap: 10px; align-items: flex-start; }
.card-top h3 { font-size: 19px; }
.card-top .code { font: 500 13px var(--font-c); color: var(--ink-3); letter-spacing: .04em; }
.card-top .badge { margin-left: auto; }
.card-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card-figs b { display: block; font: 600 18px/1.2 var(--font-c); font-variant-numeric: tabular-nums; }
.card-figs span { font-size: 12px; color: var(--ink-3); }
.card-foot { font-size: 13px; color: var(--ink-3); display: flex; justify-content: space-between; }

/* ---------------------------------------------------------------- floor plan */
.plan-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.plan { display: grid; gap: 18px; }
.zone { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); scroll-margin-top: 80px; }
.zone-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 10px; flex-wrap: wrap; }
.zone-code { font: 700 22px/1 var(--font-c); color: var(--ink); background: var(--partial); color: #1d1606; border-radius: var(--r-sm); padding: 3px 8px 2px; }
.zone-head h3 { font-size: 17px; }
.zone-head .muted { font-size: 13px; }
.zone-head .zone-occ { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.zone-head .zone-occ .occbar { width: 120px; }
.floor {
  --cols: 6; --rows: 2;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(96px, auto));
  gap: 8px; padding: 14px; margin: 0 12px 12px; border-radius: var(--r);
  background-color: var(--surface-2);
  background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 2px solid var(--ink-3);
  position: relative;
}
.bay {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; text-align: left;
  padding: 10px 11px 9px 15px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  font: inherit; color: var(--ink); min-width: 0; overflow: hidden;
}
.bay::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--tone); }
.bay-gauge { position: absolute; left: 0; bottom: 0; width: 5px; height: var(--fill, 0%); background: var(--ink); opacity: .25; }
.bay:hover { border-color: var(--tone); }
.bay[aria-expanded="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.bay-code { font: 700 20px/1 var(--font-c); letter-spacing: .03em; }
.bay-meta { font-size: 12.5px; color: var(--ink-2); line-height: 1.3; }
.bay-tenant { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bay.available { --tone: var(--available); background: var(--available-tint); }
.bay.partial   { --tone: var(--partial);   background: var(--partial-tint); }
.bay.full      { --tone: var(--full);      background: var(--full-tint); }
.bay.reserved  { --tone: var(--reserved);  background: var(--reserved-tint); }
.bay.blocked   { --tone: var(--blocked);   background: repeating-linear-gradient(135deg, var(--blocked-tint) 0 8px, var(--surface) 8px 16px); }
.bay.is-dim { opacity: .25; }
.bay-add { border: 1px dashed var(--line); background: transparent; color: var(--ink-3); display: grid; place-items: center; font-size: 13px; border-radius: var(--r-sm); }
.bay-add:hover { border-color: var(--steel); color: var(--steel); text-decoration: none; }

/* drawer */
.drawer-scrim { position: fixed; inset: 0; background: rgba(13, 19, 24, .35); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .18s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface); z-index: 61; box-shadow: var(--shadow-pop); transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer.open + .drawer-scrim, .drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-2); }
.drawer-head .bay-code { font-size: 34px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--ink-3); }
dl.facts dd { margin: 0; font-weight: 500; }
.alloc { border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; }
.alloc + .alloc { margin-top: 8px; }
.alloc b { display: block; }
.alloc .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }

/* ---------------------------------------------------------------- forms */
.form-section { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 22px 22px; border-bottom: 1px solid var(--line-2); }
.form-section:last-of-type { border-bottom: 0; }
.form-section > header h2 { font-size: 18px; }
.form-section > header p { color: var(--ink-3); font-size: 13.5px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; font-size: 14px; }
.check:has(input:checked) { border-color: var(--steel); background: var(--steel-tint); }
.form-actions { display: flex; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); position: sticky; bottom: 0; }
.form-actions .right { margin-left: auto; display: flex; gap: 10px; }
.callout { padding: 11px 14px; border-radius: var(--r); background: var(--steel-tint); color: var(--ink-2); font-size: 13.5px; }
.callout.warn { background: var(--partial-tint); }
.mini-plan { display: grid; gap: 3px; margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.mini-plan i { height: 22px; border-radius: 2px; background: var(--line-2); }
.mini-plan i.taken { background: var(--blocked); opacity: .5; }
.mini-plan i.here { background: var(--steel); }
.mini-plan i.clash { background: var(--full); }

/* ---------------------------------------------------------------- structure page */
.tree { list-style: none; margin: 0; padding: 0; }
.tree > li { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.tree > li:last-child { border-bottom: 0; }
.tree ul { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.tree ul li { padding: 3px 0 3px 10px; font-size: 14px; }

/* ---------------------------------------------------------------- empty, toast, dialog */
.empty { text-align: center; padding: 48px 20px; }
.empty-art { width: 120px; height: 64px; margin: 0 auto 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.empty-art i { border: 1.5px dashed var(--line); border-radius: 3px; }
.empty h3 { font-size: 20px; }
.empty p { color: var(--ink-3); margin: 6px auto 16px; max-width: 44ch; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { display: flex; gap: 10px; align-items: flex-start; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: var(--r); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 14px; animation: toast-in .2s ease; }
.toast::before { content: ""; width: 4px; align-self: stretch; border-radius: 2px; background: var(--available); flex: none; }
.toast.error::before { background: var(--full); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; font-size: 18px; line-height: 1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(13, 19, 24, .45); }
dialog .d-body { padding: 20px 22px 8px; }
dialog .d-body p { color: var(--ink-2); margin-top: 8px; }
dialog .d-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; }

/* ---------------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.auth-art { background: var(--side); color: var(--side-ink); padding: 44px; display: flex; flex-direction: column; }
.auth-art h1 { color: #fff; font-size: 44px; max-width: 14ch; margin-top: auto; }
.auth-art p { max-width: 42ch; margin-top: 12px; color: var(--side-mute); }
.auth-plan { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 32px; max-width: 460px; }
.auth-plan i { height: 34px; border-radius: 3px; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.auth-form h2 { font-size: 30px; }
.form-error { padding: 10px 12px; border-radius: var(--r); background: var(--full-tint); color: var(--danger); font-size: 14px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .cols-main, .cols-3 { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 70; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; box-shadow: var(--shadow-pop); }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .topbar .search input { width: 160px; }
  .page { padding: 18px 16px 90px; }
  .cols-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi { border-top: 1px solid var(--line-2); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .hero-figure { font-size: 52px; }
  .hero-split { margin-left: 0; }
  .shed { flex-direction: column; height: auto; }
  .shed-wh { height: 54px; flex: none !important; }
  .form-grid, .form-grid.g3 { grid-template-columns: 1fr; }
  .filters .field { width: calc(50% - 5px); }
  .filters .field.grow { width: 100%; }
  /* Floor plan on phones: a list of bays per zone, not a shrunken canvas */
  .floor { display: flex; flex-direction: column; background-image: none; border-width: 1px; }
  .bay { flex-direction: row; align-items: center; min-height: 58px; }
  .bay-code { font-size: 18px; min-width: 46px; }
  .bay-meta { flex: 1; }
  .bay-add { min-height: 44px; }
  .zone-head .zone-occ { margin-left: 0; width: 100%; }
  .toasts { left: 16px; right: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 480px) {
  .topbar .search { display: none; }
  .crumbs { font-size: 13px; }
}
.nav-scrim { position: fixed; inset: 0; background: rgba(13,19,24,.4); z-index: 65; opacity: 0; pointer-events: none; transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .side, .topbar, .actions, .filters, .pager { display: none !important; }
  .shell { display: block; }
}

/* ---------------------------------------------------------------- warehouse page extras */
[hidden] { display: none !important; }
h1 .badge { vertical-align: middle; font-family: var(--font); font-size: 13px; margin-left: 6px; }
.legend-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid transparent; border-radius: 99px; background: none; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.legend-btn:hover { border-color: var(--line); }
.legend-btn[aria-pressed="true"] { border-color: var(--ink-2); background: var(--surface-2); color: var(--ink); }
.zone-jump { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.zone-jump a { font: 600 13px/1 var(--font-c); padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink-2); }
.zone-jump a:hover { border-color: var(--steel); color: var(--steel); text-decoration: none; }
.bay-add svg { width: 16px; height: 16px; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag { font-size: 12.5px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line-2); }
.flag.on { color: var(--ink); border-color: var(--line); }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-radius: var(--r) 0 0 var(--r); min-width: 0; flex: 1; }
.input-unit span { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--r) var(--r) 0; background: var(--surface-2); color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.mini-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.mini-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
@media (max-width: 860px) {
  .zone-jump { margin-left: 0; }
  .bay-add.more { display: none; }
}
@media (max-width: 640px) { .hide-sm { display: none; } }
@media (max-width: 860px) {
  /* Phone bay row: big code on the left, size above tenant on the right; never wider than the screen. */
  .bay { display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: center; }
  .bay-code { grid-row: 1 / span 2; }
  .bay-meta, .bay-tenant { grid-column: 2; min-width: 0; }
  .bay-tenant { white-space: normal; overflow-wrap: anywhere; }
  .floor { margin: 0 8px 10px; padding: 8px; }
  .plan { padding: 0 10px 12px !important; }
  .zone-head .muted { width: 100%; }
}
/* Grid children must be allowed to shrink, or a wide table pushes the whole page sideways on phones. */
.grid > *, .page > * { min-width: 0; }
.panel-head { flex-wrap: wrap; }
@media (max-width: 1100px) { .cols-main, .cols-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- Phase 2: leasing */
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--partial); color: #1d1606; font: 700 12px/20px var(--font-c); text-align: center; }
.badge-info { color: var(--reserved); background: var(--reserved-tint); }
.input-unit span.pre { border-left: 1px solid var(--line); border-right: 0; border-radius: var(--r) 0 0 var(--r); }
.input-unit span.pre + input { border-radius: 0 var(--r) var(--r) 0; }
.tabs { display: flex; gap: 2px; margin-bottom: 14px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; color: var(--ink-2); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--steel); }
.tabs a span { font: 600 12px/18px var(--font-c); min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-2); text-align: center; }
.callout.bad { background: var(--full-tint); }
.text-bad { color: var(--danger) !important; }
.decide { border-color: var(--partial); box-shadow: inset 4px 0 0 var(--partial); }
.decide h2 { font-size: 18px; margin-bottom: 4px; }
.decide-row { display: flex; gap: 20px; margin-top: 14px; flex-wrap: wrap; }
.decide-row .grow { flex: 1 1 260px; }
.action-panel > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; align-items: center; gap: 8px; color: var(--danger); font-weight: 500; }
.action-panel > summary::-webkit-details-marker { display: none; }
.action-panel > summary svg { width: 16px; height: 16px; }
.action-panel[open] > summary { border-bottom: 1px solid var(--line-2); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 10px; display: flex; flex-direction: column; gap: 1px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-3); }
.timeline li.t-approve::before, .timeline li.t-activate::before { border-color: var(--available); background: var(--available); }
.timeline li.t-submit::before { border-color: var(--partial); background: var(--partial); }
.timeline li.t-reject::before, .timeline li.t-terminate::before, .timeline li.t-cancel::before { border-color: var(--full); background: var(--full); }
table.data tfoot tr:first-child td { border-top: 2px solid var(--line); }
table.data tfoot td { border-bottom: 0; padding-top: 6px; padding-bottom: 6px; }
.actions form { display: contents; }
.card.approval.flagged { box-shadow: inset 4px 0 0 var(--full); }
.term-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { font: inherit; font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--steel); color: var(--steel); }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: var(--steel); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.ag-lines td { vertical-align: top; }
.ag-lines td select { min-width: 220px; }
.ag-lines td.has-error select, .ag-lines td.has-error input { border-color: var(--danger); }
.ag-lines td.has-warn input { border-color: var(--partial); background: var(--partial-tint); }
.ag-lines .ag-amount { padding-top: 18px; }
.ag-lines .icon-btn { margin-top: 1px; }
.ag-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.ag-total { display: flex; flex-direction: column; justify-content: center; margin-left: 14px; line-height: 1.2; }
.ag-total b { font: 600 20px var(--font-c); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .ag-lines thead { display: none; }
  .ag-lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  .ag-lines td { border: 0 !important; padding: 0 !important; }
  .ag-lines td:first-child { grid-column: 1 / -1; }
  .ag-lines td select { min-width: 0; }
  .form-actions { flex-wrap: wrap; }
  .ag-total { margin-left: 0; order: -1; width: 100%; }
}
.callout-link { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.callout-link:hover { text-decoration: none; filter: brightness(.98); }
.callout-link svg { width: 18px; height: 18px; flex: none; }
.callout-link .go { margin-left: auto; font-weight: 600; white-space: nowrap; }
@media (max-width: 860px) {
  /* On phones the action bar sits at the end of the form instead of covering a third of the screen. */
  .form-actions { position: static; }
}

/* ---------------------------------------------------------------- Phase 3: billing */
.run-bar { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.run-bar .field { min-width: 180px; }
.run-bar h2 { font-size: 18px; }
.run-sum { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.run-sum b { font: 600 22px var(--font-c); }
.run-sum span { font-size: 12.5px; color: var(--ink-3); }
.bulk-bar { border-bottom: 1px solid var(--line-2); align-items: center; }
.bulk-bar .check { border: 0; padding: 0; }
.decide .run-bar > div:first-child { flex: 1 1 260px; }
.inv-lines td { vertical-align: top; }
.inv-lines textarea { min-height: 56px; min-width: 220px; }
.inv-lines .il-unit { margin-top: 4px; font-size: 13px; height: 30px; }
.inv-lines .il-amount { padding-top: 16px; }
.choice { display: grid; gap: 10px; }
.choice-item { align-items: flex-start; }
.choice-item input { margin-top: 3px; }
.row-edit { display: inline-block; text-align: left; }
.row-edit > summary { list-style: none; }
.row-edit > summary::-webkit-details-marker { display: none; }
.row-edit[open] .reg-form { display: grid; gap: 10px; padding: 12px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 300px; }
@media (max-width: 860px) {
  .run-sum { margin-left: 0; align-items: flex-start; }
  .inv-lines thead { display: none; }
  .inv-lines tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  .inv-lines td { border: 0 !important; padding: 0 !important; }
  .inv-lines td:first-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  #credit-form table.data td:first-child { min-width: 0; max-width: 140px; overflow-wrap: anywhere; }
  #credit-form table.data th:last-child, #credit-form table.data td:last-child { width: auto !important; min-width: 130px; }
}

/* ---------------------------------------------------------------- Phase 4: collections */
.rc-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.rc-tools .check { border: 0; padding: 0; }
.rc-table input { height: 34px; }
.rc-table tr.is-settled td:first-child { box-shadow: inset 3px 0 0 var(--available); }
.age-strip { display: flex; gap: 4px; min-height: 64px; }
.age-strip > div { display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; border-radius: var(--r-sm); min-width: 90px; }
.age-strip b { font: 600 18px/1.1 var(--font-c); }
.age-strip span { font-size: 12.5px; }
.age-not_due { background: var(--available-tint); }
.age-d30 { background: var(--partial-tint); }
.age-d60 { background: #f7d9b5; }
.age-d90 { background: var(--full-tint); }
.age-d90p { background: var(--full); color: #fff; }
.age-none { background: var(--available-tint); flex: 1; }
:root[data-theme="dark"] .age-d60 { background: #5a3d1c; }
.ledger .ledger-open td { background: var(--surface-2); }
tr.is-reversed td { opacity: .55; text-decoration: line-through; }
tr.is-reversed td:last-child { text-decoration: none; opacity: 1; }
.dep-actions { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line-2); }
.dep-actions > details { flex: 1 1 100%; }
.dep-actions > details:not([open]) { flex: 0 0 auto; }
.dep-actions > details > summary { list-style: none; display: inline-flex; }
.dep-actions > details > summary::-webkit-details-marker { display: none; }
.dep-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; padding: 12px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
@media (max-width: 860px) {
  .age-strip { flex-direction: column; }
  .age-strip > div { flex: none !important; }
}

/* ---------------------------------------------------------------- Phase 5: platform, notifications, reports */
.is-platform .side { background: #1c1433; }
.platform-tag { font-size: 13px; color: var(--ink-3); margin-right: auto; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.perm-grid fieldset { border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; margin: 0; display: grid; gap: 6px; }
.perm-grid legend { font-weight: 600; padding: 0 4px; }
.perm-grid .check { border: 0; padding: 2px 0; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { border-bottom: 1px solid var(--line-2); box-shadow: inset 4px 0 0 var(--steel); }
.notif-list li.sev-warn { box-shadow: inset 4px 0 0 var(--partial); }
.notif-list li.sev-alert { box-shadow: inset 4px 0 0 var(--full); }
.notif-list li.is-read { box-shadow: none; opacity: .7; }
.notif-list a { display: flex; flex-direction: column; gap: 2px; padding: 12px 18px; color: inherit; }
.notif-list a:hover { background: var(--surface-2); text-decoration: none; }
.bell { position: relative; }
.bell .bell-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--full); color: #fff; font: 700 11px/18px var(--font-c); text-align: center; }
.nowrap { white-space: nowrap; }
.audit td { vertical-align: top; }
@media print { .page-head .actions, .filters, .tabs { display: none !important; } table.report { font-size: 11px; } }
.sub-banner { padding: 10px 24px; font-size: 14px; border-bottom: 1px solid var(--line); }
.sub-grace { background: var(--partial-tint); }
.sub-read_only { background: var(--full-tint); }
.scope-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.scope-grid fieldset { border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; margin: 0; display: grid; gap: 6px; }
.scope-grid legend { font-weight: 600; padding: 0 4px; }
.scope-grid .check { border: 0; padding: 2px 0; }
