/* ═══════════════════════════════════════════════════════════════
   Production KPI Dashboard — design system
   Light + dark themes driven by tokens. Switch with the header
   toggle, ?theme=light|dark in the URL, or DEFAULT_THEME in config.
   ═══════════════════════════════════════════════════════════════ */

/* Anything marked hidden stays hidden, whatever display its classes give it */
[hidden] { display: none !important; }

/* ---------- Light theme (default tokens) ---------- */
:root {
  color-scheme: light;
  --page: #eef3f7;
  --surface: #ffffff;
  --surface-2: #f2f6fa;
  --surface-3: #e2e9f0;
  --ink: #111c24;
  --ink-2: #3c4c59;
  --muted: #5d6d7a;
  --grid: #e3eaf0;
  --axis: #c2cfda;
  --border: #d8e2ea;
  --shadow: 0 1px 2px rgba(17, 40, 60, 0.05), 0 1px 3px rgba(17, 40, 60, 0.07);
  --shadow-lg: 0 12px 32px -8px rgba(17, 45, 70, 0.16);
  /* Tiljay brand: the logo's blue (darkened where text needs contrast) and pink */
  --accent: #0077c0;
  --accent-ink: #005f99;
  --accent-soft: #dff0fb;
  --on-accent: #ffffff;
  --brand-a: #00a8ec;
  --brand-b: #0077c0;
  --brand-pink: #e6007e;

  /* status: fill (bars/marks) · ink (text) · soft (pill background) */
  --good: #0ca30c;      --good-ink: #067306;      --good-soft: #e5f5e5;
  --warning: #f2a400;   --warning-ink: #8f5b00;   --warning-soft: #fdf3dc;
  --critical: #d03b3b;  --critical-ink: #b42525;  --critical-soft: #fbe8e8;
  --none: #c3c9d3;      --none-ink: #6b7486;      --none-soft: #eef0f4;

  /* department identity (categorical slots, light steps) */
  --dept-1: #2a78d6; --dept-2: #1baf7a; --dept-3: #4a3aa7; --dept-4: #e87ba4;
  --dept-5: #eb6834; --dept-6: #008300; --dept-7: #eda100; --dept-8: #e34948;

  --radius: 14px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0e14;
  --surface: #141922;
  --surface-2: #1b212c;
  --surface-3: #242b38;
  --ink: #f4f6fa;
  --ink-2: #b3bccb;
  --muted: #8691a3;
  --grid: #242b37;
  --axis: #343d4c;
  --border: #232a36;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
  --accent: #1597de;
  --accent-ink: #5cc0f2;
  --accent-soft: #10263a;
  --on-accent: #ffffff;
  --brand-a: #00a8ec;
  --brand-b: #1597de;
  --brand-pink: #ff3fa4;

  --good: #0ca30c;      --good-ink: #3ecf3e;      --good-soft: #0f2a14;
  --warning: #fab219;   --warning-ink: #fbc34a;   --warning-soft: #2e2410;
  --critical: #d03b3b;  --critical-ink: #f07070;  --critical-soft: #331517;
  --none: #3a4252;      --none-ink: #8691a3;      --none-soft: #1b212c;

  --dept-1: #3987e5; --dept-2: #199e70; --dept-3: #9085e9; --dept-4: #d55181;
  --dept-5: #d95926; --dept-6: #0ca30c; --dept-7: #c98500; --dept-8: #e66767;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #0b0e14; --surface: #141922; --surface-2: #1b212c; --surface-3: #242b38;
    --ink: #f4f6fa; --ink-2: #b3bccb; --muted: #8691a3; --grid: #242b37; --axis: #343d4c; --border: #232a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
    --accent: #1597de; --accent-ink: #5cc0f2; --accent-soft: #10263a; --brand-a: #00a8ec; --brand-b: #1597de; --brand-pink: #ff3fa4;
    --good-ink: #3ecf3e; --good-soft: #0f2a14; --warning: #fab219; --warning-ink: #fbc34a; --warning-soft: #2e2410;
    --critical-ink: #f07070; --critical-soft: #331517; --none: #3a4252; --none-ink: #8691a3; --none-soft: #1b212c;
    --dept-1: #3987e5; --dept-2: #199e70; --dept-3: #9085e9; --dept-4: #d55181;
    --dept-5: #d95926; --dept-6: #0ca30c; --dept-7: #c98500; --dept-8: #e66767;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: clamp(12px, 0.86vw, 34px); }
body {
  margin: 0; background: var(--page); color: var(--ink); min-height: 100vh;
  font-family: var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
a { color: var(--accent-ink); }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.5em 0.95em; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; box-shadow: var(--shadow);
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--axis); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--critical-ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--ink-2); cursor: pointer; box-shadow: var(--shadow);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.icon { width: 1em; height: 1em; vertical-align: -0.125em; }

