/* ============================================================
   ScheduleGenius — design system
   Deep navy / steel + confident gold. Mobile-first, big tap
   targets, works in light & dark (body[data-theme]).
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img, svg { display: block; }

:root {
  /* dark (default) — "authoritative": the logo's deep purple-black ground,
     orange as the voice (--accent), violet as structure (--brand) */
  --bg: #0d0a1c;
  --bg-header: #17102e;
  --surface: #191333;
  --surface-2: #241c44;
  --ink: #f1eefa;
  --ink-dim: #ada3c8;
  --ink-faint: #6f6690;
  --line: rgba(176, 160, 214, 0.15);
  --line-strong: rgba(176, 160, 214, 0.28);

  --accent: #f79121;
  --accent-soft: rgba(247, 145, 33, 0.16);
  --accent-ink: #221302;
  --accent-text: #fbbf24;

  /* --brand = the structural half of the two-color identity (TCPS violet).
     Orange (--accent) is action/voice; violet (--brand) is chrome/structure.
     Both live in both themes; only the emphasis flips. */
  --brand: #7c5cc4;
  --brand-soft: rgba(124, 92, 196, 0.20);
  --brand-ink: #ffffff;
  --brand-text: #bda6ec;

  /* status colors sit on a colorblind-safe teal/amber/vermillion axis
     (blue-orange separation survives deuteranopia & protanopia; every
     hue-coded signal also carries a shape or label) */
  --ok: #2cc5a4;
  --ok-soft: rgba(44, 197, 164, 0.16);
  --ok-ink: #04241d; /* readable count text on a solid --ok map badge */
  --warn: #f5b944;
  --warn-soft: rgba(245, 185, 68, 0.15);
  --danger: #f0713a;
  --danger-soft: rgba(240, 113, 58, 0.15);
  --lock: #8494ac;

  --contract: #5ea3f0;
  --contract-soft: rgba(94, 163, 240, 0.16);
  --event: #c08bfc;
  --event-soft: rgba(192, 139, 252, 0.16);

  /* map — purple-black land to sit under the chrome, water/roads keep a cool cast */
  --map-land: #120d24;
  --map-land2: #1a1436;
  --map-water: #263a63;
  --map-park: #1a2b28;
  --map-road: #2e2b4f;
  --map-road-hi: #453f6b;
  --map-label: #8b83a8;
  --map-town: #b9b0d4;

  --sms-in: #1c2a44;
  --sms-out: #f5a623;
  --sms-out-ink: #221302;

  --shadow: 0 10px 30px rgba(2, 6, 16, 0.55);
  --shadow-soft: 0 4px 14px rgba(2, 6, 16, 0.35);
  --radius: 16px;
}

body[data-theme="light"] {
  --bg: #eef1f6;
  --bg-header: #0e1b33;
  --surface: #ffffff;
  --surface-2: #f3f6fa;
  --ink: #0e1b2e;
  --ink-dim: #51617a;
  --ink-faint: #8a99b0;
  --line: rgba(14, 27, 46, 0.12);
  --line-strong: rgba(14, 27, 46, 0.26);

  --accent: #ed7d0e;
  --accent-soft: rgba(237, 125, 14, 0.15);
  --accent-ink: #221302;
  --accent-text: #b45309;

  /* structural violet — deeper for legibility on the white base */
  --brand: #5b3e8e;
  --brand-soft: rgba(91, 62, 142, 0.12);
  --brand-ink: #ffffff;
  --brand-text: #5b3e8e;

  --ok: #0b8573;
  --ok-soft: rgba(11, 133, 115, 0.13);
  --ok-ink: #eafaf5; /* readable count text on a solid --ok map badge */
  --warn: #b97b0a;
  --warn-soft: rgba(185, 123, 10, 0.14);
  --danger: #c74a14;
  --danger-soft: rgba(199, 74, 20, 0.11);
  --lock: #6b7a92;

  --contract: #2467b3;
  --contract-soft: rgba(36, 103, 179, 0.12);
  --event: #7a3ff2;
  --event-soft: rgba(122, 63, 242, 0.11);

  --map-land: #e8edf4;
  --map-land2: #dfe6ef;
  --map-water: #a9cce6;
  --map-park: #c9e2c6;
  --map-road: #ffffff;
  --map-road-hi: #f3c87e;
  --map-label: #7c8aa0;
  --map-town: #45566e;

  --sms-in: #e6eaf1;
  --sms-out: #f59e0b;
  --sms-out-ink: #221302;

  --shadow: 0 10px 30px rgba(20, 32, 55, 0.18);
  --shadow-soft: 0 4px 14px rgba(20, 32, 55, 0.12);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #070d1a;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation; /* kill iOS double-tap zoom jank; pinch still works */
}

