/* IELTS admin panel — self-hosted styles.
 *
 * ❗ THIS FILE EXISTS SO THE PANEL CAN SHIP A STRICT, ENFORCING CSP.
 *   Every other browser surface on this box had to compromise: WeightPath's
 *   admin CSP is still Report-Only because it pulls Tailwind/Alpine/Chart.js
 *   from CDNs and Alpine needs 'unsafe-eval'; Combined's is enforcing but needs
 *   'unsafe-inline' for 48 inline handlers. Keeping all CSS and JS in real
 *   files, with no inline <style>/<script> and no external origin, is what lets
 *   the vhost send:
 *       default-src 'self'; script-src 'self'; style-src 'self'; ...
 *   with no unsafe-* at all.
 *   ⇒ DO NOT add an inline style attribute, an inline <style> block, or a CDN
 *     <link> to any admin view. It will be blocked by the browser, and the fix
 *     is not to weaken the header.
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #dfe3e8;
  --text: #1c2430;
  --muted: #64717f;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --good: #1a7f4b;
  --warn: #a8620a;
  --bad: #c0332e;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #131a24;
  color: #c7d0da;
  padding: 18px 0;
}

.sidebar .brand {
  padding: 0 18px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid #263041;
  margin-bottom: 12px;
}
.sidebar .brand small { display: block; font-weight: 400; color: #7d8b9c; font-size: 12px; }

.sidebar nav a {
  display: block;
  padding: 9px 18px;
  color: #c7d0da;
  font-size: 14px;
}
.sidebar nav a:hover { background: #1c2634; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }

.sidebar .foot {
  margin-top: 22px;
  padding: 14px 18px 0;
  border-top: 1px solid #263041;
  font-size: 12px;
  color: #7d8b9c;
}
.sidebar .foot form { margin-top: 8px; }
.sidebar .foot button {
  background: none; border: 1px solid #3a4658; color: #c7d0da;
  padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.sidebar .foot button:hover { background: #1c2634; }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- cards ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1000px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; }
}

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat .note { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.badge.ok   { background: #e7f5ed; color: var(--good); border-color: #bfe3ce; }
.badge.warn { background: #fdf3e3; color: var(--warn); border-color: #f0d6a8; }
.badge.bad  { background: #fdecea; color: var(--bad);  border-color: #f3c4c0; }
.badge.mute { background: #eef1f4; color: var(--muted); border-color: #dde2e8; }

/* ---------- forms ---------- */

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 3px; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d3fb; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1; min-width: 160px; margin-bottom: 0; }

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.check label { margin: 0; }

button, .btn {
  display: inline-block; padding: 8px 14px; font: inherit; font-weight: 600;
  border-radius: 6px; border: 1px solid var(--border); background: #fff;
  color: var(--text); cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: #f2f4f7; text-decoration: none; }
.btn-primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
}
.btn-primary:hover, button.primary:hover { background: #1a5fd0; }
.btn-danger, button.danger { background: #fff; border-color: #e6b4b1; color: var(--bad); }
.btn-danger:hover, button.danger:hover { background: #fdecea; }
.btn-sm { padding: 4px 9px; font-size: 13px; font-weight: 500; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- flash + errors ---------- */

.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash.ok  { background: #e7f5ed; border-color: #bfe3ce; color: #145c37; }
.flash.err { background: #fdecea; border-color: #f3c4c0; color: #8c2420; }
.flash ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- pagination ---------- */

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; font-size: 14px; }
.pager a, .pager span {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text);
}
.pager a:hover { background: #f2f4f7; text-decoration: none; }
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .disabled { color: #b3bcc6; background: #fafbfc; }
.pager .info { border: none; background: none; color: var(--muted); margin-left: auto; }

/* ---------- chart ---------- */

.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.swatch-sessions { background: var(--accent); }
.swatch-signups { background: #7c3aed; }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; }
.login-box .card { padding: 24px; }
.login-box h1 { font-size: 18px; margin: 0 0 4px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-box button { width: 100%; }

/* ---------- misc ---------- */

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 7px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.scores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 800px) { .scores { grid-template-columns: repeat(2, 1fr); } }
.score { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: #fff; }
.score .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.score .value { font-size: 22px; font-weight: 600; margin-top: 3px; }
.score .comment { font-size: 13px; color: var(--muted); margin-top: 6px; }

pre.transcript {
  white-space: pre-wrap; word-wrap: break-word; background: #fafbfc;
  border: 1px solid var(--border); border-radius: 6px; padding: 12px;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0;
}

.notice {
  background: #fdf3e3; border: 1px solid #f0d6a8; color: #6b4106;
  padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px;
}
