/* app/ui/static/shell.css
   The staff screens' shared look: design tokens, the sidebar shell, and the
   components every screen uses. Each page keeps only its own layout inline.
   8 px spacing grid, hairline borders, one accent (TA's deep green).
   Light and dark: each page's <head> sets data-theme on <html> (shell.js
   keeps it in step with the sidebar's Light, Dark, System choice), and only
   the tokens change. Fixed colours that stay are deliberate: map pins, the
   switch knob, shadows. */

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f6;
  --bg-hover: #f0f0ee;
  --surface: #ffffff;
  --ink: #1b1f24;
  --ink-2: #3a4047;
  --muted: #5d636a;
  --faint: #6c7178;
  --line: #e6e6e3;
  --line-strong: #d3d3cf;
  --line-hover: #bdbdb8;
  --accent: #1d5c56;
  --accent-hover: #164a45;
  --accent-tint: #ebf3f1;
  --accent-line: #c3d9d4;
  --accent-ink: #154640;
  --warn: #8a5300;
  --warn-dot: #d08a12;
  --warn-tint: #fdf6e6;
  --warn-line: #eed7a8;
  --warn-ink: #5a3800;
  --danger: #a13a26;
  --danger-tint: #fcefeb;
  --danger-line: #efc9bf;
  --danger-ink: #6e2414;
  --on-accent: #ffffff;
  --on-ink: #ffffff;
  --focus-ring: rgba(29, 92, 86, .16);
  --map-bg: #eceae4;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --pop: 0 1px 2px rgba(17, 24, 32, .06), 0 8px 24px rgba(17, 24, 32, .08);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-fast: 120ms;
  --motion-ui: 180ms;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15181b;
  --bg-subtle: #1b1f23;
  --bg-hover: #262b30;
  --surface: #1e2226;
  --ink: #e8eaec;
  --ink-2: #c8ccd0;
  --muted: #9ca2a8;
  --faint: #8a9097;
  --line: #2e3439;
  --line-strong: #3d444a;
  --line-hover: #50585f;
  --accent: #5fb3a8;
  --accent-hover: #7cc4ba;
  --accent-tint: #1a2f2c;
  --accent-line: #2e524c;
  --accent-ink: #a3d8cf;
  --warn: #e3a94b;
  --warn-dot: #e0a440;
  --warn-tint: #2c2415;
  --warn-line: #5a4521;
  --warn-ink: #f1cd8d;
  --danger: #ec8a73;
  --danger-tint: #311d18;
  --danger-line: #603429;
  --danger-ink: #f5b8a9;
  --on-accent: #0e1b19;
  --on-ink: #15181b;
  --focus-ring: rgba(95, 179, 168, .3);
  --map-bg: #22262a;
  --pop: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.5 var(--sans); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; color: var(--ink); font-weight: 600; }
h1 { font-size: 20px; line-height: 28px; letter-spacing: -.012em; }
h2 { font-size: 15px; line-height: 22px; letter-spacing: 0; }
h3 { font-size: 14px; line-height: 20px; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; line-height: 20px; margin-top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }
.icon path { vector-effect: non-scaling-stroke; }

/* ------------------------------------------------------------------ shell */

body { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: 100vh;
  height: 100vh; overflow: hidden; }
.topbar, .scrim { display: none; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--ink); color: var(--on-ink);
  padding: 8px 12px; border-radius: var(--radius); text-decoration: none; }
.skip:focus { top: 8px; color: var(--on-ink); }

.sidebar { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-subtle); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.sb-head { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px; margin-bottom: 16px; }
.brand-mark { flex: none; display: block; width: 26px; height: 24px; }
.wordmark { font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--ink); white-space: nowrap; }
.sb-close { display: none; }
.sb-label { font-size: 12px; font-weight: 500; color: var(--faint); padding: 0 8px; margin: 24px 0 8px; }
.sb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sb-list a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px;
  border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.sb-list a .icon { color: var(--muted); }
.sb-list a:hover { background: var(--bg-hover); color: var(--ink); }
.sb-list a[aria-current=page] { background: var(--accent-tint); color: var(--accent-ink); }
.sb-list a[aria-current=page] .icon { color: var(--accent); }
.sb-bottom { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; }
.sb-foot { padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 4px 8px; min-width: 0; }
.avatar { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-strong);
  display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; }
