/* CoreNine admin panel. No build step, no framework, no CDN — see index.html. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #14181d;
  --muted: #697280;
  --accent: #4c6ef5;
  --ok: #2f9e44;
  --warn: #e8a33d;
  --bad: #e03131;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --border: #262c35;
    --text: #e6e9ee;
    --muted: #8a94a3;
    --accent: #748ffc;
    --bad: #ff6b6b;
    --ok: #51cf66;
    --warn: #fcc419;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.hidden { display: none !important; }

/* ----------------------------------------------------------------- brand */

.lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);          /* the mark inherits this via currentColor */
  line-height: 1;
}

.lockup .mark {
  width: 26px;
  height: 26px;
  flex: none;
  overflow: visible;
}

.wordmark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* The name and the mark say the same thing: 'Nine' takes the accent. */
.word-core { color: var(--text); }
.word-nine { color: var(--accent); }

.lockup-stacked {
  flex-direction: column;
  gap: 14px;
  margin-bottom: 6px;
}

.lockup-stacked .mark { width: 68px; height: 68px; }
.lockup-stacked .wordmark { font-size: 28px; }

.lockup-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/*
 * The mark, alive — only where it is the subject (the login screen).
 *
 * The ring does not spin, it STEPS: nine points, 40° at a time, easing into each
 * point and then resting on it, so it reads as the figure counting through its own
 * points rather than as a generic spinner. The core breathes underneath, one full
 * breath per turn. Same motion as the app's CoreNineLoader — the brand and the wait
 * speak with one voice.
 */
[data-animated] .mark-ring,
[data-animated] .mark-core {
  transform-box: view-box;
  transform-origin: 50px 50px;
}

[data-animated] .mark-ring { animation: ring-step 3.6s infinite; }
[data-animated] .mark-core { animation: core-breathe 3.6s ease-in-out infinite; }

/* Nine steps: 62% of each step travelling, the rest resting on the point. */
@keyframes ring-step {
  0%      { transform: rotate(0deg);   animation-timing-function: cubic-bezier(.65,0,.35,1); }
  6.89%   { transform: rotate(40deg);  animation-timing-function: step-end; }
  11.11%  { transform: rotate(40deg);  animation-timing-function: cubic-bezier(.65,0,.35,1); }
  18.00%  { transform: rotate(80deg);  animation-timing-function: step-end; }
  22.22%  { transform: rotate(80deg);  animation-timing-function: cubic-bezier(.65,0,.35,1); }
  29.11%  { transform: rotate(120deg); animation-timing-function: step-end; }
  33.33%  { transform: rotate(120deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  40.22%  { transform: rotate(160deg); animation-timing-function: step-end; }
  44.44%  { transform: rotate(160deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  51.33%  { transform: rotate(200deg); animation-timing-function: step-end; }
  55.56%  { transform: rotate(200deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  62.44%  { transform: rotate(240deg); animation-timing-function: step-end; }
  66.67%  { transform: rotate(240deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  73.56%  { transform: rotate(280deg); animation-timing-function: step-end; }
  77.78%  { transform: rotate(280deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  84.67%  { transform: rotate(320deg); animation-timing-function: step-end; }
  88.89%  { transform: rotate(320deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  95.78%  { transform: rotate(360deg); animation-timing-function: step-end; }
  100%    { transform: rotate(360deg); }
}

@keyframes core-breathe {
  0%, 100% { transform: scale(1); }
  25%      { transform: scale(1.10); }
  75%      { transform: scale(0.90); }
}

/* Stand still rather than burn frames, exactly as the Flutter mark does. */
@media (prefers-reduced-motion: reduce) {
  [data-animated] .mark-ring,
  [data-animated] .mark-core { animation: none; }
}

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

#login {
  max-width: 340px;
  margin: 12vh auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#login h1 { margin: 0 0 4px; font-size: 20px; }
#login p  { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

input, select {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
}

button {
  padding: 9px 14px;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.danger {
  background: var(--bad);
  color: #fff;
  border: 0;
}

button.ghost-danger,
button.ghost.danger {
  background: transparent !important;
  border: 1px solid color-mix(in srgb, var(--bad) 55%, transparent) !important;
  color: var(--bad) !important;
}

button.ghost-danger:hover,
button.ghost.danger:hover {
  background: color-mix(in srgb, var(--bad) 16%, transparent) !important;
  border-color: var(--bad) !important;
  color: var(--bad) !important;
}

.error {
  margin-top: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border-radius: 7px;
  color: var(--bad);
  font-size: 13px;
}

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

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

header h1 { margin: 0; font-size: 15px; font-weight: 600; }
header .spacer { flex: 1; }
header .who { color: var(--muted); font-size: 12px; }

nav { display: flex; gap: 2px; }

nav button {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 7px 12px;
}

nav button.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

main { padding: 20px; max-width: 1180px; margin: 0 auto; }

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }

.note {
  margin-top: 10px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-radius: 7px;
  font-size: 12px;
  color: var(--text);
}

/* ------------------------------------------------------------------ bars */

.bar-row {
  display: grid;
  grid-template-columns: 74px 1fr 52px;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 13px;
}

.bar-row .label { color: var(--muted); }
.bar-row .value { text-align: right; font-variant-numeric: tabular-nums; }

.bar {
  height: 8px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  border-radius: 4px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.bar.ok   > span { background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.bar.bad  > span { background: var(--bad); }

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

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

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
}

.pill.ok     { background: color-mix(in srgb, var(--ok) 16%, transparent);     color: var(--ok); }
.pill.bad    { background: color-mix(in srgb, var(--bad) 16%, transparent);    color: var(--bad); }
.pill.warn   { background: color-mix(in srgb, var(--warn) 18%, transparent);   color: var(--warn); }
.pill.accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

/* An Enneagram type, in its own colour — the same nine the app paints. */
.type-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip) 18%, transparent);
  color: var(--chip);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.type-chip-none {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
  font-weight: 400;
}

.toolbar { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar label { margin: 0; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.muted { color: var(--muted); }
.wrap  { white-space: normal; }
.mono  { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* Long prose (knowledge chunks, quiz stems) must not force the page to scroll sideways. */
.clamp {
  white-space: normal;
  max-width: 560px;
  overflow-wrap: anywhere;
}

.spend-chart { width: 100%; height: 90px; display: block; }

/* ------------------------------------------------------------- enneagram */

.enn {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 4px auto 0;
  aspect-ratio: 1;
}

.enn circle,
.enn line { transition: opacity .18s ease; }

/*
 * The matrix. Cells are square and tight on purpose: 81 of them only read as a shape
 * — "the eights are a wall of pale, the nines are a wall of colour" — if the eye can
 * take the whole grid in at once.
 */
table.matrix { width: auto; border-collapse: separate; border-spacing: 2px; }

table.matrix th {
  padding: 2px;
  text-align: center;
}

.matrix-cell {
  width: 44px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  text-align: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: default;
}

/* A pair somebody actually asked for. The ring is what separates the model's opinion
   from a thing that happened. */
.matrix-real {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  font-weight: 700;
}
