/* Dashboard styling, shared by the login and dashboard pages. Same look as
   jec-dashboard so internal viewers get one familiar layout across campaigns.
   Vanilla CSS, no framework. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c1e21;
  --muted: #6b7280;
  --accent: #1a56db;
  --accent-hover: #1442ad;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1 { font-size: 20px; margin: 0; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
}
.login-card h1 { margin-bottom: 4px; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card label { font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.login-error {
  color: var(--danger);
  background: #fdecec;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 16px;
  font-size: 13px;
}

/* ── Dashboard layout ──────────────────────────────────────────────────── */
.dashboard-view { max-width: 1200px; margin: 0 auto; padding: 20px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar-sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.busy { color: var(--muted); font-size: 13px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
button { font: inherit; cursor: pointer; border-radius: 8px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 9px 16px;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
}
.btn-ghost:hover:not(:disabled) { background: #f0f1f4; }
.login-card button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px;
  font-weight: 600;
  font-size: 15px;
}
.login-card button[type="submit"]:hover:not(:disabled) { background: var(--accent-hover); }

/* ── Stat cards ────────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat-card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.stat-card--totals { display: flex; flex-direction: column; justify-content: center; }
.stat-big { font-size: 40px; font-weight: 700; margin: 0; line-height: 1; }
.stat-sub { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.stat-list li:last-child { border-bottom: none; }
.stat-key { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-count { font-weight: 700; color: var(--accent); }
.stat-empty { color: var(--muted); justify-content: flex-start !important; }

/* ── Toolbar ───────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar #search {
  flex: 1 1 280px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.toolbar #search:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.result-count { color: var(--muted); font-size: 13px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.toggle input { cursor: pointer; }

/* Legend explaining the status column — keeps the table self-documenting.
   Plain block, not flex: it is running text
   with inline <strong>, which flex would split into separate items. */
.legend {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}
.toggle select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}
.toggle select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* The per-day list grows one row per campaign day; cap it so it doesn't
   stretch the whole stats row. */
.stat-card--scroll .stat-list { max-height: 220px; overflow-y: auto; }

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  position: sticky;
  top: 0;
  background: #fafbfc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  z-index: 1;
}
.table tbody tr:hover { background: #f7f9fc; }
.table tbody tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; color: var(--muted); padding: 32px !important; }

/* ── Pager ─────────────────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}
.pager-info { color: var(--muted); font-size: 13px; }