/* theme toggle shows the icon of the theme you'd switch to */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .i-moon { display: none; }
}

/* ---------- Brand mark ---------- */
.brand { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.brand-mark {
  flex: 0 0 auto; width: 2.6rem; height: 2.6rem; border-radius: 0.7rem; display: grid; place-items: center; overflow: hidden;
  background: #ffffff; border: 1px solid var(--border); padding: 0.12rem; box-shadow: var(--shadow);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-text { min-width: 0; }
.brand-eyebrow { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.brand-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- TV shell ---------- */
.tv { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.tv-header {
  display: flex; align-items: center; gap: 1.5rem; padding: 0.9rem 2rem;
  background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto; box-shadow: var(--shadow);
  position: relative; z-index: 10; /* above chart dots so the calendar popover covers them */
  padding-top: calc(0.9rem + env(safe-area-inset-top, 0px));
}
.seg {
  display: inline-flex; padding: 0.25rem; gap: 0.2rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0.7rem;
}
.seg a {
  padding: 0.4rem 0.9rem; border-radius: 0.5rem; font-size: 0.95rem; font-weight: 500; color: var(--ink-2); text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.seg a:hover { color: var(--ink); }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.seg a svg { width: 1rem; height: 1rem; }
.hdr-spacer { flex: 1; }
.hdr-date { text-align: right; line-height: 1.2; }
.hdr-date .d { font-size: 1.15rem; font-weight: 600; white-space: nowrap; }
.hdr-date .s { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.hdr-date .s .live { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--good); margin-right: 0.35rem; vertical-align: 0.05em; box-shadow: 0 0 0 0.2rem var(--good-soft); }
body.offline .hdr-date .s .live { background: var(--warning); box-shadow: 0 0 0 0.2rem var(--warning-soft); }
body.history .hdr-date .s .live { background: var(--none); box-shadow: 0 0 0 0.2rem var(--none-soft); }
.hdr-date { position: relative; }
.hdr-day-row { display: flex; align-items: center; justify-content: flex-end; gap: 0.3rem; }
.date-btn { width: 1.9rem; height: 1.9rem; box-shadow: none; }
.date-btn svg { width: 1rem; height: 1rem; }
.date-btn:disabled { opacity: 0.35; cursor: default; }
.date-btn:disabled:hover { background: var(--surface); color: var(--ink-2); }
/* fixed width so the ‹ › buttons never move when the date text changes length */
.date-pick {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; width: 22.5rem; padding: 0.2rem 0.5rem; border-radius: var(--radius-sm);
  background: none; border: 1px solid transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.date-pick .d { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.date-pick svg { flex: 0 0 auto; }
.date-pick[aria-expanded="true"] { background: var(--surface-2); border-color: var(--accent); }
.date-pick:hover { background: var(--surface-2); border-color: var(--border); }
.date-pick svg { width: 1.05rem; height: 1.05rem; color: var(--muted); }
.date-pick:hover svg { color: var(--accent-ink); }
body.history .date-pick { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* header calendar */
.cal {
  position: absolute; top: calc(100% + 0.7rem); right: 0; z-index: 20; width: 22rem; padding: 0.9rem; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: cal-in .15s ease;
}
@keyframes cal-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cal[hidden] { display: none; }
.cal-h { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.cal-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: baseline; gap: 0.5rem; }
.cal-load { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.cal-nav { width: 2rem; height: 2rem; box-shadow: none; }
.cal-nav svg { width: 1rem; height: 1rem; }
.cal-nav:disabled { opacity: 0.35; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.2rem; }
.cal-grid b { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-align: center; padding: 0.2rem 0 0.35rem; text-transform: uppercase; letter-spacing: 0.04em; }
.cal-d {
  position: relative; height: 2.5rem; border-radius: var(--radius-sm); border: 1px solid transparent; background: none;
  font: inherit; font-size: 0.95rem; font-weight: 600; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; padding: 0;
}
.cal-d i { width: 0.36rem; height: 0.36rem; border-radius: 50%; background: var(--accent); }
.cal-d:hover { background: var(--surface-2); border-color: var(--border); }
.cal-d:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-d.off { color: var(--muted); font-weight: 500; }
.cal-d.today { border-color: var(--axis); }
.cal-d.sel { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cal-d.sel i { background: var(--on-accent); }
.cal-d:disabled { color: var(--axis); cursor: default; background: none; border-color: transparent; }
.cal-f { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--grid); }
.cal-key { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.cal-key i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--accent); margin-right: 0.3rem; }
.cal-btns { display: flex; gap: 0.4rem; }
.cal-btns .btn { font-size: 0.85rem; padding: 0.35rem 0.7rem; box-shadow: none; }
.hdr-live-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent-ink); cursor: pointer; }
.hdr-live-btn:hover { text-decoration: underline; }
.hdr-clock { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding-left: 1.2rem; border-left: 1px solid var(--border); }
.hdr-actions { display: flex; gap: 0.5rem; }
:root:not([data-theme="dark"]) .tv-header { background: linear-gradient(180deg, #ffffff, #f5f9fc); border-bottom-color: var(--border); }
:root:not([data-theme="dark"]) .seg { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, transparent); }
:root:not([data-theme="dark"]) .seg a { color: var(--accent-ink); }
:root:not([data-theme="dark"]) .seg a.on { color: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .tv-header { background: var(--surface); }
  :root:not([data-theme]) .seg { background: var(--surface-2); border-color: var(--border); }
  :root:not([data-theme]) .seg a { color: var(--ink-2); }
}
.kiosk .seg, .kiosk .hdr-actions, .kiosk .date-btn, .kiosk .date-pick svg, .kiosk .slide-ctrl, .kiosk .pseg { display: none; }
.kiosk .date-pick { pointer-events: none; }
.kiosk .tv { cursor: none; }

/* More people or departments than fit? The main area scrolls instead of squeezing everything. */
.tv-main { flex: 1 1 auto; min-height: 0; padding: 1.4rem 2rem; overflow: auto; scrollbar-width: thin; }
.tv-footer {
  flex: 0 0 auto; display: flex; gap: 1.6rem; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 0.6rem 2rem; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--border); background: var(--surface);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend-swatch { width: 0.8rem; height: 0.8rem; border-radius: 3px; }

/* ---------- Status ---------- */
.st { display: inline-flex; align-items: center; gap: 0.3em; font-weight: 700; }
.st-good { color: var(--good-ink); } .st-warning { color: var(--warning-ink); } .st-critical { color: var(--critical-ink); } .st-none { color: var(--none-ink); }
.bg-good { background: var(--good); } .bg-warning { background: var(--warning); } .bg-critical { background: var(--critical); } .bg-none { background: var(--none); }
.pill {
  display: inline-flex; align-items: center; gap: 0.35em; padding: 0.22em 0.65em; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; white-space: nowrap; line-height: 1.3;
}
.pill svg { width: 0.95em; height: 0.95em; }
.pill-good { background: var(--good-soft); color: var(--good-ink); }
.pill-warning { background: var(--warning-soft); color: var(--warning-ink); }
.pill-critical { background: var(--critical-soft); color: var(--critical-ink); }
.pill-none { background: var(--none-soft); color: var(--none-ink); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-title { font-size: 1.15rem; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-sub { font-size: 0.9rem; color: var(--muted); }
.dept-dot { display: inline-block; width: 0.62em; height: 0.62em; border-radius: 3px; margin-right: 0.45em; vertical-align: 0.04em; flex: 0 0 auto; }
/* one or more departments: "■ Sheets  ■ Sets" */
.dept-lbl { display: inline-flex; align-items: center; white-space: nowrap; }
.dept-lbl + .dept-lbl { margin-left: 0.8em; }

/* progress bar (value vs target) */
.bar { position: relative; height: 0.6rem; background: var(--surface-3); border-radius: 999px; overflow: visible; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.bar .tgt { position: absolute; top: -0.25rem; bottom: -0.25rem; width: 2px; border-radius: 2px; background: var(--ink); opacity: .55; }

/* ---------- Trend chart ---------- */
.tc { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.tc-plot { position: relative; flex: 1; min-height: 0; margin: 0.9rem 0 0 3rem; }
.tc.mini .tc-plot { margin: 0.35rem 0.35rem 0.1rem; }
.tc-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tc-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.tc-grid span { position: absolute; right: calc(100% + 0.5rem); top: -0.6em; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tc-target { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--axis); z-index: 1; }
.tc.mini .tc-target { border-top-width: 1px; }
.tc-target span { position: absolute; right: calc(100% + 0.5rem); top: -0.75em; font-size: 0.8rem; font-weight: 700; color: var(--ink-2); text-align: right; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tc-target span b { display: block; font-size: 0.62rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tc-dot { position: absolute; width: 0.55rem; height: 0.55rem; margin: 0 0 -0.275rem -0.275rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--lc); z-index: 2; }
.tc-dot.last { width: 0.9rem; height: 0.9rem; margin: 0 0 -0.45rem -0.45rem; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--c); }
.tc.mini .tc-dot.last { width: 0.6rem; height: 0.6rem; margin: 0 0 -0.3rem -0.3rem; border-width: 2px; box-shadow: 0 0 0 1.5px var(--c); }
.tc-val { position: absolute; transform: translate(-50%, -0.9rem); font-size: 1rem; font-weight: 700; z-index: 3; background: var(--surface); padding: 0 0.3rem; border-radius: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; margin-bottom: 0.2rem; }
.tc-x { position: relative; height: 1.5rem; margin-left: 3rem; border-top: 1px solid var(--axis); }
.tc-x span { position: absolute; top: 0.35rem; transform: translateX(-50%); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

/* ---------- Person profile (slideshow + team grid) ---------- */
.panel { padding: 1.4rem 1.6rem; display: flex; flex-direction: column; min-height: 0; }
.ps { display: grid; gap: 1.3rem; grid-template-columns: 1fr 1.3fr; grid-template-rows: auto minmax(0, 1fr); }
.ps-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 1.6rem; padding: 1.4rem 1.8rem; }
.ps-id { min-width: 0; }
.ps-name { font-size: 3.6rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; }
.ps-dept { font-size: 1.2rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; margin-top: 0.3rem; font-weight: 500; }
.ps-score { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; }
.ps-score .big { font-size: 5.6rem; font-weight: 800; line-height: 0.9; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-score .big small { font-size: 1.4rem; font-weight: 600; letter-spacing: 0; color: var(--muted); margin-left: 0.5rem; }
.ps-score .pill { font-size: 1.1rem; }
.ps-mini { display: flex; gap: 2.2rem; padding-left: 2.2rem; margin-left: 1.2rem; border-left: 1px solid var(--border); }
.ps-mini div { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.ps-mini b { display: block; font-size: 2rem; color: var(--ink); letter-spacing: -0.02em; text-transform: none; font-variant-numeric: tabular-nums; }
.tasks { display: flex; flex-direction: column; gap: 1.5rem; }
.task-h { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 1.3rem; margin-bottom: 0.55rem; font-weight: 500; }
.task-h b { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.task-h .of { color: var(--muted); font-variant-numeric: tabular-nums; }
.tasks .bar { height: 0.9rem; }
.chart-area { flex: 1; position: relative; min-height: 0; }
.cols7 { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1.1rem; }
.c7 { display: flex; flex-direction: column; height: 100%; text-align: center; }
.c7-track { flex: 1; position: relative; }
.c7-b { position: absolute; left: 14%; right: 14%; bottom: 0; border-radius: 8px 8px 2px 2px; min-height: 2px; background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 70%); transition: height .6s cubic-bezier(.2,.7,.2,1); }
.c7-v { position: absolute; left: 0; right: 0; font-size: 1.3rem; font-weight: 700; z-index: 1; font-variant-numeric: tabular-nums; }
.cols7.n8 { gap: 0.8rem; } .cols7.n12 { gap: 0.5rem; }
.cols7.n12 .c7-v { font-size: 1rem; } .cols7.n12 .c7-d { font-size: 0.85rem; } .cols7.n12 .c7-b { left: 8%; right: 8%; }
.pseg { display: inline-flex; padding: 0.2rem; gap: 0.15rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0.6rem; flex: 0 0 auto; }
.pseg button { background: none; border: 0; padding: 0.3rem 0.7rem; border-radius: 0.45rem; font: inherit; font-size: 0.85rem; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.pseg button:hover { color: var(--ink); }
.pseg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.pseg button .dept-dot { margin-right: 0.35em; }
.pbtns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.task-h > span:first-child { display: flex; align-items: center; }
.card-h .card-title .card-sub { font-weight: 400; }
.c7-v span { background: var(--surface); padding: 0 0.3rem; border-radius: 4px; }
.c7-t { position: absolute; left: -0.55rem; right: -0.55rem; border-top: 2px dashed var(--axis); }
.c7-d { font-size: 1rem; color: var(--muted); padding-top: 0.55rem; border-top: 1px solid var(--axis); font-weight: 500; }
.c7.today .c7-d { color: var(--ink); font-weight: 700; }
.chart-fill { flex: 1; min-height: 8rem; display: flex; }
.note { color: var(--muted); font-size: 0.95rem; margin-top: 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.note .dash { width: 1.6rem; border-top: 2px dashed var(--axis); }

/* ---------- Avatars ---------- */
.av {
  --size: 2.6rem;
  position: relative; display: inline-grid; place-items: center; flex: 0 0 auto;
  width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden;
  background: linear-gradient(140deg, color-mix(in srgb, var(--dc) 82%, #fff), var(--dc));
  color: #fff; font-weight: 700; font-size: calc(var(--size) * 0.38); letter-spacing: 0.02em;
  box-shadow: 0 0 0 2px var(--surface), 0 1px 3px rgba(0, 0, 0, 0.18);
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring-c); }
.ring-good { --ring-c: var(--good); } .ring-warning { --ring-c: var(--warning); } .ring-critical { --ring-c: var(--critical); } .ring-none { --ring-c: var(--none); }
.av.sm { --size: 2rem; } .av.md { --size: 3rem; } .av.lg { --size: 3.4rem; }
.av.xl { --size: 7rem; border-radius: 1.6rem; }
.av.xl.ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--ring-c); }

.empty { color: var(--muted); text-align: center; padding: 3rem; font-size: 1.2rem; }
/* setup / connection problem shown over the TV screens */
.load-problem {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 30; max-width: min(40rem, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--warning); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 1.4rem 1.6rem; font-size: 1.1rem; line-height: 1.5; text-align: center;
}
.muted { color: var(--muted); }

/* ---------- Sign in (start page) ---------- */
.signin-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)); position: relative; font-size: 15px; }
.signin-theme { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; }
.signin { width: 100%; max-width: 400px; padding: 32px; box-shadow: var(--shadow-lg); }
.signin .brand-mark { width: 72px; height: 72px; border-radius: 18px; padding: 4px; margin-bottom: 18px; }
.signin h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.signin .hint { color: var(--muted); font-size: 14px; margin: 14px 0 0; }
.signin label.f { display: block; font-size: 13px; font-weight: 600; margin: 18px 0 6px; color: var(--ink-2); }
.signin input[type="text"], .signin input[type="password"] {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--axis); border-radius: 10px;
}
.signin input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.signin .keep { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.signin .keep input { width: 18px; height: 18px; accent-color: var(--accent); }
.signin .err { color: var(--critical-ink); min-height: 1.4em; font-size: 14px; margin-top: 10px; }
.signin .btn.primary { width: 100%; min-height: 48px; margin-top: 8px; font-size: 16px; }
/* company name, led by three short pink bars like the ones in the logo */
.company { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.company::before { content: ""; flex: 0 0 auto; width: 16px; height: 10px; background: repeating-linear-gradient(180deg, var(--brand-pink) 0 2px, transparent 2px 4px); }
.who-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: -16px 0 20px; color: var(--muted); font-size: 14px; }
.who-bar b { color: var(--ink); }
/* small "Privacy policy" link (sign-in page, employee page) */
.pp-link { text-align: center; margin: 16px 0 calc(8px + env(safe-area-inset-bottom, 0px)); font-size: 13px; }
.pp-link a { color: var(--muted); }

/* ---------- Notification cards (employee page, admin bell): colour band + icon + label by what happened ---------- */
.nt { --t: var(--accent); --ti: var(--accent-ink); --ts: var(--accent-soft);
  display: flex; align-items: flex-start; gap: 12px; text-align: left; padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--t); border-radius: 12px; }
.nt.tone-good     { --t: var(--good);     --ti: var(--good-ink);     --ts: var(--good-soft); }
.nt.tone-warning  { --t: var(--warning);  --ti: var(--warning-ink);  --ts: var(--warning-soft); }
.nt.tone-critical { --t: var(--critical); --ti: var(--critical-ink); --ts: var(--critical-soft); }
.nt.tone-violet   { --t: #8b5cf6; --ti: #7c3aed; --ts: color-mix(in srgb, #8b5cf6 13%, var(--surface)); }
.nt.tone-none     { --t: var(--none);     --ti: var(--none-ink);     --ts: var(--none-soft); }
:root[data-theme="dark"] .nt.tone-violet { --ti: #b49cfb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nt.tone-violet { --ti: #b49cfb; } }
.nt.new { background: color-mix(in srgb, var(--ts) 70%, var(--surface)); border-color: color-mix(in srgb, var(--t) 45%, var(--border)); border-left-color: var(--t); }
.nt-ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ts); color: var(--ti); }
.nt-ic svg { width: 18px; height: 18px; }
.nt-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.nt-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nt-h b { color: var(--ink); }
.nt-tag { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ti); background: var(--ts); border: 1px solid color-mix(in srgb, var(--t) 35%, transparent); padding: 1px 7px; border-radius: 999px; }
.nt-b { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; }
.nt small { color: var(--muted); font-size: 12px; }
.nt-new { font-style: normal; font-weight: 700; color: var(--ti); }
.nt:not(.new) { opacity: .92; }
button.nt { font: inherit; color: inherit; width: 100%; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
button.nt:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--t) 60%, var(--border)); border-left-color: var(--t); }

/* ---------- Landing ---------- */
.landing { max-width: 1040px; margin: 0 auto; padding: 56px 20px; font-size: 15px; }
.landing-top { display: flex; align-items: center; gap: 20px; margin-bottom: 40px; }
.landing-top .brand-mark { width: 84px; height: 84px; border-radius: 20px; padding: 5px; box-shadow: var(--shadow-lg); }
.landing-id { flex: 1; min-width: 0; }
.landing h1 { font-size: 32px; margin: 0; letter-spacing: -0.025em; line-height: 1.1; }
.landing p.sub { color: var(--muted); margin: 8px 0 0; font-size: 15px; }
.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.links a {
  display: flex; flex-direction: column; gap: 10px; padding: 22px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.links a:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.links .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.links .ico svg { width: 20px; height: 20px; }
.links b { font-size: 16px; }
.links span { color: var(--muted); font-size: 14px; line-height: 1.45; }
.landing .tips { margin-top: 32px; padding: 16px 20px; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.landing code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════
   Phones (≤ 720px) and tablets (721–1023px).
   The TV screens stop being a fixed 16:9 canvas: the page scrolls, the
   view switcher becomes a bottom navigation bar and the calendar a sheet.
   Nothing here applies at 1024px and wider.
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  html { font-size: 15px; }
  .tv { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .kiosk .tv { padding-bottom: 0; }
  .tv-main { overflow: visible; padding: 14px 16px 18px; }
  .tv-footer { gap: 6px 10px; padding: 10px 16px; font-size: 12px; justify-content: flex-start; }
  .tv-footer .legend-item { flex-basis: 100%; }

  /* header: brand + buttons, then the date on its own row; no clock / full screen */
  .tv-header { flex-wrap: wrap; gap: 10px 12px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .hdr-spacer, .hdr-clock, #fs-btn { display: none; }
  .brand { flex: 1 1 0; min-width: 0; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-title { font-size: 1.15rem; }
  .hdr-actions { order: 2; }
  .hdr-actions .icon-btn, .date-btn { width: 44px; height: 44px; }
  .hdr-date { order: 3; flex: 1 1 100%; position: static; text-align: left; display: flex; flex-direction: column; gap: 4px; }
  .hdr-day-row { justify-content: space-between; gap: 8px; }
  .date-pick { flex: 1 1 auto; width: auto; min-width: 0; min-height: 44px; border-color: var(--border); background: var(--surface-2); }
  .hdr-date .d { font-size: 1rem; }
  .hdr-date .s { padding-left: 2px; white-space: normal; }

  /* view switcher ➜ bottom navigation */
  .tv-header .seg, :root:not([data-theme="dark"]) .tv-header .seg, :root:not([data-theme]) .tv-header .seg {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--border); border-radius: 0;
    background: var(--surface); box-shadow: 0 -6px 18px -10px rgba(0, 0, 0, 0.35);
  }
  .tv-header .seg a, :root:not([data-theme="dark"]) .tv-header .seg a, :root:not([data-theme]) .tv-header .seg a {
    flex: 1 1 0; flex-direction: column; justify-content: center; gap: 3px; min-height: 50px; padding: 4px; border-radius: 12px;
    font-size: 12px; font-weight: 600; color: var(--muted); box-shadow: none; background: none;
  }
  .tv-header .seg a svg { width: 20px; height: 20px; }
  .tv-header .seg a.on, :root:not([data-theme="dark"]) .tv-header .seg a.on, :root:not([data-theme]) .tv-header .seg a.on { color: var(--accent-ink); background: var(--accent-soft); }
  .kiosk .tv-header .seg { display: none; }

  /* calendar ➜ bottom sheet over a dimmed page */
  .cal {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40; width: auto; max-width: 560px; margin: 0 auto;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); animation: sheet-in .2s ease;
  }
  .cal-d { height: 44px; font-size: 1rem; }
  .cal-nav { width: 44px; height: 44px; }
  .cal-btns .btn { min-height: 44px; padding: 0 16px; font-size: 0.95rem; }

  /* person profile: one column */
  .ps { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 12px; }
  .ps-head { flex-wrap: wrap; gap: 14px 16px; padding: 16px; }
  .ps-head > .av { order: 1; } .ps-id { order: 2; flex: 1 1 0; } .ps-score { order: 3; } .ps-mini { order: 4; }
  .av.xl { --size: 4.6rem; border-radius: 1.1rem; }
  .ps-name { font-size: 2rem; }
  .ps-dept { font-size: 0.95rem; }
  .ps-score { flex: 1 1 100%; margin-left: 0; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  .ps-score .big { font-size: 2.8rem; }
  .ps-score .big small { font-size: 1rem; }
  .ps-score .pill { font-size: 0.85rem; white-space: normal; text-align: right; }
  .ps-mini { flex: 1 1 100%; justify-content: space-between; gap: 12px; margin: 0; padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--border); }
  .ps-mini div { font-size: 0.7rem; }
  .ps-mini b { font-size: 1.4rem; }
  .panel { padding: 16px; }
  .card-h { flex-wrap: wrap; gap: 6px 12px; margin-bottom: 12px; }
  .card-title { font-size: 1.05rem; }
  .tasks { gap: 16px; }
  .task-h { flex-wrap: wrap; font-size: 1rem; gap: 4px 12px; }
  .task-h b { font-size: 1.25rem; }
  .chart-fill { flex: none; height: 13rem; }
  .chart-area { flex: none; height: 15rem; }
  .pbtns { justify-content: flex-start; width: 100%; }
  .pseg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .pseg button { min-height: 40px; white-space: nowrap; }
  .cols7 { gap: 0.4rem; }
  .c7-v { font-size: 0.95rem; }
  .c7-d { font-size: 0.78rem; }
  .note { font-size: 0.85rem; }
  .empty { padding: 2rem 1rem; font-size: 1rem; }

  /* chip rows that scroll sideways (department tabs on the TV pages) */
  .chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 2px 16px; scroll-snap-type: x proximity; scroll-padding: 0 16px; }
  .chip-row::-webkit-scrollbar { display: none; }
  .chip-row button {
    flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; scroll-snap-align: start;
    background: var(--surface); border: 1px solid var(--border); color: var(--ink-2); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  }
  .chip-row button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

  .landing { padding: calc(28px + env(safe-area-inset-top, 0px)) 16px calc(40px + env(safe-area-inset-bottom, 0px)); }
  .landing-top { margin-bottom: 24px; }
  .landing h1 { font-size: 24px; }
  .landing-top { align-items: flex-start; gap: 14px; }
  .landing-top .brand-mark { width: 64px; height: 64px; border-radius: 16px; }
  .landing .company { font-size: 11px; letter-spacing: 0.08em; }
  .links { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .links a { flex-direction: row; align-items: flex-start; gap: 14px; padding: 16px; display: grid; grid-template-columns: 40px 1fr; }
  .links a b { align-self: center; }
  .links a span { grid-column: 2; margin-top: -6px; }
  .landing .tips { font-size: 13px; }
}
@media (min-width: 721px) and (max-width: 1023px) {
  html { font-size: 16px; }
  .links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .brand-eyebrow { display: none; }
}
@media (max-width: 1023px) {
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

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