.sb-email { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.sb-signout { justify-content: flex-start; gap: 10px; height: 36px; min-height: 36px; padding: 0 8px; border: 0;
  background: none; color: var(--ink-2); font-weight: 500; width: 100%; }
button.sb-signout .icon { color: var(--muted); }
button.sb-signout:hover { background: var(--bg-hover); color: var(--ink); }
/* Theme (Light, Dark, System) and the fold button. Their words are hidden
   visually and kept for a screen reader; the tooltip shows them. */
.sb-tools { display: flex; align-items: center; gap: 8px; padding: 8px 0 0; border-top: 1px solid var(--line); }
.sb-theme { flex: 1; display: flex; gap: 2px; padding: 2px; border-radius: var(--radius); background: var(--bg-hover); }
.sb-theme button, button.sb-fold { min-height: 32px; height: 32px; padding: 0; border: 0; background: none; color: var(--muted);
  border-radius: var(--radius-sm); }
.sb-theme button { flex: 1; }
button.sb-fold { width: 36px; flex: none; }
.sb-theme button:hover, button.sb-fold:hover { background: var(--bg-hover); color: var(--ink); }
.sb-theme button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.sb-theme .lbl, .sb-fold .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; }
.sidebar { position: relative; }

.content { grid-column: 2; grid-row: 1; min-width: 0; min-height: 0; overflow-y: auto; }
/* Focused only as the skip link's target: no ring around the whole page. */
.content:focus { outline: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 32px 40px 64px; }
.page.narrow { max-width: 760px; }
.page-head { margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* Under 900 px the sidebar becomes a drawer behind a top bar. */
@media (max-width: 899px) {
  body { display: block; height: auto; overflow: visible; }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h); padding: 0 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .topbar .brand-mark { margin-left: 4px; }
  button.menu-btn, button.sb-close { width: 40px; height: 40px; min-height: 40px; padding: 0; border: 0; background: none;
    color: var(--ink-2); }
  button.menu-btn:hover, button.sb-close:hover { background: var(--bg-hover); }
  .menu-btn .icon, .sb-close .icon { width: 20px; height: 20px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw); padding: 8px 12px 16px;
    transform: translateX(-100%); visibility: hidden; transition: transform var(--motion-ui) var(--ease), visibility 0s linear var(--motion-ui); }
  .sb-head { margin-bottom: 12px; }
  .sb-close { display: grid; place-items: center; margin-left: auto; }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform var(--motion-ui) var(--ease);
    box-shadow: var(--pop); }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(17, 24, 32, .32); }
  body.drawer-open { overflow: hidden; }
  .sb-list a, button.sb-signout { height: 44px; }
  .sb-theme button { height: 40px; min-height: 40px; }
  button.sb-fold { display: none; }
  .content { overflow: visible; }
  .page { padding: 24px 16px 48px; }
  body { font-size: 15px; }
}

/* On a computer the sidebar can fold to a rail of icons. Labels are hidden
   visually, never with display: none, so a screen reader still names each
   link and button; the title shows the name on hover. */
@media (min-width: 900px) {
  /* Through the token, so anything placed by the sidebar's width (the map's toasts) follows. */
  :root[data-sidebar="collapsed"] { --sidebar-w: 64px; }
  [data-sidebar="collapsed"] .sidebar .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; }
  [data-sidebar="collapsed"] .sidebar :is(.wordmark, .sb-label) { display: none; }
  [data-sidebar="collapsed"] .sb-head { justify-content: center; padding: 0; }
  [data-sidebar="collapsed"] .sb-list { margin-top: 0; }
  [data-sidebar="collapsed"] .sidebar :is(.sb-list a, button.sb-signout, .sb-user) { justify-content: center; padding: 0; }
  [data-sidebar="collapsed"] .sb-tools, [data-sidebar="collapsed"] .sb-theme { flex-direction: column; align-items: stretch; }
  [data-sidebar="collapsed"] button.sb-fold { width: auto; }
  [data-sidebar="collapsed"] .sb-fold .icon { transform: scaleX(-1); }
}

