@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-void: #070910;
  --bg-panel: #10141f;
  --bg-raised: #161b29;
  --line: #232a3d;
  --line-soft: #1a2030;
  --ink: #e8ecf5;
  --ink-dim: #8790a8;
  --ink-faint: #576079;
  --signal: #4da8ff;
  --signal-dim: #2c6cb8;
  --signal-glow: rgba(77, 168, 255, 0.35);
  --armed-red: #ff4d6a;
  --armed-green: #34e7a0;
  --amber: #ffb454;
  --radius: 3px;
  --radius-lg: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-void);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

.mono { font-family: 'JetBrains Mono', monospace; }

h1, h2, h3, .display {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

::selection { background: var(--signal-glow); }

/* Dark-themed scrollbars, matching the rest of the console aesthetic */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 2px solid var(--bg-void); }
::-webkit-scrollbar-thumb:hover { background: var(--signal-dim); }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* ============ Background texture (topographic lines, echoes the Z banner) ============ */
.bg-topo {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(77,168,255,0.12), transparent 60%),
    repeating-linear-gradient(115deg, rgba(77,168,255,0.035) 0px, rgba(77,168,255,0.035) 1px, transparent 1px, transparent 64px),
    var(--bg-void);
}

/* ============ Login screen ============ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
  position: relative;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
  opacity: 0.6;
}
.login-banner {
  width: 100%;
  max-width: 280px;
  height: auto;
  margin: 0 auto 4px;
  display: block;
}
.wordmark-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-top: 4px;
}
.login-desc {
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.6;
  margin: 20px 0 28px;
}
.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: #5865f2;
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14.5px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-discord:hover { background: #4752c4; }
.btn-discord:active { transform: scale(0.98); }

/* ============ App shell (sidebar + content) ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-header img { width: 24px; height: 24px; border-radius: 4px; }
.sidebar-header .name {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.03em;
}

.guild-chip {
  margin: 16px 14px 8px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
}
.guild-chip img { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.guild-chip .g-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.guild-chip .g-sub { font-size: 11px; color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; }
.back-link {
  display: flex; align-items: center; gap: 6px;
  margin: 0 14px 14px;
  font-size: 12.5px;
  color: var(--ink-dim);
}
.back-link:hover { color: var(--signal); }

.nav-list { flex: 1; padding: 6px 12px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-dim);
  margin-bottom: 2px;
  position: relative;
  border-left: 2px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.75; }
.nav-item:hover { background: var(--bg-raised); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, var(--signal-glow), transparent);
  color: var(--ink);
  border-left: 2px solid var(--signal);
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-footer img { width: 28px; height: 28px; border-radius: 50%; }
.sidebar-footer .u-name { font-size: 12.5px; font-weight: 600; }
.sidebar-footer .logout { margin-left: auto; color: var(--ink-faint); font-size: 12px; }
.sidebar-footer .logout:hover { color: var(--armed-red); }

/* ============ Content area ============ */
.content { flex: 1; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(7,9,16,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.crumb { font-size: 12px; color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 0.05em; }
.crumb .sep { margin: 0 6px; opacity: 0.5; }
.crumb .current { color: var(--signal); }
.page-title { font-size: 22px; margin-top: 2px; }

.save-zone { display: flex; align-items: center; gap: 12px; }
.dirty-pill {
  font-size: 11.5px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--amber);
  background: rgba(255,180,84,0.1);
  border: 1px solid rgba(255,180,84,0.3);
  padding: 5px 10px;
  border-radius: var(--radius);
  display: none;
}
.dirty-pill.show { display: inline-block; }
.btn-save {
  background: var(--signal);
  color: #051424;
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn-save.enabled { opacity: 1; pointer-events: auto; }
.btn-save:active { transform: scale(0.97); }

.page-body { padding: 28px 32px 80px; max-width: 880px; }

/* ============ Status strip (signature element) ============ */
.status-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
}
.status-strip.armed .status-dot { background: var(--armed-green); box-shadow: 0 0 0 4px rgba(52,231,160,0.15); animation: pulse 2s ease-in-out infinite; }
.status-strip.disarmed .status-dot { background: var(--ink-faint); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(52,231,160,0.15); }
  50% { box-shadow: 0 0 0 8px rgba(52,231,160,0.05); }
}
.status-text { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.status-strip.armed .status-text { color: var(--armed-green); }
.status-strip.disarmed .status-text { color: var(--ink-faint); }
.status-meta { margin-left: auto; font-size: 12px; color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; }

/* ============ Cards ============ */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 18px;
  position: relative;
  animation: card-in 0.35s ease both;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 20px; right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-body .card:nth-child(1) { animation-delay: 0.02s; }
.page-body .card:nth-child(2) { animation-delay: 0.06s; }
.page-body .card:nth-child(3) { animation-delay: 0.1s; }
.page-body .card:nth-child(4) { animation-delay: 0.14s; }
.page-body .card:nth-child(5) { animation-delay: 0.18s; }
.card-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 6px;
}
.card-title { font-size: 17px; margin-bottom: 4px; }
.card-desc { font-size: 13px; color: var(--ink-dim); line-height: 1.55; margin-bottom: 18px; }

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
}
.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; line-height: 1.5; }

