/* The admin page: an operations console in the look My Empower's apps' admins share. A deep sidebar in
   the app's own colour (brand.css sets --brand and --side), a pale work area, white cards with round corners and a
   soft shadow, round-ended buttons, the device's own font, one accent, and status colours that mean the same
   everywhere (red: needs attention, amber: in progress, green: fine). Dark mode follows the device; on a phone the
   menu is a row of tabs to swipe. Every colour is a token here, redefined for dark. */
:root {
  color-scheme: light;
  --bg: #F3F5F4; --card: #FFFFFF; --surface-2: #EBEFED; --surface-3: #DEE5E2; --line: #DCE3E0; --line-hi: #C5D0CC;
  --text: #13201C; --dim: #43534D; --faint: #6A7A74;
  --accent: var(--brand); --accent-hi: color-mix(in srgb, var(--brand) 82%, #000); --accent-soft: color-mix(in srgb, var(--brand) 13%, #FFF); --on-accent: var(--on-brand, #FFFFFF);
  --bad: #C8402B; --bad-soft: #FCE6E1; --warn: #9E6A00; --warn-soft: #FAEFD5; --good: #12825A; --good-soft: #DAF2E6;
  --side-text: rgba(255, 255, 255, .82); --side-dim: rgba(255, 255, 255, .55); --side-hi: rgba(255, 255, 255, .1); --side-line: rgba(255, 255, 255, .12);
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(10, 30, 24, .06), 0 4px 16px rgba(10, 30, 24, .06);
  --shadow-lift: 0 2px 6px rgba(10, 30, 24, .08), 0 14px 36px rgba(10, 30, 24, .14);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0B1210; --card: #121C19; --surface-2: #182622; --surface-3: #20312C; --line: #1F2F2A; --line-hi: #2C423B;
    --text: #E6EEEA; --dim: #B5C4BE; --faint: #8DA19A;
    --accent: var(--brand-dark); --accent-hi: color-mix(in srgb, var(--brand-dark) 82%, #FFF); --accent-soft: color-mix(in srgb, var(--brand-dark) 18%, #121C19); --on-accent: var(--on-brand-dark);
    --bad: #FF7A66; --bad-soft: #3A1E1A; --warn: #F0B13E; --warn-soft: #382B10; --good: #45D097; --good-soft: #0F3024;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .35), 0 14px 36px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.015em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.015em; min-width: 0; }
.brand img { width: 32px; height: 32px; border-radius: 9px; flex: none; display: block; background: rgba(255, 255, 255, .1); }
.brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand small { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px; border-radius: 99px;
  background: rgba(255, 255, 255, .16); color: #FFFFFF; white-space: nowrap; }

/* common pieces */
.card { background: var(--card); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card > h2 + .hint, .card > h2 + p { margin-top: 4px; }
.hint { color: var(--faint); font-size: 13px; }
.msg { min-height: 1.4em; font-size: 13.5px; color: var(--dim); }
.msg.bad { color: var(--bad); font-weight: 600; } .msg.good { color: var(--good); font-weight: 600; }
.empty { padding: 28px 4px; text-align: center; color: var(--faint); }
.stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-items: start; }

.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 99px;
  padding: 9px 18px; font-weight: 600; font-size: 14px; line-height: 1.3; cursor: pointer; background: var(--surface-2); color: var(--text); text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; color: var(--dim); } .btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad-soft); color: var(--bad); } .btn.danger:hover, .btn.danger.armed { background: var(--bad); color: #FFFFFF; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--dim); min-width: 0; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input[type=url], input[type=number], select, textarea {
  padding: 9px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 15px; font-weight: 400;
  transition: border-color .15s, box-shadow .15s; width: 100%; min-width: 0; }
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.code-input { font: 600 22px/1 var(--mono); letter-spacing: .3em; text-align: center; }

/* segmented controls: a pill track */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 99px; background: var(--surface-2); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { appearance: none; border: 0; background: transparent; border-radius: 99px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--dim); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed=true] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* a switch */
.switch { position: relative; width: 44px; height: 26px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-hi); transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #FFF; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* pills for state */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--dim); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.gold { background: color-mix(in srgb, #C8A04A 24%, var(--card)); color: color-mix(in srgb, #8A6A1E 85%, var(--text)); }

/* sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); background: linear-gradient(160deg, var(--side), color-mix(in srgb, var(--side) 70%, #000)); }
.signin .card { width: min(420px, 100%); display: grid; gap: 16px; padding: 28px; box-shadow: var(--shadow-lift); }
.signin .brand { color: var(--text); }
.signin .brand small { background: var(--accent-soft); color: var(--accent); }

/* the shell */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; gap: 14px; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #FFF; padding: 4px 8px 10px; border-bottom: 1px solid var(--side-line); }
.side .brand b { white-space: normal; line-height: 1.15; }
.navgroup { display: grid; gap: 2px; }
.navgroup > button.head { appearance: none; background: none; border: 0; color: var(--side-dim); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  text-align: left; padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-radius: 8px; }
.navgroup > button.head::after { content: "▾"; font-size: 11px; transition: transform .15s; }
.navgroup.folded > button.head::after { transform: rotate(-90deg); }
.navgroup.folded > a { display: none; }
.side a.tab { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--side-text); text-decoration: none; font-weight: 600; font-size: 14px; }
.side a.tab:hover { background: var(--side-hi); color: #FFF; }
.side a.tab[aria-current=page] { background: rgba(255, 255, 255, .16); color: #FFF; }
.side a.tab .count { margin-left: auto; min-width: 20px; padding: 0 6px; height: 20px; border-radius: 99px; background: #FFF; color: var(--side); font-size: 11.5px; font-weight: 800; display: inline-grid; place-items: center; }
.side .me { margin-top: auto; border-top: 1px solid var(--side-line); padding: 12px 8px 0; display: grid; gap: 8px; font-size: 13px; }
.side .me b { color: #FFF; font-size: 14px; }
.side .me .btn { background: var(--side-hi); color: #FFF; justify-self: start; }
.work { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; }
.work-inner { max-width: 1440px; margin: 0 auto; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.titlebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.titlebar .env { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.about { color: var(--dim); font-size: 13.5px; }
details.about summary { cursor: pointer; color: var(--faint); font-weight: 600; }
details.about p { margin-top: 6px; max-width: 80ch; }

/* numbers */
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.kpi { display: grid; gap: 4px; }
.kpi .label { color: var(--faint); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12.5px; font-weight: 700; color: var(--faint); }
.kpi .delta.up { color: var(--good); } .kpi .delta.down { color: var(--bad); }
.cols { display: flex; align-items: flex-end; gap: 3px; height: 96px; margin-top: 10px; }
.cols span { flex: 1; min-width: 2px; background: color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 3px 3px 0 0; min-height: 2px; }
.cols span.zero { background: var(--surface-3); }
.axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 11.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.attn { display: grid; gap: 8px; }
.attn a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); text-decoration: none; color: var(--text); font-weight: 600; }
.attn a::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.attn a.bad::before { background: var(--bad); } .attn a.warn::before { background: var(--warn); } .attn a.info::before { background: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px 18px; }
.fact { display: grid; gap: 2px; min-width: 0; }
.fact span { font-size: 12px; color: var(--faint); font-weight: 600; }
.fact b { font-weight: 600; overflow-wrap: anywhere; }

/* tables */
.tablewrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--faint); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
th button { appearance: none; border: 0; background: none; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 0; }
th button[aria-sort=ascending]::after { content: " ↑"; } th button[aria-sort=descending]::after { content: " ↓"; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; text-align: right; } th.num { text-align: right; }
td .sub { display: block; color: var(--faint); font-size: 12.5px; overflow-wrap: anywhere; }

/* windows (a person, a ticket, a draft) */
.win-back { position: fixed; inset: 0; background: rgba(5, 15, 12, .45); display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); z-index: 20; }
.win { width: min(760px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lift); display: grid; gap: 16px; padding: 24px; }
.win .head { display: flex; align-items: flex-start; gap: 12px; }
.win .head h2 { font-size: 20px; }
.win section { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #FFF; }
pre.json { max-height: 280px; overflow: auto; background: var(--surface-2); border-radius: 10px; padding: 12px; font: 12px/1.45 var(--mono); margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.photos .card { display: grid; gap: 10px; padding: 12px; }
.photos img { width: 100%; aspect-ratio: 1; border-radius: 12px; object-fit: cover; background: var(--surface-2); }
svg.chart { width: 100%; height: 160px; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
svg.chart text { fill: var(--faint); font-size: 11px; }
.log { display: grid; gap: 0; }
.log div { display: grid; grid-template-columns: 150px 110px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log time { color: var(--faint); font-variant-numeric: tabular-nums; }
.log b { font-weight: 600; overflow-wrap: anywhere; }

/* a phone: the menu is a row of tabs to swipe */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { min-width: 0; }
  .kpis { gap: 12px; }
  .kpi .value { font-size: 26px; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px)); overflow: visible; }
  .side .brand { border: 0; padding: 0; flex: 1; }
  .side .me { margin: 0; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .side .me .who { display: none; }
  .side nav { order: 3; width: 100%; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .side nav::-webkit-scrollbar { display: none; }
  .navgroup { display: contents; }
  .navgroup > button.head { display: none; }
  .navgroup.folded > a { display: flex; }
  .side a.tab { white-space: nowrap; padding: 7px 12px; }
  .work { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
  h1 { font-size: 24px; }
  .opt { display: none; }
  .log div { grid-template-columns: 1fr; gap: 2px; }
  .win { padding: 18px; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.stack > .seg, .win > .seg { justify-self: start; }
