/* ============================================================
   Live Zoho Desk — Swiss Industrial Print wall display
   IBM Plex Sans · industrial paper/CRT · rectilinear · light+dark
   Hairline borders · grid gap:1px · noise texture · syntax framing
   Red/amber/green are FUNCTIONAL severity (kept).
   Layout is locked to 1920×1080 and scaled to fit any screen.
   ============================================================ */

:root {
  /* Industrial unbleached paper — light (default) */
  --bg: #F7F6F3;
  --surface: #EFEEEA;
  --surface-2: #E3E2DB;
  --border: #DBD9D2;
  --border-strong: #CECCC4;
  --text: #111111;
  --text-2: rgba(17, 17, 17, 0.78);
  --text-3: #5D5D58;

  /* Functional severity (ops triage) */
  --green: #137333;
  --amber: #8A5A00;
  --amber-deep: #704D00;
  --red: #B3261E;

  /* Hazard/aviation red — structural accent */
  --accent: #c8102e;

  --font: 'IBM Plex Sans', 'Hanken Grotesk', 'Barlow', 'Host Grotesk', 'DM Sans', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;        /* deactivated CRT */
    --surface: #19191D;
    --surface-2: #252529;
    --border: #2C2C30;
    --border-strong: #3A3A3E;
    --text: #EAEAEA;       /* white phosphor */
    --text-2: rgba(234, 234, 234, 0.85);
    --text-3: rgba(234, 234, 234, 0.65);

    --green: #3fb950;
    --amber: #d29922;
    --amber-deep: #cca300;
    --red: #f85149;
    --accent: #c8102e;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  color-scheme: light dark;
  font-size: 16px;
}

html, body {
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Kiosk frame — centers the 1920×1080 design on any viewport */
#kiosk-frame {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
}

#kiosk {
  width: 1920px;
  height: 1080px;
  position: relative;
  transform-origin: center center;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Industrial noise/grain overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  body::after { mix-blend-mode: screen; opacity: 0.035; }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  height: 86px;
}

.title {
  font-weight: 300;
  font-size: 1.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 300;
  color: var(--text-2);
  margin-left: auto;
}

/* Staleness pill — color reflects functional status */
.pill {
  padding: 0.4rem 1rem;
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface-2);
  outline: 1px solid var(--border-strong);
  outline-offset: -1px;
  color: var(--text-2);
}
.pill.green { color: var(--green); outline-color: var(--green); }
.pill.amber { color: var(--amber); outline-color: var(--amber); }
.pill.red   { color: var(--red);   outline-color: var(--red); }

.refresh-readout {
  color: var(--text-3);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* View dots */
.dots { display: flex; gap: 0.4rem; }
.dot {
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  outline: 1px solid transparent;
  outline-offset: -1px;
  cursor: default;
  touch-action: manipulation;
}
.dot:focus-visible, .table-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dot.active {
  color: var(--text);
  background: var(--bg);
  outline-color: var(--text);
}

/* ---------- Views (opacity toggle, no repaint flash) ---------- */
#main { position: relative; height: 972px; }

.view {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 2rem 2.5rem;
  flex-direction: column;
  gap: 1.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.6s;
}
.view.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.6s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}

.view-title {
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.view-title[data-frame]::before { content: "[ "; font-weight: 400; color: var(--text-3); }
.view-title[data-frame]::after  { content: " ]"; font-weight: 400; color: var(--text-3); }

/* ---------- OPS KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  height: 28%;
}
.kpi-card {
  background: var(--surface);
  border: none;
  outline: none;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-top: 4px solid var(--border-strong);
  overflow: hidden;
  min-width: 0;
}
.kpi-card.green { border-top-color: var(--green); }
.kpi-card.amber { border-top-color: var(--amber); }
.kpi-card.red   { border-top-color: var(--red); }
.kpi-label {
  font-size: 0.95rem;
  color: var(--text-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}
.kpi-value {
  font-weight: 300;
  font-size: 7rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: -0.03em;
}
.kpi-value.green { color: var(--green); }
.kpi-value.amber { color: var(--amber); }
.kpi-value.red   { color: var(--red); }
.kpi-value.compact { font-size: 3.75rem; letter-spacing: -0.05em; }
.kpi-sub { font-size: 1rem; color: var(--text-2); margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 0.06em; }

.ops-lower {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 1.25rem;
  flex: 1;
  min-height: 0;
}
.aging-card, .table-card {
  background: var(--surface);
  outline: 1px solid var(--border);
  outline-offset: -1px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
h3 {
  font-size: 1.05rem;
  color: var(--text-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
  font-weight: 600;
}

.aging-bar { display: flex; flex-direction: column; gap: 0.8rem; justify-content: center; flex: 1; }
.aging-row { display: flex; align-items: center; gap: 0.75rem; }
.aging-row .lbl { width: 70px; font-size: 1rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.aging-row .track { flex: 1; height: 26px; background: var(--surface-2); border-radius: 0; overflow: hidden; }
.aging-row .fill { height: 100%; border-radius: 0; transition: width 0.4s ease; }
.aging-row .val { width: 48px; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- AGENTS view ---------- */
#view-agents .kpi-grid { height: 26%; }
#view-agents .table-scroll { overflow-y: auto; }
#agents-table thead th {
  font-size: 0.95rem;
  padding: 0.55rem 0.5rem;
}
#agents-table tbody td {
  padding: 0.7rem 0.5rem;
  font-size: 1.15rem;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 1.1rem; }
