/* JUST service console
   Direction and reasons: DESIGN.md (graphite instrument panel, dial ENERGY 2 / RHYTHM 3 / MOTION 2)
   Two themes ship. Dark is the workshop at night; light is the same shop in daylight. */

:root,
[data-theme="dark"] {
  --canvas: #0e1114;
  --panel: #151a1f;
  --panel-2: #1b2228;
  --raised: #202930;
  --surface-sunken: #12181d;
  --surface-hover: #171d23;
  --input-bg: #10151a;
  --hairline: #273039;
  --hairline-soft: #1e262c;
  --hairline-strong: #35414b;
  --ink: #e9eef3;
  --ink-muted: #95a3b0;
  --ink-faint: #7a8794;
  --chrome: #c9d4de;
  --accent: #4c8dff;
  --accent-strong: var(--accent-strong);
  --accent-dim: #23508f;
  --on-accent: #06101f;
  --ok: #37c08b;
  --warn: #f2a93b;
  --risk: #f2555a;
  --avatar-bg: #232c34;
  --auth-art: #0a0d10;
  --topbar-bg: rgba(14, 17, 20, 0.92);
  --toast-bg: #1b2228;
  --scrim: rgba(4, 6, 8, 0.62);

  --chip-bg: #12181d;
  --chip-ok-bg: #101a16;   --chip-ok-line: #1f3a30;
  --chip-warn-bg: #1a1610; --chip-warn-line: #3a3020;
  --chip-risk-bg: #1a1214; --chip-risk-line: #3a2427;
  --chip-info-bg: #101722; --chip-info-line: #1e3454;
  --danger-bg: #1d1416;    --danger-line: #3a2427;  --danger-hover: #291a1d; --danger-hover-line: #5a2f34;

  --r-xs: 4px;
  --r-sm: 8px;
  --r-lg: 12px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --font-display: Bahnschrift, "DIN Alternate", "Archivo Narrow", "Arial Narrow", system-ui, sans-serif;
  --font-text: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --shadow-lift: 0 18px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --canvas: #f4f1ea;
  --panel: #fffdf8;
  --panel-2: #f6f2e9;
  --raised: #efeade;
  --surface-sunken: #f0ece2;
  --surface-hover: #eae5d9;
  --input-bg: #ffffff;
  --hairline: #ddd5c6;
  --hairline-soft: #e7e0d2;
  --hairline-strong: #c8bfae;
  --ink: #1b1f24;
  --ink-muted: #5b646d;
  --ink-faint: #666e77;
  --chrome: #3d454e;
  --accent: #1f5fd0;
  --accent-strong: #2f6fe0;
  --accent-dim: #b9cdf0;
  --on-accent: #ffffff;
  --ok: #177a55;
  --warn: #9a6410;
  --risk: #b3242b;
  --avatar-bg: #ddd6c8;
  --auth-art: #e4ded1;
  --topbar-bg: rgba(244, 241, 234, 0.94);
  --toast-bg: #fffdf8;
  --scrim: rgba(28, 24, 16, 0.42);

  --chip-bg: #f2eee4;
  --chip-ok-bg: #e7f4ec;   --chip-ok-line: #bfe0cd;
  --chip-warn-bg: #fbf0d9; --chip-warn-line: #ecd6a8;
  --chip-risk-bg: #fbebeb; --chip-risk-line: #efc7c7;
  --chip-info-bg: #eaf0fb; --chip-info-line: #c6d6f2;
  --danger-bg: #fbebeb;    --danger-line: #efc7c7;  --danger-hover: #f7dede; --danger-hover-line: #e3aeae;

  --shadow-lift: 0 16px 34px rgba(60, 48, 30, 0.16);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
}

h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0; }

a { color: var(--accent); }

img { display: block; max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

.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: 12px; top: -60px; z-index: 60;
  background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: var(--r-xs);
  font-weight: 600; text-decoration: none; transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.muted { color: var(--ink-muted); }
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1; }

.eyebrow {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transform: skewX(-12deg);
  transform-origin: left center;
}

/* ---------------------------------------------------------------- boot */

.boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: var(--s4);
  justify-items: center; background: var(--canvas); z-index: 20;
}
.boot-mark { opacity: 0.9; }
.boot-text { color: var(--ink-faint); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.boot[hidden] { display: none; }

/* ---------------------------------------------------------------- auth */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid; place-items: center; padding: var(--s6);
  background: var(--canvas);
}
.auth[hidden] { display: none; }

.auth-card {
  width: min(900px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lift);
}

/* the brand half: the shop's own artwork on its own black */
.auth-brand {
  position: relative;
  display: grid; align-content: space-between;
  gap: var(--s5);
  padding: var(--s6);
  background: #0a0d10;
  border-right: 1px solid var(--hairline);
}
.auth-lockup { width: 100%; max-width: 330px; height: auto; }
.auth-brand::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: var(--accent); opacity: 0.9;
}
.auth-brand-foot { display: grid; gap: 2px; }
.auth-brand-name {
  font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--chrome);
}
.auth-brand-line { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }

.auth-panel { display: flex; flex-direction: column; }
.auth-panel-top { display: flex; justify-content: flex-end; padding: var(--s3) var(--s3) 0; }
.auth-body { padding: var(--s5) var(--s6) var(--s6); display: grid; gap: var(--s3); align-content: start; }
.auth-body h1 { font-size: 26px; letter-spacing: -0.01em; }
.auth-sub { font-size: 13px; color: var(--ink-muted); margin-bottom: var(--s2); }

.auth-body form { display: grid; gap: var(--s4); }
.auth-body .field > label { font-size: 10px; letter-spacing: 0.12em; }
.auth-body .field input { padding: 12px 13px; font-size: 15px; }

/* password field with its own reveal control */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 46px; }
.password-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  background: none; border: 0; border-radius: var(--r-xs);
  color: var(--ink-faint); cursor: pointer;
}
.password-eye:hover { color: var(--ink); background: var(--surface-hover); }
.password-eye[aria-pressed="true"] { color: var(--accent); }

.caps { color: var(--warn); }

.auth-submit { padding: 13px 16px; font-size: 15px; margin-top: var(--s2); }
.auth-foot { margin-top: var(--s4); font-size: 11.5px; color: var(--ink-faint); line-height: 1.5; }

/* Google sits under the password form as an alternative, not the main path */
.auth-google { display: grid; gap: var(--s3); margin-top: var(--s2); }
.auth-google[hidden] { display: none; }
.auth-or { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3); }
.auth-or::before, .auth-or::after { content: ""; height: 1px; background: var(--hairline); }
.auth-or span { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.gsi-slot { display: flex; justify-content: center; min-height: 40px; }
.gsi-slot > div { width: 100% !important; }

@media (max-width: 760px) {
  .auth { padding: var(--s4); }
  .auth-card { grid-template-columns: 1fr; }
  .auth-brand { padding: var(--s5); border-right: 0; border-bottom: 1px solid var(--hairline); }
  .auth-lockup { max-width: 240px; }
  .auth-brand-foot { display: none; }
  .auth-body { padding: var(--s4) var(--s5) var(--s5); }
  .auth-body h1 { font-size: 22px; }
}

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

.shell {
  display: block;
  min-height: 100vh;
}
.shell[hidden] { display: none; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--avatar-bg); color: var(--chrome);
  font-family: var(--font-display); font-size: 11px; letter-spacing: 0.04em;
}

.workspace { display: grid; grid-template-rows: auto 1fr; min-width: 0; }

.brand {
  display: inline-flex; align-items: baseline; gap: 8px;
  background: none; border: 0; padding: 4px 0; cursor: pointer;
}
.brand-sub { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }

.back-shop { white-space: nowrap; }

