/* Amigos Work: the company's design system, for the pages we work in (the Control Room, Compadres and every
   admin or customer page after them). docs/WORK-DESIGN-SYSTEM.md is the guide. The app and marketing keep
   AmigosDS (docs/DESIGN-SYSTEM.md); the two never mix, except inside an app zone (.app-zone, below).

   Rules: light by default, dark only when the person picks it. Pink is a signal: one primary button per view
   (.btn.hot), the Amigos mark, the "you are here" dot and "live". Never a fill, a heading, an error or a chart
   series. Status always has a word with its colour. Use these tokens; never a raw hex in a page's own CSS. */

@font-face { font-family: "Inter"; src: url("Inter.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Funnel Display"; src: url("../FunnelDisplay.ttf") format("truetype"); font-weight: 300 800; font-display: swap; }

:root {
  /* Ground: grey with a breath of the app's night violet. Text is the app's night ink. */
  --w-paper: #F6F6F9;        /* page ground */
  --w-surface: #FFFFFF;      /* cards, tables, the side menu */
  --w-surface-2: #F0F0F5;    /* hover, table head, quiet fills, code */
  --w-surface-3: #E7E7EF;    /* selected, pressed */
  --w-line: #E3E3EC;         /* dividers and card edges */
  --w-line-strong: #CFCFDD;  /* a stronger divider */
  --w-control-line: #8A8CA3; /* edges of inputs, checkboxes and switches (3:1 on surface) */
  --w-ink: #0B0B20;          /* text */
  --w-ink-2: #45475F;        /* secondary text */
  --w-ink-3: #6A6C84;        /* labels, hints, axis text (4.7:1 on paper) */
  --w-on-signal: #FFFFFF;    /* words on the primary button */

  /* The signal: Arcade pink. */
  --w-signal: #FF1F8F;       /* the mark, the menu dot, the live dot */
  --w-signal-fill: #E5007A;  /* the one primary button (white words 4.5:1) */
  --w-signal-ink: #C2006A;   /* pink as words, rarely */

  /* Status: each with a soft ground for pills and notices. Words on the ground pass 4.5:1. */
  --w-ok: #0B7A45;   --w-ok-bg: #E5F5EC;
  --w-warn: #8A6200; --w-warn-bg: #FFF4D1;
  --w-bad: #C4282D;  --w-bad-bg: #FDECEC;
  --w-info: #1260A8; --w-info-bg: #E7F1FC;
  --w-ai: #5524C7;   --w-ai-bg: #F0EBFF;   /* written or picked by an AI model */
  --w-focus: #1B86E0;                       /* the focus ring, the app's friends blue */

  /* Charts: the app's five colours, stepped for this ground and checked for colour blindness. Fixed order,
     never cycled. Pink is never a series. */
  --w-c1: #5B3FD9; --w-c2: #E07A1F; --w-c3: #1B86E0; --w-c4: #0F9F62; --w-c5: #B88A00;

  /* Type */
  --w-font-display: "Funnel Display", "Inter", system-ui, sans-serif; /* page titles and big numbers only */
  --w-font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --w-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --w-fs-title: 28px;  /* page title, display 650 */
  --w-fs-h2: 20px;     /* section or card title, display 600 */
  --w-fs-number: 26px; /* a big number, display 600 */
  --w-fs-h3: 15px;     /* small heading, ui 600 */
  --w-fs-body: 14px;
  --w-fs-small: 13px;  /* tables, fields, hints */
  --w-fs-label: 11px;  /* uppercase labels, ui 600, tracking .06em */

  /* Space: 4 px steps. */
  --w-s1: 4px; --w-s2: 8px; --w-s3: 12px; --w-s4: 16px; --w-s5: 20px; --w-s6: 24px; --w-s8: 32px; --w-s10: 40px; --w-s12: 48px;

  /* Shape and size */
  --w-r1: 4px;   /* tags, small marks */
  --w-r2: 6px;   /* buttons, fields */
  --w-r3: 8px;   /* cards, tables, notices */
  --w-r4: 12px;  /* panels, dialogs */
  --w-pill: 999px;
  --w-control: 34px;     /* a button or field */
  --w-control-sm: 28px;  /* a small one */
  --w-row: 44px;         /* a table row; also the touch minimum for a lone control on a phone */
  --w-shadow-pop: 0 1px 2px rgba(11, 11, 32, .06), 0 8px 24px rgba(11, 11, 32, .10); /* only what floats */
  --w-scrim: rgba(11, 11, 32, .36); /* behind a dialog or a sheet */

  /* Motion: fade and slide, nothing else. */
  --w-d: 120ms; --w-e: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

/* Dark, when the person picks it (work/theme.js keeps the choice). Calm graphite, not the app's night. */
:root[data-theme="dark"] {
  --w-paper: #101019; --w-surface: #171722; --w-surface-2: #1E1E2B; --w-surface-3: #282838;
  --w-line: #2A2A3A; --w-line-strong: #3C3C50; --w-control-line: #74768E;
  --w-ink: #EEEEF4; --w-ink-2: #B9BACB; --w-ink-3: #8F91A6;
  --w-signal: #FF3D9E; --w-signal-fill: #E5007A; --w-signal-ink: #FF7DBE;
  --w-ok: #3FD08A; --w-ok-bg: #12291F; --w-warn: #F2C443; --w-warn-bg: #2B2410;
  --w-bad: #FF6B6B; --w-bad-bg: #2E1517; --w-info: #6AB4FF; --w-info-bg: #142536;
  --w-ai: #B9A2FF; --w-ai-bg: #221A3D; --w-focus: #4AA6F5;
  --w-c1: #8E74FA; --w-c2: #D86F22; --w-c3: #2E9BEA; --w-c4: #1FA466; --w-c5: #AD8A14;
  --w-shadow-pop: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
  --w-scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) { :root { --w-d: 0ms; } }

/* ---- Elements */
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--w-paper); color: var(--w-ink); min-height: 100vh;
  font: 400 var(--w-fs-body)/1.5 var(--w-font-ui); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
h1 { font: 650 var(--w-fs-title)/1.15 var(--w-font-display); letter-spacing: -.015em; text-wrap: balance; }
h2 { font: 600 var(--w-fs-h2)/1.25 var(--w-font-display); letter-spacing: -.01em; text-wrap: balance; }
h3 { font: 600 var(--w-fs-label)/1.3 var(--w-font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--w-ink-3); }
a { color: var(--w-info); text-underline-offset: 2px; }
code, pre, kbd { font-family: var(--w-font-mono); }
:focus-visible { outline: 2px solid var(--w-focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--w-focus) 24%, transparent); }
.quiet { color: var(--w-ink-3); }
.small { font-size: var(--w-fs-small); }
.num, .n { font-variant-numeric: tabular-nums; }
.error { color: var(--w-bad); min-height: 1.4em; font-weight: 600; }
.error:empty { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- The mark and the name */
.brand { display: flex; gap: 10px; align-items: center; font: 650 17px/1.1 var(--w-font-display); letter-spacing: -.01em; color: var(--w-ink); }
.brand small { display: block; font: 600 var(--w-fs-label)/1.4 var(--w-font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--w-ink-3); }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--w-signal); display: inline-grid; place-items: center; flex: none; }
.mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #FFFFFF; }

