:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --surface-soft: #eef5f4;
  --text: #182230;
  --muted: #667085;
  --subtle: #98a2b3;
  --border: #d8e1ea;
  --border-soft: #e7edf3;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --blue: #2454a6;
  --warn: #b45309;
  --danger: #b42318;
  --success: #117a55;
  --neon: #29f0d4;
  --neon-2: #64b5ff;
  --glow: 0 0 0 1px rgba(41, 240, 212, 0.12), 0 0 24px rgba(41, 240, 212, 0.14);
  --sidebar: #0d1b2a;
  --sidebar-2: #10243a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 42px rgba(16, 24, 40, 0.07);
  --shadow-lift: 0 4px 24px rgba(16, 24, 40, 0.12), 0 1px 4px rgba(16, 24, 40, 0.05);
  --radius: 8px;
  --radius-lg: 14px;
  --sidebar-width: 264px;
  --sidebar-collapsed: 78px;
  --transition-base: 0.18s ease;
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg: #091116;
  --surface: #101b23;
  --surface-muted: #0c171e;
  --surface-soft: #102c2b;
  --text: #e9f7f8;
  --muted: #9fb3be;
  --subtle: #728894;
  --border: #24404b;
  --border-soft: #1b3039;
  --accent: #18c7b5;
  --accent-strong: #29f0d4;
  --blue: #64b5ff;
  --warn: #f2a444;
  --danger: #ff6b5f;
  --success: #41d89f;
  --sidebar: #071016;
  --sidebar-2: #0c2028;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.24), 0 18px 42px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 4px 32px rgba(0, 0, 0, 0.4), 0 1px 6px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

:root[data-theme="dark"] body {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: 'Geist', Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

body.is-loading {
  cursor: progress;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: 1.22rem;
}

h3 {
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

/* ─────────────────────────────────────────
   KEYFRAMES
───────────────────────────────────────── */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes meshFloat {
  0%   { background-size: 100% 100%; }
  50%  { background-size: 110% 110%; }
  100% { background-size: 100% 100%; }
}

@keyframes dotPulse {
  0%   { box-shadow: 0 0 0 0 rgba(41, 240, 212, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(41, 240, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(41, 240, 212, 0); }
}

@keyframes dotPulseOffline {
  0%   { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(180, 35, 24, 0); }
  100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0); }
}

@keyframes botSweep {
  0% {
    transform: translateX(-100%);
  }
  48%,
  100% {
    transform: translateX(100%);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}

@keyframes focusPulse {
  0%,
  100% {
    box-shadow: var(--shadow), 0 0 0 rgba(17, 122, 85, 0);
  }
  50% {
    box-shadow: var(--shadow-lift), 0 0 0 5px rgba(17, 122, 85, 0.08);
  }
}

@keyframes statusFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(36, 84, 166, 0.18);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(36, 84, 166, 0);
  }
}

/* ─────────────────────────────────────────
   STAGGER ENTRANCE
───────────────────────────────────────── */

.stagger-in {
  animation: fadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─────────────────────────────────────────
   LAYOUT SHELL
───────────────────────────────────────── */

.app-shell {
  min-height: 100vh;
}

/* ─────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #f8fafc;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-shell {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .main-shell {
  margin-left: var(--sidebar-collapsed);
}

/* ─────────────────────────────────────────
   BRAND BLOCK
───────────────────────────────────────── */

.brand-block {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.72rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark,
.nav-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  font-weight: 900;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: #d7fffb;
  background: rgba(15, 118, 110, 0.38);
  border: 1px solid rgba(215, 255, 251, 0.16);
  box-shadow: 0 0 18px rgba(41, 240, 212, 0.18);
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.brand-mark:hover {
  box-shadow: 0 0 0 4px rgba(41, 240, 212, 0.25), 0 0 32px rgba(41, 240, 212, 0.3);
  transform: scale(1.05);
}

.brand-mark.large {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.brand-copy strong {
  font-size: 1.02rem;
  font-weight: 850;
}

.brand-copy span,
.nav-section {
  color: #b8c4d6;
  font-size: 0.78rem;
}

.icon-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.52rem 0.65rem;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base);
}

:root[data-theme="dark"] .icon-button {
  background: #0f1b23;
  color: var(--text);
  border-color: var(--border);
}

.sidebar .icon-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 0.76rem;
}

.toggle-closed {
  display: none;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section {
  display: none;
}

body.sidebar-collapsed .brand-block {
  grid-template-columns: 1fr;
  justify-items: center;
}

body.sidebar-collapsed .toggle-open {
  display: none;
}

body.sidebar-collapsed .toggle-closed {
  display: inline;
}

/* ─────────────────────────────────────────
   SIDE NAV
───────────────────────────────────────── */

.side-nav {
  display: grid;
  gap: 0.22rem;
}

.side-nav a,
.nav-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.68rem;
  min-height: 42px;
  padding: 0.52rem 0.62rem;
  border-radius: var(--radius);
  color: #e7edf6;
  font-size: 0.95rem;
  font-weight: 760;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

.side-nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.11);
  padding-left: 0.85rem;
}