thead th {
  text-align: left;
  color: var(--text-3);
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  border-bottom: 2px solid var(--border-strong);
  position: sticky;
  top: 0;
  background: var(--surface);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.95rem;
}
tbody td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--text) 3%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.green { color: var(--green); font-weight: 500; }
td.amber { color: var(--amber); font-weight: 500; }
td.red   { color: var(--red);   font-weight: 500; }

.table-card { overflow: hidden; }
.table-body { flex: 1; overflow-y: auto; min-height: 0; }
.table-scroll { flex: 1; overflow: hidden; background: var(--surface); outline: 1px solid var(--border); outline-offset: -1px; padding: 0.75rem 1.25rem; }

/* ---------- Trends charts ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; flex: 1; min-height: 0; }
.chart-card {
  background: var(--surface);
  outline: 1px solid var(--border);
  outline-offset: -1px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 100%;
  overflow: hidden;
}
.chart-card canvas { flex: 1; min-height: 0; max-width: 100%; max-height: 100%; }
.chart-unavailable {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  color: var(--text-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Footer ---------- */
.footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0.5rem 2.5rem;
  font-size: 0.9rem;
  color: var(--text-2);
  letter-spacing: 0.04em;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: 22px;
  display: flex;
  align-items: center;
}

/* ---------- QUALITY chart fill ---------- */
#view-quality .charts { grid-template-columns: 1fr; }

/* ---------- QUALITY + REPLY kpi-value sizing ---------- */
/* 5-card grids at 9rem overflow the 1920px layout; drop to 7rem */
#view-quality .kpi-value,
#view-reply .kpi-value { font-size: 7rem; }
#view-quality .kpi-value.compact,
#view-reply .kpi-value.compact { font-size: 3.75rem; }
#view-quality .kpi-value.compact,
#view-reply .kpi-value.compact { font-size: 3.75rem; }

/* ---------- CLIENTS KPI strip ---------- */
#view-clients .kpi-grid { height: 26%; }

/* ---------- Fixed wall-display window label ---------- */
.window-note {
  align-self: flex-start;
  color: var(--text-3);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.65rem;
  outline: 1px solid var(--border-strong);
  outline-offset: -1px;
  pointer-events: none;
}


/* ---------- Kiosk staleness overlay ---------- */
.stale #main { opacity: 0.55; transition: opacity 0.5s; }
.stale .view.active { outline: 4px solid var(--red); outline-offset: -4px; }
.stale .dot:focus-visible, .table-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dot.active { outline-color: var(--red); color: var(--red); }

/* ---------- Daily performance ---------- */
#view-daily .kpi-grid { grid-template-columns: repeat(3, 1fr); height: 30%; }
#view-daily .kpi-value { font-size: 9rem; }
#view-daily .kpi-value.compact { font-size: 5rem; }
#view-daily .kpi-sub { font-size: 1.2rem; }
#view-daily .table-scroll { flex: 1; }

/* ---------- Leaderboard ---------- */
#view-leader table { font-size: 1.4rem; }
#view-leader tbody td:first-child { color: var(--text-3); font-weight: 400; }

/* ---------- Motion safety ---------- */
@media (prefers-reduced-motion: reduce) {
  .aging-row .fill { transition: none; }
}



