/* Internal tool. Legible and dense beats pretty — this is a work surface, not
   a product surface, so it borrows the app's palette and nothing else. */
:root{
  --bg:#0B0B0D; --s1:#131317; --s2:#1B1B21; --border:#2A2A33;
  --text:#F2F2F4; --gray:#A6A6AE;
  /* Was #77777F, which measured 4.17:1 on --s1 and 3.86:1 on --s2 — under the
     4.5:1 body-text floor everywhere it was used (table headers, .dim, stat
     labels). Dark themes fail here constantly; the token name looked fine. */
  --gray2:#9C9CA8;
  --gold:#F5A623; --green:#30A46C; --amber:#F5A623; --blue:#5B8DEF;
  /* Three reds, because one cannot serve all three jobs at AA:
     --red        borders and accents (non-text, needs only 3:1)
     --red-text   red TEXT on a dark surface
     --red-solid  a filled button that must carry white text at 4.5:1 */
  --red:#E5484D; --red-text:#FF9EA1; --red-solid:#A32126;
  --focus:#7CB2FF;
  /* A cooler neutral for toolbars, so the sticky header stays distinguishable
     from the cards scrolling under it instead of merging with them. */
  --chrome:#101014;

  /* Spacing. A 4-base gives the middle steps an 8-only scale misses, which is
     what the sixteen one-off inline margins were reaching for by hand. Named
     by role, so "space between sections" survives a value change. */
  --s1x:4px; --s2x:8px; --s3x:12px; --s4x:16px; --s5x:24px; --s6x:32px;
  --gap-tight:var(--s2x);     /* within a group */
  --gap-group:var(--s4x);     /* between groups in a card */
  --gap-section:var(--s5x);   /* between cards */

  /* Type roles. Fixed rem-ish steps, not fluid: an Operate surface is viewed at
     a consistent size and a heading that shrinks in a narrow column reads worse,
     not better. Ratio ~1.15 between adjacent roles. */
  --t-page:21px; --t-section:17px; --t-sub:15px; --t-body:14px;
  --t-meta:13px; --t-label:11px;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);
  font:var(--t-body)/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
h1,h2,h3{margin:0 0 8px;font-weight:600;letter-spacing:-.012em;line-height:1.25}
h1{font-size:var(--t-page)} h2{font-size:var(--t-section)} h3{font-size:var(--t-sub)}
/* More space above a heading than below it, so a heading binds to what follows
   rather than floating between two blocks. */
* + h2,* + h3{margin-top:20px}
.card > h2:first-child,.card > h3:first-child,.dlg-head h2{margin-top:0}
a{color:var(--blue)}
.muted{color:var(--gray)}
.prose{max-width:68ch}

/* Layout utilities, so a spacing decision lives in one place instead of being
   retyped as an inline margin at each call site. */
.page-head{margin-bottom:var(--gap-section)}
.flush{margin:0}
.stack-sm{margin-top:var(--s2x)}
.stack-md{margin-top:var(--s3x)}
.inline-tag{margin-left:var(--s2x)}
.row.top-align{align-items:flex-start}
.row.bottom-align{align-items:flex-end}
.f-fixed{flex:0 0 130px}
.f-grow{flex:1;min-width:200px}
.w-auto{width:auto}
.dim{color:var(--gray2)}
.pad{padding:24px}
/* Visible to a screen reader, not on screen. Used where a visual header is
   redundant but an unlabelled column or button would not be announced. */
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ── Gate ─────────────────────────────────────────────── */
.gate{max-width:380px;margin:14vh auto;padding:0 var(--s5x);text-align:center}
/* Sized by height; the 3:1 wordmark computes its own width. width/height
   attributes stay on the tag so the box is reserved before the image loads
   and the card below it does not jump. */
.gate-lockup{display:flex;align-items:center;justify-content:center;
  gap:var(--s3x);margin-bottom:var(--s3x)}
.gate-logo{height:44px;width:auto}
.brand-logo{height:19px;width:auto;display:block}
.gate-card{background:var(--s1);border:1px solid var(--border);border-radius:10px;
  padding:20px;margin-top:20px;display:flex;flex-direction:column;gap:10px}
.or{display:flex;align-items:center;gap:10px;color:var(--gray2);font-size:12px}
.or::before,.or::after{content:"";flex:1;height:1px;background:var(--border)}

/* ── Chrome ───────────────────────────────────────────── */
.top{display:grid;grid-template-columns:auto 1fr auto;align-items:center;
  gap:var(--s4x) var(--s5x);padding:var(--s3x) var(--s4x);
  border-bottom:1px solid var(--border);background:var(--chrome);
  position:sticky;top:0;z-index:10}