/* ---- Buttons. One .hot per view at most. */
.btn {
  font: 600 var(--w-fs-small)/1 var(--w-font-ui); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--w-control); padding: 0 14px; border-radius: var(--w-r2); border: 1px solid var(--w-line);
  background: var(--w-surface); color: var(--w-ink); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--w-d) var(--w-e), border-color var(--w-d) var(--w-e);
}
.btn:hover { background: var(--w-surface-2); border-color: var(--w-control-line); }
.btn.hot { background: var(--w-signal-fill); border-color: var(--w-signal-fill); color: var(--w-on-signal); }
.btn.hot:hover { background: var(--w-signal-ink); border-color: var(--w-signal-ink); }
.btn.link { background: none; border-color: transparent; color: var(--w-ink-2); padding: 0 8px; }
.btn.link:hover { background: var(--w-surface-2); color: var(--w-ink); }
.btn.danger { color: var(--w-bad); }
.btn.danger:hover { background: var(--w-bad-bg); border-color: var(--w-bad); }
.btn.small { min-height: var(--w-control-sm); padding: 0 10px; font-size: 12px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }

/* ---- Fields */
input, select, textarea {
  font: 400 var(--w-fs-small)/1.4 var(--w-font-ui); color: var(--w-ink); background: var(--w-surface);
  border: 1px solid var(--w-control-line); border-radius: var(--w-r2); padding: 7px 10px; min-height: var(--w-control);
}
textarea { resize: vertical; padding: 8px 10px; }
input::placeholder, textarea::placeholder { color: var(--w-ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--w-focus); outline-offset: 0; border-color: var(--w-focus); }
input[aria-invalid="true"] { border-color: var(--w-bad); }
input[type="checkbox"], input[type="radio"] { min-height: 0; padding: 0; width: 16px; height: 16px; accent-color: var(--w-ink); }
input[type="file"] { padding: 6px; background: var(--w-surface-2); border-style: dashed; }
input[type="range"] { accent-color: var(--w-ink); border: 0; background: none; padding: 0; }
label { font-size: 12px; font-weight: 600; color: var(--w-ink-2); }

