/**
 * The admin's look, from the same tokens as the public site.
 *
 * Not a copy of the site's stylesheet: the panel is a tool, not a page, and
 * needs density the marketing site does not. But the palette and the three
 * families are the same values, so the panel reads as the same company rather
 * than a bolted-on dashboard.
 */

:root {
  color-scheme: dark;

  --warm-black: #1b1817;
  --surface: #221e1d;
  --surface-2: #2a2523;
  --hairline: #332e2c;
  --border: #3d3735;

  --cream: #e9dbc5;
  --ink-2: #bdae9a;
  --ink-3: #8b8078;

  --brand-red: #c8102e;
  /* The wordmark only. #c8102e is 2.81:1 on the sidebar surface, which fails AA
     for text; this is the nearest red that clears 4.5. The deep red stays on
     buttons, where it sits on its own gradient rather than on the surface. */
  --brand-red-on-surface: #f4525c;
  --brand-orange: #ff6a3d;
  --brand-orange-lift: #ff8a5c;

  /* One palette for every chart, so a colour means the same thing on each. */
  --series-1: #ff6a3d;
  --series-2: #e9dbc5;
  --series-3: #7fa8c9;
  --series-4: #c8a15a;
  --series-5: #9d8bb0;

  --font-head: 'Roboto Slab', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 10px;
  --gap: 1rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--warm-black);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

@media (max-width: 900px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 10; }
  .sidebar nav { display: flex; gap: 0.25rem; overflow-x: auto; }
}

/* Visible focus everywhere. A keyboard user must always know where they are. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-orange);
  outline-offset: 2px;
  border-radius: 4px;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 1.25rem 1rem;
}

.brand {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 1.5rem;
}
.brand span { color: var(--brand-red-on-surface); }

.sidebar nav a {
  display: block;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.15rem;
  border-radius: 6px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--cream); }
.sidebar nav a[aria-current='page'] {
  background: var(--surface-2);
  color: var(--cream);
  box-shadow: inset 2px 0 0 var(--brand-orange);
}

main { padding: 1.5rem 1.75rem 3rem; min-width: 0; }

h1 {
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.subtitle { color: var(--ink-3); font-size: 0.85rem; margin: 0 0 1.5rem; }

h2 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

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

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--gap);
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1rem;
}

.kpi-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.4rem;
}
.kpi-value {
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.kpi-note { font-size: 0.75rem; color: var(--ink-3); margin: 0.35rem 0 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); }

/* Tables ------------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
caption { text-align: left; color: var(--ink-3); font-size: 0.75rem; padding-bottom: 0.4rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--hairline); }
th { color: var(--ink-3); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }

/* A bar drawn with a background, so the number stays readable on top. */
.bar { position: relative; }
.bar::before {
  content: '';
  position: absolute;
  inset: 2px auto 2px 0;
  width: calc(var(--pct) * 1%);
  background: color-mix(in srgb, var(--series-1) 22%, transparent);
  border-radius: 3px;
}
.bar span { position: relative; }

/* Forms -------------------------------------------------------------------- */

label { display: block; font-size: 0.75rem; color: var(--ink-2); margin: 0 0 0.3rem; }
input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--warm-black);
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
textarea { min-height: 220px; font-family: var(--font-mono); font-size: 12px; resize: vertical; }
.field { margin-bottom: 0.9rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }

button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--cream);
  cursor: pointer;
}
button.primary {
  background: linear-gradient(180deg, var(--brand-red), #a50d26);
  border-color: transparent;
  color: #fff;
}
button.primary:hover { background: linear-gradient(180deg, var(--brand-orange), var(--brand-red)); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* Status ------------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--ink-2);
}
.pill.published { color: #7fd1a3; border-color: #2f5f47; }
.pill.scheduled { color: var(--brand-orange-lift); border-color: #6b3a2a; }
.pill.draft { color: var(--ink-3); }

#status {
  margin: 0 0 1rem;
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
}
#status:empty { display: none; }
#status[data-kind='error'] { border-color: var(--brand-red); color: #ffb4a8; }

.preview {
  background: var(--warm-black);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow: auto;
  max-height: 70vh;
}

.muted { color: var(--ink-3); font-size: 0.8rem; }
.hidden { display: none; }

/* Present for assistive technology, absent for everyone else. Used for the
   per-section heading that names each view while one shared h1 carries the
   visible title. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