.owner {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.owner-name { font-size: 12px; color: var(--ink-muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the toggle shows a moon in dark mode and a sun in light mode, drawn not graded */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; }
.theme-glyph { display: block; }
.theme-sun { display: none; }
[data-theme="light"] .theme-moon { display: none; }
[data-theme="light"] .theme-sun { display: block; }

/* the supplied artwork is silver on black, so it needs inverting for the day theme */
[data-theme="light"] .brand img,
[data-theme="light"] .boot-mark img,
[data-theme="light"] .auth-logo { filter: invert(1) brightness(0.28) contrast(1.15); }

.topbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s6);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-title { display: grid; gap: 2px; min-width: 0; }
.topbar-title p { font-size: 12px; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }

.search { position: relative; display: flex; align-items: center; }
.search input {
  width: 240px; padding: 8px 34px 8px 12px;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-xs); color: var(--ink);
}
.search input::placeholder { color: var(--ink-faint); }
.search kbd {
  position: absolute; right: 8px; font-size: 10px; color: var(--ink-faint);
  border: 1px solid var(--hairline); border-radius: 3px; padding: 1px 5px;
  font-family: var(--font-text);
}

.month-pick input {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-xs); padding: 7px 10px; color: var(--ink);
}

.clock {
  font-family: var(--font-display); font-size: 12px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; letter-spacing: 0.06em;
}

#main { padding: var(--s5) var(--s6) var(--s7); min-width: 0; }

/* the shop is a full-bleed scene, so it pulls the page padding back out */
body.route-shop #main { padding: 0; }
body.route-shop .search { display: none; }
body.route-shop .topbar-title { display: none; }
body.route-shop .month-pick { display: none; }

/* -------------------------------------------------------------- the shop */

/* Scene surfaces. The drawing uses these, so the whole workshop can be a lit
   day workshop or a night workshop without redrawing a single shape. */
:root,
[data-theme="dark"] {
  --scene-floor: #1a2129;
  --scene-floor-grid: #212a33;
  --scene-wall: #141a20;
  --scene-wall-2: #0e1419;
  --scene-edge: #38434e;
  --scene-object: #2b3640;
  --scene-object-mid: #202932;
  --scene-object-dark: #171f27;
  --scene-shadow: rgba(0, 0, 0, 0.34);
  --scene-pad: #1d2730;
  --scene-lift: #39454f;
  --scene-shelf: #232d36;
  --scene-bin: #2e3a45;
  --scene-bin-empty: #1b232b;
  --scene-desk: #2a333d;
  --scene-desk-top: #333e49;
  --scene-screen: #16283f;
  --scene-board: #232d36;
  --scene-bay-num: #6b7885;
  --shop-bg: #0b0f13;
  --hud-bg: rgba(14, 18, 22, 0.88);
  --label-bg: rgba(15, 19, 24, 0.94);
  --label-bg-hover: rgba(20, 26, 33, 0.97);
}

[data-theme="light"] {
  --scene-floor: #e8e2d6;
  --scene-floor-grid: #dcd5c6;
  --scene-wall: #efeae0;
  --scene-wall-2: #e3ddd1;
  --scene-edge: #a89f8f;
  --scene-object: #cfc7b8;
  --scene-object-mid: #bdb4a4;
  --scene-object-dark: #a89e8d;
  --scene-shadow: rgba(60, 48, 30, 0.16);
  --scene-pad: #d6cec0;
  --scene-lift: #9aa7b1;
  --scene-shelf: #c6bdad;
  --scene-bin: #d9d1c2;
  --scene-bin-empty: #b3a998;
  --scene-desk: #c4bbab;
  --scene-desk-top: #d8d0c1;
  --scene-screen: #9fc0e8;
  --scene-board: #d2c9ba;
  --scene-bay-num: #6f6555;
  --shop-bg: #f3efe6;
  --hud-bg: rgba(255, 253, 248, 0.9);
  --label-bg: rgba(255, 253, 248, 0.95);
  --label-bg-hover: #ffffff;
}

.shop {
  position: relative;
  min-height: calc(100vh - 56px);
  overflow: hidden;
  background: var(--shop-bg);
}
.shop-canvas { position: relative; display: block; }
.shop-canvas svg { width: 100%; height: auto; display: block; min-height: 520px; }

/* Compact labels: they sit beside the object and show only the name until you
   reach for them, so the drawing is never hidden behind its own buttons. */