.brand{display:flex;align-items:center;gap:var(--s2x);min-width:0}
.brand-tag{font-size:var(--t-label);font-weight:700;letter-spacing:.1em;
  text-transform:uppercase;color:var(--gold);border:1px solid var(--gold);
  border-radius:5px;padding:2px var(--s2x);line-height:1.4;white-space:nowrap}
.who{display:flex;align-items:center;gap:var(--s3x);font-size:var(--t-meta);min-width:0}
.who button{white-space:nowrap}
#who-label{display:flex;align-items:center;gap:var(--s2x);min-width:0}
.who-email{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.who-role{border:1px solid var(--border);border-radius:20px;padding:1px var(--s2x);
  font-size:var(--t-label);text-transform:uppercase;letter-spacing:.06em;
  font-weight:600;white-space:nowrap}
nav{display:flex;gap:var(--s1x)}
.lbl-short{display:none}
@media (max-width:720px){
  /* Measured on a 390x844 phone: the tabs sat at y=49, the far end of the
     screen from a thumb, and every control was 28-34px against a 44px comfort
     target. Both are fixed here, and the app's own tab bar is the precedent.
     Same markup at every width; only the CSS moves. */
  .top{grid-template-columns:1fr auto}

  nav{position:fixed;left:0;right:0;bottom:0;z-index:20;gap:0;
    background:color-mix(in srgb, var(--chrome) 92%, transparent);
    backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
    border-top:1px solid var(--border);
    padding:var(--s1x) var(--s1x) calc(var(--s1x) + env(safe-area-inset-bottom))}
  nav button{flex:1;min-height:46px;display:flex;align-items:center;
    justify-content:center;gap:var(--s1x);font-size:var(--t-meta);
    border-radius:9px;padding:var(--s1x) 2px;line-height:1.2}
  .lbl-full{display:none} .lbl-short{display:inline}
  nav button.on{background:var(--s2)}
  nav button .count{margin-left:0}

  /* The bar is fixed, so the last card needs room to clear it. */
  main{padding-bottom:calc(58px + env(safe-area-inset-bottom))}

  /* The email is the long half and the least useful mid-task; the role is what
     answers "am I about to change something as owner". Keep the role, drop the
     address, and the header stops wrapping to two ragged lines. */
  .who-email{display:none}

  /* 44px is the comfort target; 24px is only the WCAG floor. */
  .btn{min-height:44px;padding:11px var(--s4x)}
  .btn-sm{min-height:44px;padding:10px var(--s3x)}
  .input,select,textarea{min-height:44px}
  summary{min-height:34px;align-items:center}

  /* A centered modal on a phone puts its actions mid-screen. A sheet rising
     from the bottom keeps them under the thumb that opened it. */
  dialog{width:100%;max-width:none;margin:0;position:fixed;inset:auto 0 0 0;
    border-radius:14px 14px 0 0;border-bottom:0;max-height:88vh;overflow-y:auto}
  .dlg-foot{padding-bottom:calc(var(--s4x) + env(safe-area-inset-bottom))}
  .dlg-foot .btn{flex:1}
}
nav button{background:none;border:1px solid transparent;color:var(--gray);
  padding:6px 11px;border-radius:7px;cursor:pointer;font:inherit;font-size:13px}
nav button:hover{color:var(--text);background:var(--s2)}
nav button.on{color:var(--text);background:var(--s2);border-color:var(--border)}
nav button .count{margin-left:6px;background:var(--gold);color:#000;font-size:11px;
  font-weight:700;border-radius:9px;padding:0 6px}
main{padding:var(--s5x) var(--s4x);max-width:1100px}

/* ── Bits ─────────────────────────────────────────────── */
.btn{background:var(--gold);color:#000;border:0;border-radius:7px;padding:9px 14px;
  font:inherit;font-weight:600;cursor:pointer}
.btn:hover{filter:brightness(1.08)}
.btn:active{filter:brightness(.94);transform:translateY(1px)}
.btn:disabled{opacity:.5;cursor:default;transform:none;filter:none}
/* Async actions used to look identical while in flight, which invites a second
   click that fires a second write. */
.btn[aria-busy="true"]{opacity:.65;cursor:progress;pointer-events:none}
.btn[aria-busy="true"]::after{content:"";display:inline-block;width:9px;height:9px;
  margin-left:7px;vertical-align:-1px;border:2px solid currentColor;border-right-color:transparent;
  border-radius:50%;animation:spin .6s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){
  .btn[aria-busy="true"]::after{animation:none;border-right-color:currentColor;opacity:.4}
  .btn:active{transform:none}
}
.btn-outline{background:none;color:var(--text);border:1px solid var(--border)}
.btn-sm{padding:5px 10px;font-size:12px;font-weight:500}
/* --red under white text measured 3.91:1 at 12px. --red-solid clears 4.5:1. */
.btn-danger{background:var(--red-solid);color:#fff;border-color:var(--red-solid)}

/* Focus. The browser default here was `outline: auto 1px rgb(16,16,16)` —
   a near-black ring on a near-black app, i.e. no visible focus indicator at
   all. :focus-visible so a mouse click does not paint a ring, and an offset
   so the ring is not swallowed by the control's own border. */
:focus-visible{outline:2px solid var(--focus);outline-offset:2px;border-radius:7px}
.top{--x:0} /* sticky header: keep the ring above the content it overlaps */
nav button:focus-visible,.who button:focus-visible{position:relative;z-index:1}
.input,textarea,select{width:100%;background:var(--s2);border:1px solid var(--border);
  color:var(--text);border-radius:7px;padding:9px 11px;font:inherit}
textarea{min-height:80px;resize:vertical}
.msg{font-size:13px;min-height:18px}
.msg.err{color:var(--red)} .msg.ok{color:var(--green)}

.card{background:var(--s1);border:1px solid var(--border);border-radius:10px;
  padding:var(--s4x);margin-bottom:var(--gap-section)}
/* Reports inside the Queue card: a list, not nested cards. Separated by a rule
   so the container keeps being the only card on that level. */
.rlist{display:flex;flex-direction:column}
.ritem{padding:14px 0;border-top:1px solid var(--border)}
.ritem:first-child{padding-top:10px}

/* Loading. A skeleton holds the shape the content will take; a centered
   "Loading..." makes the page jump when the real thing arrives. */
.skel{display:flex;flex-direction:column;gap:10px}
.skel-bar{height:12px;border-radius:6px;background:var(--s2)}
.skel-bar.w40{width:40%} .skel-bar.w70{width:70%} .skel-bar.w90{width:90%}
.skel-card{background:var(--s1);border:1px solid var(--border);border-radius:10px;padding:16px;
  display:flex;flex-direction:column;gap:10px;margin-bottom:14px}
@media (prefers-reduced-motion:no-preference){
  .skel-bar{animation:pulse 1.4s ease-in-out infinite}
  @keyframes pulse{0%,100%{opacity:.45}50%{opacity:.8}}
}

/* Empty states teach the next action rather than reporting absence. */
.empty{text-align:center;padding:26px 16px;color:var(--gray)}
.empty strong{display:block;color:var(--text);margin-bottom:var(--s1x)}

/* The reasoning behind a guarantee matters once, then it is furniture. Kept
   one keystroke away rather than reprinted above the work every time. */
details.why{margin-top:var(--s3x)}
details.why > summary{cursor:pointer;color:var(--gray);font-size:var(--t-meta);
  list-style:none;display:inline-flex;align-items:center;gap:var(--s1x)}
details.why > summary::-webkit-details-marker{display:none}
details.why > summary::before{content:"";width:6px;height:6px;border-right:1.5px solid currentColor;
  border-bottom:1.5px solid currentColor;transform:rotate(-45deg);transition:transform .15s ease}
details.why[open] > summary::before{transform:rotate(45deg)}
details.why > summary:hover{color:var(--text)}
details.why p{margin:var(--s2x) 0 0;color:var(--gray)}

/* Ops: problems first, context second. A uniform grid of eleven tiles is the
   hero-metric template and says every number matters equally, which is the
   opposite of what an ops screen is for. */
.ops-lead{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));
  gap:var(--s3x);margin-bottom:var(--gap-section)}