.side-nav a.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(41, 240, 212, 0.14), rgba(41, 240, 212, 0.04));
  box-shadow: inset 3px 0 0 var(--neon);
}

.nav-mark {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.08);
  color: #c7f4ee;
  font-size: 0.78rem;
  transition: transform 0.2s ease, background 0.15s ease;
  flex-shrink: 0;
}

.side-nav a:hover .nav-mark {
  transform: scale(1.12);
  background: rgba(255, 255, 255, 0.14);
}

.side-nav a.active .nav-mark {
  background: rgba(41, 240, 212, 0.18);
  color: var(--neon);
}

.nav-section {
  padding: 0.8rem 0.65rem 0.25rem;
  text-transform: uppercase;
  font-weight: 900;
}

.logout-form {
  margin-top: auto;
}

.sidebar-scrim {
  display: none;
}

/* ─────────────────────────────────────────
   TOPBAR
───────────────────────────────────────── */

.topbar {
  min-height: 78px;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem clamp(1rem, 2.4vw, 2rem);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 25;
}

:root[data-theme="dark"] .topbar {
  background: rgba(16, 27, 35, 0.9);
}

.theme-toggle {
  flex: 0 0 auto;
  width: 42px;
  padding: 0;
  box-shadow: var(--glow);
}

.topbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-menu {
  display: none;
}

.topbar h1 {
  margin: 0.1rem 0 0;
  font-size: 1.35rem;
}

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.account-box {
  min-width: 0;
  margin-left: auto;
  display: grid;
  justify-items: end;
  gap: 0.14rem;
  text-align: right;
  font-size: 0.88rem;
}

.account-box strong,
.account-box span:not(.chip) {
  max-width: min(34vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-box span:not(.chip) {
  color: var(--muted);
}

/* ─────────────────────────────────────────
   CONTAINER
───────────────────────────────────────── */

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.35rem clamp(1rem, 2.3vw, 2rem) 2.8rem;
  display: grid;
  gap: 1rem;
}

/* ─────────────────────────────────────────
   BOT LIVE STRIP
───────────────────────────────────────── */

.bot-live-strip {
  position: sticky;
  top: 78px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(420px, 1.6fr) minmax(220px, 0.8fr);
  align-items: center;
  gap: 0.9rem;
  padding: 0.72rem clamp(1rem, 2.4vw, 2rem);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 36px rgba(16, 24, 40, 0.06);
  overflow: hidden;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.bot-live-strip::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon), var(--neon-2), transparent);
  opacity: 0.46;
  transform: translateX(-100%);
}

.bot-live-strip.is-live::after {
  animation: botSweep 3.2s ease-in-out infinite;
}

