/* =============================================================================
 * 3DTSI Operations Status Board — style.css
 * High-contrast dark "operations command center" theme. Tuned for 1920x1080
 * and 4K TVs: large type, heavy color coding, readable from across a room.
 * ========================================================================== */

:root {
  --bg:        #070b14;
  --bg-2:      #0c1220;
  --panel:     #111a2b;
  --panel-2:   #16233a;
  --line:      #1f2e47;
  --text:      #e8eef7;
  --text-dim:  #9fb0c8;
  --text-mute: #64748b;
  --good:    #1fb96e;
  --caution: #f2c14e;
  --risk:    #f08c2e;
  --urgent:  #e23b4e;
  --info:    #2f9be0;
  --idle:    #8a93a6;
  --accent:  #38bdf8;
  --radius: 14px;
  --gap: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 800px at 70% -10%, #0e1a30 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

/* ---------------- App shell ---------------- */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 22px;
  background: linear-gradient(180deg, #0b1320, #0a111d);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo {
  width: 46px; height: 46px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #1d6fd6);
  display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #04121f;
  box-shadow: 0 0 22px rgba(56,189,248,.35);
}
.brand .name { font-size: 20px; font-weight: 800; letter-spacing: .4px; }
.brand .tag { font-size: 12px; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; }

.topbar .spacer { flex: 1; }
.clock { text-align: right; line-height: 1.15; }
.clock #clock-time { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.clock .row2 { display: flex; gap: 12px; justify-content: flex-end; font-size: 12px; color: var(--text-dim); }
.badge-week { color: var(--accent); font-weight: 700; }

#freshness {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 700;
  border: 1px solid var(--line);
}
#freshness[data-status="good"]    { color: var(--good);    border-color: var(--good); }
#freshness[data-status="caution"] { color: var(--caution); border-color: var(--caution); }
#freshness[data-status="urgent"]  { color: var(--urgent);  border-color: var(--urgent); }
#freshness[data-status="idle"]    { color: var(--idle);    border-color: var(--idle); }

.controls { display: flex; gap: 8px; }
.controls button, .linkbtn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 13px; font-size: 13px; font-weight: 600;
  text-decoration: none; display: inline-flex; align-items: center;
}
.controls button:hover, .linkbtn:hover { border-color: var(--accent); color: #fff; }

/* ---------------- Stage (rotating sections) ---------------- */
.stage-wrap { flex: 1; position: relative; overflow: hidden; padding: 18px 22px 6px; }
#stage { height: 100%; }
.section { height: 100%; display: flex; flex-direction: column; }
.fade-in { animation: fade .6s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 14px; flex: 0 0 auto; }
.section-head h2 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: .3px; }
.section-meta { color: var(--text-dim); font-size: 14px; }
.legend { display: flex; gap: 16px; margin-left: auto; align-items: center; }
.legend-item { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-item::before { content: ''; width: 12px; height: 12px; border-radius: 3px; background: var(--c); box-shadow: 0 0 8px var(--c); }

/* ---------------- KPI grid (Section A) ---------------- */
.kpi-grid {
  display: grid; gap: var(--gap); flex: 1;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
}
.kpi {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-left: 5px solid var(--c, var(--info));
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; justify-content: center;
  box-shadow: inset 0 0 30px rgba(0,0,0,.25);
}
.kpi-label { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.kpi-value { font-size: clamp(28px, 3.2vw, 52px); font-weight: 800; line-height: 1.05; color: var(--c, var(--text)); font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-mute); }

/* ---------------- Badges / chips / bars ---------------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .3px;
  color: var(--c); border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  white-space: nowrap;
}
.chip {
  display: inline-block; padding: 2px 9px; margin: 2px 4px 2px 0; border-radius: 7px;
  font-size: 11.5px; font-weight: 600; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.bar { position: relative; height: 18px; background: #0a1322; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 6px 0 0 6px; transition: width .6s ease; }
.bar-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); }

/* ---------------- Project cards (Section B) ---------------- */
/* flex:1 + min-height:0 makes the grid a height-bounded scroll container so
   long sections scroll INSIDE the stage (instead of overflowing off-screen) */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); overflow: auto; align-content: start; padding-bottom: 6px; flex: 1 1 auto; min-height: 0; }