.ops-lead .stat{padding:var(--s4x)}
.ops-lead .stat .n{font-size:30px}
.subhead{font-size:var(--t-label);text-transform:uppercase;letter-spacing:.08em;
  color:var(--gray2);font-weight:600;margin:0 0 var(--s3x)}
.stat-quiet{padding:var(--s3x)}
.stat-quiet .n{font-size:18px}
.row{display:flex;gap:var(--s3x);align-items:center;flex-wrap:wrap}
.spread{justify-content:space-between}

table{width:100%;border-collapse:collapse;font-size:var(--t-meta)}
/* Counts, dates and durations line up only with tabular figures; proportional
   digits make a column of numbers read ragged. */
.num,td.num,.stat .n,.count{font-variant-numeric:tabular-nums}
td.num{text-align:right}
th.num{text-align:right}
th{text-align:left;color:var(--gray2);font-weight:600;font-size:11px;
  text-transform:uppercase;letter-spacing:.06em;padding:6px 10px;border-bottom:1px solid var(--border)}
td{padding:9px 10px;border-bottom:1px solid var(--border);vertical-align:top}
tr:last-child td{border-bottom:0}
.wrap{overflow-x:auto}

/* Below 640px a six-column table becomes a sideways-scrolling strip where the
   action button lives off-screen. Scrolling inside .wrap satisfies reflow, but
   satisfying the rule is not the same as being usable one-thumbed. Each row
   becomes a stacked card instead, labelled from the header via data-label, so
   there is still only one markup path to keep correct. */