.hotspot-btn {
  position: absolute;
  transform: translate(-50%, 0);
  display: grid; gap: 0; justify-items: center;
  max-width: 132px;
  padding: 5px 9px;
  background: var(--label-bg);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, padding 0.16s ease;
}
.hotspot-btn:hover, .hotspot-btn:focus-visible {
  transform: translate(-50%, 0) translateY(-3px);
  border-color: var(--accent);
  background: var(--label-bg-hover);
  box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.18);
  outline: none;
  padding: 6px 11px;
}
.hotspot-name {
  font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  color: var(--ink); white-space: nowrap;
}
.hotspot-stat {
  font-size: 9px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height 0.16s ease, opacity 0.16s ease;
}
.hotspot-btn:hover .hotspot-stat, .hotspot-btn:focus-visible .hotspot-stat { max-height: 14px; opacity: 1; }
.hotspot-go { display: none; }
.hotspot-btn[data-tone="warn"] .hotspot-stat { color: var(--warn); }
.hotspot-btn[data-tone="risk"] .hotspot-stat { color: var(--risk); }

/* On a narrow screen the scene is a picture and this list is the way in: the
   same eight departments, the same live numbers, reachable with a thumb. */
.shop-list { display: none; gap: 8px; padding: 0 12px 14px; grid-template-columns: 1fr 1fr; }
.shop-list-btn {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 12px 14px; min-height: 46px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.shop-list-btn:active { background: var(--panel-2); }
.shop-list-name { font-family: var(--font-display); font-size: 13px; font-weight: 600; }
.shop-list-stat { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.shop-list-btn[data-tone="warn"] .shop-list-stat { color: var(--warn); }
.shop-list-btn[data-tone="risk"] .shop-list-stat { color: var(--risk); }

/* game HUD in the corner */
.shop-hud {
  position: absolute; top: 18px; left: 18px; z-index: 2;
  display: grid; gap: 10px;
  padding: 14px 16px;
  background: var(--hud-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  max-width: 320px;
}
.shop-hud-nums { display: flex; gap: 18px; }
.shop-hud-num { display: grid; gap: 1px; }
.shop-hud-num b {
  font-family: var(--font-display); font-weight: 600; font-size: 18px;
  color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.shop-hud-num i { font-style: normal; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.shop-hud-num[data-tone="ok"] b { color: var(--ok); }
.shop-hud-num[data-tone="risk"] b { color: var(--risk); }

/* entrance sweep and idle life */
.shop-canvas svg { opacity: 0; transform: scale(0.985); transition: opacity 0.5s ease, transform 0.5s ease; }
.shop.is-entered .shop-canvas svg { opacity: 1; transform: none; }
.shop-hud { opacity: 0; transform: translateY(-6px); transition: opacity 0.4s ease 0.15s, transform 0.4s ease 0.15s; }
.shop.is-entered .shop-hud { opacity: 1; transform: none; }

.shop-fan {
  transform-origin: center;
  animation: shop-spin 5s linear infinite;
}
@keyframes shop-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .hotspot-btn { max-width: 108px; padding: 4px 7px; }
  .hotspot-name { font-size: 10px; }
  .shop-hud { position: static; margin: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .shop-fan { animation: none; }
  .shop-canvas svg, .shop-hud, .hotspot-btn { transition: none !important; }
}

/* ------------------------------------------------------------ primitives */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-xs);
  border: 1px solid var(--hairline);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--raised); border-color: var(--hairline-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-hover); }

.btn-danger { color: var(--risk); border-color: var(--danger-line); background: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover-line); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.icon-btn {
  background: none; border: 1px solid transparent; border-radius: var(--r-xs);
  color: var(--ink-muted); padding: 6px 8px; cursor: pointer; font-size: 12px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--hairline); background: var(--panel); }

.field { display: grid; gap: 6px; }
.field > label {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); font-family: var(--font-display);
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xs);
  padding: 9px 11px;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-dim); }
.field .hint { font-size: 11px; color: var(--ink-faint); }

/* a select that sits next to its "+ Add" button */
.field-row { display: flex; gap: var(--s2); align-items: center; }
.field-row select { flex: 1; }