/* ---------- stage & device frames (desktop demo theater) ---------- */
#stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(94, 163, 240, 0.10), transparent 60%),
    radial-gradient(1000px 700px at 90% 110%, rgba(245, 166, 35, 0.07), transparent 60%),
    #070d1a;
}
.device {
  width: min(430px, 100vw);
  height: min(890px, 100dvh);
  background: var(--bg);
  border-radius: 34px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(151, 173, 205, 0.14);
}
.sms-device { width: min(390px, 100vw); height: min(780px, 100dvh); }
.hidden { display: none !important; }

@media (max-width: 900px) {
  #stage { padding: 0; gap: 0; }
  .device { width: 100vw; height: 100dvh; border-radius: 0; box-shadow: none; }
  .sms-device {
    position: fixed; inset: 0; z-index: 60;
    width: 100vw; height: 100dvh; border-radius: 0;
  }
}

#app, #smsapp { height: 100%; display: flex; flex-direction: column; }

/* ---------- desktop layout (both roles, ≥901px) ----------
   Same controls as mobile — identical DOM from the one render pass — laid out
   as a wide console: tab bar becomes a left sidebar, content becomes a
   centered reading column. Phones always get the phone layout (this media
   query never matches); on big screens s.frame === "phone" (menu: "Present in
   a phone frame", or ?frame=phone) removes .desk to demo the mobile app. */