input[type=text], input[type=number], input[type=url], textarea, select {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 13px;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--signal);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
select { cursor: pointer; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

/* ============ Toggle switch ============ */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info .t-name { font-size: 13.5px; font-weight: 600; }
.toggle-info .t-desc { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--bg-void);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--ink-faint);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .track { background: rgba(77,168,255,0.15); border-color: var(--signal); }
.switch input:checked + .track .knob { transform: translateX(18px); background: var(--signal); box-shadow: 0 0 8px var(--signal-glow); }
.switch .track .knob { position: absolute; top: 2px; left: 2px; }

/* ============ Color swatch input ============ */
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] {
  width: 42px; height: 38px;
  padding: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.color-field input[type=text] { flex: 1; }

/* ============ Empty state ============ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-faint);
}
.empty-state .e-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.5; }
.empty-state .e-title { color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty-state .e-desc { font-size: 13px; max-width: 320px; margin: 0 auto; line-height: 1.6; }

/* ============ Guild picker ============ */
.picker-shell { max-width: 920px; margin: 0 auto; padding: 60px 24px; }
.picker-head { margin-bottom: 32px; }
.picker-head .p-eyebrow { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--signal); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 8px; }
.picker-head h1 { font-size: 30px; }
.picker-user { display: flex; align-items: center; gap: 10px; }
.picker-user img { width: 32px; height: 32px; border-radius: 50%; }
.picker-user .u-name { font-size: 13px; font-weight: 600; }
.picker-user .logout { font-size: 12px; color: var(--ink-faint); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 14px; transition: color 0.15s ease, border-color 0.15s ease; white-space: nowrap; }
.picker-user .logout:hover { color: var(--armed-red); border-color: var(--armed-red); }
.picker-section-title { font-size: 13px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.06em; margin: 28px 0 12px; font-family: 'JetBrains Mono', monospace; }
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.guild-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.guild-card:hover { border-color: var(--signal-dim); transform: translateY(-1px); }
.guild-card img, .guild-card .g-fallback {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-raised); font-weight: 700; font-size: 15px; color: var(--signal);
}
.guild-card .g-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.guild-card .g-manage { font-size: 11px; color: var(--signal); margin-top: 2px; }
.guild-card.disabled { opacity: 0.55; }
.guild-card .g-invite { margin-left: auto; font-size: 11px; color: var(--ink-faint); border: 1px solid var(--line); padding: 5px 9px; border-radius: var(--radius); flex-shrink: 0; }
.guild-card:hover .g-invite { color: var(--signal); border-color: var(--signal-dim); }

/* ============ Toast ============ */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--armed-green);
  border-radius: var(--radius);
  padding: 13px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 100;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.error { border-left-color: var(--armed-red); }

/* ============ Repeating row editor (ticket types, application questions) ============ */
.row-editor-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.row-editor-item .rei-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-faint);
  padding-top: 10px;
  width: 20px;
  flex-shrink: 0;
}
.row-editor-item .rei-fields { flex: 1; display: flex; gap: 8px; flex-wrap: wrap; }
.row-editor-item .rei-fields input { flex: 1; min-width: 100px; }
.row-editor-item .rei-fields input.rei-emoji { flex: 0 0 60px; text-align: center; }
.row-editor-item .rei-remove {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--armed-red);
  width: 34px; height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.row-editor-item .rei-remove:hover { background: rgba(255,77,106,0.1); border-color: var(--armed-red); }
.row-editor-empty { color: var(--ink-faint); font-size: 13px; padding: 12px 0; }
.btn-add-row {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--signal);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn-add-row:hover { border-color: var(--signal); background: rgba(77,168,255,0.05); }

