:root {
  --bg: #ffffff;
  --bg-light: #f9fafb;
  --bg-darker: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #0f172a;
  --ink-light: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --primary-light: #e0eeff;
  --primary-soft: #f0f5ff;
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #cffafe;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius: 6px;
  --radius-lg: 12px;
  /* Sidebar */
  --sidebar-w: 220px;
  --sidebar-bg: #f6f8fa;
  --sidebar-ink: #24292f;
  --sidebar-muted: #57606a;
  --sidebar-hover: #eaeef2;
  --sidebar-active-bg: #dce9f8;
  --sidebar-active-ink: #0550ae;
  --sidebar-border: #d0d7de;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-light: #1a2442;
  --bg-darker: #0f172a;
  --surface: #1a2442;
  --surface-soft: #243558;
  --ink: #f1f5f9;
  --ink-light: #cbd5e1;
  --muted: #94a3b8;
  --line: #334155;
  --line-strong: #475569;
  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-light: #1e3a8a;
  --primary-soft: #1e3a8a;
  --success: #10b981;
  --success-soft: #064e3b;
  --warning: #f59e0b;
  --warning-soft: #78350f;
  --danger: #ef4444;
  --danger-soft: #7f1d1d;
  --info: #06b6d4;
  --info-soft: #164e63;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  /* Sidebar dark */
  --sidebar-bg: #161b22;
  --sidebar-ink: #c9d1d9;
  --sidebar-muted: #8b949e;
  --sidebar-hover: #21262d;
  --sidebar-active-bg: #1f3558;
  --sidebar-active-ink: #58a6ff;
  --sidebar-border: #30363d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar layout ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

.layout-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Brand in sidebar */
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  color: var(--sidebar-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 60px;
  flex-shrink: 0;
}
.sidebar .brand:hover { text-decoration: none; background: var(--sidebar-hover); }
.sidebar .brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
}
.sidebar .brand-text strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--sidebar-ink);
  line-height: 1.2;
}
.sidebar .brand-text small {
  display: block;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
}

.nav-section-label {
  margin: 8px 0 4px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-ink);
  text-decoration: none;
}
.nav-item.active,
.nav-item[aria-current="page"] {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-ink);
  font-weight: 600;
}
.nav-cta {
  color: var(--primary);
  font-weight: 600;
}
.nav-cta:hover {
  background: var(--sidebar-hover);
  color: var(--primary-dark);
}
[data-theme="dark"] .nav-cta { color: #58a6ff; }

.nav-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  opacity: 0.75;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px 0;
}

/* Sidebar footer (theme toggle + collapse) */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.theme-btn {
  font-size: 0.875rem;
  justify-content: flex-start;
}
.sidebar-collapse-btn {
  font-size: 0.875rem;
  justify-content: flex-start;
  gap: 8px;
  color: var(--sidebar-muted);
}
.sidebar-collapse-btn:hover { color: var(--sidebar-ink); }
.sidebar-collapse-icon { transition: transform 0.2s ease; }

/* Collapsed sidebar */
.sidebar.collapsed {
  width: 52px;
  min-width: 52px;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-divider,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .theme-btn span,
.sidebar.collapsed .sidebar-collapse-btn span { display: none; }
.sidebar.collapsed .brand { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .brand-mark { margin: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-footer { align-items: center; }
.sidebar.collapsed .sidebar-collapse-icon { transform: rotate(180deg); }
.sidebar.collapsed .theme-btn,
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; }

/* Hamburger toggle (mobile only) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: 36px;
  height: 36px;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
}
.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--sidebar-ink);
  border-radius: 2px;
  transition: all 0.2s ease;
}
.sidebar-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Flash banner ── */
.flash-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  min-width: 340px;
  max-width: 560px;
  animation: flash-in 0.3s ease;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.flash-success {
  background: var(--success-soft);
  border: 1px solid var(--success);
  color: var(--success);
}
.flash-icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex-shrink: 0;
}
.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  color: inherit;
  padding: 0 2px;
  opacity: 0.7;
  flex-shrink: 0;
}
.flash-close:hover { opacity: 1; }

