/*
 * openGym admin panel — the design system.
 *
 * A dark-first operations console in the app's default palette: near-black
 * with the brochure's neon green and gold frames in dark, deep green on a pale
 * ground in light. Three rules hold the sheet together, and none of
 * them is a preference:
 *
 * 1. LOGICAL PROPERTIES ONLY. There is no `left`, `right`, `margin-left` or
 *    `text-align: left` anywhere below — only `inline-start`, `inline-end` and
 *    `start`/`end`. The panel is Persian first and English second, and a
 *    physical property is a bug that only appears for half the users. The one
 *    place direction is decided is `dir` on <html>; everything here follows it
 *    for free. (ADR-0007.)
 *
 * 2. TOKENS, NEVER RAW COLOUR. Every colour a component uses is a variable
 *    defined once per theme, and the text/ground pairs are checked by
 *    arithmetic in `tests/adminpanel/test_token_contrast.py`, which parses
 *    this file. A hex in a component is how a panel ends up with nine greys
 *    and a dark mode that is wrong in three places.
 *
 * 3. GLOW IS STATE, NOT DECORATION. Gold light marks the thing that is
 *    active, focused or selected. A surface that glows is a surface that is
 *    doing something, which keeps the effect legible instead of noisy — and
 *    lets `prefers-reduced-motion` drop the animation without losing meaning.
 *
 * Density is dashboard-grade: an operator looking at 200 members wants rows,
 * not cards with breathing room. The scale is 4px-based and tight.
 */

/* ==========================================================================
   Font
   ========================================================================== */

/* Self-hosted, one variable file for every weight. A CDN is not something a
   panel used from Tehran can depend on, and a Persian UI in the system's
   fallback font is a different product. Licence: fonts/OFL.txt. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.f6d31671339d.woff2") format("woff2-variations"),
       url("../fonts/Vazirmatn-Variable.f6d31671339d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   Tokens — light
   ========================================================================== */
:root {
  color-scheme: light;

  /* Turquoise in light, olive in dark, and gold for every frame (the same
     choices as the app's palettes). `-700` is ink on a light ground, `-400`
     is ink and light on a dark one. */
  --brand-300: #22e06b;
  --brand-400: #17a84f;
  --brand-500: #0e8a4f;
  --brand-600: #0a7040;
  --brand-700: #075c34;
  --brand-rgb: 10 112 64;
  --gold-rgb: 176 134 10;
  --gold: #7a5a08;
  --frame: rgb(var(--gold-rgb) / 0.42);

  /* Semantic — what components actually reference. */
  --bg: #f3f6f4;
  --bg-subtle: #e9efeb;
  --surface: #ffffff;
  --surface-raised: #fafcfb;
  --border: #dde5e0;
  /* A control boundary, not a divider: the edge of an input. Somebody who
     cannot see where a field starts cannot use it, so this clears 3:1. */
  --border-strong: #6b7b73;
  --text: #0a1410;
  --text-muted: #4b5b53;
  --text-inverse: #ffffff;
  --accent: var(--brand-600);
  --accent-hover: var(--brand-700);
  --accent-text: #ffffff;
  --accent-subtle: rgb(10 112 64 / 0.1);
  --danger: #b42318;
  --danger-subtle: rgb(180 35 24 / 0.08);
  --warn: #8a4b06;
  --warn-subtle: rgb(138 75 6 / 0.1);
  --info: #1e5a8c;
  --info-subtle: rgb(30 90 140 / 0.08);
  --ring: var(--brand-600);

  --gradient: linear-gradient(135deg, var(--brand-600), var(--brand-500));
  --glow: 0 0 0 1px rgb(10 112 64 / 0.25), 0 6px 18px -6px rgb(10 112 64 / 0.4);
  --shadow-sm: 0 1px 2px rgb(11 34 36 / 0.06);
  --shadow-md: 0 2px 6px rgb(11 34 36 / 0.06), 0 12px 32px -12px rgb(11 34 36 / 0.18);
  --shadow-lg: 0 8px 24px rgb(11 34 36 / 0.1), 0 32px 64px -24px rgb(11 34 36 / 0.25);
  --glass: rgb(255 255 255 / 0.78);
  --backdrop: radial-gradient(60rem 30rem at 100% -10%, rgb(34 224 107 / 0.10), transparent 60%);
  --grid-line: transparent;

  /* The sidebar is charcoal in both themes, framed in gold: the one fixed
     surface a returning operator recognises before reading a word. It
     carries its own tokens so the light theme cannot bleach it. */
  --side-bg: #050706;
  --side-surface: #0b110e;
  --side-border: rgb(245 197 24 / 0.16);
  --side-fg: #e6efe9;
  --side-muted: #93a79a;
  --side-accent: #22e06b;
  --side-active: rgb(34 224 107 / 0.12);

  /* Dashboard density: 4px base, tight. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --sidebar-width: 16rem;
  --sidebar-collapsed: 4.5rem;
  --header-height: 3.75rem;

  /* One duration per intent, not one duration for everything. Exits are
     faster than entrances: something leaving should never make you wait. */
  --t-fast: 140ms;
  --t-base: 220ms;
  --t-slow: 380ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Direction as a number, for the one thing logical properties cannot
     express: a centring translate. */
  --dir: 1;
}

[dir="rtl"] {
  --dir: -1;
}