.bot-live-strip[data-bot-state="marking"] {
  background: color-mix(in srgb, var(--surface-soft) 85%, rgba(41, 240, 212, 0.06) 15%);
  box-shadow: var(--glow), 0 12px 36px rgba(16, 24, 40, 0.07), inset 0 0 0 1px rgba(41, 240, 212, 0.12);
}

.bot-live-strip.status-updated {
  animation: statusFlash 0.85s ease;
}

.status-updated {
  animation: statusFlash 0.85s ease;
}

.bot-live-strip[data-live-connection-state="offline"] {
  border-bottom-color: color-mix(in srgb, var(--danger) 42%, var(--border));
}

.bot-live-strip[data-live-connection-state="live"] [data-live-connection] {
  color: var(--success);
}

.bot-live-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.bot-live-identity div,
.bot-live-stats div,
.bot-live-detail {
  min-width: 0;
}

.bot-live-identity span:not(.bot-live-dot),
.bot-live-stats span,
.bot-live-detail span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bot-live-identity strong,
.bot-live-stats strong {
  display: block;
  margin-top: 0.08rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-live-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--neon);
  animation: dotPulse 2s ease infinite;
}

.bot-live-strip.is-offline .bot-live-dot {
  background: var(--danger);
  animation: dotPulseOffline 2.5s ease infinite;
}

.bot-live-stats {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(92px, 0.55fr) minmax(104px, 0.55fr) minmax(120px, 0.7fr) minmax(180px, 1fr);
  gap: 0.75rem;
}

.bot-live-detail {
  display: grid;
  gap: 0.1rem;
  justify-items: end;
  text-align: right;
}

.bot-live-detail [data-bot-detail] {
  color: var(--text);
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.bot-live-detail [data-live-connection] {
  font-weight: 820;
}

/* ─────────────────────────────────────────
   CARDS & PANELS
───────────────────────────────────────── */

.panel,
.card,
.auth-card,
.lesson-card,
.metric-card,
.admin-user-card,
.action-panel,
.maintenance-item {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .lesson-card,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .admin-user-card,
:root[data-theme="dark"] .action-panel,
:root[data-theme="dark"] .maintenance-item {
  box-shadow: var(--shadow), var(--glow);
}

.panel,
.card,
.lesson-card,
.admin-user-card,
.maintenance-item {
  padding: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover,
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

:root[data-theme="dark"] .panel:hover,
:root[data-theme="dark"] .card:hover {
  box-shadow: var(--shadow-lift), var(--glow);
}

/* ─────────────────────────────────────────
   AUTH
───────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(36, 84, 166, 0.08), transparent 34%),
    var(--bg);
}

/* Neutral wrapper for unauthenticated pages — each page provides its own centering */
.auth-outer {
  min-height: 100vh;
}

/* Flash inside auth pages gets max-width and margin so it doesn't span full viewport */
.auth-outer > .flash {
  max-width: min(460px, 100%);
  margin: 1.25rem auto 0;
}

/* Enhanced auth hero */
.auth-hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% 30%, rgba(15, 118, 110, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(36, 84, 166, 0.14) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 50% 0%, rgba(41, 240, 212, 0.08) 0%, transparent 50%),
    var(--bg);
  animation: meshFloat 10s ease-in-out infinite alternate;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-brand h1 {
  margin: 0 0 0.1rem;
  font-size: 1.5rem;
  font-weight: 900;
}

.auth-brand .eyebrow {
  display: block;
  margin-top: 0;
}

.auth-card {
  width: min(460px, 100%);
  padding: 1.75rem;
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

:root[data-theme="dark"] .auth-card {
  border-color: rgba(41, 240, 212, 0.1);
  box-shadow: var(--shadow), 0 0 0 1px rgba(41, 240, 212, 0.06);
}

/* ─────────────────────────────────────────
   PAGE INTRO & SECTION HEADS
───────────────────────────────────────── */

.page-intro,
.section-head,
.lesson-card header,
.admin-user-header,
.maintenance-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.page-intro {
  padding: 0.25rem 0 0.1rem;
}

.page-intro h2 {
  margin-bottom: 0.22rem;
  font-size: 1.45rem;
}

.page-intro p,
.section-head p,
.maintenance-summary p,
.admin-user-card p,
.lesson-card p {
  margin-bottom: 0;
}

.section-head.compact {
  align-items: center;
}

/* ─────────────────────────────────────────
   TOOLBARS & ROWS
───────────────────────────────────────── */

.toolbar,
.button-row,
.chip-row,
.actions-row,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-bar {
  align-items: end;
}

.filter-bar label {
  min-width: min(360px, 100%);
}

.user-filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(150px, 0.7fr)) auto auto auto;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
}

.check-line input {
  width: auto;
}

.period-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 850;
  white-space: nowrap;
}

/* ─────────────────────────────────────────
   GRIDS
───────────────────────────────────────── */

.summary-grid,
.content-grid,
.lesson-list,
.admin-user-list,
.action-grid,
.maintenance-list {
  display: grid;
  gap: 1rem;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.content-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ─────────────────────────────────────────
   DASHBOARD LAYOUT
───────────────────────────────────────── */

.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem;
  align-items: start;
}

.dashboard-content {
  display: grid;
  gap: 1rem;
}

.dashboard-aside {
  display: grid;
  gap: 1rem;
}

.dashboard-main-premium {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.summary-grid-compact {
  gap: 0.75rem;
}

/* ─────────────────────────────────────────
   DASHBOARD FOCUS
───────────────────────────────────────── */

.focus-panel {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 2vw, 1.35rem);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, var(--surface-soft) 8%), var(--surface)),
    var(--surface);
  box-shadow: var(--shadow);
}