/* part thumbnails: a photo when the owner supplies one, a drawn glyph otherwise */
.thumb-cell { width: 52px; }
.thumb {
  width: 38px; height: 38px; border-radius: var(--r-xs); overflow: hidden;
  display: grid; place-items: center;
  background: var(--surface-sunken); border: 1px solid var(--hairline);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 26px; height: 26px; }

.part-photo {
  width: 100%; max-width: 240px; aspect-ratio: 4 / 3;
  border-radius: var(--r-sm); overflow: hidden;
  background: var(--surface-sunken); border: 1px solid var(--hairline);
  display: grid; place-items: center; gap: 6px;
  padding: var(--s3);
}
.part-photo img { width: 100%; height: 100%; object-fit: cover; }
.part-photo-glyph svg { width: 72px; height: 72px; }

.chip-x {
  background: none; border: 0; cursor: pointer; padding: 0 0 0 4px;
  color: inherit; opacity: 0.55; font-size: 13px; line-height: 1;
}
.chip-x:hover { opacity: 1; color: var(--risk); }

/* one service per row: name on the left, editable price on the right */
.svc-row { display: grid; grid-template-columns: 1fr 110px 24px; gap: var(--s2); align-items: center; }
.svc-name { font-size: 13px; }
.svc-price {
  width: 100%; text-align: right;
  background: var(--input-bg); border: 1px solid var(--hairline);
  border-radius: var(--r-xs); padding: 7px 9px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 620px) {
  .svc-row { grid-template-columns: 1fr 90px 22px; }
  .svc-name { font-size: 12px; }
}

.form-error {
  color: var(--risk); font-size: 12px;
  background: var(--danger-bg); border: 1px solid var(--danger-line); border-radius: var(--r-xs);
  padding: 8px 10px;
}
.form-error[hidden] { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}
.panel-head {
  display: flex; align-items: baseline; gap: var(--s3);
  padding: var(--s4) var(--s4) 0;
}
.panel-head h2 { font-size: 14px; }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: var(--s4); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; line-height: 1.6;
  border: 1px solid var(--hairline); color: var(--ink-muted);
  background: var(--surface-sunken);
  white-space: nowrap;
}
.chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  opacity: 0.9;
}
.chip[data-state="ok"] { color: var(--ok); border-color: var(--chip-ok-line); background: var(--chip-ok-bg); }
.chip[data-state="warn"] { color: var(--warn); border-color: var(--chip-warn-line); background: var(--chip-warn-bg); }
.chip[data-state="risk"] { color: var(--risk); border-color: var(--chip-risk-line); background: var(--chip-risk-bg); }
.chip[data-state="info"] { color: var(--accent); border-color: var(--chip-info-line); background: var(--chip-info-bg); }
.chip[data-state="mute"] { color: var(--ink-faint); }

.stat-row { display: flex; gap: var(--s2); flex-wrap: wrap; }


/* ------------------------------------------------------- figure tiles */
/* Used by Finance and Payroll: a row of headline numbers above a statement. */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s5);
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: var(--s4);
  display: grid; gap: 6px;
  position: relative; overflow: hidden;
}
.kpi-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); font-family: var(--font-display); }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 11px; color: var(--ink-muted); }
.kpi[data-tone="ok"] .kpi-value { color: var(--ok); }
.kpi[data-tone="risk"] .kpi-value { color: var(--risk); }
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
  border-left: 1px solid var(--hairline-soft); transform: rotate(12deg); opacity: 0.55;
}

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-family: var(--font-display); font-weight: 500;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint);
  padding: 10px var(--s3);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