/* ==========================================================================
   Tokens — dark

   Dark is the console's home, not an inverted filter: surfaces step *up*
   from the background, and the olive brightens to stay the loudest thing on
   screen. Declared twice — once for a viewer on system default, once for an
   explicit choice — so the toggle wins in both directions. The contrast test
   checks that the two blocks agree.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand-300: #7df0b1;
    --brand-400: #22e06b;
    --brand-500: #17a84f;
    --brand-rgb: 34 224 107;
    --gold-rgb: 245 197 24;
    --gold: #f5c518;
    --frame: rgb(var(--gold-rgb) / 0.3);
    --bg: #060809;
    --bg-subtle: #0b100e;
    --surface: #101815;
    --surface-raised: #15201b;
    --border: #1c2a23;
    --border-strong: #5e7568;
    --text: #edf4ef;
    --text-muted: #93a79a;
    --accent: var(--brand-400);
    --accent-hover: var(--brand-300);
    --accent-text: #03140a;
    --accent-subtle: rgb(34 224 107 / 0.12);
    --danger: #ff8a7a;
    --danger-subtle: rgb(242 135 125 / 0.14);
    --warn: #f5c518;
    --warn-subtle: rgb(245 197 24 / 0.12);
    --info: #7fc4ff;
    --info-subtle: rgb(127 185 230 / 0.14);
    --ring: var(--brand-400);
    --gradient: linear-gradient(135deg, var(--brand-400), var(--brand-500));
    --glow: 0 0 0 1px rgb(34 224 107 / 0.35), 0 0 24px -4px rgb(34 224 107 / 0.45);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.45);
    --shadow-md: 0 2px 6px rgb(0 0 0 / 0.4), 0 12px 32px -12px rgb(0 0 0 / 0.65);
    --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.5), 0 32px 64px -24px rgb(0 0 0 / 0.8);
    --glass: rgb(11 16 14 / 0.78);
    --backdrop: radial-gradient(60rem 32rem at 100% -10%, rgb(34 224 107 / 0.08), transparent 60%), radial-gradient(40rem 24rem at 0% 110%, rgb(245 197 24 / 0.05), transparent 60%);
    --grid-line: rgb(34 224 107 / 0.025);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-300: #7df0b1;
  --brand-400: #22e06b;
  --brand-500: #17a84f;
  --brand-rgb: 34 224 107;
  --gold-rgb: 245 197 24;
  --gold: #f5c518;
  --frame: rgb(var(--gold-rgb) / 0.3);
  --bg: #060809;
  --bg-subtle: #0b100e;
  --surface: #101815;
  --surface-raised: #15201b;
  --border: #1c2a23;
  --border-strong: #5e7568;
  --text: #edf4ef;
  --text-muted: #93a79a;
  --accent: var(--brand-400);
  --accent-hover: var(--brand-300);
  --accent-text: #03140a;
  --accent-subtle: rgb(34 224 107 / 0.12);
  --danger: #ff8a7a;
  --danger-subtle: rgb(242 135 125 / 0.14);
  --warn: #f5c518;
  --warn-subtle: rgb(245 197 24 / 0.12);
  --info: #7fc4ff;
  --info-subtle: rgb(127 185 230 / 0.14);
  --ring: var(--brand-400);
  --gradient: linear-gradient(135deg, var(--brand-400), var(--brand-500));
  --glow: 0 0 0 1px rgb(34 224 107 / 0.35), 0 0 24px -4px rgb(34 224 107 / 0.45);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.45);
  --shadow-md: 0 2px 6px rgb(0 0 0 / 0.4), 0 12px 32px -12px rgb(0 0 0 / 0.65);
  --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.5), 0 32px 64px -24px rgb(0 0 0 / 0.8);
  --glass: rgb(11 16 14 / 0.78);
  --backdrop: radial-gradient(60rem 32rem at 100% -10%, rgb(34 224 107 / 0.08), transparent 60%), radial-gradient(40rem 24rem at 0% 110%, rgb(245 197 24 / 0.05), transparent 60%);
  --grid-line: rgb(34 224 107 / 0.025);
}

/* Compact density drops row height without changing type size — an operator
   scanning 200 rows wants more of them per screen, not smaller words. */
:root[data-density="compact"] {
  --space-3: 0.5rem;
  --space-4: 0.75rem;
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: "Vazirmatn", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-block-size: 100vh;
  background-color: var(--bg);
  /* A faint warm light from the top corner, and in dark a graph-paper grid:
     the console's texture. Both are tokens, so the light theme turns the grid
     off rather than painting it pale. */
  background-image:
    var(--backdrop),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.6;
  /* Tabular figures everywhere: a column of money or counts that jitters as
     digits change is a column nobody can scan. */
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* Persian glyphs sit taller than Latin ones; the default line height clips
   descenders on ی and ج at body sizes. */
html[lang="fa"] body {
  line-height: 1.75;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
h1 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.0625rem;
}
h3 {
  font-size: 0.9375rem;
}

::selection {
  background: var(--accent-subtle);
  color: var(--text);
}

/* One visible focus ring for the whole panel. Never removed — a panel a
   keyboard user cannot navigate is a panel half the staff cannot use. */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skipped rather than tabbed through: the sidebar is 30+ links before the
   table on every single page. */
.skip-link {
  position: absolute;
  inset-block-start: -100vh;
  inset-inline-start: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius);
}
.skip-link:focus {
  inset-block-start: var(--space-4);
}

/* Directional glyphs point the way the page reads. A chevron that says
   "next" must point left in Persian. */
[dir="rtl"] .icon--chevron,
[dir="rtl"] .icon--arrow {
  transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Shell
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--header-height) 1fr;
  /* Named areas rather than column numbers, so RTL needs no override: the
     grid follows the writing direction on its own. */
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-block-size: 100vh;
  transition: grid-template-columns var(--t-base) var(--ease);
}

/* -- Sidebar --------------------------------------------------------------- */
.sidebar {
  grid-area: sidebar;
  position: sticky;
  inset-block-start: 0;
  block-size: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(18rem 14rem at 50% -4rem, rgb(var(--brand-rgb) / 0.1), transparent 70%),
    var(--side-bg);
  border-inline-end: 1px solid var(--side-border);
  color: var(--side-fg);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  color: var(--side-fg);
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}
.brand__mark {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: var(--radius);
  /* The openGym mark sits on its own dark tile whatever the theme: its
     figures are white, and on the light surface they would vanish. */
  background: #060809;
  overflow: hidden;
  color: #03130b;
  box-shadow: 0 0 20px -4px rgb(var(--brand-rgb) / 0.6);
}

.brand__mark--large {
  inline-size: 3.5rem;
  block-size: 3.5rem;
}

.brand__logo {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}
.brand__name small {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--side-muted);
  letter-spacing: 0;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--gold-rgb) / 0.15) transparent;
}

.nav-group {
  margin-block-end: var(--space-4);
}
.nav-group__label {
  padding-inline: var(--space-3);
  margin-block: var(--space-2);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--side-muted);
  white-space: nowrap;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--side-fg);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-link:hover {
  background: rgb(255 255 255 / 0.05);
  color: #ffffff;
  text-decoration: none;
}
.nav-link svg {
  flex-shrink: 0;
  color: var(--side-muted);
  transition: color var(--t-fast) var(--ease);
}
.nav-link:hover svg {
  color: var(--side-fg);
}
/* The current page: a lit bar on the reading edge, the one place in the
   sidebar that glows. */
.nav-link[aria-current="page"] {
  background: var(--side-active);
  color: #ffffff;
  font-weight: 600;
}
.nav-link[aria-current="page"] svg {
  color: var(--side-accent);
}
.nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-block: 0.55rem;
  inset-inline-start: calc(var(--space-3) * -1);
  inline-size: 3px;
  border-start-end-radius: 3px;
  border-end-end-radius: 3px;
  background: var(--side-accent);
  box-shadow: 0 0 12px rgb(var(--brand-rgb) / 0.8);
}
.nav-link:focus-visible {
  outline-color: var(--side-accent);
}