@media (min-width: 901px) {
  .device.desk { width: min(1180px, calc(100vw - 48px)); transition: width 0.2s ease; }
  .device.desk #app:has(> .tabbar) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: 188px minmax(0, 1fr);
    grid-template-areas: "top top" "nav main";
  }
  .device.desk #app:has(> .tabbar) > .topbar { grid-area: top; }
  .device.desk #app:has(> .tabbar) > .content { grid-area: main; }
  .device.desk #app:has(> .tabbar) > .tabbar {
    grid-area: nav;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    border-top: 0; border-right: 1px solid rgba(151, 173, 205, 0.12);
    padding: 14px 10px;
  }
  .device.desk .tabbar button {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 11px;
    padding: 11px 13px; font-size: 13.5px; letter-spacing: 0;
  }
  .device.desk .tabbar button.on { background: var(--brand-soft); }
  .device.desk .tabbar button .ic { width: 19px; height: 19px; }
  .device.desk .tabbar button.cta-tab .tabicon { width: 30px; height: 30px; flex-shrink: 0; }
  /* readable column: every screen block caps + centers in the wide main area */
  .device.desk .content > * { max-width: 880px; margin-left: auto; margin-right: auto; }
  .device.desk .topbar .role-switch.grow { flex: 0 1 300px; margin-left: auto; }
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--bg-header);
  color: #f2f6fd;
  padding: 14px 14px 10px;
  display: flex; flex-direction: column; gap: 10px;
  flex-shrink: 0;
}
.topbar-row { display: flex; align-items: center; gap: 8px; }
.wordmark {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 17px; letter-spacing: -0.01em;
}
.wordmark .ic { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
.wordmark b { color: var(--brand-text); font-weight: 800; }
.wordmark .brandlogo { height: 26px; width: auto; max-width: 150px; object-fit: contain; }
.top-actions { margin-left: auto; display: flex; gap: 6px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #cdd9ea; background: rgba(255, 255, 255, 0.06);
  transition: background 0.15s;
  position: relative;
}
.iconbtn:hover { background: rgba(255, 255, 255, 0.12); }
.iconbtn .ic { width: 20px; height: 20px; }
.iconbtn .dot {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}

/* role switcher */
.role-switch {
  display: flex; background: rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 3px; gap: 3px;
}
.role-switch button {
  flex: 1; padding: 9px 10px; border-radius: 9px;
  font-size: 13.5px; font-weight: 650; color: #b9c7db;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: all 0.15s;
}
.role-switch button .ic { width: 16px; height: 16px; }
/* navigation/chrome (role + bottom tabs) leans on the brand color; actions
   (buttons, filters, links, the Post FAB) stay the action color */
.role-switch button.on { background: var(--brand); color: var(--brand-ink); }
.persona-pick {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 11px; padding: 6px 10px 6px 6px;
  color: #dbe5f2; font-size: 13px; font-weight: 600;
  max-width: 100%;
}
.persona-pick:hover { background: rgba(255,255,255,0.12); }
.persona-pick .chev { width: 14px; height: 14px; color: #8fa1ba; flex-shrink: 0; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3d5a86, #24344d);
  color: #eaf1fb; font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: 0.02em;
  overflow: hidden; /* photo avatars clip to the same shape */
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.gold { background: linear-gradient(135deg, #f5a623, #d97706); color: #221302; }
.avatar.gold img { border: 1.5px solid var(--accent); border-radius: inherit; box-sizing: border-box; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 16px; }

/* screen header (inner pages) */
.screen-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px 4px;
}
.screen-head h1 { font-size: 22px; letter-spacing: -0.02em; color: var(--brand-text); }
.screen-head .sub { color: var(--ink-dim); font-size: 13px; margin-top: 2px; }
.backbtn {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-dim);
}
.backbtn .ic { width: 19px; height: 19px; }

/* ---------- content scroller ---------- */
.content { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 18px; }
.content.nopad { padding-bottom: 0; }
.pad { padding: 0 16px; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  display: flex; flex-shrink: 0;
  background: var(--bg-header);
  border-top: 1px solid rgba(151, 173, 205, 0.12);
  padding: 6px 8px calc(10px + env(safe-area-inset-bottom, 0px));
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px 4px; border-radius: 12px;
  color: #7f91ab; font-size: 10.5px; font-weight: 650; letter-spacing: 0.02em;
}
.tabbar button .ic { width: 22px; height: 22px; }
.tabbar button.on { color: var(--brand-text); }
.tabbar button.cta-tab .tabicon {
  width: 44px; height: 30px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
}
.tabbar button.cta-tab .tabicon .ic { width: 20px; height: 20px; }
.tabbar button.cta-tab.on .tabicon { box-shadow: 0 0 0 2px var(--accent-soft); }
.tabbar button.cta-tab { color: #7f91ab; }

/* ---------- chips / filters / segments ---------- */
.chiprow {
  display: flex; gap: 7px; overflow-x: auto; padding: 10px 16px 8px;
  scrollbar-width: none; flex-shrink: 0;
}
.chiprow::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-dim); font-size: 13px; font-weight: 600;
  transition: all 0.12s;
}
.chip .ic { width: 14px; height: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.mini { padding: 5px 10px; font-size: 12px; }

.seg {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 3px; gap: 2px;
}
.seg button {
  flex: 1; padding: 8px 6px; border-radius: 9px;
  color: var(--ink-dim); font-size: 12.5px; font-weight: 650;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button .ic { width: 15px; height: 15px; }
.seg button.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
body[data-theme="light"] .seg button.on { background: #0e1b33; color: #fff; box-shadow: none; }

/* ---------- cards & rows ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow-soft);
}
.card + .card { margin-top: 10px; }
.card.tappable:active { transform: scale(0.985); }
.card.flat { box-shadow: none; }

.job-card { display: flex; flex-direction: column; gap: 9px; }
.job-card-top { display: flex; gap: 10px; align-items: flex-start; }
.job-card h3 { font-size: 15.5px; letter-spacing: -0.01em; line-height: 1.25; }
.job-when { font-size: 12.5px; color: var(--accent-text); font-weight: 700; margin-bottom: 2px; }
.job-meta { font-size: 12.5px; color: var(--ink-dim); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.job-meta span { display: inline-flex; align-items: center; gap: 4px; }
.job-meta .ic { width: 13px; height: 13px; }
.pay { margin-left: auto; text-align: right; flex-shrink: 0; }
.pay b { font-size: 16px; letter-spacing: -0.01em; }
.pay small { display: block; color: var(--ink-faint); font-size: 10.5px; font-weight: 600; }
.pay.premium b { color: var(--accent-text); }
.pay.premium small { color: var(--accent-text); opacity: 0.85; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px;
}
.badge .ic { width: 11px; height: 11px; }
.badge.contract { background: var(--contract-soft); color: var(--contract); }
.badge.event { background: var(--event-soft); color: var(--event); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-2); color: var(--ink-dim); }

/* staffing meter */
.meter { display: flex; align-items: center; gap: 8px; }
.meter .pips { display: flex; gap: 3px; flex: 1; max-width: 220px; }
.meter .pip { height: 7px; flex: 1; border-radius: 3px; min-width: 8px; max-width: 26px;
  background: transparent; border: 1.5px solid var(--line-strong); } /* hollow = open — shape, not just hue */
.meter .pip.fill { background: var(--ok); border-color: var(--ok); }
.meter.warn .pip.fill { background: var(--warn); border-color: var(--warn); }
.meter.bad .pip.fill { background: var(--danger); border-color: var(--danger); }
.meter .pip.sup { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.meter .mtext { font-size: 11.5px; font-weight: 700; color: var(--ink-dim); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px; }
.meter .mtext .ic { width: 12px; height: 12px; }
.meter .mtext.ok { color: var(--ok); }
.meter .mtext.warn { color: var(--warn); }
.meter .mtext.bad { color: var(--danger); }

/* cert chips */
.certrow { display: flex; flex-wrap: wrap; gap: 6px; }
.cert {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-dim);
}
.cert .ic { width: 12px; height: 12px; }
.cert.have { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.cert.expired { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.cert.dead { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.cert.missing { background: var(--surface-2); color: var(--lock); }
.cert.none { color: var(--ink-faint); font-weight: 500; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 16px; border-radius: 14px;
  font-size: 15.5px; font-weight: 750; letter-spacing: -0.01em;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(245, 166, 35, 0.25); }
.btn.primary:disabled { background: var(--surface-2); color: var(--ink-faint); box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); }
.btn.subtle { background: var(--surface-2); color: var(--ink); }
.btn.danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn.ok-ghost { background: var(--ok-soft); color: var(--ok); }
.btn.sm { padding: 10px 13px; font-size: 13.5px; border-radius: 11px; width: auto; }
.btn.xs { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; width: auto; gap: 5px; }
.btn.xs .ic { width: 14px; height: 14px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.hint { font-size: 12px; color: var(--ink-faint); text-align: center; margin-top: 8px; line-height: 1.45; }
.hint.left { text-align: left; }
.hint.warn { color: var(--warn); }
.hint.danger { color: var(--danger); }

/* ---------- section titles ---------- */
.sect { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 9px; }
.sect h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand-text); font-weight: 800; }
.sect .count { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.sect .right { margin-left: auto; font-size: 12.5px; color: var(--accent-text); font-weight: 700; }

.day-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 16px 0 8px; font-size: 13px; font-weight: 800;
}
.day-head .dn { color: var(--ink); }
.day-head .dd { color: var(--ink-faint); font-weight: 600; }
.day-head.today .dn { color: var(--accent-text); }

/* ---------- map screen ---------- */
.mapwrap { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--map-land); }
.mapwrap svg.metro { width: 100%; height: 100%; display: block; }
.map-attrib {
  position: absolute; left: 10px; bottom: 10px;
  font-size: 9.5px; color: var(--map-label); opacity: 0.85;
  background: color-mix(in srgb, var(--map-land) 72%, transparent);
  padding: 3px 7px; border-radius: 6px; pointer-events: none;
}
.legend {
  position: absolute; bottom: 38px; left: 10px; right: auto;
  display: flex; flex-direction: column; gap: 5px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px;
  font-size: 11px; font-weight: 600; color: var(--ink-dim);
  box-shadow: var(--shadow-soft);
}
.legend .lrow { display: flex; align-items: center; gap: 7px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend .swatch.open { background: var(--ok); }
.legend .swatch.partial { background: transparent; border: 2px solid var(--warn); }
.legend .swatch.locked { background: linear-gradient(135deg, transparent 42%, var(--lock) 42%, var(--lock) 58%, transparent 58%); border: 2px solid var(--lock); }

/* pan/zoom */
svg.metro.pannable { touch-action: none; cursor: grab; }
svg.metro.pannable.panning { cursor: grabbing; }
.map-ctrl {
  position: absolute; right: 10px; bottom: 38px; z-index: 5;
  display: flex; flex-direction: column; gap: 7px;
}
.map-ctrl button {
  width: 42px; height: 42px; border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line-strong); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft);
}
.map-ctrl button .ic { width: 19px; height: 19px; }
.map-ctrl button:active { transform: scale(0.94); }

.map-empty {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; text-align: center; width: 78%; max-width: 300px;
  box-shadow: var(--shadow);
}
.map-empty h3 { font-size: 15px; margin-bottom: 4px; }
.map-empty p { font-size: 12.5px; color: var(--ink-dim); line-height: 1.45; }

/* pin styling lives mostly in SVG attrs; interactive states here */
g.pin { cursor: pointer; transform-box: fill-box; transform-origin: 50% 100%; }
g.pin:focus { outline: none; }
g.pin:focus-visible .pin-body { stroke: var(--accent); stroke-width: 5; }
g.pin .pin-tap { fill: transparent; }
g.pin.selected .pin-body { stroke: #fff; stroke-width: 5; }
@keyframes pin-drop { 0% { transform: translateY(-18px) scale(0.55); opacity: 0; } 100% { transform: none; opacity: 1; } }
g.pin { animation: pin-drop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.pin-pulse { transform-box: fill-box; transform-origin: center; animation: pin-pulse 2s ease-out infinite; }
@keyframes pin-pulse { 0% { transform: scale(0.55); opacity: 0.6; } 75% { opacity: 0; } 100% { transform: scale(1.6); opacity: 0; } }

/* peek card over map */
.peek {
  position: absolute; left: 10px; right: 10px; bottom: 12px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 18px; padding: 13px 14px;
  box-shadow: var(--shadow);
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- job detail ---------- */
.hero-band { padding: 16px 16px 12px; }
.hero-band h1 { font-size: 23px; letter-spacing: -0.02em; line-height: 1.15; margin: 7px 0 3px; }
.hero-band .client { color: var(--ink-dim); font-size: 13.5px; font-weight: 600; }
.fact {
  display: flex; gap: 11px; padding: 12px 2px; align-items: flex-start;
  border-top: 1px solid var(--line);
}
.fact:first-child { border-top: 0; }
.fact .ic { width: 18px; height: 18px; color: var(--accent-text); flex-shrink: 0; margin-top: 1px; }
.fact b { font-size: 14.5px; font-weight: 700; display: block; }
.fact small { font-size: 12.5px; color: var(--ink-dim); display: block; margin-top: 1px; line-height: 1.4; }
.fact .link { color: var(--accent-text); font-weight: 700; font-size: 12.5px; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; margin-top: 3px; }
.fact .link .ic { width: 13px; height: 13px; margin: 0; color: var(--accent-text); }

.slot-list { display: flex; flex-direction: column; gap: 7px; }
.slot-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border-radius: 12px; padding: 9px 12px;
  border: 1px solid var(--line);
}
.slot-row .ic { width: 16px; height: 16px; color: var(--ink-faint); }
.slot-row.filled .ic { color: var(--ok); }
.slot-row .who { font-size: 13.5px; font-weight: 650; }
.slot-row .role-lab { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 800; width: 84px; flex-shrink: 0; }
.slot-row .open-lab { color: var(--accent-text); font-size: 13px; font-weight: 700; }
.slot-row .you { color: var(--accent-text); }

.claimbar {
  position: sticky; bottom: 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}

/* ---------- calendar ---------- */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-head b { font-size: 14.5px; }
.cal-head .spacer { flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 10px; font-weight: 800; color: var(--ink-faint); padding: 4px 0; text-transform: uppercase; }
.cal-cell {
  aspect-ratio: 1 / 0.92; border-radius: 10px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 5px; font-size: 12.5px; font-weight: 650; color: var(--ink-dim);
}
.cal-cell.out { opacity: 0.28; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-text); }
.cal-cell.sel { background: var(--accent); color: var(--accent-ink) !important; }
.cal-cell.sel .cdot { border: 1px solid rgba(0,0,0,0.35); }
.cal-dots { display: flex; gap: 2.5px; margin-top: 3px; flex-wrap: wrap; justify-content: center; padding: 0 2px; }
/* dot shapes carry the status even with hue removed:
   ok = solid dot · warn = hollow ring · bad = solid diamond ·
   mine = solid gold · lock = slashed ring */
.cdot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); flex-shrink: 0; }
.cdot.ok { background: var(--ok); }
.cdot.warn { background: transparent; border: 1.6px solid var(--warn); }
.cdot.bad { background: var(--danger); border-radius: 1px; transform: rotate(45deg) scale(0.92); }
.cdot.mine { background: var(--accent); }
.cdot.lock { background: linear-gradient(135deg, transparent 42%, var(--lock) 42%, var(--lock) 58%, transparent 58%); border: 1.6px solid var(--lock); }

/* ---------- forms ---------- */
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12px; font-weight: 750; color: var(--ink-dim); margin-bottom: 6px; letter-spacing: 0.02em; }
.input, textarea.input, select.input {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 13px 13px; color: var(--ink);
  font-size: 16px; /* >=16px: keeps iOS Safari from auto-zooming the page on focus */
  outline: none; appearance: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--ink-faint); }
