/* ClimaEdge client portal -- design tokens copied verbatim from
   website/css/style.css so the portal reads as the same product, not a
   different app. Portal is its own self-contained static site (deployed
   to its own subdomain), so nothing here is @imported from website/. */
:root {
  --bg:            #0A1421;
  --bg-raised:     #0E1A2A;
  --panel:         #101E2F;
  --panel-edge:    rgba(143, 170, 191, 0.14);
  --panel-edge-hi: rgba(143, 170, 191, 0.30);
  --ink:           #E8EFF6;
  --ink-soft:      #9FB4C6;
  --muted:         #7C93A6;
  --brand:         #156082;
  --brand-bright:  #4FA8D5;
  --brand-glow:    rgba(79, 168, 213, 0.16);
  --amber:         #E8A33D;
  --amber-deep:    #C97C1E;
  --danger:        #E05252;
  --ok:            #4FBF8B;
  --radius:        10px;
  --shell:         1160px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  min-height: 100vh;
}

/* ── Login page (adapted from website's .modal-backdrop/.login-panel --
   same visual language, but the page itself IS the panel, not an overlay
   on top of other content) ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-panel {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--panel-edge-hi);
  border-radius: 14px;
  padding: 36px 34px 30px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.login-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 46%;
  height: 4px;
  background: var(--brand);
  clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  border-radius: 14px 0 0 0;
}
.login-panel .mark { height: 40px; margin-bottom: 18px; }
.login-panel h2 { font-size: 21px; font-weight: 700; margin: 0 0 6px; }
.login-panel .sub { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 24px; }

.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.form-row input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--panel-edge-hi);
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
  padding: 10px 12px;
  font-family: inherit;
}
.form-row input:focus { border-color: var(--brand-bright); outline: none; }

.btn-solid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.btn-solid:hover { background: #1B76A0; border-color: #1B76A0; }
.btn-solid:disabled { opacity: 0.6; cursor: not-allowed; }
.login-panel .btn-solid { width: 100%; justify-content: center; margin-top: 6px; }

.login-status {
  display: none;
  margin-top: 14px;
  font-size: 13px;
  color: var(--amber);
  background: rgba(232, 163, 61, 0.09);
  border: 1px solid rgba(232, 163, 61, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
}
.login-status.show { display: block; }
.login-status.error {
  color: var(--danger);
  background: rgba(224, 82, 82, 0.09);
  border-color: rgba(224, 82, 82, 0.3);
}

.login-foot {
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ── Portal shell (dashboard / admin pages) ─────────────────────────── */
.shell { max-width: var(--shell); margin: 0 auto; padding: 0 24px; }

.portal-nav {
  border-bottom: 1px solid var(--panel-edge);
  background: var(--bg-raised);
  position: sticky; top: 0; z-index: 10;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.nav-logo { height: 26px; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-client { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }

.btn-ghost {
  background: none;
  border: 1px solid var(--panel-edge-hi);
  color: var(--ink-soft);
  font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  cursor: pointer; font-family: inherit;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--brand-bright); }

.portal-main { padding-top: 36px; padding-bottom: 72px; }
.loading, .load-error { color: var(--muted); font-size: 14px; padding: 40px 0; }
.load-error { display: none; color: var(--danger); }
.load-error.show { display: block; }

.page-head { margin-bottom: 36px; }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
.page-sub { color: var(--ink-soft); font-size: 14px; margin: 0; }

.block { margin-bottom: 44px; }
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
  margin: 0 0 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-edge);
}
.empty { color: var(--muted); font-size: 14px; }
.empty-sm { color: var(--muted); font-size: 12.5px; margin: 0; }

/* ── Fixture cards ──────────────────────────────────────────────────── */
.fixture-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
}
.fixture-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.fixture-opp { font-size: 17px; margin-bottom: 4px; }
.fixture-opp strong { font-weight: 700; }
.fixture-meta { font-size: 13px; color: var(--ink-soft); }
.countdown {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--brand-bright);
  background: var(--brand-glow); border: 1px solid rgba(79,168,213,0.35);
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}
.fixture-reports { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--panel-edge); }
.reports-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px;
}
.report-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.report-list a {
  display: inline-block; font-size: 12.5px; font-weight: 600;
  color: var(--brand-bright); text-decoration: none;
  background: var(--bg-raised); border: 1px solid var(--panel-edge-hi);
  padding: 6px 12px; border-radius: 7px;
}
.report-list a:hover { border-color: var(--brand-bright); }

/* ── League table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.league-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.league-table th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--panel-edge-hi); white-space: nowrap;
}
.league-table td { padding: 10px 12px; border-bottom: 1px solid var(--panel-edge); }
.league-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.league-table th.num { text-align: right; }
.league-table .strong { font-weight: 700; }
.league-table tr.is-client {
  background: var(--brand-glow);
  border-left: 3px solid var(--brand-bright);
}
.league-table tr.is-client td { color: var(--ink); font-weight: 600; }

/* Report list items (name + View/Download actions) */
.report-list { flex-direction: column; align-items: stretch; gap: 6px; }
.report-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--panel-edge);
  border-radius: 7px;
  padding: 8px 12px;
}
.report-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.report-btn {
  background: none;
  border: 1px solid var(--panel-edge-hi);
  color: var(--brand-bright);
  font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px;
  cursor: pointer; font-family: inherit;
}
.report-btn:hover { border-color: var(--brand-bright); background: var(--brand-glow); }