.sidebar__foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-block-start: 1px solid var(--side-border);
  background: var(--side-surface);
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: 50%;
  background: rgb(var(--brand-rgb) / 0.14);
  color: var(--side-accent);
  font-weight: 700;
  font-size: 0.875rem;
  border: 1px solid rgb(var(--brand-rgb) / 0.3);
}
.sidebar__who {
  min-inline-size: 0;
  flex: 1;
  line-height: 1.35;
}
.sidebar__who strong {
  display: block;
  color: #ffffff;
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__who span {
  display: block;
  color: var(--side-muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__foot .btn--ghost {
  color: var(--side-muted);
}
.sidebar__foot .btn--ghost:hover {
  background: rgb(255 255 255 / 0.06);
  color: #ffffff;
}

/* Collapsed on a wide screen: icons only, and every link keeps its name as a
   tooltip and an accessible label. */
.shell[data-sidebar="collapsed"] {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}
.shell[data-sidebar="collapsed"] .brand__name,
.shell[data-sidebar="collapsed"] .nav-link span,
.shell[data-sidebar="collapsed"] .sidebar__who,
.shell[data-sidebar="collapsed"] .nav-group__label {
  display: none;
}
.shell[data-sidebar="collapsed"] .brand,
.shell[data-sidebar="collapsed"] .nav-link,
.shell[data-sidebar="collapsed"] .sidebar__foot {
  justify-content: center;
  padding-inline: 0;
}
.shell[data-sidebar="collapsed"] .nav-group {
  padding-block-start: var(--space-2);
  border-block-start: 1px solid var(--side-border);
}
.shell[data-sidebar="collapsed"] .nav-group:first-child {
  border-block-start: 0;
}
.shell[data-sidebar="collapsed"] .sidebar__foot {
  flex-direction: column;
}

/* -- Header ---------------------------------------------------------------- */
.header {
  grid-area: header;
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-5);
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-block-end: 1px solid var(--border);
}
.header__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header__crumb {
  color: var(--text-muted);
  font-weight: 500;
}
.header__spacer {
  margin-inline-start: auto;
}
.header__divider {
  inline-size: 1px;
  block-size: 1.5rem;
  background: var(--border);
  margin-inline: var(--space-1);
}

.org-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-inline-size: 16rem;
  min-block-size: 2.25rem;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
}
.org-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.org-chip svg {
  color: var(--accent);
  flex: none;
}
a.org-chip:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--glow);
}
.org-chip__dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--brand-400);
  box-shadow: 0 0 8px var(--brand-400);
  flex: none;
}

/* The theme toggle shows the theme you are in. */
.theme-icon {
  display: none;
}
:root[data-theme="light"] .theme-icon--light,
:root[data-theme="dark"] .theme-icon--dark,
:root[data-theme="system"] .theme-icon--system,
:root:not([data-theme]) .theme-icon--system {
  display: inline-flex;
}

.main {
  grid-area: main;
  padding: var(--space-5) var(--space-6) var(--space-8);
  min-inline-size: 0; /* lets a wide table scroll instead of stretching the grid */
  animation: enter var(--t-slow) var(--ease-out) both;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-block-end: var(--space-5);
}
.page-head__icon {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 3rem;
  block-size: 3rem;
  border-radius: var(--radius-lg);
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.page-head__text {
  min-inline-size: 0;
}
.page-head__sub {
  margin-block: var(--space-1) 0;
  color: var(--text-muted);
}
.page-head__actions {
  margin-inline-start: auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.backdrop {
  display: none;
}

@media (max-width: 60rem) {
  .shell,
  .shell[data-sidebar="collapsed"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "header"
      "main";
  }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: min(var(--sidebar-width), 85vw);
    transform: translateX(calc(-100% * var(--dir)));
    transition: transform var(--t-base) var(--ease-out);
    box-shadow: var(--shadow-lg);
    z-index: 40;
  }
  .sidebar[data-open="true"] {
    transform: none;
  }
  .sidebar[data-open="true"] ~ .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(0 0 0 / 0.5);
  }
  .shell[data-sidebar="collapsed"] .brand__name,
  .shell[data-sidebar="collapsed"] .nav-link span,
  .shell[data-sidebar="collapsed"] .sidebar__who,
  .shell[data-sidebar="collapsed"] .nav-group__label {
    display: revert;
  }
  .header {
    padding-inline: var(--space-3);
  }
  .main {
    padding: var(--space-4) var(--space-4) var(--space-6);
  }
  .hide-narrow,
  .collapse-toggle {
    display: none !important;
  }
}

@media (min-width: 60.01rem) {
  .menu-toggle {
    display: none !important;
  }
}

/* ==========================================================================
   Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-block-size: 2.375rem;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn--primary {
  background: var(--gradient);
  border-color: transparent;
  color: var(--accent-text);
}
.btn--primary:hover {
  background: var(--gradient);
  border-color: transparent;
  box-shadow: var(--glow);
  color: var(--accent-text);
}
.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}
.btn--danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-subtle);
}
.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  border-color: transparent;
  background: var(--bg-subtle);
  color: var(--text);
}
.btn--sm {
  min-block-size: 2rem;
  padding: var(--space-1) var(--space-3);
  font-size: 0.8125rem;
}
/* An icon-only button is still a 40px target: the panel runs on front-desk
   tablets, not only under a mouse. */
.btn--icon {
  inline-size: 2.5rem;
  min-block-size: 2.5rem;
  padding: 0;
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-block-end: var(--space-4);
}
/* A visible label, always. A placeholder disappears the moment someone types,
   which is exactly when they need to know what the box is for. */
.field label,
.field__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text);
}
.field__hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input,
.select {
  inline-size: 100%;
  min-block-size: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text);
  font: inherit;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.input:hover,
.select:hover {
  border-color: var(--text-muted);
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-subtle);
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  inline-size: 1rem;
  block-size: 1rem;
}

/* An email address or a phone number is never RTL, whatever the page is. */
.input--ltr {
  direction: ltr;
  text-align: start;
}

.form {
  max-inline-size: 40rem;
}
.form__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-4);
}

/* A small, keyboard-reachable "what is this?" next to a label or a heading.
   Its text is the accessible name too, so nothing lives only in a hover. */
.help {
  display: inline-grid;
  place-items: center;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: help;
  vertical-align: middle;
  transition: color var(--t-fast) var(--ease);
}
.help:hover,
.help:focus-visible {
  color: var(--accent);
}

/* ==========================================================================
   Tooltip — one floating element, positioned by panel.js

   Not a CSS ::after. A pseudo-element is clipped by any scrolling ancestor,
   and every table in this panel sits in one; a tooltip on a column header
   that vanishes at the table's edge is worse than none.
   ========================================================================== */
.tooltip {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: 1000;
  max-inline-size: 18rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: #0b1210;
  color: #eaf5ef;
  border: 1px solid rgb(var(--gold-rgb) / 0.22);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35), 0 0 18px -6px rgb(var(--brand-rgb) / 0.35);
  font-size: 0.78rem;
  line-height: 1.6;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.tooltip[data-visible="true"] {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Hint — the "what is this screen for" note at the top of a page

   Dismissible, and remembered per browser: a hint that is useful on day one
   is furniture by day ten. The ? in the header brings them all back.
   ========================================================================== */
.hint {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-block-end: var(--space-5);
  padding: var(--space-3) var(--space-4);
  padding-inline-end: var(--space-8);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: var(--radius-lg);
  background:
    linear-gradient(90deg, var(--accent-subtle), transparent 70%),
    var(--surface);
  color: var(--text);
  animation: enter var(--t-base) var(--ease-out) both;
}
[dir="rtl"] .hint {
  background:
    linear-gradient(270deg, var(--accent-subtle), transparent 70%),
    var(--surface);
}
.hint__icon {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--accent);
}
.hint__title {
  display: block;
  font-weight: 700;
  margin-block-end: 0.125rem;
}
.hint__text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.hint__close {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-end: var(--space-2);
}
.hint[hidden],
:root[data-hints="off"] .hint {
  display: none;
}