.focus-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--blue);
}

.focus-state-open,
.focus-state-marking {
  animation: focusPulse 2.8s ease-in-out infinite;
}

.focus-state-open::before,
.focus-state-marked::before {
  background: var(--success);
}

.focus-state-marking::before,
.focus-state-blocked::before {
  background: var(--warn);
}

.focus-state-error::before {
  background: var(--danger);
}

.focus-topline,
.focus-hero,
.focus-signal-grid,
.attempt-item,
.attempt-meta {
  min-width: 0;
}

.focus-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.focus-kicker,
.focus-title span,
.focus-countdown span,
.focus-signal-grid span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.focus-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  gap: 1rem;
  align-items: end;
}

.focus-title h2 {
  margin: 0.2rem 0 0.3rem;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  letter-spacing: 0;
}

.focus-title p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.focus-countdown {
  display: grid;
  gap: 0.25rem;
  justify-items: end;
  text-align: right;
}

.focus-countdown strong {
  font-size: clamp(1.45rem, 3.3vw, 2.15rem);
  line-height: 1;
  letter-spacing: 0;
}

.focus-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
}

.focus-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 0.45s ease;
}

.focus-state-blocked .focus-progress span {
  background: linear-gradient(90deg, var(--warn), #d97706);
}

.focus-state-error .focus-progress span {
  background: linear-gradient(90deg, var(--danger), #ef4444);
}

.focus-signal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  padding-top: 0.25rem;
}

.focus-signal-grid div {
  display: grid;
  gap: 0.2rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border-soft);
}

.focus-signal-grid div:first-child {
  padding-left: 0;
  border-left: 0;
}

.focus-signal-grid strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-note {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 0.9rem;
}

.focus-panel.is-empty .focus-hero {
  align-items: center;
}

/* ─────────────────────────────────────────
   ACTION PANEL (details/summary)
───────────────────────────────────────── */

.action-panel {
  padding: 0;
  overflow: hidden;
}

.action-panel summary,
.edit-drawer summary,
.legacy-box summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 850;
}

