/* ESS Dashboard — brand tokens + base shell.
   Brand source: brand-guidelines-ess (60% main / 30% gray / 10% gold accent, WCAG AA).
   Dark-first: TVs run the dark theme; desktop/mobile share it for consistency. */

:root {
  /* main */
  --ess-black: #000000;
  --ess-navy: #222733;      /* Dark Blue Gray — primary surface */
  --ess-white: #ffffff;
  /* accents */
  --ess-gold: #c4a35a;      /* primary accent / highlights */
  --ess-bronze: #b08e58;
  --ess-slate: #404c59;     /* Dark Gray Blue — cards, dividers */
  --ess-gray: #7d868b;      /* Medium Gray — secondary text */
  /* semantic */
  --ok: #6fae7b;
  --warn: #d9a441;
  --bad: #c96a5a;

  --font-heading: 'South Korea Serif', 'Arial Black', Arial, sans-serif;
  --font-sub: 'Shibui', Arial, sans-serif;
  --font-body: 'Magallanes', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--ess-navy);
  color: var(--ess-white);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-wrap: anywhere;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

a { color: var(--ess-gold); }

/* ─── footer ─── */
.site-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
  color: var(--ess-gray);
  font-size: 0.8rem;
  border-top: 1px solid var(--ess-slate);
}
.footer-logo { height: 1.4rem; width: auto; opacity: 0.8; }

/* ─── landing page ─── */
.landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.25rem;
  gap: 1rem;
}
.landing-logo { width: min(320px, 70vw); height: auto; }
.landing h1 { font-size: clamp(2rem, 6vw, 3.5rem); }
.landing-sub { color: var(--ess-gold); font-size: clamp(1rem, 3vw, 1.4rem); margin: 0; text-transform: uppercase; letter-spacing: 0.12em; }
.landing-screens {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  color: var(--ess-gray);
  font-size: 1rem;
}
.landing-screens strong { color: var(--ess-white); }
.landing-note { color: var(--ess-gray); font-size: 0.85rem; }