/* ==========================================================================
   Cards, stats, tables, badges
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-block-end: var(--space-5);
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-block-end: 1px solid var(--border);
}
.card__head svg {
  color: var(--accent);
  flex: none;
}
.card__head .page-head__actions,
.card__actions {
  margin-inline-start: auto;
  display: flex;
  gap: var(--space-2);
}
.card__body {
  padding: var(--space-5);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: var(--space-4);
  margin-block-end: var(--space-5);
}
.stat {
  position: relative;
  overflow: hidden;
  padding: var(--space-4) var(--space-5) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    transform var(--t-base) var(--ease);
}
/* A lit edge along the top: every figure on this panel is a live one. */
.stat::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: 2px;
  background: var(--gradient);
  opacity: 0.8;
}
.stat:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-block-end: var(--space-3);
}
.stat__icon {
  display: grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--accent);
}
.stat__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-block-end: var(--space-1);
}
.stat__value {
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat__note {
  margin-block-start: var(--space-2);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Shortcut tiles on the dashboard: one per screen, grouped. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--space-3);
}
.tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: 3.5rem;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 600;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.tile:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
  text-decoration: none;
  transform: translateY(-1px);
}
.tile__icon {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
}
.tile__group {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* The wrapper is what keeps a wide table inside the page instead of pushing
   the whole layout sideways. */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card .table-scroll {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.table {
  inline-size: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}
.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: start;
  border-block-end: 1px solid var(--border);
}
.table thead th {
  position: sticky;
  inset-block-start: 0;
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  z-index: 1;
}
.table tbody tr {
  transition: background var(--t-fast) var(--ease);
}
.table tbody tr:last-child td {
  border-block-end: none;
}
.table tbody tr:hover {
  background: var(--accent-subtle);
}
/* The row under the pointer gets the lit edge the sidebar's current page has. */
.table tbody tr:hover td:first-child {
  box-shadow: inset calc(3px * var(--dir)) 0 0 var(--accent);
}
.table td.numeric,
.table th.numeric {
  text-align: end;
}
.table__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}
.table__sort:hover,
.table__sort[aria-sort] {
  color: var(--accent);
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  /* Never wraps mid-label: a status chip broken across two lines reads as two
     statuses. */
  white-space: nowrap;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid transparent;
}
/* Status carries a dot as well as a colour: colour alone is invisible to a
   colourblind operator, and this panel shows paid/overdue side by side. */
.badge::before {
  content: "";
  inline-size: 0.4rem;
  block-size: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}
.badge--ok {
  background: var(--accent-subtle);
  color: var(--accent);
}
.badge--ok::before {
  box-shadow: 0 0 6px currentColor;
}
.badge--warn {
  background: var(--warn-subtle);
  color: var(--warn);
}
.badge--danger {
  background: var(--danger-subtle);
  color: var(--danger);
}
.badge--plain {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.badge--plain::before {
  display: none;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  margin-block-end: var(--space-4);
  font-weight: 500;
}
.alert svg {
  flex: none;
  margin-block-start: 0.2rem;
}
.alert--error {
  background: var(--danger-subtle);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}
.alert--info {
  background: var(--accent-subtle);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}
.alert a {
  color: inherit;
  text-decoration: underline;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--text-muted);
}
.empty__icon {
  display: grid;
  place-items: center;
  inline-size: 4rem;
  block-size: 4rem;
  margin-block-end: var(--space-2);
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 6%, transparent);
}
.empty__title {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9375rem;
}
.empty p {
  margin: 0;
  max-inline-size: 32rem;
}
.empty .btn {
  margin-block-start: var(--space-3);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  padding: var(--space-4);
  margin-block-end: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.filters .field {
  margin-block-end: 0;
  min-inline-size: 10rem;
  flex: 1 1 10rem;
  max-inline-size: 16rem;
}
.filters__actions {
  display: flex;
  gap: var(--space-2);
}

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-block-end: var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.bulk-bar__count {
  margin-inline-end: auto;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-block-start: var(--space-4);
}
.pagination__info {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  position: relative;
  display: flex;
  gap: var(--space-3);
  padding-block: var(--space-3);
  padding-inline-start: var(--space-5);
  border-block-end: 1px solid var(--border);
}
.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.25rem;
  inset-block-start: 1.15rem;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.timeline li:last-child {
  border-block-end: none;
}
.timeline__when {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
  min-inline-size: 9rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-3);
  margin: 0;
}
.detail-grid > div {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}
.detail-grid dt {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-block-end: var(--space-1);
}
.detail-grid dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Sign-in — the one page with no shell
   ========================================================================== */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  min-block-size: 100vh;
  background: var(--bg);
}
.auth__aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-8);
  overflow: hidden;
  color: var(--side-fg);
  background:
    radial-gradient(40rem 26rem at 20% 110%, rgb(var(--brand-rgb) / 0.22), transparent 60%),
    radial-gradient(30rem 20rem at 100% 0%, rgb(var(--brand-rgb) / 0.14), transparent 60%),
    linear-gradient(rgb(var(--gold-rgb) / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgb(var(--gold-rgb) / 0.04) 1px, transparent 1px),
    var(--side-bg);
  background-size: auto, auto, 32px 32px, 32px 32px, auto;
}
.auth__aside .brand {
  padding: 0;
  font-size: 1.25rem;
}
.auth__pitch h2 {
  color: #ffffff;
  font-size: 2rem;
  line-height: 1.35;
  font-weight: 800;
  max-inline-size: 24rem;
}
.auth__pitch h2 em {
  font-style: normal;
  color: var(--side-accent);
  text-shadow: 0 0 24px rgb(var(--brand-rgb) / 0.5);
}
.auth__pitch p {
  color: var(--side-muted);
  max-inline-size: 26rem;
  margin-block: var(--space-3) 0;
}
.auth__points {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.auth__points li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--side-fg);
}
.auth__points svg {
  color: var(--side-accent);
  flex: none;
}
.auth__main {
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-4);
}
.auth__card {
  inline-size: 100%;
  max-inline-size: 25rem;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: enter var(--t-slow) var(--ease-out) both;
}
.auth__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-block-end: var(--space-2);
  font-size: 1.25rem;
  font-weight: 800;
}
.auth__brand .brand__mark {
  inline-size: 2.5rem;
  block-size: 2.5rem;
}
.auth__subtitle {
  color: var(--text-muted);
  margin-block: 0 var(--space-5);
}
.auth__card .btn--primary {
  inline-size: 100%;
  min-block-size: 2.75rem;
}
.auth__footer {
  margin-block-start: var(--space-5);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* A signed-in dead end (no organization) reuses the card without the pitch. */
.auth--single {
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: var(--space-4);
}

@media (max-width: 56rem) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }
  .auth__aside {
    display: none;
  }
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Insight
   -------------------------------------------------------------------------- */