table.data th.num, table.data td.num { text-align: right; }
table.data td {
  padding: 11px var(--s3);
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
}
table.data tbody tr { cursor: pointer; transition: background 0.1s ease; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.nowrap { white-space: nowrap; }
.cell-main { display: grid; gap: 1px; }
.cell-main strong { font-weight: 500; }
.cell-main span { font-size: 11px; color: var(--ink-faint); }

.empty {
  display: grid; gap: var(--s2); justify-items: start;
  padding: var(--s6);
  border: 1px dashed var(--hairline);
  border-radius: var(--r-sm);
  background: var(--input-bg);
}
.empty h3 { font-size: 14px; }
.empty p { color: var(--ink-muted); font-size: 13px; max-width: 46ch; }

/* ------------------------------------------------------------------ misc */

.toolbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: var(--r-xs); overflow: hidden; }
.seg button {
  background: transparent; border: 0; padding: 6px 12px; font-size: 12px;
  color: var(--ink-muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--ink); }
.seg button + button { border-left: 1px solid var(--hairline); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.stack { display: grid; gap: var(--s4); }
.stack-sm { display: grid; gap: var(--s2); }

.section-title { display: flex; align-items: baseline; gap: var(--s3); margin: var(--s6) 0 var(--s3); }
.section-title h2 { font-size: 15px; }
.section-title .rule { flex: 1; height: 1px; background: var(--hairline); }

/* finance statement */
.statement { display: grid; }
.statement-row {
  display: grid; grid-template-columns: 1fr auto; gap: var(--s4);
  padding: 11px var(--s4);
  border-bottom: 1px solid var(--hairline-soft);
  align-items: baseline;
}
.statement-row:last-child { border-bottom: 0; }
.statement-row .lbl { color: var(--ink-muted); font-size: 13px; }
.statement-row .val { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 15px; }
.statement-row.total { background: var(--surface-sunken); border-top: 1px solid var(--hairline); }
.statement-row.total .lbl { color: var(--ink); font-weight: 600; }
.statement-row.total .val { font-size: 20px; color: var(--chrome); }
.statement-row.minor .lbl { padding-left: var(--s4); font-size: 12px; }
.neg { color: var(--risk); }
.pos { color: var(--ok); }

/* chart */
.chart { display: grid; grid-auto-flow: column; gap: 6px; align-items: end; height: 160px; padding: var(--s4) var(--s4) 0; }
.chart-col { display: grid; gap: 3px; justify-items: center; align-content: end; height: 100%; }
.chart-bars { display: flex; align-items: end; gap: 3px; height: 100%; }
.chart-bar { width: 9px; border-radius: 1px 1px 0 0; min-height: 2px; }
.chart-bar.rev { background: var(--accent-dim); }
.chart-bar.net { background: var(--chrome); opacity: 0.85; }
.chart-bar.net.neg { background: var(--risk); opacity: 0.7; }
.chart-x { font-size: 9px; color: var(--ink-faint); letter-spacing: 0.04em; }
.chart-key { display: flex; gap: var(--s3); padding: 0 var(--s4) var(--s4); font-size: 11px; color: var(--ink-muted); }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { width: 8px; height: 8px; display: inline-block; border-radius: 1px; }

/* bar list */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s3); font-size: 12px; }
.bar-track { grid-column: 1 / -1; height: 4px; background: var(--surface-sunken); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent-dim); }

/* drawer */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 40;
}
.scrim[hidden] { display: none; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--hairline);
  z-index: 50; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lift);
  animation: slide-in 0.18s ease-out;
}
.drawer[hidden] { display: none; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s5) var(--s5) var(--s3);
  border-bottom: 1px solid var(--hairline);
}
.drawer-head h2 { font-size: 18px; margin-top: 2px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { padding: var(--s5); overflow-y: auto; display: grid; gap: var(--s5); align-content: start; }

/* modal */
.modal {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 94vw); max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
}
.modal[hidden] { display: none; }
.modal-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s5) var(--s5) var(--s3); border-bottom: 1px solid var(--hairline); }
.modal-head h2 { font-size: 16px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: var(--s5); display: grid; gap: var(--s4); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--hairline); }

