/* ============================================================================
   GymPulse design system
   Mobile first · dark by default with a first-class light theme · EN/AR (RTL)
   ========================================================================== */

:root {
  --brand: #22c55e;
  --brand-2: #38bdf8;
  --brand-ink: #04240f;

  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 44px;

  --font-latin: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', 'Manrope', system-ui, sans-serif;
  --dur-fast: 140ms;
  --dur: 240ms;
  --ease: cubic-bezier(0.22, 0.68, 0.36, 1);

  --shadow-sm: 0 1px 2px rgba(2, 8, 23, 0.08);
  --shadow-md: 0 10px 30px -18px rgba(2, 8, 23, 0.45);
  --shadow-lg: 0 30px 60px -30px rgba(2, 8, 23, 0.55);
  --shadow-brand: 0 18px 40px -22px color-mix(in srgb, var(--brand) 70%, transparent);
}

html[data-theme='dark'] {
  --bg: #060a12;
  --bg-2: #080d18;
  --surface: #0d1420;
  --surface-2: #121b2b;
  --surface-3: #182338;
  --border: #1e2a3f;
  --border-strong: #2b3a55;
  --text: #f5f8fc;
  --text-2: #cbd5e1;
  --muted: #8ea0b8;
  --overlay: rgba(4, 8, 15, 0.72);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --chip: rgba(255, 255, 255, 0.05);
  color-scheme: dark;
}

html[data-theme='light'] {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e4e9f1;
  --border-strong: #cdd6e4;
  --text: #0b1220;
  --text-2: #33415c;
  --muted: #64748b;
  --overlay: rgba(15, 23, 42, 0.42);
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --info: #2563eb;
  --chip: rgba(15, 23, 42, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-latin);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html[dir='rtl'] body { font-family: var(--font-arabic); }

h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: 1.25; letter-spacing: -0.015em; font-weight: 800; }
h1 { font-size: clamp(26px, 6vw, 40px); }
h2 { font-size: clamp(20px, 4.4vw, 28px); }
h3 { font-size: clamp(17px, 3.4vw, 21px); }
p { margin: 0 0 var(--space-3); color: var(--text-2); }
a { color: inherit; text-decoration: none; }
small { color: var(--muted); }
strong { font-weight: 700; }
::selection { background: color-mix(in srgb, var(--brand) 35%, transparent); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  inset-inline-start: -999px;
  top: 8px;
  z-index: 60;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}
.skip-link:focus { inset-inline-start: 12px; }

.noscript-note { max-width: 560px; margin: 80px auto; padding: 24px; text-align: center; }

/* ---------------------------------------------------------------- buttons */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 62%, var(--brand-2)));
  --btn-fg: var(--brand-ink);
  border-color: transparent;
  box-shadow: var(--shadow-brand);
}
.btn-ghost { --btn-bg: transparent; }
.btn-quiet { --btn-bg: transparent; border-color: transparent; color: var(--text-2); }
.btn-danger { --btn-bg: color-mix(in srgb, var(--bad) 16%, transparent); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 var(--space-4); font-size: 13px; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; border-radius: var(--radius-pill); }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin 700ms linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }


/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.card-tight { padding: var(--space-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-title { font-size: 15px; font-weight: 800; margin: 0; }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-4) 0; }

/* --------------------------------------------------------------- surfaces */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--chip);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.chip-good { background: color-mix(in srgb, var(--good) 16%, transparent); border-color: color-mix(in srgb, var(--good) 34%, transparent); color: var(--good); }
.chip-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); border-color: color-mix(in srgb, var(--warn) 34%, transparent); color: var(--warn); }
.chip-bad { background: color-mix(in srgb, var(--bad) 16%, transparent); border-color: color-mix(in srgb, var(--bad) 34%, transparent); color: var(--bad); }
.chip-brand { background: color-mix(in srgb, var(--brand) 18%, transparent); border-color: color-mix(in srgb, var(--brand) 38%, transparent); color: var(--brand); }

.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge-dot.live { background: var(--good); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { opacity: 0.45; } 100% { opacity: 1; } }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  overflow: hidden;
  flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 60px; height: 60px; border-radius: var(--radius-md); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--muted); }