/* ---- Cards */
.card { background: var(--w-surface); border: 1px solid var(--w-line); border-radius: var(--w-r3); padding: var(--w-s4); min-width: 0; }

/* ---- Chips: a word with its colour. Tones: ok/calm/live, warn/amber, bad/red, info/person, ai, plain. */
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 2px 8px; border-radius: var(--w-pill);
  font: 600 11.5px/1.2 var(--w-font-ui); letter-spacing: 0; text-transform: none; white-space: nowrap;
  background: var(--w-surface-2); color: var(--w-ink-2);
}
.chip.ok, .chip.calm, .chip.live { background: var(--w-ok-bg); color: var(--w-ok); }
.chip.warn, .chip.amber { background: var(--w-warn-bg); color: var(--w-warn); }
.chip.bad, .chip.red { background: var(--w-bad-bg); color: var(--w-bad); }
.chip.info, .chip.person { background: var(--w-info-bg); color: var(--w-info); }
.chip.ai { background: var(--w-ai-bg); color: var(--w-ai); }
.chip.plain { background: var(--w-surface-2); color: var(--w-ink-2); }
.chip.on-air::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--w-signal); }
a.chip { text-decoration: none; }
a.chip:hover { background: var(--w-surface-3); }

/* ---- Notices */
.notice { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--w-r3); font-size: var(--w-fs-small); line-height: 1.45; background: var(--w-surface-2); color: var(--w-ink-2); }
.notice.ok { background: var(--w-ok-bg); color: var(--w-ok); }
.notice.warn { background: var(--w-warn-bg); color: var(--w-warn); }
.notice.bad { background: var(--w-bad-bg); color: var(--w-bad); }
.notice.info { background: var(--w-info-bg); color: var(--w-info); }

/* ---- Tables */
table { width: 100%; border-collapse: collapse; font-size: var(--w-fs-small); }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--w-line); vertical-align: top; }
th { border-top: 0; font: 600 var(--w-fs-label)/1.3 var(--w-font-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--w-ink-3); white-space: nowrap; }
thead th { border-bottom: 1px solid var(--w-line); }
thead + tbody tr:first-child td { border-top: 0; }
th.n, td.n { text-align: right; font-variant-numeric: tabular-nums; }
td code { font-size: 12px; color: var(--w-ink-3); }

/* ---- Tabs: an underline row. The same class makes a segmented pick inside .tabs.small. */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  font: 500 var(--w-fs-small)/1 var(--w-font-ui); color: var(--w-ink-2); background: none; border: 1px solid transparent;
  border-radius: var(--w-r2); padding: 0 10px; min-height: var(--w-control); cursor: pointer;
}
.tab:hover { background: var(--w-surface-2); color: var(--w-ink); }
.tab.on, .tab[aria-selected="true"] { background: var(--w-surface); color: var(--w-ink); font-weight: 600; border-color: var(--w-line); box-shadow: 0 1px 2px rgba(11, 11, 32, .06); }
.tab.small { min-height: var(--w-control-sm); font-size: 12px; padding: 0 8px; }

/* ---- Sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--w-paper); }
.signin-card { width: min(400px, 100%); background: var(--w-surface); border: 1px solid var(--w-line); border-radius: var(--w-r4); padding: 28px; display: grid; gap: 18px; box-shadow: var(--w-shadow-pop); }
.signin-card form { display: grid; gap: 10px; }
.signin-card .btn { min-height: 40px; }
.signin-card input { min-height: 40px; }

/* ---- The light/dark pick (work/theme.js) */
.theme-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--w-ink-3); }
.theme-pick button { font: 500 12px/1 var(--w-font-ui); min-height: var(--w-control-sm); padding: 0 8px; border-radius: var(--w-r2); border: 1px solid var(--w-line); background: var(--w-surface); color: var(--w-ink-2); cursor: pointer; }
.theme-pick button:hover { background: var(--w-surface-2); color: var(--w-ink); }

/* ---- App zone: where a page shows the app's own screens (the Library's Cabinet phones, Compadres' phone
   preview, the Sandbox's Make screen). Everything inside keeps the app's look from AmigosDS; nothing of Amigos
   Work reaches in. Pages set the app's colours on the zone itself (cabinet-stage.css, phone.css, .mk-phone). */
.app-zone { color-scheme: dark; }
/* A game in a frame paints on the light scheme, as it always has. Without this, a frame on a dark page gets an
   opaque white backdrop from the browser (its document and its frame would disagree on the scheme). */
iframe { color-scheme: normal; }
