:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5d6b7a;
  --line: #dde2e8;
  --brand: #1f5f8b;
  --brand-ink: #ffffff;
  --danger: #b42318;
  --ok: #1a7f4b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --panel: #161d24;
    --ink: #e6ebf0;
    --muted: #9aa8b6;
    --line: #2a343e;
    --brand: #5aa7d8;
    --brand-ink: #0b1218;
    --danger: #f97066;
    --ok: #47cd89;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1419;
    --panel: #161d24;
    --ink: #e6ebf0;
    --muted: #9aa8b6;
    --line: #2a343e;
    --brand: #5aa7d8;
    --brand-ink: #0b1218;
    --danger: #f97066;
    --ok: #47cd89;
    --shadow: none;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--ink); text-decoration: none; }
.brand svg { fill: var(--brand); }
.org-switch { flex: 1; }
.org-switch select { max-width: 280px; }
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.main { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 16px 0;
}
.hero { max-width: 520px; margin: 60px auto; text-align: center; }
.hero h1 { font-size: 30px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select {
  font: inherit; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button, .button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px; padding: 8px 14px;
  border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); text-decoration: none; display: inline-block;
}
button.secondary, .button.secondary { background: transparent; color: var(--brand); }
button.link { background: none; border: none; color: var(--brand); padding: 4px 6px; font-weight: 500; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 8px; overflow-x: auto; }
.tabs a {
  padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .n { font-size: 26px; font-weight: 650; }
.tile .l { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.error { color: var(--danger); }
.notice { border-left: 3px solid var(--brand); padding: 10px 14px; background: var(--panel); border-radius: 4px; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow);
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .main { padding: 20px 16px 48px; }
  .hide-sm { display: none; }
  th, td { padding: 8px 4px; }
}
.row.center { justify-content: center; }
.grow2 { flex: 2; min-width: 220px; }
.grow1 { flex: 1; min-width: 160px; }
.small { font-size: 13px; }
.grow2 input, .grow1 select, .stack > div > input, .stack > div > select { width: 100%; max-width: 520px; }
.card:has(table) { overflow-x: auto; }
td select { max-width: 100%; }
.user-menu { margin-left: auto; }
@media (max-width: 640px) {
  .card { padding: 14px; }
  .org-switch { flex-basis: 100%; order: 3; }
  .org-switch select { width: 100%; max-width: none; }
  td select { max-width: 150px; }
}

/* ---------- phase 1: buildings and the stacking plan ---------- */
.spread { justify-content: space-between; }
.grow { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.crumbs { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.grid2, .grid3 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field input, .field select { width: 100%; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 500; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.tiles.seats { margin-top: 24px; }
td.actions { white-space: nowrap; text-align: right; }
.floor-head { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
h3 { font-size: 15px; margin: 14px 0 4px; }

.dlg { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(560px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); }
.dlg::backdrop { background: rgba(15, 20, 25, 0.45); }
.dlg h2 { margin-top: 0; }

.plan-controls { margin: 4px 0 12px; }
.plan-layout { display: flex; gap: 16px; align-items: flex-start; }
.plan { flex: 1; min-width: 0; }
.side-panel {
  position: fixed; right: 16px; top: 76px; width: 320px; max-height: calc(100vh - 92px); overflow: auto; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
}
.side-panel h2 { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; font-size: 13px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.15); vertical-align: -2px; }
.stack-chart { display: flex; flex-direction: column; gap: 4px; }
.floor { display: grid; grid-template-columns: 76px 1fr 84px; gap: 8px; align-items: center; }
.f-label { display: flex; flex-direction: column; line-height: 1.2; }
.f-pct { text-align: right; }
.bar-wrap { min-width: 0; }
.bar { display: flex; gap: 2px; width: var(--w, 100%); min-height: 38px; }
.block {
  flex: var(--g, 1) 1 0; min-width: 22px; overflow: hidden; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 3px;
  padding: 3px 5px; text-align: left; font: inherit; font-size: 12px; line-height: 1.25; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; font-weight: 500;
}
.block:hover, .block:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; z-index: 1; }
.block .b-label { font-weight: 700; white-space: nowrap; }
.block .b-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.9; }
.block.empty { background: transparent; border-style: dashed; color: var(--muted); cursor: default; }

/* Status colours. Dark text on light fills, white on dark; patterns help colour-blind readers and print. */
.s-occupied { background: #3b6fa8; color: #fff; }
.s-expiring { background: #e3a72f; color: #1b1b1b; }
.s-notice { background: #b04a2e; color: #fff; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.18) 0 4px, transparent 4px 9px); }
.s-leased { background: #1f7a71; color: #fff; background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,0.2) 0 3px, transparent 3px 8px); }
.s-available { background: #a7d79a; color: #13361a; }
.s-unavailable { background: #c9cfd6; color: #1b2733; }
.s-construction { background: #8a939d; color: #fff; background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.25) 0 2px, transparent 2px 7px); }
.s-offline { background: #5b6470; color: #fff; background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.15) 0 2px, transparent 2px 6px); }
.s-common { background: #eef0f3; color: #4a5562; border-style: dashed; }
.u-office { background: #3b6fa8; color: #fff; } .u-retail { background: #b5651d; color: #fff; } .u-residential { background: #6a8f3a; color: #fff; }
.u-storage { background: #8a7e6b; color: #fff; } .u-amenity { background: #7d5ba6; color: #fff; } .u-parking { background: #6b7280; color: #fff; } .u-other { background: #a3a9b1; color: #111; }
.e-y0 { background: #b8322a; color: #fff; } .e-y1 { background: #e07b39; color: #111; } .e-y2 { background: #edc14b; color: #111; }
.e-y3 { background: #9cc56b; color: #111; } .e-y4 { background: #4f9a6b; color: #fff; } .e-y5 { background: #2f6b8f; color: #fff; } .e-mtm { background: #8e6bb5; color: #fff; }

.print-only { display: none; }
@media (max-width: 640px) {
  .side-panel { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 60vh; }
}
@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .floor { grid-template-columns: 44px 1fr; }
  .f-pct { display: none; }
  .block .b-name { display: none; }
  .block { min-width: 18px; padding: 2px 3px; font-size: 10px; }
}
@media print {
  @page { size: landscape; margin: 12mm; }
  body { background: #fff; color: #000; }
  .topbar, .no-print, .plan-controls, .side-panel, .toast, .tabs, .crumbs { display: none !important; }
  .main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; }
  .print-only { display: block; margin-top: 10px; }
  .block { -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
  .sw, .tile { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .floor { break-inside: avoid; }
}
.toast { z-index: 50; }

/* ---------- phase 2: leases, tenants, import ---------- */
.badge.st-active { color: #1a7f4b; border-color: #8fd1ae; }
.badge.st-future { color: #1f6f8b; border-color: #9cd0e3; }
.badge.st-holdover, .badge.st-notice { color: #b5531f; border-color: #f0b893; }
.badge.st-expired, .badge.st-ended, .badge.st-cancelled { color: var(--muted); }
.badge + .badge { margin-left: 4px; }
.pick-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.pick-list .check { padding: 3px 0; }
.step-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1.2fr auto; gap: 6px; align-items: center; }
.step-row.head span { font-weight: 600; }
tr.current td { background: rgba(59, 111, 168, 0.08); font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); }
textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
input[type="search"] { min-width: 220px; }
@media (max-width: 640px) {
  .step-row { grid-template-columns: 1fr 1fr; }
  input[type="search"] { min-width: 0; width: 100%; }
}

/* ---------- Phase 3: plan colour modes, charts, dashboard ---------- */
:root {
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #6250d6;
  --div-neg2: #c43a39; --div-neg1: #f2a3a2; --div-mid: #e4e3df; --div-pos1: #86b6ef; --div-pos2: #1c5cab;
  --viz-surface: var(--panel); --viz-grid: #e6e9ed; --viz-future: rgba(93, 107, 122, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9;
    --div-neg2: #e66767; --div-neg1: #8f3a3a; --div-mid: #383835; --div-pos1: #2b5d99; --div-pos2: #6da7ec;
    --viz-grid: #26303a; --viz-future: rgba(154, 168, 182, 0.08);
  }
}
:root[data-theme="dark"] {
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9;
    --div-neg2: #e66767; --div-neg1: #8f3a3a; --div-mid: #383835; --div-pos1: #2b5d99; --div-pos2: #6da7ec;
    --viz-grid: #26303a; --viz-future: rgba(154, 168, 182, 0.08);
  }

.c1 { background: var(--c1); color: #fff; } .c2 { background: var(--c2); color: #111; } .c3 { background: var(--c3); color: #111; }
.c4 { background: var(--c4); color: #111; } .c5 { background: var(--c5); color: #111; } .c6 { background: var(--c6); color: #fff; }
.c7 { background: var(--c7); color: #fff; }
.c-other { background: #8f969e; color: #fff; }
.c-none { background: #eef0f3; color: #4a5562; }
.r-m2 { background: var(--div-neg2); color: #fff; } .r-m1 { background: var(--div-neg1); color: #111; }
.r-0 { background: var(--div-mid); color: var(--ink); }
.r-p1 { background: var(--div-pos1); color: #111; } .r-p2 { background: var(--div-pos2); color: #fff; }
.r-na { background: #c9cfd6; color: #1b2733; background-image: repeating-linear-gradient(135deg, rgba(0,0,0,0.12) 0 2px, transparent 2px 7px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .r-m1, :root:not([data-theme="light"]) .r-p1 { color: #fff; }
  :root:not([data-theme="light"]) .r-p2 { color: #111; }
  :root:not([data-theme="light"]) .c-none { background: #2a343e; color: var(--muted); }
}
:root[data-theme="dark"] .r-m1, :root[data-theme="dark"] .r-p1 { color: #fff; }
:root[data-theme="dark"] .r-p2 { color: #111; }
:root[data-theme="dark"] .c-none { background: #2a343e; color: var(--muted); }

.slider-label { gap: 8px; }
.month-slider { width: 180px; accent-color: var(--brand); }
.slider-out { min-width: 72px; }

.charts { margin-top: 16px; }
.viz { margin: 0; }
.viz figcaption { font-weight: 600; font-size: 14px; }
.viz-wrap { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { fill: var(--muted); font-size: 11px; }
.viz-label { fill: var(--ink); font-size: 11px; }
.viz-bar { stroke: var(--viz-surface); stroke-width: 2; }
.viz-bar.s1 { fill: var(--c1); }
.viz-hit { fill: transparent; cursor: crosshair; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-line.s1 { stroke: var(--c1); } .viz-line.s2 { stroke: var(--c2); } .viz-line.s3 { stroke: var(--c3); }
.viz-dot { stroke: var(--viz-surface); stroke-width: 2; }
.viz-dot.s1 { fill: var(--c1); } .viz-dot.s2 { fill: var(--c2); } .viz-dot.s3 { fill: var(--c3); }
.viz-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.viz-future { fill: var(--viz-future); }
.viz-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 140px; max-width: 220px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font-size: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.viz-tip-head { font-weight: 600; margin-bottom: 2px; }
.viz-table { margin-top: 8px; max-height: 260px; overflow: auto; }
.sw-line { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; }
.sw-line.s1 { border-color: var(--c1); } .sw-line.s2 { border-color: var(--c2); } .sw-line.s3 { border-color: var(--c3); }
.tile[title] { cursor: help; }
@media (max-width: 900px) { .grid2.charts { grid-template-columns: 1fr; } }
@media print {
  .r-na { background-image: none; }
}
.r-none { background: #e3e6ea; color: #1b2733; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .r-none { background: #3a434d; color: var(--ink); }
}
:root[data-theme="dark"] .r-none { background: #3a434d; color: var(--ink); }

.viz-line.dash1 { stroke-dasharray: 6 3; }
.viz-line.dash2 { stroke-dasharray: 2 3; }
.sw-line.s2 { border-top-style: dashed; } .sw-line.s3 { border-top-style: dotted; }
.viz-sub { margin: 0 0 4px; }
.viz figcaption + button, .viz .row.spread { flex-wrap: nowrap; }

/* ---------- Phase 4 ---------- */
.check-list { display: grid; gap: 6px; max-height: 280px; overflow: auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.check-list label { font-weight: 400; }
.banner { margin-bottom: 14px; }
.banner.danger, .notice.danger { border-left-color: var(--danger); }
.badge.danger { color: var(--danger); border-color: var(--danger); }
.alert-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
h3 { font-size: 15px; margin: 8px 0 4px; }
.alerts-form label.inline, .dlg label.inline { display: flex; gap: 6px; align-items: center; font-weight: 400; }

/* ---------- Phase 5: pipeline, documents, accessibility ---------- */
.deal-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; width: min(calc(100vw - 32px), 1400px); position: relative; left: 50%; transform: translateX(-50%); }
.deal-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 160px; display: flex; flex-direction: column; gap: 8px; }
.deal-col header h3 { margin: 0; font-size: 14px; }
.deal-col.drop { outline: 2px dashed var(--brand); outline-offset: 2px; }
.deal-col.st-signed { border-top: 3px solid var(--ok); }
.deal-col.st-lost { border-top: 3px solid var(--muted); }
.deal-list { display: flex; flex-direction: column; gap: 8px; }
.deal-card { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--bg); display: grid; gap: 4px; cursor: grab; }
.deal-card.dragging { opacity: .5; }
.deal-card.lost { opacity: .7; }
.deal-card select { width: 100%; }
.deal-name { font-weight: 600; }
.block.has-deal { box-shadow: inset 0 0 0 2px var(--panel), 0 0 0 2px var(--c7); }
.deal-mark { font-weight: 600; white-space: nowrap; }
.sw.deal-sw { background: transparent; border: 2px solid var(--c7); }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.doc-upload { margin-top: 8px; flex-wrap: wrap; }
.danger-text { color: var(--danger); }

/* Accessibility: visible keyboard focus everywhere, a skip link, screen-reader-only text. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.block:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .block, .sw, .viz-bar, .deal-card { forced-color-adjust: none; border: 1px solid CanvasText; } }
h1[tabindex="-1"]:focus { outline: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.st-active { color: #5fd39a; border-color: #2f7a55; }
  :root:not([data-theme="light"]) .badge.st-future { color: #6cc0dd; border-color: #2f6c82; }
  :root:not([data-theme="light"]) .badge.st-holdover, :root:not([data-theme="light"]) .badge.st-notice { color: #f0a067; border-color: #8a5530; }
}
:root[data-theme="dark"] .badge.st-active { color: #5fd39a; border-color: #2f7a55; }
:root[data-theme="dark"] .badge.st-future { color: #6cc0dd; border-color: #2f6c82; }
:root[data-theme="dark"] .badge.st-holdover, :root[data-theme="dark"] .badge.st-notice { color: #f0a067; border-color: #8a5530; }


/* ---------- Platform admin console and invoices ---------- */
.admin-link { font-weight: 600; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; }
.tile.warn { border-color: var(--danger); }
.tile .n.small-n { font-size: 17px; line-height: 1.3; }
input.short { width: 90px; }
.pre { white-space: pre-line; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.table-wrap { overflow-x: auto; }
.admin-top { align-items: start; margin-bottom: 20px; }
td.actions { white-space: nowrap; }
.invoice { max-width: 820px; margin: 16px auto; padding: 32px; display: grid; gap: 20px; }
.inv-brand { font-size: 22px; font-weight: 700; color: var(--brand); }
.inv-meta { text-align: right; }
.inv-meta h1 { font-size: 22px; margin: 0 0 6px; }
.inv-lines { width: 100%; }
.inv-lines tfoot th { border-top: 2px solid var(--ink); font-size: 16px; }
@media print {
  .invoice { border: 0; box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .admin-link { display: none; }
}
.theme-toggle { background: none; border: 0; padding: 4px; cursor: pointer; }
.tt-track { display: inline-flex; align-items: center; width: 46px; height: 24px; border-radius: 999px; background: var(--line); padding: 2px; transition: background .2s; }
.tt-knob { width: 20px; height: 20px; border-radius: 50%; background: var(--panel); color: var(--ink); display: grid; place-items: center; font-size: 12px; line-height: 1; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.theme-toggle[aria-checked="true"] .tt-track { background: var(--brand); }
.theme-toggle[aria-checked="true"] .tt-knob { transform: translateX(22px); }

/* ---------- contact support (D-020) ---------- */
.help-link { font-weight: 600; text-decoration: none; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.field textarea { width: 100%; font: inherit; }
.thread { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; max-width: 760px; }
.msg-support { border-left: 4px solid var(--brand); }
.msg-user { border-left: 4px solid var(--line); }
.msg-note { border-style: dashed; background: transparent; }
.msg-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.tile-link { color: inherit; text-decoration: none; display: block; }
.tile-link:hover, .tile-link:focus-visible { border-color: var(--brand); }
.field.row { margin: 0; }
.field.row label { margin: 0; }
.field.row select { width: auto; }
.card > h2:first-child { margin-top: 0; }

/* ---------- admin tools (D-021) ---------- */
.danger-zone { border-color: var(--danger); margin-top: 24px; }
.danger-zone h3 { margin-top: 0; color: var(--danger); }
.link.danger-text, .danger-text { color: var(--danger); }
.span2 { grid-column: span 2; }
@media (max-width: 700px) { .span2 { grid-column: auto; } }
.announcement { width: min(940px, calc(100% - 32px)); box-sizing: border-box; margin: 12px auto 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid; white-space: pre-line; }
.announcement.info { background: #eaf3fa; border-color: #9cc3df; color: #17405f; }
.announcement.warning { background: #fff4e5; border-color: #f0b893; color: #7a3410; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .announcement.info { background: #13283a; border-color: #2c5b80; color: #cfe5f5; }
  :root:not([data-theme="light"]) .announcement.warning { background: #33210f; border-color: #8a4d1f; color: #f8d9bd; }
}
:root[data-theme="dark"] .announcement.info { background: #13283a; border-color: #2c5b80; color: #cfe5f5; }
:root[data-theme="dark"] .announcement.warning { background: #33210f; border-color: #8a4d1f; color: #f8d9bd; }

/* ---------- licenses (D-022) ---------- */
.tiles.small-tiles { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.tiles.small-tiles .tile { padding: 10px; }
.tiles.small-tiles .tile .n { font-size: 20px; }
tr[hidden] { display: none; }

/* ---------- two-step verification (D-023) ---------- */
.narrow-page { max-width: 560px; margin: 32px auto; }
.code-input { font-size: 22px; letter-spacing: 4px; max-width: 220px; font-variant-numeric: tabular-nums; }
.qr-wrap { margin: 10px 0; }
.qr { background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--line); width: 200px; height: 200px; }
.mfa-key { font-size: 14px; word-break: break-all; }
.steps-list { padding-left: 20px; display: grid; gap: 14px; }
.steps-list label { display: block; margin-bottom: 6px; }
.recovery-codes { columns: 2; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; padding-left: 20px; }
.account-link { color: var(--muted); text-decoration: none; }
.account-link:hover { text-decoration: underline; }

/* ---------- company logo (D-028) ---------- */
.org-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.org-head h1 { margin: 0; }
.org-logo { max-height: 48px; max-width: 200px; object-fit: contain; display: block; }
.logo-preview { width: 160px; height: 80px; object-fit: contain; border: 1px dashed var(--line); border-radius: var(--radius); padding: 8px; background: var(--panel); }
.logo-preview.empty { display: flex; align-items: center; justify-content: center; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); padding: 0; cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--brand); }
.logo-canvas-wrap { background: repeating-conic-gradient(var(--line) 0% 25%, transparent 0% 50%) 50% / 16px 16px; border-radius: var(--radius); padding: 10px; text-align: center; }
.logo-canvas { max-width: 100%; max-height: 160px; }
.print-only.org-logo { display: none; }
@media print { .print-only.org-logo { display: block; margin-bottom: 8px; } }

/* ---------- company in the top bar (D-029) ---------- */
.brand-logo { max-height: 34px; max-width: 180px; object-fit: contain; display: block; }
.org-switch { display: flex; align-items: center; gap: 12px; }
.org-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.logo-link { color: var(--muted); }

/* ---------- email campaigns (D-030) ---------- */
.flyer-thumb { max-width: 220px; max-height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 16px; }
progress { width: 100%; height: 14px; accent-color: var(--brand); }

/* ---------- storage allowance (D-032) ---------- */
.storage-meter { display: grid; gap: 6px; }
.storage-meter .row { justify-content: space-between; }
.storage-warn progress, .storage-high progress { accent-color: #c27c0e; }
.storage-full progress { accent-color: var(--danger); }

/* ---------- plans (D-033) ---------- */
.plan-name { font-size: 22px; font-weight: 700; }
.plan-price { font-size: 22px; font-weight: 700; }
.plan-total { text-align: right; }
.plan-head { align-items: flex-start; }
.use-grid, .plan-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.use-grid .card, .plan-grid .card { padding: 14px; margin: 0; }
.use-n { font-size: 20px; font-weight: 700; margin: 2px 0 6px; }
.plan-card.current { border: 2px solid var(--brand); }
.plans-table input { width: 100%; min-width: 70px; }

/* ---------- building photos (D-034) ---------- */
.bld-cell { display: flex; gap: 12px; align-items: center; }
.bld-thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: none; display: block; }
.bld-thumb.empty { display: flex; align-items: center; justify-content: center; background: var(--alt, #eef2f6); color: var(--muted); font-weight: 700; }
.bld-hero { margin: 0 0 12px; position: relative; }
.bld-hero img { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.bld-hero figcaption { position: absolute; right: 10px; bottom: 10px; background: color-mix(in srgb, var(--panel) 92%, transparent); padding: 6px 10px; border-radius: 8px; }
.bld-photo-add { margin: 0 0 8px; }
.bld-photo-preview img { max-width: 320px; max-height: 200px; border-radius: 8px; border: 1px solid var(--line); display: block; }
@media print { .bld-hero img { max-height: 160px; } }

/* ---------- role permissions (D-035) ---------- */
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: center; font-size: 14px; }
.perm-table tbody th { text-align: left; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 14px; }
.perm-table .perm-help { text-transform: none; letter-spacing: 0; }
.perm-table thead th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.perm-table .perm-group th { background: var(--alt, #f4f6f8); font-weight: 700; font-size: 13px; text-align: left; }
.perm-help { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.perm-na { color: var(--muted); }
input.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 11px; background: #c9cfd6; position: relative; cursor: pointer; vertical-align: middle; margin: 0; transition: background .15s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
input.switch:checked { background: var(--brand); }
input.switch:checked::after { left: 19px; }
input.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- stacking plan search ---------- */
.plan-search { width: 220px; }
.plan-search-wrap { gap: 8px; }
.stack-chart .block.dim { opacity: .22; }
.stack-chart .block.match { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 1; }
@media print { .stack-chart .block.dim { opacity: 1; } .stack-chart .block.match { outline: none; } }

/* ---------- portfolio map (D-037) ---------- */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented .seg { background: var(--panel); color: var(--ink); border: 0; border-radius: 0; padding: 6px 14px; font-weight: 600; cursor: pointer; }
.segmented .seg + .seg { border-left: 1px solid var(--line); }
.segmented .seg[aria-pressed="true"] { background: var(--brand); color: #fff; }
.map { position: relative; height: 440px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #dfe7ee; touch-action: none; cursor: grab; user-select: none; }
.map.dragging { cursor: grabbing; }
.map:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.map-tiles img { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; }
.map-pins { position: absolute; inset: 0; pointer-events: none; }
.map-pin { position: absolute; left: 0; top: 0; pointer-events: auto; width: 22px; height: 22px; margin: -11px 0 0 -11px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; }
.map-pin::after { content: ""; position: absolute; left: 5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.map-pin-label { position: absolute; left: 26px; top: -2px; white-space: nowrap; font-size: 12px; font-weight: 700; color: #16202b; background: rgba(255,255,255,.9); padding: 1px 6px; border-radius: 4px; pointer-events: none; }
.map-pin:focus-visible { outline: 3px solid var(--ink); }
.map-popup { position: absolute; left: 0; top: 0; z-index: 3; width: 240px; margin: 12px 0 0 -120px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); overflow: hidden; cursor: default; }
.map-photo { width: 100%; height: 110px; object-fit: cover; display: block; }
.map-popup-body { padding: 10px 12px; display: grid; gap: 4px; }
.map-controls { position: absolute; right: 10px; top: 10px; display: grid; gap: 4px; z-index: 2; }
.map-btn { width: 34px; height: 34px; padding: 0; border-radius: 6px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); font-size: 18px; font-weight: 700; cursor: pointer; }
.map-btn.wide { font-size: 12px; }
.map-btn:disabled { opacity: .4; cursor: default; }
.map-attrib { position: absolute; right: 0; bottom: 0; z-index: 2; font-size: 11px; background: rgba(255,255,255,.85); color: #333; padding: 2px 6px; border-top-left-radius: 6px; }
.map-attrib a { color: #1f5f8b; }
.map-missing ul { margin: 0; padding-left: 18px; }