/* ------------------------------------------------------------------ forms */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--bad); font-weight: 600; }

.input, .textarea, .select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand) 60%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}
.input[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--bad); }
.input-sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
input[type='color'].input { padding: 4px; cursor: pointer; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 46px; height: 26px; border-radius: var(--radius-pill);
  background: var(--surface-3); border: 1px solid var(--border);
  position: relative; transition: background var(--dur) var(--ease); flex: 0 0 auto;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--text);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .track { background: color-mix(in srgb, var(--brand) 45%, transparent); border-color: color-mix(in srgb, var(--brand) 60%, transparent); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--brand); }
html[dir='rtl'] .switch input:checked + .track::after { transform: translateX(-20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row .switch-copy { max-width: 78%; }
.switch-row .switch-copy b { display: block; font-size: 14px; color: var(--text); }
.switch-row .switch-copy span { font-size: 12.5px; color: var(--muted); }

.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); }
.segmented button {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 700;
  padding: 8px 14px; border-radius: var(--radius-pill); cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.tag-good { border-color: color-mix(in srgb, var(--good) 40%, transparent); color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }

/* ==========================================================================
   Public pages (landing · survey · thank you)
   ========================================================================== */

.public-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.public-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 10px clamp(14px, 4vw, 32px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand-mini { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mini .avatar { width: 38px; height: 38px; border-radius: 12px; font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 7vw, 72px) clamp(16px, 5vw, 40px);
  background:
    radial-gradient(1000px 420px at 12% -10%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 62%),
    radial-gradient(760px 420px at 92% 8%, color-mix(in srgb, var(--brand-2) 20%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}
.hero-inner { max-width: 1080px; margin: 0 auto; display: grid; gap: var(--space-6); }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  padding: 6px 14px; border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--brand) 34%, transparent);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand); font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em;
}
.hero h1 { font-size: clamp(30px, 8vw, 60px); letter-spacing: -0.03em; margin-bottom: var(--space-3); }
.hero h1 .accent {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { font-size: clamp(15px, 4.2vw, 19px); max-width: 62ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.hero-stats { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.stat-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border);
}
.stat-pill b { font-size: 18px; }
.stat-pill span { font-size: 12px; color: var(--muted); }

.section { padding: clamp(26px, 6vw, 56px) clamp(16px, 5vw, 40px); }
.section-inner { max-width: 1080px; margin: 0 auto; }
.section-title { text-align: center; margin-bottom: var(--space-6); }
.section-title h2 { margin-bottom: 6px; }
.section-title p { margin: 0 auto; max-width: 56ch; }

.why-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.why-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-5); display: flex; gap: var(--space-4); align-items: flex-start;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.why-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); box-shadow: var(--shadow-md); }
.why-icon {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 14px;
  display: grid; place-items: center; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
}
.why-card h3 { font-size: 15px; margin-bottom: 4px; }
.why-card p { font-size: 13.5px; margin: 0; }

.public-footer {
  margin-top: auto; padding: var(--space-6) clamp(16px, 5vw, 40px);
  border-top: 1px solid var(--border); color: var(--muted); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; align-items: center;
}



/* ------------------------------------------------------------------ survey */

.survey-shell { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.survey-top { padding: 10px clamp(14px, 4vw, 32px) 14px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.progress-track { height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.progress-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width var(--dur) var(--ease);
}

.q-area { flex: 1; display: flex; justify-content: center; padding: clamp(18px, 5vw, 44px) clamp(14px, 4vw, 32px) 150px; }
.q-card { width: 100%; max-width: 780px; }
.q-index {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--brand);
}
.q-text { font-size: clamp(20px, 5.4vw, 30px); font-weight: 800; letter-spacing: -0.02em; margin: var(--space-3) 0 var(--space-5); }
.q-anim { animation: qIn var(--dur) var(--ease); }
@keyframes qIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.option-list { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 15px 16px; min-height: 60px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
  font-weight: 600; color: var(--text-2); text-align: start;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
  width: 100%; font-family: inherit; font-size: 15px;
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.option:active { transform: scale(0.995); }
.option .mark {
  width: 24px; height: 24px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid var(--border-strong); position: relative; transition: all var(--dur) var(--ease);
}
.option.selected { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); color: var(--text); }
.option.selected .mark { border-color: var(--brand); background: var(--brand); }
.option.selected .mark::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--brand-ink); }
.option.square .mark { border-radius: 8px; }
.option.square.selected .mark::after { inset: 4px; border-radius: 4px; }