.action-panel summary {
  padding: 0.95rem 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border-soft);
}

.action-panel:not([open]) summary {
  border-bottom: 0;
}

.action-panel form {
  padding: 1rem;
}

/* ─────────────────────────────────────────
   FORMS
───────────────────────────────────────── */

.dense-form,
.stack,
form {
  display: grid;
  gap: 0.75rem;
}

.lesson-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.82fr);
  gap: 1rem;
}

.form-grid,
.credential-form-grid,
.admin-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

label {
  min-width: 0;
  display: grid;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.62rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .calendar-day header,
:root[data-theme="dark"] .calendar-event,
:root[data-theme="dark"] .period-pill,
:root[data-theme="dark"] .loading-card {
  background: #0f1b23;
}

:root[data-theme="dark"] .button.ghost,
:root[data-theme="dark"] button.ghost {
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15), 0 0 20px rgba(41, 240, 212, 0.12);
}

textarea {
  min-height: 78px;
  resize: vertical;
}

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */

.button,
button[type="submit"] {
  width: fit-content;
  max-width: 100%;
  min-height: 40px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.62rem 0.85rem;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

form > button[type="submit"] {
  justify-self: start;
}

.auth-card form > button[type="submit"],
.logout-form button[type="submit"] {
  width: 100%;
}

.button:hover,
button[type="submit"]:hover {
  background: var(--accent-strong);
}

.button:active,
button[type="submit"]:active {
  transform: scale(0.97);
}

.button.secondary,
button.secondary {
  background: #2f455f;
}

.button.secondary:hover,
button.secondary:hover {
  background: #23364d;
}

.button.warn,
button.warn {
  background: var(--warn);
}

.button.danger,
button.danger {
  background: var(--danger);
}

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

.button.ghost:hover,
button.ghost:hover {
  background: var(--surface-soft);
}

.sidebar button.ghost {
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.18);
}

.sidebar button.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.button-row form,
.actions-row form {
  display: inline-flex;
}

/* ─────────────────────────────────────────
   CHIPS & PILLS
───────────────────────────────────────── */

.chip,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  max-width: 100%;
  padding: 0.24rem 0.52rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
}

.chip::before,
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.65;
}

.chip.neutral::before,
.pill.neutral::before {
  display: none;
}

.chip.success,
.pill.success {
  color: var(--success);
  background: rgba(17, 122, 85, 0.1);
  border-color: rgba(17, 122, 85, 0.22);
}

.chip.warn,
.pill.warn {
  color: var(--warn);
  background: rgba(180, 83, 9, 0.1);
  border-color: rgba(180, 83, 9, 0.24);
}

.chip.error,
.pill.error {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.1);
  border-color: rgba(180, 35, 24, 0.24);
}

.chip.info,
.pill.info {
  color: var(--blue);
  background: rgba(36, 84, 166, 0.1);
  border-color: rgba(36, 84, 166, 0.2);
}

.chip.success,
.chip.info {
  box-shadow: 0 0 14px rgba(41, 240, 212, 0.08);
}

.chip.neutral,
.pill.neutral {
  color: var(--muted);
}

/* ─────────────────────────────────────────
   CALENDAR
───────────────────────────────────────── */

.calendar-panel {
  overflow: hidden;
}

.lesson-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.calendar-day {
  min-width: 150px;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-muted);
  overflow: hidden;
}

.calendar-day header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  background: #ffffff;
}

.calendar-day header span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.calendar-events {
  display: grid;
  align-content: start;
  gap: 0.6rem;
  padding: 0.65rem;
}

.calendar-event {
  display: grid;
  gap: 0.28rem;
  padding: 0.68rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: #ffffff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.calendar-event:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow);
}

.calendar-event.is-processing,
.maintenance-item.is-processing,
.lesson-row.is-processing {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 3px rgba(41, 240, 212, 0.1);
}

