/* ClubOS — "Desert Dusk" design system. Tokens first; components below.
   Charts: categorical order #C4552D → #2563A8 → #8A6D1A → #7B4B94 (light)
   and #CE5730 → #3987E5 → #A87F14 → #9D6BC4 (stage/dark). Validated — do not restep. */

:root {
  --bg: #F6F1E7;
  --card: #FFFFFF;
  --line: #E6DFD2;
  --ink: #22283A;
  --ink-soft: #6E6759;
  --accent: #C4552D;
  --accent-deep: #A03F1D;
  --accent-soft: #F7E3D9;
  --indigo: #2563A8;
  --gold: #946A00;
  --gold-soft: #C9A227;
  --ok: #2F7D4F;
  --warn: #B7791F;
  --danger: #C0392B;
  --t-green: #2FA36B;
  --t-amber: #E3A008;
  --t-red: #E25C4A;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(34, 40, 58, .07), 0 6px 20px rgba(34, 40, 58, .05);
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

body.stage {
  --bg: #131722;
  --card: #1C2230;
  --line: #2A3145;
  --ink: #F2EDE3;
  --ink-soft: #9BA3B5;
  --accent: #E8794E;
  --accent-deep: #CE5730;
  --accent-soft: #33261F;
  --indigo: #3987E5;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 30px; margin: 0 0 6px; }
h2 { font-size: 22px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

/* ---------- layout ---------- */
#shell { display: flex; min-height: 100vh; }
#sidebar {
  width: 232px; flex: 0 0 232px;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
#main { flex: 1; padding: 28px 32px 60px; min-width: 0; }
#view { max-width: 1080px; margin: 0 auto; }

.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 17px;
  display: grid; place-items: center;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--ink-soft); }

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a {
  display: flex; gap: 10px; align-items: center;
  padding: 9px 12px; border-radius: 9px;
  color: var(--ink); font-weight: 500; font-size: 14px;
}
#nav a:hover { background: rgba(196, 85, 45, .07); text-decoration: none; }
#nav a.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.nav-icon { width: 20px; text-align: center; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 4px; }
#officer-slot { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------- components ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-tight { padding: 12px 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 9px 16px; border-radius: 9px; font: 600 14px var(--font-ui);
}
.btn:hover { background: var(--accent-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(34, 40, 58, .05); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #9C2D22; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 14px 26px; font-size: 17px; border-radius: 12px; }

.input, .select, .textarea {
  font: 400 14px var(--font-ui); color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
.textarea { min-height: 84px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; font-weight: 500; font-size: 13px; color: var(--ink-soft); }
label.field > .input, label.field > .select, label.field > .textarea { margin-top: 4px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font: 600 12px var(--font-ui); text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(196, 85, 45, .03); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font: 600 12px var(--font-ui);
  background: var(--accent-soft); color: var(--accent-deep);
}
.badge-ok { background: #E2F0E7; color: var(--ok); }
.badge-warn { background: #F7ECD8; color: var(--warn); }
.badge-danger { background: #F7DEDA; color: var(--danger); }
.badge-indigo { background: #E1EBF7; color: var(--indigo); }
body.stage .badge-ok { background: #1D3328; }
body.stage .badge-warn { background: #38301B; }
body.stage .badge-danger { background: #3B2321; }
body.stage .badge-indigo { background: #1C2C42; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font: 500 13px var(--font-ui);
  border: 1px solid var(--line); color: var(--ink-soft);
}
.pill-ok { color: var(--ok); border-color: currentColor; }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .kpi-value { font: 700 28px var(--font-display); color: var(--ink); }
.kpi .kpi-label { font: 500 12px var(--font-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; }

.award-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px;
  background: linear-gradient(135deg, #FBF6E8, #F6EDD4);
  border: 1px solid #E8D9A8; color: var(--gold); font-weight: 600; font-size: 14px;
}
body.stage .award-chip { background: linear-gradient(135deg, #2A2717, #332D15); border-color: #4A421F; color: var(--gold-soft); }

/* ---------- bars & charts ---------- */
.bar-row { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 56px; gap: 10px; align-items: center; margin: 7px 0; }
.bar-row-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 22px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bar-row-value { font-weight: 600; font-size: 14px; text-align: right; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-tick { font: 11px var(--font-ui); fill: var(--ink-soft); }
.chart-direct-label { font: 600 12px var(--font-ui); fill: var(--ink); }

/* ---------- modal & toast ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 16, 12, .45);
  display: grid; place-items: center; z-index: 60; padding: 16px;
}
.modal { max-width: 460px; width: 100%; margin: 0; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font: 500 14px var(--font-ui); opacity: 0; transform: translateY(8px); transition: all .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-err { background: var(--danger); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
.login-row { display: flex; gap: 8px; align-items: center; }

/* ---------- stage (projector) ---------- */
body.stage #sidebar { display: none; }
body.stage #main { padding: 0; }
body.stage #view { max-width: none; }
.stage-full {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 40px; text-align: center;
}
.stage-full h1 { font-size: clamp(34px, 5vw, 64px); }
.stage-exit { position: fixed; top: 14px; right: 16px; z-index: 10; opacity: .6; }
.stage-exit:hover { opacity: 1; }

/* timer display colors take the whole screen */
.timer-neutral { background: var(--bg); }
.timer-green { background: #10381F !important; }
.timer-amber { background: #4A3407 !important; }
.timer-red { background: #471410 !important; }
.timer-clock { font: 700 clamp(90px, 22vw, 260px) var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.qr { border: 8px solid #fff; border-radius: 10px; background: #fff; }
.qr-fallback { word-break: break-all; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #shell { flex-direction: column; }
  #sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  #nav { flex-direction: row; flex: 1; gap: 2px; }
  #nav a { padding: 7px 10px; white-space: nowrap; }
  #nav a span:last-child { display: none; }
  #nav a.active span:last-child { display: inline; }
  .nav-sep { display: none; }
  .brand-sub, .brand-name { display: none; }
  #officer-slot { flex-direction: row; }
  #main { padding: 16px 14px 48px; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

/* ---------- print (agenda PDF via browser print) ---------- */
@media print {
  #sidebar, #officer-slot, #toasts, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  #main { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: inherit; }
}