.rating-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.rating-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 4px; min-height: 92px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; color: var(--text-2);
  font-family: inherit; font-size: 11.5px; font-weight: 600; text-align: center;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.rating-btn .emoji { font-size: 26px; line-height: 1; filter: grayscale(0.4); transition: filter var(--dur) var(--ease), transform var(--dur) var(--ease); }
.rating-btn .num { font-size: 15px; font-weight: 800; }
.rating-btn:hover { border-color: var(--border-strong); }
.rating-btn.selected { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--text); }
.rating-btn.selected .emoji { filter: none; transform: scale(1.12); }
.rating-legend { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 10px; }

.counter { text-align: end; font-size: 12px; color: var(--muted); margin-top: 6px; }

.q-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: flex; gap: var(--space-3); align-items: center; justify-content: space-between;
  padding: 12px clamp(14px, 4vw, 32px) calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.q-nav .spacer { flex: 1; }
.q-actions { display: flex; align-items: center; gap: 10px; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.review-list { display: grid; gap: 10px; }
.review-item {
  display: flex; justify-content: space-between; gap: var(--space-3);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.review-item .q { color: var(--muted); font-size: 12.5px; }
.review-item .a { font-weight: 700; text-align: end; }

.hp-field { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }

.thanks-card {
  max-width: 620px; margin: clamp(30px, 8vw, 80px) auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(24px, 6vw, 48px);
}
.thanks-check {
  width: 84px; height: 84px; margin: 0 auto var(--space-5); border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 34%, transparent);
  color: var(--brand);
  animation: pop 520ms var(--ease);
}
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }


/* ==========================================================================
   Admin console
   ========================================================================== */

.admin-shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: 264px; flex: 0 0 auto;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  padding: var(--space-5) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-5);
  position: sticky; top: 0; height: 100dvh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: 14px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.nav-item svg { flex: 0 0 auto; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.user-card .who { min-width: 0; }
.user-card b { display: block; font-size: 13px; }
.user-card span { font-size: 11.5px; color: var(--muted); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 14px clamp(14px, 3vw, 28px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: clamp(18px, 3.4vw, 24px); margin: 0; }
.topbar .sub { color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-body { padding: clamp(14px, 3vw, 28px); display: flex; flex-direction: column; gap: var(--space-5); max-width: 1500px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.filter-bar .field { min-width: 160px; flex: 1 1 160px; }
.filter-bar .field.grow { flex: 2 1 240px; }

.kpi-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-4); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.kpi-value { font-size: clamp(24px, 4.6vw, 34px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-value small { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.kpi-icon {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand);
}

.chart-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-grid.wide { grid-template-columns: 1.4fr 1fr; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-5); }
.chart-card .legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
svg .chart-grid-line { stroke: var(--border); stroke-width: 1; }
svg .chart-axis-text { fill: var(--muted); font-size: 10px; font-family: inherit; }
svg .chart-label { fill: var(--text-2); font-size: 11.5px; font-family: inherit; }
svg .chart-value { fill: var(--text); font-size: 11.5px; font-weight: 700; font-family: inherit; }

.bar-row { display: grid; grid-template-columns: minmax(96px, 1.1fr) 2fr auto; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.bar-track { height: 12px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); animation: grow var(--dur) var(--ease); }
@keyframes grow { from { width: 0; } }
.bar-value { font-weight: 700; color: var(--text-2); min-width: 34px; text-align: end; }


/* ------------------------------------------------------------------ tables */

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.data th, table.data td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
table.data tbody tr { transition: background var(--dur) var(--ease); cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
.stars { display: inline-flex; gap: 2px; color: var(--warn); letter-spacing: 1px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }
.pager button {
  min-width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); font-weight: 700; cursor: pointer; font-family: inherit;
}
.pager button[aria-current='true'] { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.pager button[disabled] { opacity: 0.45; cursor: not-allowed; }

.mobile-cards { display: none; }

/* ---------------------------------------------------------- drawer/modal */

.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 50; }
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(560px, 100%); z-index: 51;
  background: var(--bg-2); border-inline-start: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 16px var(--space-5); border-bottom: 1px solid var(--border); }
.drawer-body { padding: var(--space-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.detail-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); }
.detail-box span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-box b { font-size: 15px; }

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--space-4); }
.modal-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-md); width: min(520px, 100%); padding: var(--space-5); box-shadow: var(--shadow-lg); }