/* ── Admin view ─────────────────────────────────────────────────────── */
.cell-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill.ok    { color: var(--ok);    background: rgba(79,191,139,.10);  border: 1px solid rgba(79,191,139,.35); }
.pill.warn  { color: var(--amber); background: rgba(232,163,61,.10);  border: 1px solid rgba(232,163,61,.35); }
.pill.bad   { color: var(--danger);background: rgba(224,82,82,.10);   border: 1px solid rgba(224,82,82,.35); }
.pill.muted { color: var(--muted); background: rgba(124,147,166,.10); border: 1px solid var(--panel-edge-hi); }

.kv-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px; margin-bottom: 8px;
}
.kv-key { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; }
.kv-val { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.pending-list { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13.5px; }
.pending-list li { margin-bottom: 5px; }

/* Status banner + alert list (admin) */
.status-banner {
  font-size: 15px; font-weight: 700;
  padding: 14px 18px; border-radius: var(--radius);
  margin-bottom: 14px;
}
.status-banner.ok   { color: var(--ok);     background: rgba(79,191,139,.10); border: 1px solid rgba(79,191,139,.35); }
.status-banner.warn { color: var(--amber);  background: rgba(232,163,61,.10); border: 1px solid rgba(232,163,61,.35); }
.status-banner.bad  { color: var(--danger); background: rgba(224,82,82,.10);  border: 1px solid rgba(224,82,82,.35); }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; color: var(--ink-soft);
  padding: 10px 14px; margin-bottom: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
}
.alert-row.critical { border-left: 3px solid var(--danger); }
.alert-row.warning  { border-left: 3px solid var(--amber); }
.alert-row.info     { border-left: 3px solid var(--panel-edge-hi); }

/* Admin action rows */
.action-row { flex-wrap: wrap; }
.action-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.report-btn:disabled { opacity: .4; cursor: not-allowed; }
#action-result:empty { display: none; }

/* ── Tabs ─────────────────────────────────────────────────────────────
   Dashboard sections are tabbed rather than stacked so the EMSI demo can
   sit alongside the fixtures without pushing reports below the fold. */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--panel-edge);
  margin-bottom: 32px;
  overflow-x: auto;
}
.tab {
  flex: 0 0 auto;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: 600 13.5px/1 inherit;
  letter-spacing: 0.01em;
  padding: 12px 16px 13px;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink-soft); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--brand-bright); }
.tab:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: -2px; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.panel-head { max-width: 660px; margin-bottom: 32px; }
.panel-head h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.panel-head p { color: var(--ink-soft); font-size: 14.5px; margin: 0; }

/* ── EMSI demo (moved from the public marketing site) ─────────────────── */
.demo-grid {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 48px;
  align-items: start;
}
@media (max-width: 880px) { .demo-grid { grid-template-columns: 1fr; gap: 28px; } }
.demo-controls {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 30px 30px 26px;
}
.slider-row { margin-bottom: 26px; }
.slider-row:last-of-type { margin-bottom: 16px; }
.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.slider-val {
  font-variant-numeric: tabular-nums;
  color: var(--brand-bright);
  font-weight: 700;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--panel-edge-hi);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand-bright);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--brand-bright);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand-bright);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--brand-bright);
  cursor: pointer;
}
input[type="range"]:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 4px; }
.demo-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

/* ── Score gauge panel ────────────────────────────────────────────────── */
.report-preview {
  position: relative;
  background: linear-gradient(160deg, var(--panel) 0%, #0C1826 100%);
  border: 1px solid var(--panel-edge-hi);
  border-radius: var(--radius);
  padding: 26px 28px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.report-preview::before {
  /* diagonal slash motif from the logo mark */
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 42%;
  height: 4px;
  background: var(--brand);
  clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  border-radius: var(--radius) 0 0 0;
}
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}
.preview-head .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.preview-head .fixture {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.gauge-wrap { position: relative; width: 230px; margin: 0 auto; }
.gauge-wrap svg { width: 100%; height: auto; display: block; }
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 4px;
}
.gauge-center .num {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.gauge-center .denom { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.gauge-band {
  text-align: center;
  margin-top: 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--amber);
}
.gauge-meta {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.driver-chips {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.driver-chips span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--panel-edge-hi);
  border-radius: 999px;
  padding: 4px 11px;
}
.driver-chips span.hot {
  color: var(--amber);
  border-color: rgba(232, 163, 61, 0.45);
  background: rgba(232, 163, 61, 0.08);
}
.demo-preview #demo-arc { transition: stroke-dashoffset .35s ease, stroke .35s ease; }
.demo-preview .gauge-band,
.demo-preview #demo-score { transition: color .25s ease; }

@media (prefers-reduced-motion: reduce) {
  .demo-preview #demo-arc,
  .demo-preview .gauge-band,
  .demo-preview #demo-score { transition: none; }
}