/* toasts */
.toasts { position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; }
.toast {
  background: var(--toast-bg); border: 1px solid var(--hairline); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: var(--r-xs); font-size: 13px; box-shadow: var(--shadow-lift);
  animation: toast-in 0.16s ease-out;
}
.toast[data-kind="error"] { border-left-color: var(--risk); }
.toast[data-kind="ok"] { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ responsive */

.nav-toggle { display: none; }
.burger { display: block; width: 16px; height: 1px; background: currentColor; position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; width: 16px; height: 1px; background: currentColor; }
.burger::before { top: -5px; }
.burger::after { top: 5px; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* phones and small tablets: the scene keeps the picture, the list does the work */
@media (max-width: 900px) {
  #main { padding: var(--s4) var(--s4) var(--s6); }
  .topbar { padding: var(--s3) var(--s4); gap: var(--s3); flex-wrap: wrap; }
  .topbar-tools { width: 100%; margin-left: 0; flex-wrap: wrap; gap: var(--s2); }
  .search { flex: 1 1 160px; }
  .search input { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-panel { grid-template-columns: 1fr; }
  .auth-logo { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--hairline); }
  .statement-row { padding: 10px var(--s3); }
  .chart { padding: var(--s3) var(--s3) 0; }
  .panel-head { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  /* the scene label pills would pile up on a narrow drawing, so the list below
     carries the same eight departments, with the same live numbers */
  .hotspot-btn { display: none; }
  .shop-list { display: grid; }
  .shop { min-height: 0; }
  .shop-canvas svg { min-height: 0; }
  .shop-hud { position: static; margin: var(--s3); max-width: none; }
  .shop-hud-nums { justify-content: space-between; }
  .clock { display: none; }
  .owner-name { display: none; }
  .back-shop { padding: 6px 8px; }
  .topbar-title h1 { font-size: 16px; }
  .topbar-title p { display: none; }
  .month-pick { flex: 1 1 130px; }
  .month-pick input { width: 100%; }
  .drawer { width: 100%; }
  .modal { width: 94vw; }
  .toasts { left: 12px; right: 12px; transform: none; }
}

@media (max-width: 620px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi-value { font-size: 22px; }
  .shop-list { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 calc(-1 * var(--s4)); }
  table.data th, table.data td { padding: 9px var(--s3); }
  .statement-row { padding: 9px var(--s2); }
}

/* touch: bigger targets, no hover-only affordances */
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .icon-btn { min-height: 42px; min-width: 42px; }
  .chip { padding: 5px 10px; }
  table.data tbody tr { min-height: 48px; }
}

/* notched phones: keep content clear of the home bar and the camera cut-out */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(var(--s4), env(safe-area-inset-left));
    padding-right: max(var(--s4), env(safe-area-inset-right));
    padding-top: max(var(--s3), env(safe-area-inset-top));
  }
  #main { padding-bottom: max(var(--s6), env(safe-area-inset-bottom)); }
  .drawer { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 760px) {
  .brand img { width: 104px; height: auto; }
  .brand-sub { display: none; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}



@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- print */

.print-only { display: none; }

@page { size: A4; margin: 14mm; }

@media print {
  body { background: #fff; color: #111; }
  .rail, .topbar, .toasts, .scrim, .drawer, .modal, .toolbar, .skip-link, #boot, #auth { display: none !important; }
  .shell, #main, table.data, .kpis { display: none !important; }
  .print-only { display: block; }
  .no-print { display: none !important; }

  .sheet {
    width: 100%; color: #111;
    font-family: var(--font-text);
  }
  .sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; border-bottom: 2px solid #111; padding-bottom: 16px; }
  .sheet-logo { width: 210px; filter: invert(1) brightness(0.2); }
  .sheet h1 { font-size: 22px; }
  .sheet table { width: 100%; border-collapse: collapse; font-size: 12px; }
  .sheet th, .sheet td { padding: 8px 6px; border-bottom: 1px solid #ccc; text-align: left; }
  .sheet th.num, .sheet td.num { text-align: right; }
  .sheet-totals { margin-left: auto; width: 280px; margin-top: 16px; }
  .sheet-totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
  .sheet-totals .grand { border-top: 2px solid #111; font-weight: 700; font-size: 15px; }
  .sheet-meta { display: grid; gap: 4px; font-size: 12px; color: #333; }
  .sheet-foot { margin-top: 28px; font-size: 11px; color: #444; border-top: 1px solid #ddd; padding-top: 10px; }
}