.toast-root { position: fixed; z-index: 80; inset-block-end: calc(20px + env(safe-area-inset-bottom)); inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 600;
}
.toast.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }

/* ------------------------------------------------------------- QR page */

.qr-layout { display: grid; gap: var(--space-4); grid-template-columns: minmax(300px, 1fr) minmax(280px, 360px); align-items: start; }
.qr-poster {
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 36px); text-align: center;
}
.qr-poster img { width: min(320px, 74vw); height: auto; border-radius: var(--radius-md); background: #fff; padding: 14px; }
.qr-poster h3 { margin-top: var(--space-4); }
.qr-share { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: var(--space-4); }
.copy-field { display: flex; gap: 8px; align-items: center; }
.copy-field input { flex: 1; }

/* --------------------------------------------------- page states / misc */

.boot-screen { min-height: 70dvh; display: grid; place-content: center; gap: 14px; justify-items: center; }
.boot-logo { width: 54px; height: 54px; border-radius: 16px; border: 2px solid var(--border); position: relative; }
.boot-logo span {
  position: absolute; inset: 6px; border-radius: 10px;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  animation: pulse 1.4s infinite;
}
.boot-text { color: var(--muted); font-size: 13px; }

.error-note {
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  color: var(--bad); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px; font-weight: 600;
}

/* -------------------------------------------------------------- responsive */

.mobile-nav { display: none; }
.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 1024px) {
  .qr-layout { grid-template-columns: 1fr; }
  .chart-grid.wide { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-nav {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto; gap: 2px;
  }
  .mobile-nav a {
    flex: 1 0 auto; min-width: 72px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 6px; border-radius: 12px; font-size: 11px; font-weight: 700; color: var(--muted);
  }
  .mobile-nav a.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
  .page-body { padding-bottom: 92px; }
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .rating-btn { min-height: 82px; padding: 12px 2px; }
  .rating-btn .emoji { font-size: 22px; }
  .filter-bar .field { flex: 1 1 100%; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .card, .chart-card { padding: var(--space-4); }
  .hero { padding-top: 24px; }
  .q-nav .btn { flex: 1; }
  .toast-root { inset-inline: 12px; }
  .toast { max-width: none; }
  .bar-row { grid-template-columns: minmax(84px, 1.2fr) 1.6fr auto; font-size: 12.5px; }
}

/* ------------------------------------------------------------------- print */

@media print {
  .sidebar, .mobile-nav, .topbar-actions, .q-nav, .public-top, .toast-root, .no-print { display: none !important; }
  body { background: #fff; }
  .page-body { padding: 0; }
  .card, .chart-card, .table-wrap { break-inside: avoid; border-color: #cbd5e1; }
  a[href]::after { content: ''; }
}

@media print {
  body.print-qr-only .admin-shell > *:not(.print-target) { display: none !important; }
  body.print-qr-only .print-target { display: block !important; }
  body.print-qr-only .qr-poster { border: 0; background: #fff; color: #000; }
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------- admin free-text comment blocks */
.comment-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 10px 12px;
  margin: 10px 0;
  line-height: 1.65;
}
.comment-block p { margin: 0 0 6px; }
.comment-block p:last-child { margin-bottom: 0; }
.drawer-body .switch-row:last-child { border-bottom: 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.filter-bar .field { flex: 1 1 160px; }
.filter-bar .field.grow { flex: 2 1 240px; }