/* A segmented control for the reporting period. Logical properties throughout,
   so under RTL the first button rounds on the right without a second rule. */
.seg {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}
.seg .btn {
  border-color: transparent;
  background: transparent;
  min-block-size: 2rem;
  color: var(--text-muted);
}
.seg .btn:hover {
  color: var(--text);
  background: var(--surface);
}
.seg .btn[aria-current="true"],
.seg .btn[aria-pressed="true"],
.seg .btn--primary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* The chart is drawn server-side as an SVG path; only its skin lives here.
   `preserveAspectRatio="none"` on the element is what lets it fill the card,
   and `vector-effect` is what stops the stroke stretching with it. */
.chart {
  inline-size: 100%;
  block-size: 12rem;
  display: block;
  overflow: visible;
}
.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.25;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent));
}
.chart__area {
  fill: var(--accent-subtle);
  stroke: none;
}
.chart__caption {
  margin-block-start: var(--space-3);
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}
.chart__data {
  margin-block-start: var(--space-4);
}
.chart__data > summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding-block: var(--space-2);
}
.chart__data > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chart__data .table-scroll {
  margin-block-start: var(--space-3);
}

/* ---------------------------------------------------------------------------
   Reason chips
   --------------------------------------------------------------------------

   Every computed number on the training screens carries the reasons that
   produced it. They wrap; they are never clipped into a fixed-height row —
   the reason a coach cannot read is precisely the one that would have
   explained the number they did not expect. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-start: var(--space-2);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding-block: 2px;
  padding-inline: var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid transparent;
}
.chip--warn {
  background: var(--warn-subtle);
  color: var(--warn);
}
.chip--plain {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

/* A single inline notice inside a card. Not a toast: this one is a property
   of the data on screen, so it must survive a page it was never dismissed
   on. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-block-start: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 0.875rem;
}
.notice--warn {
  border-color: color-mix(in srgb, var(--warn) 55%, transparent);
  background: var(--warn-subtle);
}
.notice svg {
  flex: none;
  margin-block-start: 2px;
}

.muted {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* A field's own error, under it. Colour is never the only signal: the input
   also carries aria-invalid, and the message says what to change. */
.field__error {
  color: var(--danger);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-block-start: var(--space-1);
}