/* ============ Logging: channel-group header chip + repair action ============ */
.log-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.log-chan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  white-space: nowrap;
}
.log-chan-chip.found { border-color: rgba(52,231,160,0.35); color: var(--armed-green); background: rgba(52,231,160,0.06); }
.log-chan-chip.missing { border-color: rgba(255,180,84,0.35); color: var(--amber); background: rgba(255,180,84,0.06); }
.btn-repair {
  background: transparent;
  border: 1px solid var(--signal-dim);
  color: var(--signal);
  padding: 11px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn-repair:hover { border-color: var(--signal); background: rgba(77,168,255,0.08); }
.btn-repair:disabled { opacity: 0.5; cursor: default; }
.log-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.log-summary-text { font-size: 12.5px; color: var(--ink-dim); line-height: 1.6; }

/* ============ Mobile: genuinely different navigation pattern ============
   Desktop = persistent left rail. Mobile = on-demand bottom sheet + a
   thumb-reachable fixed save bar — not the same sidebar just narrower. */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 12px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 19;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar-overlay.open { display: block; opacity: 1; }

@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }

  /* The sidebar becomes a BOTTOM SHEET on mobile — slides up from the bottom
     edge with a rounded top and a drag-handle affordance, capped at 80% of
     viewport height and scrollable, instead of a full-height side drawer.
     Same DOM/content, fundamentally different interaction model. */
  .sidebar {
    position: fixed;
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: auto;
    max-height: 82vh;
    z-index: 20;
    border-right: none;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.5);
    overflow-y: auto;
    padding-top: 6px;
  }
  .sidebar::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--line);
    border-radius: 999px;
    margin: 8px auto 4px;
  }
  .sidebar.open { transform: translateY(0); }
  .back-link { display: none; } /* redundant on mobile — the sheet itself is dismissible */
  .nav-list { overflow-y: visible; }
  .nav-item { padding: 14px 14px; font-size: 14.5px; } /* bigger touch target than desktop's compact rail */

  .content { width: 100%; }
  .topbar { padding: 14px 16px; }
  .page-title { font-size: 19px; }
  .crumb { font-size: 11px; }

  /* Save controls move OFF the topbar entirely and become a fixed bottom bar —
     the thumb-reachable zone on a phone, appearing only once there's something
     to save. Reuses the exact same #save-btn/#dirty-pill elements and IDs, so
     dashboard.js's logic needs zero changes — this is pure repositioning. */
  .save-zone {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 15;
    background: var(--bg-panel);
    border-top: 1px solid var(--line);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    justify-content: space-between;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
    transform: translateY(100%);
    transition: transform 0.22s ease;
  }
  .save-zone.active { transform: translateY(0); }
  .btn-save { flex: 1; padding: 13px 18px; font-size: 14px; }
  .dirty-pill { flex-shrink: 0; }
  .page-body { padding: 16px 16px 96px; } /* clears the fixed save bar */

  .card { padding: 18px 16px; }
  .toggle-row { padding: 15px 0; } /* taller tap target than desktop */
  .switch { width: 44px; height: 25px; } /* bigger than desktop for easier tapping */
  .switch .knob { width: 19px; height: 19px; }
  .switch input:checked + .track .knob { transform: translateX(19px); }

  .hero-card { flex-direction: column; align-items: flex-start; gap: 14px; padding: 20px; }
  .hero-stats { gap: 20px; flex-wrap: wrap; }
  .module-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .picker-shell { padding: 30px 16px; }
  .picker-head h1 { font-size: 24px; }
  .guild-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .guild-card { padding: 14px; }
  #toast { left: 16px; right: 16px; bottom: 96px; } /* clears the save bar too */
}

@media (max-width: 480px) {
  .toggle-row { flex-wrap: wrap; gap: 8px; }
  .row-editor-item { flex-wrap: wrap; }
  .row-editor-item .rei-fields input { min-width: 100%; }
  .row-editor-item .rei-remove { width: 100%; height: 38px; }
  .hero-stats { gap: 16px; }
  .hs-num { font-size: 16px; }
  .login-card { padding: 28px 22px; }
  .login-banner { max-width: 220px; }
}

/* ============ Overview page ============ */
.hero-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  animation: card-in 0.3s ease both;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
  opacity: 0.5;
}
.hero-icon { width: 64px; height: 64px; border-radius: 14px; flex-shrink: 0; }
.hero-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-raised); color: var(--signal);
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 26px;
}
.hero-info h2 { font-size: 20px; margin-bottom: 10px; }
.hero-stats { display: flex; gap: 28px; }
.hero-stat { display: flex; flex-direction: column; }
.hs-num { font-family: 'JetBrains Mono', monospace; font-size: 19px; font-weight: 600; color: var(--signal); }
.hs-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.module-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color 0.15s ease, transform 0.1s ease;
  animation: card-in 0.35s ease both;
}
.module-grid .module-card:nth-child(1) { animation-delay: 0.02s; }
.module-grid .module-card:nth-child(2) { animation-delay: 0.05s; }
.module-grid .module-card:nth-child(3) { animation-delay: 0.08s; }
.module-grid .module-card:nth-child(4) { animation-delay: 0.11s; }
.module-grid .module-card:nth-child(5) { animation-delay: 0.14s; }
.module-grid .module-card:nth-child(6) { animation-delay: 0.17s; }
.module-grid .module-card:nth-child(7) { animation-delay: 0.2s; }
.module-card:hover { border-color: var(--signal-dim); transform: translateY(-2px); }
.mc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mc-name { font-size: 14px; font-weight: 600; }
.mc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mc-dot.on { background: var(--armed-green); box-shadow: 0 0 6px rgba(52,231,160,0.5); }
.mc-dot.off { background: var(--ink-faint); }
.mc-status { font-size: 12px; color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; }

.cmd-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--signal);
  padding: 7px 12px;
  border-radius: var(--radius);
}

/* ============ Error page ============ */
.error-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.error-shell .e-code { font-family: 'JetBrains Mono', monospace; color: var(--armed-red); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 10px; }
.error-shell h1 { font-size: 24px; margin-bottom: 10px; }
.error-shell p { color: var(--ink-dim); max-width: 400px; margin: 0 auto 24px; line-height: 1.6; }