/* ─── responsive breakpoint (inventory convention: single 992px break) ─── */
@media (min-width: 992px) {
  .landing-screens { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
}

@media print {
  body { background: var(--ess-white); color: var(--ess-black); }
  .site-footer { border-top-color: var(--ess-gray); }
}

/* ═══════════════════════════════════════════════════════════════════
   TV SHELL — the command board. Dark navy field with layered depth,
   structural gold hairlines, uppercase display headers. Readable at
   3 m on 1080p; degrades gracefully to desktop/mobile.
   ═══════════════════════════════════════════════════════════════════ */

body.tv {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(120% 90% at 50% -10%, #2b3140 0%, var(--ess-navy) 55%, #1a1e28 100%);
  position: relative;
}
body.tv::before {
  /* faint structural grain — diagonal hairlines, barely-there */
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    115deg,
    transparent 0px,
    transparent 34px,
    rgba(196, 163, 90, 0.025) 34px,
    rgba(196, 163, 90, 0.025) 35px
  );
}

.tv-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.1rem 2rem 0.9rem;
  border-bottom: 1px solid var(--ess-slate);
  position: relative;
}
.tv-head::after {
  /* gold signature rule under the header */
  content: '';
  position: absolute;
  left: 2rem;
  bottom: -1px;
  width: 7.5rem;
  height: 2px;
  background: linear-gradient(90deg, var(--ess-gold), transparent);
}
.tv-logo { height: clamp(2rem, 4.5vh, 3.2rem); width: auto; }
.tv-title {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: clamp(1.1rem, 3.2vh, 2rem);
  color: var(--ess-white);
}
.tv-right {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
}
.clock {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 3.2vh, 2rem);
  color: var(--ess-gold);
  letter-spacing: 0.06em;
}
.freshness {
  font-size: clamp(0.65rem, 1.6vh, 0.85rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.3em 0.75em;
  border: 1px solid var(--ess-slate);
  color: var(--ess-gray);
}
.freshness--ok { color: var(--ok); border-color: var(--ok); }
.freshness--warn { color: var(--warn); border-color: var(--warn); animation: fresh-pulse 3s ease-in-out infinite; }
.freshness--bad { color: var(--bad); border-color: var(--bad); animation: fresh-pulse 1.6s ease-in-out infinite; }
@keyframes fresh-pulse { 50% { opacity: 0.45; } }

.tv-stage {
  padding: 1.4rem 2rem 0.8rem;
  min-height: 0;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.stage--out { opacity: 0; transform: translateY(0.5rem); }

.tv-foot {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.55rem 2rem calc(0.55rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ess-slate);
  color: var(--ess-gray);
  font-size: clamp(0.6rem, 1.5vh, 0.8rem);
  letter-spacing: 0.08em;
}
.tv-company { margin-left: auto; text-transform: uppercase; }
.rotation-dots { display: flex; gap: 0.45rem; }
.dot {
  width: 0.5rem; height: 0.5rem;
  background: var(--ess-slate);
  transform: rotate(45deg);   /* diamond — squares are for other companies */
  transition: background 0.3s ease;
}
.dot--on { background: var(--ess-gold); }

/* ── screens: shared chrome ── */
.screen { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.screen-head {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 0.9rem;
}
.screen-head h2 {
  font-size: clamp(1.3rem, 3.6vh, 2.2rem);
  color: var(--ess-gold);
}
.screen-stats { display: flex; gap: 1.4rem; margin-left: auto; }
.stat {
  font-size: clamp(0.75rem, 2vh, 1rem);
  color: var(--ess-gray);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.stat strong { color: var(--ess-white); font-size: 1.25em; margin-right: 0.3em; }
.stat--warn strong { color: var(--warn); }
.stat--dim { opacity: 0.6; }

.pages { flex: 1; min-height: 0; position: relative; }
.page { display: none; height: 100%; }
.page--on, .pages[data-pages="1"] .page { display: block; animation: page-in 0.35s ease; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
.empty-state { color: var(--ess-gray); font-size: clamp(1rem, 2.6vh, 1.4rem); padding: 2rem 0; }
.dim { color: var(--ess-gray); }

/* ── board tables (jobs + aging) ── */
.board {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.85rem, 2.35vh, 1.25rem);
}
.board th {
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66em;
  color: var(--ess-gray);
  padding: 0 0.75rem 0.45rem;
  border-bottom: 1px solid var(--ess-gold);
}
.board td {
  padding: 0.42em 0.75rem;
  border-bottom: 1px solid rgba(64, 76, 89, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}
.board td.col-job { width: 38%; }
.board .num, .board th.num { text-align: right; }
.row--overdue td { background: rgba(201, 106, 90, 0.08); }

.job-chip {
  display: inline-block;
  width: 0.55em; height: 0.55em;
  margin-right: 0.55em;
  transform: rotate(45deg);
  vertical-align: baseline;
}
.job-name { color: var(--ess-white); font-weight: 600; }
.job-city { color: var(--ess-gray); margin-left: 0.6em; font-size: 0.8em; }

.phase { display: flex; align-items: center; gap: 0.6em; }
.phase-title { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.phase-pct { color: var(--ess-gray); font-size: 0.8em; min-width: 2.6em; text-align: right; }
.meter {
  flex: 1 0 3.5em;
  height: 0.45em;
  background: rgba(64, 76, 89, 0.6);
  overflow: hidden;
}
.meter-fill { height: 100%; background: linear-gradient(90deg, var(--ess-bronze), var(--ess-gold)); }
.due--overdue { color: var(--bad); font-weight: 700; }
.due--warn { color: var(--warn); font-weight: 600; }

/* ── leaderboard ladder ── */
.ladder {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.3rem, 1vh, 0.7rem);
  height: 100%;
  overflow: hidden;
}
.ladder-row {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: clamp(0.3rem, 1.2vh, 0.7rem) 1rem;
  border-left: 3px solid var(--ess-slate);
  background: rgba(0, 0, 0, 0.18);
}
.rank {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 4.5vh, 2.6rem);
  color: var(--ess-slate);
  min-width: 1.6em;
  text-align: center;
}
.rank--gold { border-left-color: var(--ess-gold); }
.rank--gold .rank { color: var(--ess-gold); }
.rank--bronze { border-left-color: var(--ess-bronze); }
.rank--bronze .rank { color: var(--ess-bronze); }
.rank--slate { border-left-color: var(--ess-gray); }
.rank--slate .rank { color: var(--ess-gray); }
.ladder-main { flex: 1; min-width: 0; }
.ladder-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.person { font-size: clamp(0.95rem, 2.7vh, 1.5rem); font-weight: 600; color: var(--ess-white); }
.sales {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 3vh, 1.7rem);
  color: var(--ess-gold);
  letter-spacing: 0.03em;
}
.ladder-bar { height: 0.35rem; background: rgba(64, 76, 89, 0.5); margin: 0.3em 0; }
.ladder-fill { height: 100%; background: linear-gradient(90deg, var(--ess-bronze), var(--ess-gold)); }
.ladder-meta { display: flex; gap: 1.4rem; color: var(--ess-gray); font-size: clamp(0.65rem, 1.7vh, 0.9rem); text-transform: uppercase; letter-spacing: 0.09em; }

/* ── accountability ── */
.aging-meter {
  display: flex;
  height: clamp(1.6rem, 4.5vh, 2.6rem);
  margin-bottom: 1rem;
  border: 1px solid var(--ess-slate);
}
.aging-seg {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  font-size: clamp(0.6rem, 1.7vh, 0.85rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ess-white);
}
.aging-seg span { padding: 0 0.5em; overflow: hidden; text-overflow: ellipsis; }
.b-current { background: rgba(64, 76, 89, 0.85); }
.b-30 { background: rgba(176, 142, 88, 0.55); }
.b-60 { background: rgba(196, 163, 90, 0.75); color: var(--ess-black); }
.b-90 { background: rgba(217, 164, 65, 0.85); color: var(--ess-black); }
.b-max { background: var(--bad); }

.board--aging td { padding: 0.5em 0.75rem; }
.receipts-panel {
  margin-top: auto;
  padding: 0.8rem 1rem;
  border: 1px solid var(--ess-slate);
  border-left: 3px solid var(--ess-gold);
  font-size: clamp(0.8rem, 2vh, 1.05rem);
}
.receipts-panel h3 {
  font-size: 0.75em;
  color: var(--ess-gold);
  letter-spacing: 0.16em;
  margin-bottom: 0.35em;
}
.receipts-panel--pending { border-left-color: var(--ess-gray); color: var(--ess-gray); }
.receipts-panel p { margin: 0; }

/* ── admin panel ── */
.admin, .admin-login {
  width: min(920px, 100% - 2rem);
  margin: 0 auto;
  padding: 2rem 0 3rem;
  flex: 1;
}
.admin-login { display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; padding-top: 4rem; }
.admin-login .landing-logo { width: min(240px, 60vw); }
.login-form { display: flex; flex-direction: column; gap: 0.9rem; width: min(320px, 100%); text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--ess-gray); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; }
.form-error { color: var(--bad); }

input, button {
  font: inherit;
  color: var(--ess-white);
}
input[type="text"], input[type="password"], input[type="number"], input:not([type]) {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--ess-slate);
  padding: 0.55em 0.75em;
}
input:focus { outline: 2px solid var(--ess-gold); outline-offset: 1px; }
.btn {
  background: var(--ess-gold);
  color: var(--ess-black);
  border: none;
  padding: 0.55em 1.2em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--ess-bronze); }