/* ------------------------------------------------------------------ controls */

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 20px; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
button:hover, .button:hover { background: var(--bg-subtle); border-color: var(--line-hover); color: var(--ink); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
button.ghost { border-color: transparent; background: none; color: var(--ink-2); }
button.ghost:hover { background: var(--bg-hover); border-color: transparent; }
button.quiet { border-color: transparent; background: none; color: var(--muted); padding: 0 10px; }
button.quiet:hover { color: var(--danger); background: var(--danger-tint); border-color: transparent; }
button.text { border: 0; background: none; min-height: 28px; padding: 0 2px; color: var(--accent); font-weight: 500; }
button.text:hover { background: none; text-decoration: underline; text-underline-offset: 2px; color: var(--accent-hover); }
button.small, .button.small { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
button:disabled, button:disabled:hover { opacity: .5; cursor: not-allowed; background: var(--surface); }
button.primary:disabled { background: var(--accent); }

label, .label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin: 0 0 6px; }
input:not([type=radio]):not([type=checkbox]):not([type=range]), select, textarea {
  font: inherit; color: inherit; background: var(--surface); width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
textarea { resize: vertical; display: block; line-height: 1.5; }
input:not([type=radio]):not([type=checkbox]):not([type=range]):hover, select:hover, textarea:hover { border-color: var(--line-hover); }
input:not([type=radio]):not([type=checkbox]):not([type=range]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring);
}
input[type=radio], input[type=checkbox] { accent-color: var(--accent); }
::placeholder { color: var(--faint); }
.inline { display: flex; gap: 8px; }
.inline > input { flex: 1; min-width: 0; }

@media (max-width: 899px) {
  button, .button { min-height: 44px; font-size: 15px; }
  button.small, .button.small { min-height: 36px; }
  input:not([type=radio]):not([type=checkbox]):not([type=range]), select, textarea { font-size: 16px; min-height: 44px; }
}

/* ------------------------------------------------------------------ surfaces */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
@media (max-width: 899px) { .card { padding: 16px; } }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--bg-subtle); color: var(--ink-2); border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.plain { background: none; border-color: transparent; border-radius: 0; padding: 0; color: var(--muted); }
.badge.plain::before { display: none; }
.badge[data-tone=accent] { background: var(--accent-tint); color: var(--accent-ink); border-color: var(--accent-line); }
.badge[data-tone=warn] { background: var(--warn-tint); color: var(--warn-ink); border-color: var(--warn-line); }
.badge[data-tone=warn]::before { background: var(--warn-dot); opacity: 1; }
.badge[data-tone=danger] { background: var(--danger-tint); color: var(--danger-ink); border-color: var(--danger-line); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:last-child, td:last-child { padding-right: 0; }

.ok, .warn, .err { padding: 12px; border: 1px solid; border-radius: var(--radius); font-size: 14px; line-height: 20px; }
.ok { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-ink); }
.warn { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn-ink); }
.err { background: var(--danger-tint); border-color: var(--danger-line); color: var(--danger-ink); }
.ok b, .warn b, .err b { font-weight: 600; }

.empty { display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--muted);
  padding: 48px 24px; font-size: 14px; }
.empty .icon { width: 28px; height: 28px; color: var(--faint); margin-bottom: 4px; }
.empty b { color: var(--ink); font-weight: 600; }

.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: var(--on-ink); padding: 12px 16px; border-radius: var(--radius); font-size: 14px;
  box-shadow: var(--pop); max-width: 360px; animation: toast-in var(--motion-ui) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (max-width: 899px) { .toasts { left: 16px; right: 16px; bottom: 16px; } .toast { max-width: none; } }

@media (prefers-reduced-motion: reduce) {
  :root { --motion-fast: 0ms; --motion-ui: 0ms; }
  .sidebar { transition: none !important; }
  .toast { animation: none; }
}

/* ------------------------------------------------------------------ maps (Leaflet) */

/* The street map is drawn light; in dark mode it is inverted, and the lot
   boundaries over it with it (black lines and numbers on a white halo turn
   white on black). Aerial photos, and lots over them, are left as they are. */
[data-theme="dark"] .leaflet-container:has(.street-tiles) :is(.street-tiles, .lot-tiles) {
  filter: invert(.9) hue-rotate(180deg) saturate(.8);
}
/* The search radius and the parcel pin take the accent of the theme. */
path.accent-ring { stroke: var(--accent); fill: var(--accent); }
path.accent-fill { fill: var(--accent); }