.calendar-event.is-processing {
  border-left-color: var(--neon);
}

.calendar-event.is-cancelled {
  border-left-color: var(--warn);
  background: #fffaf4;
}

:root[data-theme="dark"] .calendar-event.is-cancelled {
  background: #24180c;
}

.calendar-event.is-paused {
  border-left-color: #687588;
}

.event-time {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.event-title {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.event-meta,
.calendar-event p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.calendar-event .chip-row {
  gap: 0.3rem;
}

.calendar-event .chip {
  white-space: normal;
}

/* ─────────────────────────────────────────
   MAINTENANCE LIST
───────────────────────────────────────── */

.maintenance-list {
  gap: 0.75rem;
}

.maintenance-item {
  box-shadow: none;
}

.maintenance-summary {
  align-items: center;
}

.edit-drawer {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.edit-drawer summary {
  width: fit-content;
  color: var(--accent-strong);
}

.edit-drawer[open] summary {
  margin-bottom: 0.85rem;
}

/* ─────────────────────────────────────────
   METRIC CARDS — REDESIGN
───────────────────────────────────────── */

.metric-card {
  padding: 0.95rem;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--surface) 60%, var(--surface-soft) 100%);
  border-top: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--neon));
  border-radius: var(--radius) var(--radius) 0 0;
}

:root[data-theme="dark"] .metric-card::before {
  box-shadow: 0 0 12px rgba(41, 240, 212, 0.4);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

:root[data-theme="dark"] .metric-card:hover {
  box-shadow: var(--shadow-lift), var(--glow);
}

.metric {
  padding: 0.95rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.metric-card span,
.metric-list span,
.metric span,
.lesson-row span,
.timeline span,
.status-note span {
  color: var(--muted);
  font-size: 0.84rem;
}

.metric-card strong,
.metric strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  animation: countUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  letter-spacing: -0.02em;
}

/* ─────────────────────────────────────────
   METRIC LIST
───────────────────────────────────────── */

.metric-list,
.lesson-table,
.timeline,
.status-stack {
  display: grid;
  gap: 0.65rem;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.metric-list div:last-child {
  border-bottom: 0;
}

/* ─────────────────────────────────────────
   LESSON ROWS
───────────────────────────────────────── */

.lesson-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.72rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.lesson-row:last-child {
  border-bottom: 0;
}

/* ─────────────────────────────────────────
   ROBOT STATUS
───────────────────────────────────────── */

.robot-status-list {
  display: grid;
  gap: 0.65rem;
}

.robot-status-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(160px, auto);
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-muted);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.robot-status-row:hover {
  background: color-mix(in srgb, var(--surface-soft) 80%, var(--accent) 5%);
  border-color: rgba(15, 118, 110, 0.2);
}

.robot-status-row span:not(.chip),
.robot-note span {
  color: var(--muted);
  font-size: 0.82rem;
}

.attempt-timeline {
  display: grid;
  gap: 0.65rem;
}

.attempt-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.8rem 0.9rem 0.8rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-muted);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.attempt-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--blue);
}

.attempt-item.is-success::before {
  background: var(--success);
}

.attempt-item.is-warn::before {
  background: var(--warn);
}

.attempt-item.is-error::before {
  background: var(--danger);
}

.attempt-item:hover {
  background: color-mix(in srgb, var(--surface-soft) 82%, var(--surface) 18%);
  border-color: color-mix(in srgb, var(--border) 72%, var(--accent) 28%);
  transform: translateY(-1px);
}

.attempt-item strong,
.attempt-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attempt-item span:not(.chip) {
  color: var(--muted);
  font-size: 0.82rem;
}

.attempt-meta {
  display: grid;
  gap: 0.28rem;
  justify-items: end;
  text-align: right;
}

/* ─────────────────────────────────────────
   TIMELINE
───────────────────────────────────────── */