/* Utility for the handful of layouts that are a row of things. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* --- exercise library -------------------------------------------------- */
.ex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--space-4);
}
.ex-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.ex-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.ex-card[aria-disabled="true"] { cursor: default; }
.ex-card[aria-disabled="true"]:hover { transform: none; border-color: var(--border); }
.ex-card--hidden .ex-card__media { opacity: 0.45; }
.ex-card__media {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: #fff;
  border-block-end: 1px solid var(--border);
}
.ex-card__media img { inline-size: 100%; block-size: 100%; object-fit: contain; }
.ex-card__placeholder { color: var(--text-muted); }
.ex-card__body { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); }
.ex-card__name { font-size: 0.9375rem; line-height: 1.4; }
.ex-card__alt { color: var(--text-muted); font-size: 0.75rem; text-align: start; }
.ex-form { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); margin-block-end: var(--space-4); }
.ex-form textarea, .ex-form select, .ex-form input[type="text"], .ex-form input[type="url"] {
  inline-size: 100%;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.ex-form select[multiple] { min-block-size: 9rem; }
.ex-previews { display: flex; gap: var(--space-4); margin-block-end: var(--space-4); }
.ex-preview { margin: 0; display: grid; gap: var(--space-2); justify-items: center; }
.ex-preview img, .ex-preview .ex-card__placeholder {
  inline-size: 9rem; block-size: 9rem; display: grid; place-items: center;
  object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
}
.ex-preview figcaption { color: var(--text-muted); font-size: 0.8125rem; }
.field--check .check { display: flex; align-items: center; gap: var(--space-2); }

/* ==========================================================================
   Frames — gold, as in the app

   Every card, figure and panel sits in a thin gold frame. The frame is a
   token (`--frame`), so the light theme's turquoise console keeps a warmer,
   quieter edge and the charcoal one a brighter one. The mark itself is the
   brand's green, never the frame's gold.
   ========================================================================== */
.card,
.stat {
  border-color: var(--frame);
}
.brand__mark {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgb(255 255 255 / 0.35), transparent 55%),
    linear-gradient(135deg, #22e06b, #0e8a4f);
  color: #03130b;
  box-shadow:
    0 0 0 1px rgb(34 224 107 / 0.55),
    0 0 22px -4px rgb(34 224 107 / 0.75);
}
.brand__mark svg {
  filter: drop-shadow(0 1px 0 rgb(255 255 255 / 0.25));
}
.sidebar {
  background:
    radial-gradient(18rem 14rem at 50% -4rem, rgb(34 224 107 / 0.12), transparent 70%),
    var(--side-bg);
}

/* ==========================================================================
   The navigation tree — section › group › screen

   Three levels, three different shapes so the eye never has to count
   indents: a section is a row with its icon in a tile; a group is a small
   caption on a guide line; a screen is a dot on that line. The section you
   are in is lit, and the screen you are on is the brightest thing in it.
   ========================================================================== */
.nav-link--top {
  margin-block-end: var(--space-3);
}
.nav-section {
  position: relative;
  margin-block-end: 0.375rem;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.nav-section[open] {
  background: linear-gradient(180deg, rgb(34 224 107 / 0.07), rgb(255 255 255 / 0.015) 3.5rem);
  border-color: rgb(34 224 107 / 0.16);
}
.nav-section:has([aria-current="page"]) {
  border-color: rgb(34 224 107 / 0.3);
  box-shadow: 0 0 18px -10px rgb(34 224 107 / 0.8);
}
.nav-section__head,
.nav-sub__head {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.nav-section__head::-webkit-details-marker,
.nav-sub__head::-webkit-details-marker {
  display: none;
}
.nav-section__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: 2.75rem;
  padding: 0.375rem var(--space-2);
  border-radius: var(--radius-lg);
  color: var(--side-fg);
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-section__head:hover {
  background: rgb(255 255 255 / 0.045);
  color: #ffffff;
}
.nav-section__head:focus-visible {
  outline: 2px solid var(--side-accent);
  outline-offset: -2px;
}
/* The section's icon sits in a tile, so a closed menu still reads as a
   column of places rather than a list of words. */
.nav-section__head > svg:first-child {
  flex: none;
  box-sizing: content-box;
  padding: 0.4375rem;
  border-radius: 0.625rem;
  background: rgb(255 255 255 / 0.05);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
  color: var(--side-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.nav-section__head:hover > svg:first-child {
  color: var(--side-fg);
}
.nav-section[open] > .nav-section__head > svg:first-child {
  background: rgb(34 224 107 / 0.12);
  box-shadow: inset 0 0 0 1px rgb(34 224 107 / 0.3);
  color: var(--side-accent);
}
.nav-section:has([aria-current="page"]) > .nav-section__head > svg:first-child {
  background: linear-gradient(135deg, #22e06b, #0e8a4f);
  box-shadow: 0 0 14px -2px rgb(34 224 107 / 0.7);
  color: #03130b;
}
.nav-section[open] > .nav-section__head {
  color: #ffffff;
}
.nav-section__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-section__count {
  min-inline-size: 1.5rem;
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.06);
  color: var(--side-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-section[open] > .nav-section__head .nav-section__count {
  background: rgb(34 224 107 / 0.14);
  color: var(--side-accent);
}
.nav-section__chevron {
  display: inline-flex;
  color: var(--side-muted);
  opacity: 0.7;
  transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
  transform: rotate(calc(90deg * var(--dir)));
}
.nav-section__head:hover .nav-section__chevron,
.nav-sub__head:hover .nav-section__chevron {
  opacity: 1;
}
details[open] > summary .nav-section__chevron {
  transform: rotate(calc(-90deg * var(--dir)));
}
.nav-section[open] > .nav-section__body {
  animation: nav-open var(--t-fast) var(--ease-out) both;
}
@keyframes nav-open {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
/* The guide line: everything inside a section hangs off it, under the
   middle of the section's icon tile. */
.nav-section__body {
  position: relative;
  margin-inline-start: 1.5rem;
  padding: 0.125rem 0 var(--space-2);
  padding-inline: var(--space-2) var(--space-1);
  border-inline-start: 1px solid rgb(255 255 255 / 0.08);
}
.nav-section:has([aria-current="page"]) > .nav-section__body {
  border-inline-start-color: rgb(34 224 107 / 0.25);
}
.nav-sub {
  margin-block-start: 0.375rem;
}
.nav-sub:first-child {
  margin-block-start: 0.125rem;
}
.nav-sub__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3125rem var(--space-2);
  border-radius: var(--radius);
  color: var(--side-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color var(--t-fast) var(--ease);
}
.nav-sub__head > span:first-child {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-sub__head:hover {
  color: var(--side-fg);
}
.nav-sub:has([aria-current="page"]) > .nav-sub__head {
  color: #b9f5cf;
}
.nav-link--leaf {
  gap: var(--space-2);
  min-block-size: 2.125rem;
  margin-block: 1px;
  padding-block: 0.3125rem;
  padding-inline: var(--space-3) var(--space-2);
  border-radius: var(--radius);
  color: rgb(230 239 233 / 0.82);
  font-size: 0.8125rem;
  font-weight: 500;
}
/* A screen is a dot on the guide line. */
.nav-link--leaf::after {
  content: "";
  position: absolute;
  inset-inline-start: calc(var(--space-2) * -1 - 3.5px);
  inset-block-start: 50%;
  inline-size: 6px;
  block-size: 6px;
  margin-block-start: -3px;
  border-radius: 50%;
  background: var(--side-bg);
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.2);
  transition: box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.nav-link--leaf:hover {
  background: rgb(255 255 255 / 0.05);
  color: #ffffff;
}
.nav-link--leaf:hover::after {
  box-shadow: inset 0 0 0 1.5px var(--side-accent);
}
.nav-link--leaf[aria-current="page"] {
  background: linear-gradient(90deg, rgb(34 224 107 / 0.16), rgb(34 224 107 / 0.04));
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgb(34 224 107 / 0.22);
}
[dir="rtl"] .nav-link--leaf[aria-current="page"] {
  background: linear-gradient(270deg, rgb(34 224 107 / 0.16), rgb(34 224 107 / 0.04));
}
.nav-link--leaf[aria-current="page"]::before {
  display: none;
}
.nav-link--leaf[aria-current="page"]::after {
  background: var(--side-accent);
  box-shadow: 0 0 0 3px rgb(34 224 107 / 0.18), 0 0 10px rgb(34 224 107 / 0.9);
}
.nav-link--leaf svg {
  inline-size: 16px;
  block-size: 16px;
  opacity: 0.85;
}
.shell[data-sidebar="collapsed"] .nav-section__label,
.shell[data-sidebar="collapsed"] .nav-section__count,
.shell[data-sidebar="collapsed"] .nav-section__chevron,
.shell[data-sidebar="collapsed"] .nav-sub__head {
  display: none;
}
.shell[data-sidebar="collapsed"] .nav-section__head {
  justify-content: center;
  padding-inline: 0;
}
.shell[data-sidebar="collapsed"] .nav-section__body {
  margin-inline-start: 0;
  padding-inline: 0;
  border-inline-start: 0;
}
.shell[data-sidebar="collapsed"] .nav-link--leaf {
  padding-inline: 0;
  justify-content: center;
}
.shell[data-sidebar="collapsed"] .nav-link--leaf::after {
  display: none;
}
@media (max-width: 1023.98px) {
  .shell[data-sidebar="collapsed"] .nav-section__label,
  .shell[data-sidebar="collapsed"] .nav-section__count,
  .shell[data-sidebar="collapsed"] .nav-section__chevron,
  .shell[data-sidebar="collapsed"] .nav-sub__head {
    display: revert;
  }
  .shell[data-sidebar="collapsed"] .nav-section__body {
    margin-inline-start: 1.5rem;
    padding-inline: var(--space-2) var(--space-1);
    border-inline-start: 1px solid rgb(255 255 255 / 0.08);
  }
  .shell[data-sidebar="collapsed"] .nav-link--leaf::after {
    display: revert;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nav-section[open] > .nav-section__body {
    animation: none;
  }
}

/* -- Breadcrumbs: where you are, in the sidebar's own words ---------------- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin-block-end: var(--space-4);
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.crumbs__sep {
  display: inline-flex;
  opacity: 0.6;
}
[dir="rtl"] .crumbs__sep svg {
  transform: scaleX(-1);
}
.crumbs__item--here {
  color: var(--text);
  font-weight: 600;
}

/* -- Forms ------------------------------------------------------------------ */
.form-card {
  max-inline-size: 56rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0 var(--space-5);
}
.form-grid textarea.input {
  min-block-size: 6rem;
  resize: vertical;
}
.form-card__foot {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-block-start: 1px solid var(--border);
  background: var(--bg-subtle);
}
.field__error {
  margin: 0;
  color: var(--danger);
  font-size: 0.75rem;
}

/* -- Activity --------------------------------------------------------------- */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-4);
  margin-block-end: var(--space-5);
}
.section-card {
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--frame);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.section-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-end: var(--space-3);
  font-weight: 700;
}
.section-card__head svg {
  color: var(--accent);
}
.figure-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-1);
  border-block-end: 1px dashed var(--border);
}
.figure-row:last-child {
  border-block-end: 0;
}
.figure-row__value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}
.figure-row__of {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-end: var(--space-4);
}
.tab {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-weight: 600;
}
.tab:hover {
  text-decoration: none;
  color: var(--text);
}
.tab[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--text);
}
.meter {
  display: inline-block;
  inline-size: 5rem;
  block-size: 0.375rem;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
  vertical-align: middle;
}
.meter > i {
  display: block;
  block-size: 100%;
  background: var(--gradient);
}
.days {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.days__day {
  inline-size: 0.875rem;
  block-size: 0.875rem;
  border-radius: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.days__day--on {
  background: var(--accent);
  border-color: var(--accent);
}
.person-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-block-end: var(--space-5);
}
.person-head .avatar {
  inline-size: 3.5rem;
  block-size: 3.5rem;
  font-size: 1.25rem;
  background: rgb(var(--gold-rgb) / 0.14);
  border-color: var(--frame);
  color: var(--gold);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem var(--space-2);
  border: 1px solid var(--frame);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  color: var(--text);
}
.data-output {
  max-block-size: 18rem;
  overflow: auto;
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.75rem;
  direction: ltr;
  text-align: start;
  white-space: pre-wrap;
}

/* ==========================================================================
   Neon layer

   The brochure's look on the console: a seam of green-to-gold light down the
   sidebar and under the header, a lit rail on each page heading, cards framed
   in gold that brighten when they can be acted on. Glow still marks state —
   the link you are on, the figure you can open, the item waiting for you —
   and `prefers-reduced-motion` drops only the pulse.
   ========================================================================== */
.sidebar {
  position: sticky;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-end: -1px;
  inline-size: 1px;
  background: linear-gradient(180deg, transparent, rgb(34 224 107 / 0.6) 22%, rgb(245 197 24 / 0.5) 70%, transparent);
  pointer-events: none;
}
.header {
  position: relative;
}
.header::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: -1px;
  block-size: 1px;
  background: linear-gradient(90deg, transparent, rgb(var(--brand-rgb) / 0.55), rgb(var(--gold-rgb) / 0.45), transparent);
  pointer-events: none;
}

.page-head {
  position: relative;
  overflow: hidden;
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--frame);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.page-head::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: 3px;
  background: linear-gradient(180deg, var(--brand-400), rgb(var(--gold-rgb)));
  box-shadow: 0 0 16px 1px rgb(var(--brand-rgb) / 0.55);
}
.page-head::after {
  content: "";
  position: absolute;
  inset-block-start: -70%;
  inset-inline-end: -4%;
  inline-size: 22rem;
  block-size: 14rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(var(--brand-rgb) / 0.14), transparent 68%);
  pointer-events: none;
}
.page-head--hero {
  padding-block: var(--space-5);
}

.card {
  border-color: var(--frame);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
.card:hover {
  border-color: rgb(var(--gold-rgb) / 0.5);
}
.card--attention {
  border-color: rgb(var(--gold-rgb) / 0.6);
  box-shadow: 0 0 0 1px rgb(var(--gold-rgb) / 0.18), 0 0 28px -10px rgb(var(--gold-rgb) / 0.55);
}
.card__head .link,
.link {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
}

.table thead th {
  border-block-end: 1px solid rgb(var(--brand-rgb) / 0.35);
  box-shadow: 0 1px 0 rgb(var(--brand-rgb) / 0.12);
}

/* -- Scope: the whole system, or one gym ---------------------------------- */
.scope-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid rgb(var(--brand-rgb) / 0.4);
  background: var(--accent-subtle);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.scope-chip--gym {
  border-color: rgb(var(--gold-rgb) / 0.55);
  background: rgb(var(--gold-rgb) / 0.1);
}
.scope-chip__dot,
.health__dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--brand-400);
  box-shadow: 0 0 0 0 rgb(var(--brand-rgb) / 0.7);
  animation: neon-pulse 2.2s var(--ease) infinite;
}
@keyframes neon-pulse {
  0% { box-shadow: 0 0 0 0 rgb(var(--brand-rgb) / 0.7); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.scope-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-block-end: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgb(var(--gold-rgb) / 0.55);
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, rgb(var(--gold-rgb) / 0.14), rgb(var(--gold-rgb) / 0.03));
  color: var(--text);
}
.scope-banner > span {
  flex: 1;
  min-inline-size: 14rem;
}
.scope-banner form {
  margin: 0;
}