/* branding preview chips — each brand color rendered against BOTH a light
   (#fff) and dark (#12102a) base so you see it works in either theme */
.brand-pv {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 26px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line-strong); line-height: 1; flex-shrink: 0;
}
.brand-pv b { font-size: 13px; font-weight: 800; }
.brand-pv-btn {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border-radius: 5px; font-size: 10.5px; font-weight: 800; line-height: 1;
}
textarea.input { resize: none; min-height: 74px; line-height: 1.4; }
.input-row { display: flex; gap: 8px; }
.input-row > * { flex: 1; min-width: 0; }
.type-cards { display: flex; gap: 8px; }
.type-card {
  flex: 1; border: 1.5px solid var(--line-strong); border-radius: 14px;
  background: var(--surface); padding: 13px 12px; text-align: left;
}
.type-card .ic { width: 20px; height: 20px; margin-bottom: 7px; color: var(--ink-faint); }
.type-card b { display: block; font-size: 14.5px; }
.type-card small { color: var(--ink-dim); font-size: 11.5px; line-height: 1.3; display: block; margin-top: 2px; }
.type-card.on { border-color: var(--accent); background: var(--accent-soft); }
.type-card.on .ic { color: var(--accent-text); }

.stepper {
  display: flex; align-items: center; gap: 0;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  overflow: hidden;
}
.stepper button { width: 46px; height: 46px; font-size: 20px; font-weight: 700; color: var(--accent-text); flex-shrink: 0; }
.stepper button:disabled { color: var(--ink-faint); opacity: 0.5; }
.stepper .num { flex: 1; text-align: center; font-size: 16px; font-weight: 800; }
.stepper-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stepper-row .lab { flex: 1; font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.stepper-row .lab .ic { width: 16px; height: 16px; color: var(--ink-faint); }
.stepper-row .stepper { width: 138px; flex: none; }

.switchrow {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
}
.switchrow .lab { flex: 1; }
.switchrow .lab b { font-size: 14.5px; display: block; }
.switchrow .lab small { font-size: 12px; color: var(--ink-dim); }
.switch {
  width: 48px; height: 29px; border-radius: 999px; flex-shrink: 0;
  background: var(--line-strong); position: relative; transition: background 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px;
  border-radius: 50%; background: #fff; transition: left 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.switch.on { background: var(--ok); }
.switch.on::after { left: 22px; }

/* ---------- sheets ---------- */
#sheet-root .scrim {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4, 8, 18, 0.62);
  animation: fade 0.18s both;
  display: flex; align-items: flex-end; justify-content: center;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(430px, 100vw); max-height: 88dvh;
  background: var(--bg); border-radius: 24px 24px 0 0;
  border: 1px solid var(--line); border-bottom: 0;
  overflow-y: auto; padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: sheet-up 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@media (min-width: 901px) { #sheet-root .scrim { align-items: center; } .sheet { border-radius: 24px; border-bottom: 1px solid var(--line); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4.5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 14px; }
.sheet h2.sheet-title { font-size: 19px; letter-spacing: -0.02em; margin-bottom: 4px; }
.sheet .sheet-sub { color: var(--ink-dim); font-size: 13.5px; line-height: 1.45; margin-bottom: 14px; }

.opt-row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 12px 12px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--surface); margin-bottom: 8px; text-align: left;
}
.opt-row .ic { width: 18px; height: 18px; color: var(--ink-dim); flex-shrink: 0; }
.opt-row b { font-size: 14.5px; display: block; }
.opt-row small { font-size: 12px; color: var(--ink-dim); display: block; margin-top: 1px; line-height: 1.35; }
.opt-row.on { border-color: var(--accent); background: var(--accent-soft); }
.opt-row.on .ic { color: var(--accent-text); }
.opt-row:disabled { opacity: 0.45; cursor: not-allowed; }
.opt-row .end { margin-left: auto; flex-shrink: 0; }

.size-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.size-cell {
  padding: 13px 0; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--surface); font-size: 14.5px; font-weight: 750; text-align: center;
}
.size-cell.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