.timeline div,
.status-note,
.control-panel {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-muted);
  transition: background 0.15s ease;
}

.timeline div:hover {
  background: var(--surface-soft);
}

.compact-panel {
  padding: 0.9rem;
}

.compact-panel h2 {
  font-size: 1rem;
}

.compact-timeline {
  gap: 0.5rem;
}

.compact-timeline div {
  padding: 0.65rem;
}

.profile-compact form {
  gap: 0.55rem;
}

.profile-compact input {
  min-height: 40px;
}

.dashboard-details {
  padding: 0;
  overflow: hidden;
}

.dashboard-details summary {
  cursor: pointer;
  padding: 1rem;
  color: var(--text);
  font-weight: 850;
}

.dashboard-details[open] summary {
  border-bottom: 1px solid var(--border-soft);
}

.dashboard-history-grid {
  padding: 1rem;
}

.dashboard-history-grid article {
  min-width: 0;
}

.compact-lessons {
  gap: 0;
}

.compact-lesson-row {
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
}

/* ─────────────────────────────────────────
   TABLES
───────────────────────────────────────── */

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  text-align: left;
  padding: 0.68rem 0.58rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  word-break: break-word;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 900;
  background: var(--surface-muted);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.018);
}

:root[data-theme="dark"] tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.compact-table {
  margin-top: 0.9rem;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
}

.empty,
.muted {
  color: var(--muted);
}

/* ─────────────────────────────────────────
   FLASH MESSAGES
───────────────────────────────────────── */

.flash {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  animation: slideDown 0.3s ease both;
}

.flash.success {
  color: var(--success);
  border-color: rgba(17, 122, 85, 0.25);
  background: rgba(17, 122, 85, 0.08);
}

.flash.error {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(180, 35, 24, 0.08);
}

.flash.info {
  color: var(--blue);
  border-color: rgba(36, 84, 166, 0.22);
  background: rgba(36, 84, 166, 0.08);
}

/* ─────────────────────────────────────────
   TABS
───────────────────────────────────────── */

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tab-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tab-button:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.tab-button.is-active {
  color: var(--text);
  border-color: rgba(41, 240, 212, 0.32);
  background: rgba(41, 240, 212, 0.1);
  box-shadow: var(--glow);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: fadeIn 0.22s ease both;
}

.action-grid.tab-panel.is-active {
  display: grid;
}

/* ─────────────────────────────────────────
   LOADING OVERLAY — GLASSMORPHISM
───────────────────────────────────────── */

.page-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(9, 17, 22, 0.55);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.page-loading.is-active {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border: 1px solid rgba(41, 240, 212, 0.15);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(41, 240, 212, 0.08), 0 24px 64px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: fadeUp 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

:root[data-theme="dark"] .loading-card {
  background: #0f1b23;
}

.loading-card strong {
  font-size: 1.05rem;
}

.loading-card span:not(.loading-spinner) {
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

form[data-submitting="true"] button[type="submit"] {
  opacity: 0.82;
  cursor: wait;
}

/* ─────────────────────────────────────────
   USER / ADMIN CARDS
───────────────────────────────────────── */

.user-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface-soft), var(--accent) 200%);
  color: var(--accent-strong);
  font-weight: 900;
  font-size: 0.95rem;
}

:root[data-theme="dark"] .avatar {
  background: linear-gradient(135deg, rgba(41, 240, 212, 0.15), rgba(41, 240, 212, 0.05));
  color: var(--neon);
}

.user-identity h2,
.user-identity p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.9fr);
  gap: 0.9rem;
}

.admin-danger-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.admin-danger-zone form {
  display: inline-flex;
}

/* ─────────────────────────────────────────
   MINI HEAD
───────────────────────────────────────── */

.mini-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.8rem;
}

.mini-head strong {
  font-size: 0.98rem;
}

.mini-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

.compact-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
}

.credential-form {
  display: grid;
  gap: 0.75rem;
}