/* -- Health ---------------------------------------------------------------- */
.health {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  position: relative;
  z-index: 1;
}
.health__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 0.75rem;
  font-weight: 600;
}
.health__item--down .health__dot {
  background: var(--danger);
  animation: none;
  box-shadow: 0 0 8px var(--danger);
}

/* -- KPI tiles -------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-3);
  margin-block-end: var(--space-4);
}
.kpi-grid--3 {
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}
.kpi {
  --tone: var(--brand-rgb);
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--frame);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(14rem 8rem at 100% 0%, rgb(var(--tone) / 0.12), transparent 70%),
    var(--surface);
  color: var(--text);
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-fast) var(--ease);
}
.kpi::after {
  content: "";
  position: absolute;
  inset-inline: var(--space-4);
  inset-block-end: 0;
  block-size: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgb(var(--tone) / 0.9), transparent);
  box-shadow: 0 0 10px rgb(var(--tone) / 0.6);
}
.kpi--gold { --tone: var(--gold-rgb); }
.kpi--blue { --tone: 56 189 248; }
.kpi--violet { --tone: 167 139 250; }
.kpi--link:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: rgb(var(--tone) / 0.6);
  box-shadow: 0 0 0 1px rgb(var(--tone) / 0.25), 0 0 26px -8px rgb(var(--tone) / 0.6);
}
.kpi__icon {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  border-radius: var(--radius);
  background: rgb(var(--tone) / 0.14);
  color: rgb(var(--tone));
  box-shadow: inset 0 0 0 1px rgb(var(--tone) / 0.3), 0 0 18px -6px rgb(var(--tone) / 0.7);
}
:root:not([data-theme="dark"]) .kpi--green .kpi__icon { color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kpi--green .kpi__icon { color: var(--brand-400); }
}
.kpi__body {
  min-inline-size: 0;
}
.kpi__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}
.kpi__value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi__sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* -- Dashboard grids -------------------------------------------------------- */
.dash-grid {
  display: grid;
  gap: var(--space-3);
  margin-block-end: var(--space-3);
}
.dash-grid > .card,
.dash-grid > div > .card {
  margin-block-end: 0;
}
.dash-grid > div {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}
.dash-grid--2 { grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); }
.dash-grid--3 { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.dash-grid--wide { grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); }
@media (max-width: 64rem) {
  .dash-grid--wide { grid-template-columns: minmax(0, 1fr); }
}