.panel { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.proj-card { border-top: 4px solid var(--c, var(--info)); }
.proj-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.proj-name { font-size: 17px; font-weight: 800; }
.proj-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.proj-health { text-align: right; }
.proj-score { font-size: 11px; color: var(--text-mute); margin-top: 4px; }
.proj-badges { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.lbl { display: flex; flex-direction: column; gap: 3px; }
.lbl-t { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .5px; }
.proj-bars { display: grid; gap: 7px; }
.br { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; }
.br-t { font-size: 11px; color: var(--text-dim); }
.proj-foot { margin-top: 10px; }
.proj-chips { display: flex; flex-wrap: wrap; }
.proj-next { margin-top: 6px; font-size: 12px; color: var(--accent); }

/* ---------------- Stat grid (Service / Profit) ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--gap); margin-bottom: 14px; flex: 0 0 auto; }
.stat { background: var(--panel); border: 1px solid var(--line); border-bottom: 4px solid var(--c, var(--info)); border-radius: 11px; padding: 12px; text-align: center; }
.stat-value { font-size: clamp(22px, 2.4vw, 34px); font-weight: 800; color: var(--c, var(--text)); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; margin-top: 3px; }

/* ---------------- Tables ---------------- */
.tbl-scroll { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(8,14,24,.5); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 2; background: #0d1626; text-align: left;
  padding: 12px 14px; color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .7px;
  border-bottom: 2px solid var(--line);
}
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(31,46,71,.5); }
.tbl tbody tr { border-left: 4px solid var(--row-c, transparent); }
.tbl tbody tr:hover { background: rgba(56,189,248,.05); }
.tbl-empty { text-align: center; color: var(--text-mute); padding: 30px; }
.warn-cell { line-height: 1.8; }

/* ---------------- Priority board (Section G) ---------------- */
.priority-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); overflow: auto; align-content: start; flex: 1 1 auto; min-height: 0; }
.plist { padding: 12px 14px; }
.panel-title { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); margin-bottom: 8px; }
.plist-rows { display: flex; flex-direction: column; gap: 5px; }
.plist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed rgba(31,46,71,.5); }
.plist-num { width: 20px; height: 20px; border-radius: 6px; background: var(--panel-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-dim); flex: 0 0 auto; }
.plist-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist-right { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.plist-empty { color: var(--good); font-size: 13px; padding: 8px 0; }

/* ---------------- Bottom bar: ticker + nav ---------------- */
.bottombar { flex: 0 0 auto; display: flex; align-items: center; gap: 18px; border-top: 1px solid var(--line); background: #0a111d; padding: 0 16px; height: 50px; }
.ticker-label { font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--urgent); text-transform: uppercase; flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.ticker-label::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--urgent); box-shadow: 0 0 10px var(--urgent); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
#ticker { flex: 1; overflow: hidden; height: 100%; position: relative; }
.ticker-track { display: flex; gap: 38px; align-items: center; height: 100%; white-space: nowrap; animation: scrollx linear infinite; will-change: transform; }
.paused .ticker-track { animation-play-state: paused; }
@keyframes scrollx { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-item { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--c); }
.ticker-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }

.nav { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
#section-label { font-size: 12px; color: var(--text-dim); min-width: 150px; text-align: right; }
#nav-dots { display: flex; gap: 7px; }
.nav-dot { width: 11px; height: 11px; border-radius: 50%; border: none; background: #2a3a55; padding: 0; }
.nav-dot.on { background: var(--accent); box-shadow: 0 0 9px var(--accent); }

/* ---------------- TV mode tweaks ---------------- */
body.tv .controls .hide-tv { display: none; }
body.tv { cursor: none; }
body.tv .kpi-value { font-size: clamp(34px, 3.6vw, 64px); }

/* ---------------- Admin ---------------- */
.admin-body { overflow: auto; }
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 22px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab { background: none; border: none; color: var(--text-dim); padding: 12px 20px; font-size: 15px; font-weight: 700; border-bottom: 3px solid transparent; }
.tab.on { color: #fff; border-bottom-color: var(--accent); }
.tab-panel { display: none; } .tab-panel.on { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card h3 { margin: 0 0 14px; font-size: 17px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.hide { display: none !important; }
.muted { color: var(--text-mute); font-size: 14px; }

#dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--text-dim); cursor: pointer; transition: .2s; }
#dropzone:hover, #dropzone.drag { border-color: var(--accent); background: rgba(56,189,248,.06); color: #fff; }
#dropzone .big { font-size: 18px; font-weight: 700; color: var(--text); }

select, input, textarea { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 70px; width: 100%; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--text-dim); }

.btn { background: var(--accent); color: #04121f; border: none; border-radius: 9px; padding: 10px 18px; font-weight: 800; font-size: 14px; }
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--urgent); color: #fff; }
.btn-sm { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; margin-left: 6px; }
.btn-sm.danger { border-color: var(--urgent); color: var(--urgent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.map-row { display: grid; grid-template-columns: 1fr 280px; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.map-src { display: flex; flex-direction: column; gap: 2px; }
.map-sample { font-size: 12px; color: var(--text-mute); }
.map-select { width: 100%; }

.msg { padding: 9px 13px; border-radius: 8px; font-size: 13.5px; margin: 6px 0; }
.msg.ok { background: rgba(31,185,110,.12); color: var(--good); border: 1px solid rgba(31,185,110,.3); }
.msg.err { background: rgba(226,59,78,.12); color: var(--urgent); border: 1px solid rgba(226,59,78,.3); }
.msg.warn { background: rgba(242,193,78,.12); color: var(--caution); border: 1px solid rgba(242,193,78,.3); }

.preview-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }

.rec-tabs, .rec-actions { display: flex; gap: 8px; }
.rec-tab { background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim); border-radius: 8px; padding: 8px 16px; font-weight: 600; }
.rec-tab.on { color: #fff; border-color: var(--accent); }
.rec-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px; }
.rec-title { font-weight: 700; }
.rec-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.editor-overlay { position: fixed; inset: 0; background: rgba(3,7,14,.8); display: grid; place-items: center; z-index: 50; padding: 30px; }
.editor-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: min(820px, 100%); max-height: 86vh; overflow: auto; padding: 24px; }
#editor-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.hist-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.set-row label { min-width: 280px; font-size: 14px; }

/* responsive: stack KPIs on narrower screens */
@media (max-width: 1500px) {
  .kpi-grid, .stat-grid { grid-template-columns: repeat(5, 1fr); }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .priority-grid { grid-template-columns: repeat(2, 1fr); }
}