.btn--ghost { background: transparent; color: var(--ess-gold); border: 1px solid var(--ess-gold); font-weight: 400; }
.btn--ghost:hover { background: rgba(196, 163, 90, 0.15); }
.btn--danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); font-weight: 400; }
.btn--danger:hover { background: rgba(201, 106, 90, 0.15); }

.admin-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.admin-head h1 { color: var(--ess-gold); font-size: 1.6rem; }
.inline-form { display: inline-flex; align-items: baseline; gap: 0.75rem; }
.admin-section { margin-bottom: 2.2rem; }
.admin-section h2 { font-size: 1rem; color: var(--ess-gray); letter-spacing: 0.16em; margin-bottom: 0.8rem; border-bottom: 1px solid var(--ess-slate); padding-bottom: 0.4rem; }

.device-card {
  border: 1px solid var(--ess-slate);
  border-left: 3px solid var(--ess-gold);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.18);
}
.device-card--off { border-left-color: var(--ess-gray); opacity: 0.65; }
.device-card--new { border-left-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.device-row { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.device-row strong { font-size: 1.05rem; }
.device-row .inline-form:first-of-type { margin-left: auto; }
.device-url { margin: 0.5rem 0; font-size: 0.8rem; overflow-wrap: anywhere; }
.device-url code { color: var(--ess-gold); background: rgba(0,0,0,0.3); padding: 0.15em 0.4em; }
.device-url--new { color: var(--ok); }
.screen-config { display: flex; flex-wrap: wrap; gap: 0.8rem 1.6rem; align-items: center; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px dashed var(--ess-slate); }
.screen-config-row { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--ess-white); }
.screen-config-row input[type="number"] { width: 4.2em; padding: 0.25em 0.4em; }
.device-create { display: flex; gap: 0.8rem; margin-top: 1rem; }
.device-create input[name="name"] { flex: 1; }

.sync-panel p { margin: 0.35rem 0; }
.sync-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border: 1px solid var(--ess-slate);
  color: var(--ess-gray);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  margin-right: 0.6rem;
}
.sync-badge--ok { color: var(--ok); border-color: var(--ok); }
.sync-badge--bad { color: var(--bad); border-color: var(--bad); }
.sync-cookie { margin-top: 0.8rem; }
.sync-cookie summary { cursor: pointer; color: var(--ess-gold); }
.cookie-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; max-width: 640px; }
.cookie-form textarea {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--ess-slate);
  color: var(--ess-white);
  font: inherit;
  padding: 0.55em 0.75em;
  resize: vertical;
}
.cookie-form button { align-self: flex-start; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { text-align: left; color: var(--ess-gray); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; padding: 0.35em 0.6em; border-bottom: 1px solid var(--ess-gold); }
.admin-table td { padding: 0.4em 0.6em; border-bottom: 1px solid rgba(64, 76, 89, 0.5); }
.admin-table .num { text-align: right; }

/* ── sub-TV viewports (desktop windows, tablets, phones) ── */
@media (max-width: 991px) {
  body.tv { height: 100dvh; }
  .tv-head, .tv-stage, .tv-foot { padding-left: 1rem; padding-right: 1rem; }
  .tv-head::after { left: 1rem; }
  .screen-head { flex-wrap: wrap; gap: 0.5rem 1rem; }
  .screen-stats { margin-left: 0; flex-wrap: wrap; gap: 0.75rem; }
  .board td.col-pm, .board th.col-pm { display: none; }
  .job-city { display: none; }
  .ladder-meta { gap: 0.8rem; }
  .tv-company { display: none; }
}