@media (max-width:640px){
  table.stack thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  table.stack tr{display:block;border:1px solid var(--border);border-radius:9px;
    padding:10px 12px;margin-bottom:10px;background:var(--s2)}
  table.stack td{display:flex;gap:10px;justify-content:space-between;align-items:baseline;
    border:0;padding:3px 0;text-align:right}
  table.stack td::before{content:attr(data-label);color:var(--gray2);font-size:11px;
    text-transform:uppercase;letter-spacing:.06em;font-weight:600;text-align:left;flex:0 0 auto}
  table.stack td:empty{display:none}
  table.stack td[data-label=""]{justify-content:flex-end}
  table.stack td[data-label=""]::before{content:none}
}

.pill{display:inline-block;font-size:11px;font-weight:600;padding:2px 8px;
  border-radius:20px;border:1px solid var(--border);color:var(--gray)}
.pill.open{color:var(--gold);border-color:var(--gold)}
/* Text takes --red-text (the border can stay --red: non-text needs only 3:1).
   --red measured 4.38:1 as 11px text, which is under the floor. */
.pill.urgent,.pill.high{color:var(--red-text);border-color:var(--red)}
.pill.resolved,.pill.closed,.pill.ok{color:var(--green);border-color:var(--green)}
.pill.warn{color:var(--amber);border-color:var(--amber)}

.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(146px,1fr));gap:var(--s2x)}
.stat{background:var(--s1);border:1px solid var(--border);border-radius:10px;padding:14px}
.stat .n{font-size:24px;font-weight:700;line-height:1.1}
.stat .k{font-size:11px;color:var(--gray2);text-transform:uppercase;letter-spacing:.06em;margin-top:4px}
.stat.bad .n{color:var(--red)} .stat.warn .n{color:var(--amber)}

.snapshot{background:var(--s2);border:1px solid var(--border);border-radius:7px;
  padding:10px 12px;margin:8px 0;white-space:pre-wrap;word-break:break-word;font-size:13px}
.note{white-space:pre-wrap;word-break:break-word}
.internal{border-color:var(--blue)}

/* ── Dialog ───────────────────────────────────────────────
   Native <dialog>, so Esc, the backdrop, focus containment and returning
   focus to the opener are the platform's job rather than four hand-rolled
   listeners that will drift. */
dialog{background:var(--s1);border:1px solid var(--border);border-radius:12px;
  color:var(--text);padding:0;width:min(460px,calc(100vw - 32px));font:inherit}
dialog::backdrop{background:rgba(0,0,0,.6)}
.dlg-head{padding:16px 18px 0}
.dlg-head h2{margin:0 0 4px}
.dlg-body{padding:14px 18px;display:flex;flex-direction:column;gap:12px}
.dlg-foot{padding:0 18px 16px;display:flex;gap:8px;justify-content:flex-end}
.field{display:flex;flex-direction:column;gap:5px}
.field label{font-size:12px;color:var(--gray);font-weight:600}
.field .hint{font-size:12px;color:var(--gray2)}
.field .err{font-size:12px;color:var(--red-text)}
.field.invalid .input,.field.invalid textarea{border-color:var(--red)}

/* ── Toast ────────────────────────────────────────────────
   Actions that only re-render otherwise look identical to actions that
   silently failed. */
#toasts{position:fixed;left:50%;transform:translateX(-50%);bottom:20px;z-index:50;
  display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none}
.toast{background:var(--s2);border:1px solid var(--border);border-radius:8px;
  padding:10px 14px;font-size:13px;box-shadow:0 6px 24px rgba(0,0,0,.5);max-width:90vw}
.toast.ok{border-color:var(--green)} .toast.err{border-color:var(--red)}
@media (prefers-reduced-motion:no-preference){
  .toast{animation:toast-in .18s ease-out}
  @keyframes toast-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
}
