/* DASH — throughput dashboard. Plain CSS, no build step, theme-switchable for TV display. */

:root {
  --bg:        #eef1f6;
  --panel:     #ffffff;
  --panel-2:   #f6f8fb;
  --line:      #dbe1ea;
  --text:      #1a2233;
  --text-dim:  #5b6578;
  --accent:    #2c6fe0;
  --good:      #1f9d63;
  --warn:      #d98a10;
  --bad:       #d64545;

  --c-backlog: #7b8aa6;
  --c-cnc:     #e0812c;
  --c-hr:      #2c9fe0;
  --c-assy:    #6a4ce0;
  --c-output:  #1f9d63;

  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 8px 24px rgba(20, 30, 50, 0.06);
  --radius: 16px;
  --font-ui:   'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'SFMono-Regular', Menlo, monospace;
}

html[data-theme="night"] {
  --bg:        #0d1420;
  --panel:     #161f30;
  --panel-2:   #1c2740;
  --line:      #2a374f;
  --text:      #e7ecf5;
  --text-dim:  #93a1bb;
  --accent:    #5b9dff;
  --good:      #3ecf8e;
  --warn:      #f0ad3d;
  --bad:       #f0625f;

  --c-backlog: #8593ad;
  --c-cnc:     #ff9d47;
  --c-hr:      #4fb6ff;
  --c-assy:    #9b81ff;
  --c-output:  #3ecf8e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar .brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.topbar .brand small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.version-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-dim);
  vertical-align: middle;
}

.tabs { display: flex; gap: 6px; margin-left: 12px; }
.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.tab-btn:hover:not(.active) { background: var(--panel-2); }

.spacer { flex: 1; }

.updated {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

main { flex: 1; padding: 22px 28px 40px; }

.view { display: none; }
.view.active { display: block; }

/* ── Hourglass ─────────────────────────────────────────────────────── */

.hourglass-wrap {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 8px;
  margin-bottom: 22px;
}

.hourglass-svg { width: 100%; height: auto; display: block; }

.zone-label {
  font-size: 13px;
  font-weight: 700;
  fill: var(--text);
}
.zone-sub {
  font-size: 11px;
  fill: var(--text-dim);
  font-family: var(--font-mono);
}

/* ── Stat cards / trend row ────────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.card .big {
  font-size: 30px;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
}
.card .unit { font-size: 14px; color: var(--text-dim); font-weight: 600; margin-left: 4px; }

.trend-row { display: flex; align-items: flex-end; gap: 6px; height: 64px; margin-top: 10px; }
.trend-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trend-bar {
  width: 100%;
  border-radius: 4px 4px 2px 2px;
  background: var(--accent);
  min-height: 3px;
}
.trend-day { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
.trend-bar-wrap.today .trend-day { color: var(--text); font-weight: 700; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.pill.good { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill.bad  { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }

/* ── Money tab ─────────────────────────────────────────────────────────────
   Compact, flat, QBO-style KPI cards: a title row with a small right-aligned
   period tag, a moderate-size number, a one-line colored delta vs. last week,
   and a description pinned to the bottom — dense like a real accounting
   dashboard, not a wall of oversized hero numbers. Every tile variant shares
   this skeleton so numbers land on the same baseline across a row, and one
   fixed-column grid spans all four sections so card edges line up throughout
   the tab. */

.money-updated {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-bottom: 16px;
}

.money-section { margin-bottom: 22px; }
.money-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.money-section h2::before {
  content: '';
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

.money-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.money-tile {
  display: flex;
  flex-direction: column;
  min-height: 148px;
  padding: 16px 18px;
  border-radius: 10px;
  box-shadow: none;
  border: 1px solid var(--line);
}

.money-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}

.money-tile h3 {
  margin: 0;
  line-height: 1.35;
}

.money-period {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}

.money-tile .big {
  font-family: var(--font-ui);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 2px 0 3px;
}

.money-delta-row { min-height: 16px; font-size: 12px; font-family: var(--font-mono); }
.money-delta.good { color: var(--good); }
.money-delta.bad  { color: var(--bad); }
.money-delta.flat { color: var(--text-dim); }

.money-tile .cap-readout {
  margin-top: auto;
  padding-top: 8px;
  font-size: 12px;
}

.money-unavailable { opacity: 0.55; }
.money-unavailable .cap-readout { margin-top: 0; padding-top: 0; border-top: none; }

.badge-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  flex: none;
}

@media (max-width: 1180px) { .money-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px)  { .money-grid { grid-template-columns: 1fr; } }

/* ── Settings ──────────────────────────────────────────────────────── */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.field-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.field-row label { flex: 1; color: var(--text-dim); font-size: 13px; }
.field-row input {
  width: 100px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
}
.field-row input[type="text"] { width: 160px; }

.cap-readout {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.btn {
  border: none;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
}
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }

.save-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.save-msg { font-size: 13px; color: var(--good); font-weight: 600; }

/* ── Calendar ──────────────────────────────────────────────────────── */

.cal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.cal-header h2 { margin: 0; font-size: 20px; min-width: 200px; text-align: center; }
.cal-nav-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  width: 36px; height: 36px;
  font-size: 16px;
  cursor: pointer;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  padding-bottom: 4px;
}
.cal-cell {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-height: 108px;
  padding: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.other-month { opacity: 0.35; }
.cal-cell.weekend { background: var(--panel-2); box-shadow: none; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell .cal-daynum { font-weight: 800; font-size: 14px; }
.cal-cell .cal-cap-line {
  font-size: 10px;
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
}
.cal-cell .cal-note { font-size: 10px; color: var(--warn); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-cell.closed { display: flex; align-items: center; justify-content: center; }
.cal-cell.closed .cal-open-hint { font-size: 10px; color: var(--text-dim); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 22, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: 420px;
  max-width: 92vw;
}
.modal h3 { margin-top: 0; }
.modal .field-row input { width: 90px; }
.modal-actions { display: flex; justify-content: space-between; margin-top: 18px; }

footer.tv-footer {
  text-align: center;
  padding: 10px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .cal-grid { grid-template-columns: repeat(7, minmax(0,1fr)); }
  .cal-cell { min-height: 76px; font-size: 11px; }
}