.legacy-box {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.legacy-box summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
}

/* ─────────────────────────────────────────
   UTILITIES
───────────────────────────────────────── */

.grid {
  display: grid;
  gap: 1rem;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.setup-list {
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  line-height: 1.7;
}

/* ─────────────────────────────────────────
   RESPONSIVE — 1180px
───────────────────────────────────────── */

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2 {
    grid-column: span 2;
  }

  .lesson-grid,
  .admin-user-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────
   RESPONSIVE — 1100px (dashboard)
───────────────────────────────────────── */

@media (max-width: 1100px) {
  .dashboard-main {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────
   RESPONSIVE — 900px (mobile sidebar)
───────────────────────────────────────── */

@media (max-width: 900px) {
  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-100%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main-shell,
  body.sidebar-collapsed .main-shell {
    margin-left: 0;
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(13, 27, 42, 0.36);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  body.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    position: sticky;
  }

  .bot-live-strip {
    position: relative;
    top: auto;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .bot-live-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bot-live-detail {
    justify-items: start;
    text-align: left;
  }

  .content-grid,
  .grid.cols-2,
  .grid.cols-3,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .lesson-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .robot-status-row,
  .attempt-item,
  .user-filter-bar {
    grid-template-columns: 1fr;
  }

  .focus-hero,
  .focus-signal-grid {
    grid-template-columns: 1fr 1fr;
  }

  .focus-countdown {
    justify-items: start;
    text-align: left;
  }

  body.sidebar-collapsed .brand-copy,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-section {
    display: initial;
  }

  body.sidebar-collapsed .sidebar {
    width: min(86vw, 320px);
  }

  body.sidebar-collapsed .brand-block {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    justify-items: stretch;
  }

  body.sidebar-collapsed .toggle-open {
    display: inline;
  }

  body.sidebar-collapsed .toggle-closed {
    display: none;
  }
}

/* ─────────────────────────────────────────
   RESPONSIVE — 768px (tablet)
───────────────────────────────────────── */

@media (max-width: 768px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bot-live-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lesson-row {
    grid-template-columns: 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-grid {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────
   RESPONSIVE — 640px (mobile)
───────────────────────────────────────── */

@media (max-width: 640px) {
  .container {
    padding: 1rem 0.75rem 2rem;
  }

  .topbar,
  .page-intro,
  .section-head,
  .lesson-card header,
  .admin-user-header,
  .maintenance-summary {
    display: grid;
  }

  .bot-live-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .account-box {
    margin-left: 0;
    justify-items: start;
    text-align: left;
  }

  .account-box strong,
  .account-box span:not(.chip) {
    max-width: 100%;
  }

  .summary-grid,
  .form-grid,
  .admin-control-grid,
  .credential-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .focus-hero,
  .focus-signal-grid,
  .compact-lesson-row {
    grid-template-columns: 1fr;
  }

  .focus-signal-grid div,
  .focus-signal-grid div:first-child {
    padding-left: 0;
    padding-top: 0.55rem;
    border-left: 0;
    border-top: 1px solid var(--border-soft);
  }

  .focus-signal-grid div:first-child {
    border-top: 0;
  }

  .attempt-meta {
    justify-items: start;
    text-align: left;
  }

  .compact-form {
    grid-template-columns: 1fr;
  }

  .button,
  button[type="submit"] {
    width: 100%;
    white-space: normal;
  }

  .toolbar,
  .filter-bar {
    align-items: stretch;
  }

  .period-pill {
    justify-content: center;
  }
}

/* ─────────────────────────────────────────
   RESPONSIVE — 480px (small mobile)
───────────────────────────────────────── */

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card strong,
  .metric strong {
    font-size: 1.6rem;
  }

  .topbar h1 {
    font-size: 1.1rem;
  }

  .auth-brand h1 {
    font-size: 1.2rem;
  }
}

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