/* ============================================================================
   Elevated Performance System — STYLES
   Industrial contractor scoreboard theme: black / white / red / gray + metal.
   ========================================================================== */

:root {
  --black:      #0b0c0e;
  --panel:      #16181d;
  --panel-2:    #1e2128;
  --panel-3:    #262a33;
  --line:       #33383f;
  --gray:       #8a929e;
  --gray-light: #c3c9d2;
  --white:      #f4f6f9;
  --red:        #e11d2a;
  --red-dark:   #b4141f;
  --red-glow:   rgba(225, 29, 42, 0.35);
  --green:      #22c55e;
  --amber:      #f2b134;
  --blue:       #3b82f6;
  --metal: linear-gradient(180deg, #2b2f37 0%, #1a1d23 100%);
  --metal-red: linear-gradient(180deg, #e11d2a 0%, #a10f19 100%);
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0,0,0,0.45);
  --mono: "SF Mono", "Roboto Mono", "Consolas", ui-monospace, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--black);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 15% -10%, rgba(225,29,42,0.10), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(59,130,246,0.06), transparent 35%);
  min-height: 100vh;
}

/* ---------------------------------------------------------------- Layout ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}
.brand .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 0.5px; font-size: 15px;
}
.brand .logo .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--metal-red);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 900; color: #fff;
  box-shadow: 0 0 14px var(--red-glow);
}
.brand .sub { color: var(--gray); font-size: 11px; margin-top: 6px; line-height: 1.4; }

.nav { padding: 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 9px;
  color: var(--gray-light); text-decoration: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a:hover { background: var(--panel-2); color: var(--white); }
.nav a.active {
  background: var(--panel-3);
  color: #fff;
  border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--red);
}
.nav-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: rgba(11,12,14,0.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px; }

/* --------------------------------------------------------------- Controls -- */
.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--white);
  padding: 9px 15px; border-radius: 9px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--sans);
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--metal-red); border-color: var(--red-dark); box-shadow: 0 0 14px var(--red-glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: #ff8b93; border-color: #5a2327; }
.btn.danger:hover { background: #2a1416; }

.week-picker { display: flex; align-items: center; gap: 6px; }
.week-picker .label { font-weight: 700; font-size: 13px; min-width: 120px; text-align: center; }

select, input[type="text"], input[type="number"], input[type="date"] {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--white);
  border-radius: 8px; padding: 9px 11px; font-size: 13px;
  font-family: var(--sans); width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }

/* Hide the up/down spinner arrows on number fields so values can just be typed
   (decimals to the tenth still work, e.g. 8.3 hours). */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
label.field { display: block; margin-bottom: 12px; }
label.field .lab { display: block; font-size: 12px; color: var(--gray); margin-bottom: 5px; font-weight: 600; }

/* ----------------------------------------------------------------- Cards --- */
.grid { display: grid; gap: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .card-h {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 14px; letter-spacing: .3px;
  text-transform: uppercase; color: var(--gray-light);
}
.card .card-h .tag { margin-left: auto; }
.card .card-b { padding: 18px; }

.tag {
  font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .4px;
  background: var(--panel-3); color: var(--gray-light); border: 1px solid var(--line);
}
.tag.green { background: rgba(34,197,94,.15); color: #6ee7a0; border-color: #1f6b3f; }
.tag.red   { background: rgba(225,29,42,.15); color: #ff8b93; border-color: #5a2327; }
.tag.amber { background: rgba(242,177,52,.15); color: #ffd789; border-color: #6b5320; }
.tag.gray  { background: var(--panel-3); color: var(--gray-light); }
.tag.blue  { background: rgba(59,130,246,.15); color: #93c0ff; border-color: #274a80; }

/* KPI stat */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: 12px; color: var(--gray); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 26px; font-weight: 900; font-family: var(--mono); letter-spacing: -.5px; }
.stat .v.red { color: #ff6b74; }
.stat .v.green { color: #6ee7a0; }
.stat .sub { font-size: 12px; color: var(--gray); }

/* Progress bars */
.progress { position: relative; height: 26px; background: var(--panel-3); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--metal-red); border-radius: 999px; transition: width .5s ease; box-shadow: 0 0 14px var(--red-glow); }
.progress .fill.green { background: linear-gradient(180deg,#22c55e,#12813a); box-shadow: 0 0 14px rgba(34,197,94,.35); }
.progress .fill.amber { background: linear-gradient(180deg,#f2b134,#b9821a); }
.progress .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: rgba(255,255,255,.5); }
.progress .mark .cap { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--gray-light); white-space: nowrap; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 7px; color: var(--gray-light); font-weight: 600; }
.progress-label .big { font-family: var(--mono); font-weight: 800; color: #fff; }

/* -------------------------------------------------------------- Tables ----- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); font-weight: 800; position: sticky; top: 0; background: var(--panel); }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--mono); }
table.tbl tr:hover td { background: var(--panel-2); }
table.tbl tr.total-row td { font-weight: 800; border-top: 2px solid var(--line); background: var(--panel-2); }

.money { font-family: var(--mono); }
.pos { color: #6ee7a0; }
.neg { color: #ff8b93; }
.muted { color: var(--gray); }

/* Leaderboard */
.lead-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--line); }
.lead-row:last-child { border-bottom: none; }
.lead-rank { font-family: var(--mono); font-weight: 900; font-size: 18px; color: var(--gray); text-align: center; }
.lead-row.top1 .lead-rank { color: var(--red); }
.lead-name { font-weight: 700; }
.lead-name .dept { font-size: 11px; color: var(--gray); font-weight: 600; }
.lead-bar { height: 8px; background: var(--panel-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.lead-bar .f { height: 100%; background: var(--metal-red); }
.lead-pct { font-family: var(--mono); font-weight: 800; font-size: 16px; text-align: right; min-width: 66px; }

/* Callout / help */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; align-items: flex-start; }
.callout.warn { border-color: #6b5320; background: rgba(242,177,52,.08); }
.callout.bad  { border-color: #5a2327; background: rgba(225,29,42,.08); }
.callout .ic { font-size: 18px; }

/* Formula box — "do not hide the math" */
.formula { font-family: var(--mono); font-size: 12px; background: #0e1013; border: 1px dashed var(--line); border-radius: 8px; padding: 12px 14px; color: var(--gray-light); line-height: 1.7; white-space: pre-wrap; }
.formula b { color: #ffd789; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Crew editor */
.crew-line { display: grid; grid-template-columns: 24px 1fr 110px 90px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.crew-line .credit { font-family: var(--mono); font-size: 12px; color: #6ee7a0; text-align: right; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: min(760px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal .m-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; font-weight: 800; }
.modal .m-b { padding: 20px; }
.modal .m-f { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--gray); font-weight: 800; margin: 22px 0 12px; }

/* ------------------------------------------------------------- TV MODE ----- */
body.tv .sidebar { display: none; }
body.tv .topbar { display: none; }
body.tv .content { padding: 0; }
.tv-only { display: none; }
body.tv .tv-only { display: block; }
body.tv .no-tv { display: none; }

.tv-board { padding: 26px 34px; }
.tv-head { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.tv-head .mark { width: 56px; height: 56px; border-radius: 12px; background: var(--metal-red); display: grid; place-items: center; font-size: 30px; font-weight: 900; box-shadow: 0 0 24px var(--red-glow); }
.tv-head h1 { font-size: 34px; margin: 0; font-weight: 900; letter-spacing: .5px; }
.tv-head .sub { color: var(--gray); font-size: 15px; }
.tv-head .clock { margin-left: auto; text-align: right; font-family: var(--mono); }
.tv-head .clock .t { font-size: 30px; font-weight: 800; }
.tv-head .clock .d { color: var(--gray); font-size: 14px; }

.tv-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.tv-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.tv-card h2 { margin: 0 0 16px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--gray); }
.tv-huge { font-size: 60px; font-weight: 900; font-family: var(--mono); letter-spacing: -2px; line-height: 1; }
.tv-progress { height: 40px; margin-top: 14px; }
.tv-progress .fill { font-family: var(--mono); }
.tv-lead-row { display: grid; grid-template-columns: 46px 1fr 120px; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tv-lead-row .r { font-size: 26px; font-weight: 900; font-family: var(--mono); color: var(--gray); text-align: center; }
.tv-lead-row.top1 .r { color: var(--red); }
.tv-lead-row .nm { font-size: 20px; font-weight: 800; }
.tv-lead-row .nm .d { font-size: 12px; color: var(--gray); font-weight: 600; text-transform: uppercase; }
.tv-lead-row .pc { font-size: 26px; font-weight: 900; font-family: var(--mono); text-align: right; }
.tv-dept { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.tv-dept .d { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tv-dept .d .nm { font-size: 13px; color: var(--gray); text-transform: uppercase; font-weight: 800; letter-spacing: .5px; }
.tv-dept .d .v { font-size: 26px; font-weight: 900; font-family: var(--mono); margin: 6px 0; }
.tv-strip { display: grid; grid-template-columns: repeat(4,1fr); gap: 22px; margin-top: 22px; }
.tv-strip .s { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; text-align: center; }
.tv-strip .s .k { font-size: 13px; color: var(--gray); text-transform: uppercase; letter-spacing: .6px; font-weight: 800; }
.tv-strip .s .v { font-size: 34px; font-weight: 900; font-family: var(--mono); margin-top: 6px; }

/* Utility */
.flex { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.right { margin-left: auto; }
.hint { font-size: 12px; color: var(--gray); }
.empty { text-align: center; padding: 40px; color: var(--gray); }

/* --------------------------------------------------------------- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background-image: radial-gradient(circle at 20% 0%, rgba(225,29,42,0.14), transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(59,130,246,0.08), transparent 40%); }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-brand .mark { width: 48px; height: 48px; border-radius: 11px; background: var(--metal-red);
  display: grid; place-items: center; font-size: 26px; font-weight: 900; box-shadow: 0 0 18px var(--red-glow); }
.login-brand .lt { font-weight: 900; font-size: 16px; letter-spacing: .4px; line-height: 1.2; }
.login-brand .ls { color: var(--gray); font-size: 12px; margin-top: 3px; }
.login-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.login-quick .btn { justify-content: center; padding: 12px; }
.acct { display: flex; flex-direction: column; gap: 8px; }
.acct .who { line-height: 1.3; margin-bottom: 4px; }
.acct .who b { display: block; font-size: 13px; }
.acct .who .hint { font-size: 11px; word-break: break-all; }

/* Responsive */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; }
  .sidebar .brand { display: none; }
  .nav { flex-direction: row; }
  .nav-foot { display: none; }
  .row2, .row3, .tv-grid, .tv-dept, .tv-strip { grid-template-columns: 1fr; }
}
