/* FSN Pulse — extends the trib.xyz palette (see website/STYLE-GUIDE.md).
   Dashboard surface is a light neutral; accents are Yale Blue / Stormy Teal. */
:root {
  --graphite: #353535;
  --stormy-teal: #3c6e71;
  --yale-blue: #284b63;
  --dust-grey: #d9d9d9;
  --surface: #f5f7f9;
  --white: #ffffff;
  --success: #2e7d32;
  --warning: #e65100;
  --danger: #c0392b;
  --muted: #6b7785;
  --green-bg: #e3f2e1;
  --yellow-bg: #fff3e0;
  --red-bg: #fdecea;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lift: 0 4px 16px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: var(--surface);
  color: var(--graphite);
  font-size: 15px;
  line-height: 1.5;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--yale-blue);
  color: #fff;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 1.5rem;
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 34px; width: auto; display: block; background: #fff; padding: 4px 8px; border-radius: 6px; }
.view-toggle { display: flex; gap: 0.25rem; margin: 0 auto; background: rgba(255,255,255,0.08); padding: 0.25rem; border-radius: 999px; }
.toggle-btn {
  border: none; background: none; color: rgba(255,255,255,0.7);
  font: inherit; font-weight: 600; font-size: 0.85rem;
  padding: 0.4rem 1.1rem; border-radius: 999px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.toggle-btn:hover { color: #fff; }
.toggle-btn.is-active { background: #fff; color: var(--yale-blue); }
.src-pill {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; background: rgba(255,255,255,0.15);
  padding: 0.25rem 0.6rem; border-radius: 999px;
}
.hdr-btn {
  border: 1px solid rgba(255,255,255,0.3); background: none; color: #fff;
  font: inherit; font-size: 0.75rem; font-weight: 600; padding: 0.3rem 0.7rem;
  border-radius: 4px; cursor: pointer; transition: background 0.15s;
}
.hdr-btn:hover, .hdr-btn.on { background: rgba(255,255,255,0.18); }
.user-pill {
  border: 1px solid rgba(255,255,255,0.3); background: none; color: #fff;
  font: inherit; font-size: 0.72rem; font-weight: 600; padding: 0.3rem 0.7rem;
  border-radius: 999px; cursor: pointer; max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.user-pill:hover { background: rgba(255,255,255,0.18); }
.user-pill::after { content: ' ⏻'; opacity: 0.7; }

/* Login overlay (soft email gate) */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--yale-blue);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.login-card {
  background: #fff; border-radius: 10px; padding: 2.5rem 2.5rem 2rem;
  width: 100%; max-width: 400px; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.login-logo { height: 48px; width: auto; margin-bottom: 1rem; }
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; color: var(--yale-blue); }
.login-card p { margin: 0 0 1.25rem; color: var(--graphite); font-size: 0.95rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.6rem; }
.login-card input {
  border: 1.5px solid var(--dust-grey); border-radius: 4px; padding: 0.7rem 0.8rem;
  font: inherit; font-size: 1rem; text-align: center;
}
.login-card input:focus { border-color: var(--yale-blue); outline: none; }
.login-card button[type=submit] {
  background: var(--yale-blue); color: #fff; border: none; border-radius: 4px;
  padding: 0.7rem; font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.login-card button[type=submit]:hover { background: var(--stormy-teal); }
.login-error { margin-top: 0.9rem; color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.login-fine { margin-top: 1.25rem; color: var(--muted); font-size: 0.75rem; }
.login-link { display: inline-block; margin-top: 1.1rem; color: var(--yale-blue); font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.login-link:hover { color: var(--stormy-teal); text-decoration: underline; }
.export-btn {
  float: right; border: 1px solid var(--dust-grey); background: #fff; color: var(--graphite);
  font: inherit; font-size: 0.75rem; font-weight: 600; padding: 0.3rem 0.7rem;
  border-radius: 4px; cursor: pointer; margin-top: -2.4rem;
}
.export-btn:hover { border-color: var(--yale-blue); color: var(--yale-blue); }

/* ---- Filter bar ---- */
.filterbar { background: var(--white); border-bottom: 1px solid var(--dust-grey); position: sticky; top: 53px; z-index: 20; }
.filterbar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: flex-end; gap: 1rem; padding: 0.75rem 1.5rem; flex-wrap: wrap; }
.filter { display: flex; flex-direction: column; gap: 0.2rem; }
.filter > span { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.filter select {
  border: 1.5px solid var(--dust-grey); border-radius: 4px;
  padding: 0.4rem 0.6rem; font: inherit; font-size: 0.9rem; background: #fff; color: var(--graphite);
  min-width: 140px;
}
.filter select:focus { border-color: var(--yale-blue); outline: none; }
.filter-spacer { flex: 1; }
.updated { font-size: 0.75rem; color: var(--muted); align-self: center; }

/* ---- Content ---- */
.content { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.loading { padding: 4rem; text-align: center; color: var(--muted); }
.section-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1.5rem 0 0.75rem; }
.section-title:first-child { margin-top: 0; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
.kpi {
  background: #fff; border-radius: 8px; box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; border-left: 3px solid var(--dust-grey);
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi.good { border-left-color: var(--success); }
.kpi.warn { border-left-color: var(--warning); }
.kpi.bad { border-left-color: var(--danger); }
.kpi-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.kpi-value { font-size: 1.85rem; font-weight: 700; color: var(--yale-blue); line-height: 1.15; margin-top: 0.25rem; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.kpi-trend { font-size: 0.78rem; font-weight: 600; margin-top: 0.3rem; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* Panels / charts */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.panel { background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1.5rem; }
.panel-grid .panel { margin-bottom: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { margin: 0 0 0.25rem; font-size: 1.05rem; font-weight: 600; color: var(--yale-blue); }
.panel .hint { margin: 0 0 0.9rem; font-size: 0.8rem; color: var(--muted); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.tbl th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; padding: 0.5rem 0.6rem; border-bottom: 2px solid var(--dust-grey); }
.tbl td { padding: 0.5rem 0.6rem; border-bottom: 1px solid #eef1f4; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .rep-name { font-weight: 600; color: var(--graphite); }

/* Stoplight pills */
.light { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; }
.light.g { background: var(--success); }
.light.y { background: var(--warning); }
.light.r { background: var(--danger); }
.cell-g { background: var(--green-bg); }
.cell-y { background: var(--yellow-bg); }
.cell-r { background: var(--red-bg); }

.note { background: var(--yellow-bg); border-left: 3px solid var(--warning); border-radius: 4px; padding: 0.75rem 1rem; font-size: 0.85rem; color: var(--graphite); margin-bottom: 1rem; }

/* Comparison scorecard: leader cell highlight */
.tbl td.leader { background: var(--green-bg); font-weight: 700; color: var(--success); }
.tbl td.rank { color: var(--muted); font-weight: 700; width: 2.2rem; }
.tbl .rep-name.you { color: var(--yale-blue); }

/* Metric switcher (segmented control) */
.metric-switch { display: inline-flex; gap: 0.2rem; background: var(--surface); border: 1px solid var(--dust-grey); padding: 0.2rem; border-radius: 999px; margin: 0 0 1rem; flex-wrap: wrap; }
.metric-switch button { border: none; background: none; font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--muted); padding: 0.3rem 0.85rem; border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.metric-switch button:hover { color: var(--graphite); }
.metric-switch button.on { background: var(--yale-blue); color: #fff; }

/* Empty / phase-2 state */
.empty-state { background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 3rem 2rem; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--yale-blue); margin: 0 0 0.5rem; }
.empty-state p { max-width: 520px; margin: 0.4rem auto; font-size: 0.9rem; }

.foot { max-width: 1400px; margin: 1rem auto 2rem; padding: 0 1.5rem; font-size: 0.75rem; color: var(--muted); }

/* Wall-display mode: bigger type for an office screen, hide filter bar */
body.wall .filterbar { display: none; }
body.wall .kpi-value { font-size: 2.6rem; }
body.wall .kpi-label { font-size: 0.85rem; }
body.wall .content { max-width: 1800px; }
body.wall .panel h3 { font-size: 1.4rem; }
body.wall .tbl { font-size: 1.05rem; }
body.wall .tbl th { font-size: 0.8rem; }

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; gap: 0.75rem; }
  .view-toggle { margin: 0; order: 3; width: 100%; justify-content: space-between; }
  .filterbar { position: static; }
}