/* ---------- universal search ---------- */
.search-scrim {
  position: absolute; inset: 0; z-index: 70;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: fade 0.15s both;
}
.search-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px; flex-shrink: 0;
  background: var(--bg-header);
}
.search-inputwrap {
  flex: 1; display: flex; align-items: center; gap: 9px;
  background: rgba(255, 255, 255, 0.09); border-radius: 12px; padding: 0 12px;
}
.search-inputwrap .ic { width: 18px; height: 18px; color: #93a6c0; flex-shrink: 0; }
.search-inputwrap input {
  flex: 1; background: none; border: 0; outline: none;
  padding: 12px 0; font-size: 16px; color: #f0f5fc; min-width: 0;
}
.search-inputwrap input::placeholder { color: #7f91ab; }
.search-head .btn { color: #cdd9ea; background: rgba(255,255,255,0.07); flex-shrink: 0; }
.search-results { flex: 1; overflow-y: auto; padding: 2px 16px 24px; }
.search-results .opt-row small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
.search-results .hl { color: var(--accent-text); font-weight: 800; display: inline; }

/* ---------- toasts ---------- */
#toast-root {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(400px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  background: #101b30; color: #eef3fb;
  border: 1px solid rgba(151, 173, 205, 0.28);
  border-radius: 14px; padding: 12px 14px; width: 100%;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
  pointer-events: auto; cursor: pointer;
}
@keyframes toast-in { from { transform: translateY(-16px) scale(0.96); opacity: 0; } }
.toast.leaving { transition: all 0.22s; opacity: 0; transform: translateY(-10px); }
.toast .ic { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.toast.ok .ic { color: #46d68d; }
.toast.warn .ic { color: #f5b944; }
.toast b { font-weight: 750; }
.toast .t-body { font-size: 13px; line-height: 1.4; }
.toast small { color: #9fb0c8; font-size: 11.5px; display: block; margin-top: 1px; }

/* ---------- SMS phone ---------- */
.sms-shell { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.sms-head {
  background: var(--bg-header); color: #f0f5fc; padding: 12px 14px 10px;
  display: flex; flex-direction: column; gap: 9px; flex-shrink: 0;
}
.sms-head .rowa { display: flex; align-items: center; gap: 9px; }
.sms-head .title { font-size: 13.5px; font-weight: 750; }
.sms-head .num { font-size: 11px; color: #93a6c0; font-weight: 600; }
.sms-persona-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sms-persona-row::-webkit-scrollbar { display: none; }
.sms-persona {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 5px 10px 5px 5px; border-radius: 999px;
  background: rgba(255,255,255,0.07); color: #c9d6e8; font-size: 12px; font-weight: 650;
}
.sms-persona .avatar { width: 24px; height: 24px; font-size: 9.5px; }
.sms-persona.on { background: var(--accent); color: var(--accent-ink); }
.sms-thread { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 7px; }
.bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 18px;
  font-size: 13.5px; line-height: 1.42; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.in { align-self: flex-start; background: var(--sms-in); color: var(--ink); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--sms-out); color: var(--sms-out-ink); border-bottom-right-radius: 6px; font-weight: 550; }
.bubble-ts { align-self: center; font-size: 10.5px; color: var(--ink-faint); margin: 8px 0 2px; font-weight: 650; }
.sms-empty { margin: auto; text-align: center; color: var(--ink-faint); font-size: 13px; padding: 0 30px; line-height: 1.5; }
.sms-empty .ic { width: 30px; height: 30px; margin: 0 auto 10px; }
.sms-compose { flex-shrink: 0; padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.sms-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.sms-quick::-webkit-scrollbar { display: none; }
.sms-quick .chip { padding: 6px 11px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sms-inputrow { display: flex; gap: 8px; }
.sms-inputrow input {
  flex: 1; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 11px 16px; outline: none; color: var(--ink);
  font-size: 16px; /* >=16px: no iOS focus zoom */
}
.sms-inputrow input:focus { border-color: var(--accent); }
.sms-send {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
}
.sms-send .ic { width: 19px; height: 19px; }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; } .typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.25; } 35% { opacity: 1; } }

/* ---------- people / roster ---------- */
.person-row { display: flex; align-items: center; gap: 11px; }
.person-row .info { flex: 1; min-width: 0; }
.person-row .info b { font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.person-row .info small { font-size: 12px; color: var(--ink-dim); display: block; margin-top: 2px; }
.tag-sup {
  font-size: 9px; font-weight: 800; letter-spacing: 0.05em;
  background: var(--accent-soft); color: var(--accent-text);
  padding: 2px 6px; border-radius: 5px; text-transform: uppercase;
}
.tally { display: flex; gap: 7px; flex-wrap: wrap; }
.tally .t {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; text-align: center; min-width: 52px;
}
.tally .t b { font-size: 17px; display: block; letter-spacing: -0.01em; }
.tally .t small { font-size: 10px; color: var(--ink-faint); font-weight: 750; text-transform: uppercase; letter-spacing: 0.05em; }

.alert-band {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 13px; padding: 11px 13px; margin-bottom: 10px;
  font-size: 13px; line-height: 1.4;
}
.alert-band .ic { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-band.warn { background: var(--warn-soft); color: var(--warn); }
.alert-band.danger { background: var(--danger-soft); color: var(--danger); }
.alert-band.ok { background: var(--ok-soft); color: var(--ok); }
.alert-band.info { background: var(--contract-soft); color: var(--contract); }
.alert-band b { font-weight: 750; }

/* attention strip (admin) */
.attn-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; scrollbar-width: none; }
.attn-strip::-webkit-scrollbar { display: none; }
.attn-card {
  flex-shrink: 0; width: 168px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  border-radius: 13px; padding: 10px 12px;
}
.attn-card.warn { border-left-color: var(--warn); }
.attn-card b { font-size: 13px; display: block; line-height: 1.25; }
.attn-card .when { font-size: 11px; color: var(--accent-text); font-weight: 750; margin-bottom: 2px; }
.attn-card .need { font-size: 11.5px; margin-top: 4px; font-weight: 700; color: var(--danger); }
.attn-card.warn .need { color: var(--warn); }

/* empty states */
.empty { text-align: center; padding: 44px 30px; color: var(--ink-dim); }
.empty .ic { width: 34px; height: 34px; margin: 0 auto 12px; color: var(--ink-faint); }
.empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 5px; }
.empty p { font-size: 13px; line-height: 1.5; }

/* hello card */
.hello {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.16), rgba(94, 163, 240, 0.10)), var(--surface);
  border: 1px solid var(--line-strong); border-radius: 18px; padding: 15px;
  position: relative; overflow: hidden;
}
.hello h3 { font-size: 16.5px; letter-spacing: -0.01em; margin-bottom: 4px; }
.hello p { font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.hello .x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--ink-faint); }
.hello .x .ic { width: 15px; height: 15px; }

/* misc */
.ic { width: 20px; height: 20px; }
.muted { color: var(--ink-dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 700;
  color: var(--accent-text);
}
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.spacer8 { height: 8px; } .spacer16 { height: 16px; } .spacer24 { height: 24px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

::-webkit-scrollbar { width: 0; height: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

/* ---------- print (shirt order sheet) ---------- */
#print-root { display: none; }
@media print {
  body * { visibility: hidden; }
  #stage, #sheet-root, #toast-root { display: none !important; }
  #print-root { display: block !important; visibility: visible; position: absolute; inset: 0; background: #fff; color: #111; padding: 32px; font-family: Georgia, serif; }
  #print-root * { visibility: visible; }
  #print-root h1 { font-size: 22px; margin-bottom: 2px; }
  #print-root .psub { color: #555; font-size: 13px; margin-bottom: 18px; }
  #print-root table { width: 100%; border-collapse: collapse; font-size: 13px; }
  #print-root th, #print-root td { border: 1px solid #bbb; padding: 7px 10px; text-align: left; }
  #print-root th { background: #f0f0f0; }
  #print-root .ptally { margin: 14px 0 20px; font-size: 15px; font-weight: bold; }
  /* crew sheet (photo roster + signature column = paper backup sign-in) */
  #print-root table.crew td { vertical-align: middle; height: 54px; }
  #print-root .cphoto { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; display: block; }
  #print-root span.cphoto { display: flex; align-items: center; justify-content: center; background: #ececec; color: #666; font-weight: bold; font-size: 15px; border: 1px solid #ccc; }
  #print-root td.open-slot { color: #999; font-style: italic; }
  #print-root .plogo { height: 40px; margin-bottom: 8px; }
  #print-root .pfoot { margin-top: 16px; font-size: 11px; color: #777; }
}
