/* New Issue IQ engagement dashboard — brand palette + minimal chrome. */
:root {
  --navy: #0a2540;
  --ink: #1a1a1a;
  --bg: #fafaf7;
  --card: #ffffff;
  --rule: #e6e6e6;
  --rule-soft: #f0f0ec;
  --grey: #6a7280;
  --grey-mut: #8a8f98;
  --accent: #1b6fa3;
  --green: #1f7a4d;
  --red: #b00020;
  --gold: #f0a900;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ── Auth gate ── */
#auth-gate {
  position: fixed;
  inset: 0;
  display: none; /* shown by auth.js when needed */
  align-items: center;
  justify-content: center;
  background: var(--navy);
  z-index: 1000;
}
#auth-gate .auth-card {
  background: var(--card);
  border-radius: 8px;
  padding: 36px 40px;
  width: 360px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
#auth-gate h1 {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--navy);
}
#auth-gate p {
  font-size: 13px;
  color: var(--grey);
  margin: 0 0 20px;
}
#auth-gate input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin-bottom: 12px;
}
#auth-gate button {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#auth-error {
  color: var(--red);
  font-size: 12px;
  min-height: 16px;
  margin-top: 8px;
}

/* ── Header ── */
header {
  background: var(--navy);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}
header .refreshed {
  font-size: 11px;
  color: #9fb3c8;
}

/* ── Filters bar ── */
.filters {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}
.filters label {
  display: flex;
  flex-direction: column;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-mut);
  font-weight: 600;
  gap: 4px;
}
.filters input,
.filters select {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  min-width: 140px;
}
.filters button {
  font-size: 12px;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
}

/* ── Tabs ── */
nav.tabs {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}
nav.tabs button {
  font-size: 13px;
  font-weight: 600;
  padding: 12px 18px;
  border: none;
  background: none;
  color: var(--grey);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
nav.tabs button.active {
  color: var(--navy);
  border-bottom-color: var(--gold);
}

/* ── Main / views ── */
main {
  padding: 24px 28px 80px;
}
.view { display: none; }
.view.active { display: block; }

.view-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  margin: 0 0 14px;
}
.muted { color: var(--grey-mut); }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
}
th {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-mut);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.num { text-align: right; }
th .arrow { color: var(--gold); margin-left: 4px; }
td {
  font-size: 13px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--rule-soft); }
.url-cell {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--accent);
}

/* ── Chart ── */
#chart-time {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 16px;
  min-height: 320px;
}

/* ── Loading ── */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-size: 14px;
  color: var(--grey);
  z-index: 500;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--rule);
  border-top-color: var(--navy);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Overview: KPI cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 18px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey);
  font-weight: 600;
  margin-top: 6px;
}
.kpi-sub {
  font-size: 11px;
  color: var(--grey-mut);
  margin-top: 3px;
}

.overview-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 760px) {
  .overview-cols { grid-template-columns: 1fr; }
}
.mini-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  margin: 0 0 10px;
}
table.mini { font-size: 12px; }
table.mini th { padding: 6px 10px; }
table.mini td { padding: 7px 10px; }
#overview-chart {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px;
  overflow-x: auto;
}

/* ── Timing callouts + heatmap ── */
.callout-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.callout {
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 12px 18px;
  min-width: 200px;
}
.callout-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-mut);
  font-weight: 600;
}
.callout-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 2px;
}
.callout-sub {
  font-size: 11px;
  color: var(--grey-mut);
  margin-top: 1px;
}
.heatmap-wrap {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 12px;
  overflow-x: auto;
}

/* ── Tier badges ── */
.tier {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
}
.tier-hot { background: #fde2e4; color: #b00020; }
.tier-warm { background: #fff2d6; color: #9a6b00; }
.tier-cool { background: #e0eef7; color: #1b6fa3; }
.tier-dormant { background: #eceef0; color: #8a8f98; }

/* ── Drilldown panel ── */
#drilldown {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 2px solid var(--rule);
  display: none;
}
#drilldown.active { display: block; }
#drilldown .close {
  float: right;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
}
.empty {
  padding: 40px;
  text-align: center;
  color: var(--grey-mut);
  font-size: 13px;
}