a { 
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { 
  color: var(--primary-dark);
  text-decoration: underline;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1rem 0;
}

h1 { font-size: 2.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.875rem; letter-spacing: -0.01em; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p { margin: 0 0 1rem 0; }
.lead { font-size: 1.125rem; line-height: 1.8; color: var(--ink-light); }
.eyebrow { 
  font-size: 0.85rem; 
  font-weight: 700; 
  letter-spacing: 0.05em; 
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 0.5rem 0;
}

/* Topbar — kept for legacy/non-sidebar pages */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 84px;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

/* Main Content */
.page {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Hero Section */
.hero-panel {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 40px;
  align-items: center;
  margin: 24px 0;
  padding: 64px 40px;
  background: radial-gradient(circle at top left, rgba(0, 102, 204, 0.15), transparent 36%),
              linear-gradient(135deg, var(--bg-light) 0%, #fff 50%, var(--bg) 100%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 32px;
}

.hero-panel > div:first-child {
  max-width: 560px;
}

.hero-panel h1 {
  font-size: clamp(2.8rem, 4vw, 4.4rem);
  line-height: 1.02;
  color: var(--ink);
  margin: 0;
}

.hero-panel .lead {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--ink-light);
  margin: 28px 0 32px 0;
}

.hero-stat {
  display: grid;
  gap: 20px;
  padding: 36px;
  background: var(--surface);
  border-radius: 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.hero-stat strong {
  font-size: 1.5rem;
  color: var(--ink);
}
.hero-stat small {
  color: var(--muted);
}

.hero-panel .btn.primary {
  padding: 16px 30px;
}

.hero-panel .btn-icon {
  background: rgba(255,255,255,0.16);
  color: #fff;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin: 48px 0;
}

.feature-card {
  padding: 32px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  display: block;
}

.feature-card h3 {
  margin: 0 0 12px 0;
  color: var(--ink);
  font-size: 1.25rem;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Problem/Solution Tiles */
.problem-solution {
  margin: 48px 0;
  padding: 48px 0;
  background: rgba(0, 102, 204, 0.05);
  border-radius: var(--radius-lg);
}

.problem-solution .container {
  max-width: 100%;
  padding: 0 32px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  margin-top: 32px;
}

.tile {
  padding: 40px;
  background: var(--surface);
  border-radius: 28px;
  border: none;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}
.tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.tile h2 {
  font-size: 1.95rem;
  margin: 0 0 18px 0;
  color: var(--ink);
}

.tile p {
  margin: 0 0 20px 0;
  color: var(--ink-light);
  font-size: 1rem;
}

.tile ul {
  margin: 0;
  padding-left: 20px;
  list-style: none;
}

.tile li {
  position: relative;
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.8;
  font-size: 1rem;
  padding-left: 26px;
}
.tile li:before {
  content: "✔";
  position: absolute;
  left: 0;
  top: 0.1rem;
  color: var(--primary);
  font-weight: 700;
}

/* CTA Section */
.cta-section {
  margin: 0 -24px;
  padding: 80px 32px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  text-align: center;
}

.cta-section .container {
  max-width: 700px;
  margin: 0 auto;
}

.cta-section h2 {
  margin: 0 0 16px 0;
  color: #fff;
  font-size: 2.25rem;
}

.cta-section p {
  margin: 0 0 32px 0;
  opacity: 0.95;
  line-height: 1.8;
  font-size: 1.1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.btn.large {
  padding: 14px 32px;
  font-size: 1.05rem;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  font-size: 0.875rem;
  font-weight: 700;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 768px) {
  .form-grid.two {
    grid-template-columns: 1fr;
  }
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 22px;
  margin-bottom: 22px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.setting-toggle {
  justify-content: flex-start;
  width: auto;
  min-width: 0;
  padding: 8px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.setting-toggle input {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
}

.settings-hint {
  margin: 0;
  line-height: 1.55;
}

.settings-form label:not(.toggle-field) {
  display: block;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}

.settings-form label span.required {
  color: var(--danger);
}

.settings-form label:not(.toggle-field) input,
.settings-form label:not(.toggle-field) select {
  display: block;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  min-width: 0;
  max-width: none;
  width: 100%;
}

.settings-form label:not(.toggle-field) input:focus,
.settings-form label:not(.toggle-field) select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.settings-form label.toggle-field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}

label input,
label select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  min-width: 0;
  max-width: 220px;
}

label input:focus,
label select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.required { color: var(--danger); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 480px; margin: 32px auto; }
.register-card {
  width: min(720px, 100%);
  margin: 32px auto;
}

.register-form {
  gap: 18px;
}

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

.register-form .form-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 44px;
}

.register-form .field-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.register-form .form-row input,
.register-form .form-row select {
  width: 100%;
  max-width: none;
}

.register-form > .form-row {
  grid-template-columns: 170px minmax(0, 1fr);
}

.register-submit {
  width: fit-content;
  min-width: 190px;
  justify-self: center;
  margin-top: 8px;
}

/* Footer */
.trust-footer {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 24px;
  margin: 32px 24px 48px 24px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  color: var(--muted);
}

.support-link {
  text-align: center;
  margin-bottom: 0;
  order: -1;
}

.support-link a {
  color: #063f6c;
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: rgba(0, 102, 204, 0.08);
  border-radius: 999px;
  transition: all 0.2s ease;
}

.support-link a:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.trust-footer strong {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.trust-footer p {
  max-width: 760px;
  margin: 0;
  line-height: 1.75;
  font-size: 0.95rem;
}

.trust-points {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.trust-points span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 14px;
  background: var(--bg-light);
  border-radius: 999px;
  border: 1px solid var(--line);
}
.trust-points span:before {
  content: "✓";
  color: var(--success);
}

/* Admin dashboard layout */
.dashboard-hero {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 28px;
  align-items: start;
  margin: 24px 0;
  padding: 24px 0;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 24px;
}

.hero-console {
  display: grid;
  gap: 20px;
  padding: 24px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.console-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--success);
}

.console-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-height: 136px;
}

.console-chart i {
  display: block;
  width: 18px;
  border-radius: 999px;
  background: var(--primary);
}

.console-chart i:nth-child(2) { background: var(--primary-dark); }
.console-chart i:nth-child(4) { background: var(--primary-dark); }

.console-list {
  display: grid;
  gap: 10px;
}

.console-list span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.console-list b {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--line-strong);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero-actions form {
  margin: 0;
}

.hero-actions .btn {
  min-width: 110px;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  font-size: 0.9rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: nowrap;
}

.section-head > div:first-child {
  flex: 1 1 0;
  min-width: 0;
}

.grid-tools {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  min-width: 0;
}

.grid-tools label,
.search-field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 0;
}

.grid-tools input,
.search-field input {
  border: none;
  background: transparent;
  outline: none;
  min-width: 0;
  width: auto;
  max-width: 220px;
}

.bulk-actions,
.pager,
.row-actions .action-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.row-actions .action-group {
  justify-content: flex-end;
}

.grid-tools form,
.bulk-actions form,
.row-actions .action-group form {
  margin: 0;
  display: inline-flex;
}

.grid-tools button,
.bulk-actions button,
.row-actions .action-group button {
  white-space: nowrap;
}

.compact-head {
  align-items: flex-start;
}


.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: inline-grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.grid-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.grid-tools label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.grid-tools input {
  border: none;
  background: transparent;
  outline: none;
  min-width: 160px;
  color: var(--ink);
}

.grid-tools input::placeholder {
  color: var(--muted);
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.row-actions .action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.row-actions .action-group form,
.row-actions .action-group button {
  margin: 0;
}

.schedule-cell .schedule-fields {
  display: grid;
  gap: 10px;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-field input {
  margin: 0;
}

.btn.compact {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn.secondary {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn.secondary:hover {
  background: var(--bg-darker);
  text-decoration: none;
}

.btn.success {
  background: var(--success);
  color: #fff;
}

.btn.success:hover {
  background: #047857;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn.info {
  background: var(--info);
  color: #fff;
}

.btn.info:hover {
  background: #0b60a0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--ink);
}

.badge.neutral { background: var(--surface-soft); color: var(--muted); }
.status-active { background: #d1fae5; color: #064e3b; }
.status-inactive { background: #fee2e2; color: #991b1b; }
.status-success { background: #d1fae5; color: #064e3b; }
.status-failed { background: #fee2e2; color: #b91c1c; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-skipped { background: #e5e7eb; color: #374151; }
.status-running { background: #bfdbfe; color: #1d4ed8; }
.status-not_run { background: #e2e8f0; color: #475569; }

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.3;
}

.data-table th {
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.data-table td {
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-light);
}

.data-table tbody tr:hover {
  background: var(--bg-light);
}

.data-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .truncate.wide {
  max-width: 300px;
}

/* Logs */
.log-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-family: monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 600px;
  overflow-y: auto;
  color: var(--ink-light);
}

/* Responsive */
@media (max-width: 768px) {
  body { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .layout-main {
    padding-top: 56px;
  }

  .page {
    padding: 0 16px;
  }

  .flash-banner {
    min-width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }

  .hero-panel {
    grid-template-columns: 1fr;
    padding: 48px 16px;
    gap: 32px;
  }

  .register-card {
    width: 100%;
    margin: 24px auto;
  }

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

  .register-form .form-row,
  .register-form > .form-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 6px;
  }

  .hero-panel h1 {
    font-size: 2rem;
  }

  .tiles {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .tile {
    padding: 24px;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }

  .cta-section {
    padding: 48px 16px;
  }

  .cta-section h2 {
    font-size: 1.5rem;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
    padding: 24px 0;
  }

  .hero-console {
    padding: 20px;
  }

  .summary-grid {
    margin: 24px auto;
  }

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

  .trust-footer {
    width: calc(100% - 32px);
    margin-left: 16px;
    margin-right: 16px;
  }
}

/* ── Add-property form ── */
.property-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.property-form label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.property-form label input,
.property-form label select {
  display: block;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  max-width: none;
  min-width: 0;
}

.property-form label input:focus,
.property-form label select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.property-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 4px;
}

/* ── Section spacing ── */
.page > .card,
.page > .data-card,
.page > .settings-grid {
  margin-bottom: 24px;
}

/* ── Hide text abbreviations inside button icons ── */
.btn .btn-icon {
  display: none;
}

/* ── Alert / notice banners ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--success-soft);
  border: 1px solid var(--success);
  color: var(--success);
}

/* ── Departments add-form toggle ── */
.dept-add-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 14px;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}
.dept-add-toggle:hover { background: var(--primary-soft); border-color: var(--primary); }

.dept-add-form { display: none; }
.dept-add-form.open { display: block; }

/* ── Editable grid rows ── */
.data-table tr .row-view { display: table-cell; }
.data-table tr .row-edit { display: none; }
.data-table tr[data-editing] .row-view { display: none; }
.data-table tr[data-editing] .row-edit { display: table-cell; }
.data-table tr[data-editing] { background: var(--primary-soft) !important; }

/* ── Empty state row ── */
.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 0.9rem;
}