.figure-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart--compact {
  inline-size: 100%;
  block-size: 7.5rem;
}
.chart--gold .chart__line { stroke: rgb(var(--gold-rgb)); filter: drop-shadow(0 0 4px rgb(var(--gold-rgb) / 0.6)); }
.chart--gold .chart__area { fill: rgb(var(--gold-rgb) / 0.12); }
.chart__axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* -- Lists ------------------------------------------------------------------ */
.list {
  list-style: none;
  margin: 0;
  padding: var(--space-1) 0;
}
.list__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-block-end: 1px solid var(--border);
}
.list__row:last-child { border-block-end: 0; }
.list__main {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.list__main:hover { text-decoration: none; }
a.list__main:hover strong { color: var(--accent); }
.list__main .muted { font-size: 0.75rem; }
.list__empty {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--text-muted);
}
.avatar--sm {
  inline-size: 1.875rem;
  block-size: 1.875rem;
  font-size: 0.75rem;
  color: var(--accent);
}
.rank {
  display: grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border-radius: 50%;
  border: 1px solid rgb(var(--gold-rgb) / 0.6);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
}
.person-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* -- Bars ------------------------------------------------------------------- */
.bars {
  display: grid;
  gap: var(--space-3);
}
.bar__label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.8125rem;
  margin-block-end: var(--space-1);
}
.bar__track {
  block-size: 0.375rem;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
}
.bar__fill {
  display: block;
  block-size: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  box-shadow: 0 0 10px rgb(var(--brand-rgb) / 0.6);
}
.bar__fill--gold {
  background: linear-gradient(90deg, rgb(var(--gold-rgb) / 0.7), rgb(var(--gold-rgb)));
  box-shadow: 0 0 10px rgb(var(--gold-rgb) / 0.5);
}

/* -- Shortcuts -------------------------------------------------------------- */
.quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.quick__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.quick__item svg { color: var(--accent); flex: none; }
.quick__item:hover {
  text-decoration: none;
  border-color: rgb(var(--brand-rgb) / 0.5);
  box-shadow: var(--glow);
}

.timeline--dense li {
  padding-block: var(--space-2);
}

/* -- Tabs counters ---------------------------------------------------------- */
.tab__count {
  display: inline-block;
  min-inline-size: 1.25rem;
  margin-inline-start: var(--space-1);
  padding: 0 var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  font-size: 0.6875rem;
  font-weight: 700;
  text-align: center;
}
.tab--on {
  color: var(--accent);
  border-color: var(--accent);
}

.disclosure > summary {
  cursor: pointer;
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }

/* -- Ready-made content ----------------------------------------------------- */
.stat-grid--dense {
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: var(--space-3);
  margin-block: var(--space-4);
}
.job {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--frame);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.job:hover { border-color: rgb(var(--brand-rgb) / 0.45); }
.job__head { display: flex; align-items: center; gap: var(--space-2); }
.job__icon {
  display: grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--accent);
}
.job__title { margin: 0; font-size: 0.9375rem; }
.job__about { margin: 0; flex: 1; font-size: 0.8125rem; color: var(--text-muted); }
.job .btn { align-self: flex-start; }
.run > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

/* -- System map ------------------------------------------------------------- */
.flow {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--space-4);
  counter-reset: step;
}
.flow__step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-3) var(--space-3);
  border: 1px solid rgb(var(--brand-rgb) / 0.35);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgb(var(--brand-rgb) / 0.08), transparent 60%), var(--surface-raised);
  font-size: 0.8125rem;
  counter-increment: step;
}
.flow__step > span:not(.flow__icon):not(.flow__count) { color: var(--text-muted); }
.flow__step::before {
  content: counter(step);
  position: absolute;
  inset-block-start: -0.7rem;
  inset-inline-start: var(--space-3);
  display: grid;
  place-items: center;
  inline-size: 1.4rem;
  block-size: 1.4rem;
  border-radius: 50%;
  background: var(--brand-400);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 800;
  box-shadow: 0 0 12px rgb(var(--brand-rgb) / 0.7);
}
:root:not([data-theme="dark"]) .flow__step::before { color: #03140a; }
.flow__step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: calc(var(--space-4) * -1);
  inline-size: var(--space-4);
  block-size: 2px;
  background: linear-gradient(90deg, rgb(var(--brand-rgb) / 0.8), rgb(var(--gold-rgb) / 0.8));
}
.flow__step--gold {
  border-color: rgb(var(--gold-rgb) / 0.55);
  background: linear-gradient(180deg, rgb(var(--gold-rgb) / 0.1), transparent 60%), var(--surface-raised);
}
.flow__step--gold::before { background: rgb(var(--gold-rgb)); box-shadow: 0 0 12px rgb(var(--gold-rgb) / 0.7); }
.flow__icon { color: var(--accent); }
.flow__step--gold .flow__icon { color: var(--gold); }
.flow__count {
  margin-block-start: auto;
  font-weight: 700;
  color: var(--accent);
}
.map-level p { margin-block: 0 var(--space-2); }
.map-level__where { display: flex; align-items: center; gap: var(--space-2); font-size: 0.8125rem; color: var(--text-muted); }
.map-level__count { font-size: 1.25rem; font-weight: 800; }
.map-level--platform { border-color: rgb(var(--brand-rgb) / 0.5); }
.map-level--gym { border-color: rgb(var(--gold-rgb) / 0.55); }
.matrix th[scope="row"] { min-inline-size: 13rem; text-align: start; font-weight: 500; }
.matrix__area { font-size: 0.6875rem; white-space: normal; min-inline-size: 3.5rem; text-align: center; text-transform: none; letter-spacing: 0; }
.matrix td, .matrix th { padding-inline: var(--space-2); }
.matrix__cell { text-align: center; }
.matrix__yes {
  display: inline-grid;
  place-items: center;
  inline-size: 1.4rem;
  block-size: 1.4rem;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  box-shadow: 0 0 10px -2px rgb(var(--brand-rgb) / 0.7);
}
.matrix__no { color: var(--border-strong); }

@media (prefers-reduced-motion: reduce) {
  .scope-chip__dot,
  .health__dot { animation: none; }
  .kpi--link:hover { transform: none; }
}

/* Time runs left to right in a chart whatever the reading direction: the
   newest day is on the right in Persian too, as on every chart people read. */
.chart,
.chart__axis {
  direction: ltr;
}
body {
  background-attachment: fixed;
}

/* A label and its value, one pair per row, inside a card. */
.kv {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
  margin: 0;
  padding: var(--space-2) var(--space-4);
}
.kv dt,
.kv dd {
  margin: 0;
  padding-block: var(--space-2);
  border-block-end: 1px solid var(--border);
}
.kv dt {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.kv dd {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.kv dt:last-of-type,
.kv dd:last-of-type {
  border-block-end: 0;
}

/* ==========================================================================
   One gym, from openGym's side
   ========================================================================== */
.gym-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block: calc(var(--space-2) * -1) var(--space-4);
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.gym-note svg {
  flex: none;
  color: var(--accent);
}
.tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.gym-chips {
  margin-block-end: var(--space-3);
}
.gym-chips .chip {
  text-decoration: none;
}
.chip--on {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--text);
  font-weight: 600;
}
.kpi-grid--4 {
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
}
.card--danger-zone {
  border-color: rgb(220 38 38 / 0.35);
}
.org-name {
  font-weight: 700;
  color: var(--text);
}
.org-name:hover {
  color: var(--accent);
}

/* -- AI & models ------------------------------------------------------------- */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}
.row-actions form {
  margin: 0;
}
