:root {
  --bg: #f7fbf8;
  --bg-elevated: #ffffff;
  --bg-soft: #eaf6ef;
  --text: #10281a;
  --muted: #5a7463;
  --border: #d5e8db;
  --primary: #178a4a;
  --primary-strong: #0f5f33;
  --primary-soft: #d7f3e4;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 2px 10px rgba(16, 40, 26, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar: #0c2f1d;
  --sidebar-text: #eaf7ef;
  --font: "DM Sans", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --ring: 0 0 0 3px rgba(23, 138, 74, 0.15);
  --sidebar-w: 250px;
  --page-pad: 1.5rem;
}

html[data-theme="dark"] {
  --bg: #08140e;
  --bg-elevated: #101c15;
  --bg-soft: #16281d;
  --text: #e9f6ee;
  --muted: #97b3a3;
  --border: #24392c;
  --primary: #3dcb74;
  --primary-strong: #79e4a4;
  --primary-soft: #163525;
  --danger: #ff8a7a;
  --danger-soft: #3a1c18;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --sidebar: #06110b;
  --sidebar-text: #dff5e8;
  --ring: 0 0 0 3px rgba(61, 203, 116, 0.18);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-strong); text-decoration: none; }
a:hover { color: var(--primary); }
code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.86em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  align-items: stretch;
}

/* Mobile top header */
.app-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 60;
  align-items: center;
  gap: 0.75rem;
  min-height: 58px;
  padding: 0.65rem 0.9rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.app-header-brand {
  flex: 1;
  min-width: 0;
}
.app-header-brand .brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55vw;
}
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.menu-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.menu-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}
.theme-toggle-compact {
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(8, 20, 12, 0.42);
}
.sidebar-backdrop[hidden] { display: none !important; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #123d26 0%, var(--sidebar) 100%);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 80;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.3rem;
}
.brand-inline { color: inherit; text-decoration: none; }
.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(61, 203, 116, 0.18);
  flex-shrink: 0;
}
.brand-text {
  font-family: var(--display);
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}

.nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.55;
  padding: 0.45rem 0.75rem 0.2rem;
}
.nav-link {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  opacity: 0.9;
}
.nav-link:hover,
.nav-link.is-active {
  background: rgba(255,255,255,0.1);
  text-decoration: none;
  opacity: 1;
}
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 0.45rem 0.35rem;
}

.sidebar-foot { display: flex; flex-direction: column; gap: 0.7rem; }
.user-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.9rem;
}
.user-chip span { opacity: 0.72; font-size: 0.78rem; }

.main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: var(--page-pad) 1.75rem 2.5rem;
}

.main-full {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1rem 2rem 2.5rem;
}

.topbar-public {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding: 0.35rem 0;
}
.topbar-public-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  width: 100%;
}
.page-head h1,
.auth-card h1,
.hero h1 {
  font-family: var(--display);
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  font-size: clamp(1.7rem, 2.2vw, 2.2rem);
  line-height: 1.15;
  font-weight: 700;
}
.page-head .muted { max-width: 60rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}
.text-danger { color: var(--danger); }

.panel,
.auth-card,
.stat-card,
.hero-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel {
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.15rem;
  width: 100%;
}
.panel.narrow {
  max-width: none;
  width: 100%;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.75rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.15rem;
  width: 100%;
}
.stat-card {
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}
.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.stat-card strong {
  font-size: 1.55rem;
  font-family: var(--display);
  letter-spacing: -0.02em;
  font-weight: 700;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  align-items: start;
  width: 100%;
}
.grid-2 > .panel {
  margin-bottom: 0;
  height: 100%;
}

.form { display: flex; flex-direction: column; gap: 0.85rem; }
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 560;
  font-size: 0.93rem;
}
.form input,
.form select,
.form textarea {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  width: 100%;
}
.form input:focus,
.form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem !important;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.86rem; }
.btn-block { width: 100%; }
.sidebar .btn-ghost {
  border-color: rgba(255,255,255,0.16);
  color: var(--sidebar-text);
}
.sidebar .btn-ghost:hover { background: rgba(255,255,255,0.08); }

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.pager-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex: 1;
}
.pager-btn,
.pager-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  min-height: 2.1rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1;
}
a.pager-btn:hover,
a.pager-page:hover {
  background: var(--bg-soft);
  border-color: var(--accent);
}
.pager-page.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.pager-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pager-ellipsis {
  padding: 0 0.2rem;
  color: var(--muted);
}
.list-item {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  display: grid;
  gap: 0.75rem;
}
.list-item:first-of-type { border-top: 0; padding-top: 0; }
.edit-form {
  margin-top: 0.15rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 100%;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.85rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
th {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--bg-soft);
}
.stats-cell { white-space: nowrap; font-size: 0.9rem; }
.stats-cell span { margin-right: 0.4rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-soft);
  color: var(--primary-strong);
  border: 1px solid var(--border);
}
.badge-running,
.badge-active,
.badge-live,
.badge-completed {
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.badge-paused,
.badge-disabled,
.badge-idle {
  background: #f3ecda;
  color: #7a5b16;
  border-color: #e5d7b2;
}
.badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}
html[data-theme="dark"] .badge-paused,
html[data-theme="dark"] .badge-disabled,
html[data-theme="dark"] .badge-idle {
  background: #3a3118;
  color: #f0d48a;
  border-color: #665422;
}

.alert {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.alert-success { background: var(--primary-soft); color: var(--primary-strong); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-impersonate {
  background: #fff5da;
  color: #7a5b16;
  border-color: #e6cfa0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
html[data-theme="dark"] .alert-impersonate {
  background: #3a3118;
  color: #f0d48a;
  border-color: #665422;
}

.auth-card {
  max-width: 440px;
  width: 100%;
  margin: 2rem auto;
  padding: 1.6rem 1.5rem 1.4rem;
}
.auth-card h1 { font-size: 1.9rem; }
.auth-card .form { margin: 1.15rem 0 0.9rem; }

.public-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.75rem;
  align-items: center;
  min-height: 68vh;
  width: 100%;
  padding: 0.5rem 0 1.5rem;
}
.hero-brand {
  font-family: var(--display);
  font-size: clamp(2.4rem, 4.5vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 0.85rem;
  color: var(--primary-strong);
}
.hero h1 {
  font-size: clamp(1.45rem, 2.2vw, 1.9rem);
  font-weight: 650;
  max-width: 20ch;
  color: var(--text);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--primary-strong);
  font-weight: 750;
  margin: 0 0 0.7rem;
}
.lede {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 36rem;
  line-height: 1.6;
  margin: 0.55rem 0 0;
}
.hero-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.35rem;
  flex-wrap: wrap;
}
.hero-visual {
  position: relative;
  min-height: 340px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #0f3d24, #178a4a 60%, #7ed9a8);
}
.hero-visual-card {
  position: absolute;
  left: 1.2rem;
  right: 1.2rem;
  bottom: 1.2rem;
  background: rgba(8, 30, 18, 0.45);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 1rem 1.05rem;
  color: #f4fff8;
  display: grid;
  gap: 0.55rem;
}
.hero-visual-card strong {
  font-family: var(--display);
  font-size: 1.1rem;
}
.hero-metric-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
}
.hero-metric-row span { opacity: 0.85; }

.fact-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.fact-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.fact-list li:last-child { border-bottom: 0; }

.theme-toggle {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: inherit;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font: inherit;
}
.main-full .theme-toggle,
.topbar-public .theme-toggle {
  border-color: var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.live-panel {
  border-color: var(--primary);
  width: 100%;
}
.live-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
  margin-bottom: 0;
}
.progress-wrap { margin-top: 0.75rem; }
.progress-bar {
  height: 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
}
.progress-meta {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

body.modal-open { overflow: hidden; }
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 20, 12, 0.4);
}
.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(80vh, 720px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.2rem;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.modal-head h3 {
  margin: 0;
  font-family: var(--display);
}
.detail-block { margin-top: 0.9rem; }
.detail-block h4 {
  margin: 0 0 0.3rem;
  font-size: 0.86rem;
  color: var(--muted);
}
.detail-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  font-size: 0.88rem;
  color: var(--text);
}

.empty-state {
  padding: 1rem 0.1rem;
  color: var(--muted);
}
.fail-reason-cell {
  max-width: 320px;
  font-size: 0.9rem;
  color: var(--muted);
}

.fo-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.fo-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.fo-filter {
  position: relative;
}
.fo-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.fo-filter-btn:hover { background: var(--bg-soft); }
.fo-filter.is-open .fo-filter-btn {
  border-color: var(--accent);
  background: var(--bg-soft);
}
.fo-filter-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 650;
}
.fo-filter-value {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.fo-filter-caret { color: var(--muted); font-size: 0.75rem; }
.fo-filter-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 50;
  width: min(320px, 86vw);
  padding: 0.55rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
}
.fo-filter-search-wrap { margin-bottom: 0.4rem; }
.fo-filter-search {
  width: 100%;
  min-height: 2.1rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.fo-filter-options {
  max-height: 240px;
  overflow: auto;
  display: grid;
  gap: 0.15rem;
}
.fo-filter-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.fo-filter-option:hover,
.fo-filter-option.is-active {
  background: var(--bg-soft);
}
.fo-filter-option-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fo-filter-count {
  flex: 0 0 auto;
  min-width: 2rem;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 650;
}
.fo-filter-empty {
  margin: 0.35rem 0.2rem 0.15rem;
  font-size: 0.85rem;
}
.fo-bulk-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.55rem 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.fo-bulk-label { font-size: 0.9rem; }
.col-check {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}
.col-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}
html[data-theme="dark"] .fo-filter-panel {
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}
.col-nowrap {
  white-space: nowrap;
}
th.col-actions,
td.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}
.row-action-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  line-height: 1;
}

.dropdown {
  position: relative;
  display: inline-block;
  text-align: left;
}
.dropdown-toggle {
  min-width: 5.5rem;
}
.dropdown-menu {
  position: fixed;
  z-index: 80;
  min-width: 9.5rem;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  display: none;
  gap: 0.15rem;
}
.dropdown-menu.is-visible {
  display: grid;
}
.dropdown-menu[hidden] {
  display: none !important;
}
.dropdown-form { margin: 0; }
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.dropdown-item:hover {
  background: var(--bg-soft);
}
.dropdown-item.is-danger {
  color: var(--danger);
}
html[data-theme="dark"] .dropdown-menu {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.settings-form { width: 100%; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  width: 100%;
  align-items: stretch;
}
.settings-grid > .panel { margin-bottom: 0; height: 100%; }
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
.settings-switch {
  align-items: flex-start !important;
  gap: 0.75rem !important;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}
.settings-switch input { margin-top: 0.2rem; }
.settings-switch strong { display: block; margin-bottom: 0.15rem; }
.settings-switch small { display: block; line-height: 1.45; }
.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.15rem;
  padding-top: 0.25rem;
}

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

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

  .app-shell { min-height: calc(100vh - 58px); }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    flex: none;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .22s ease;
    padding-top: max(1rem, env(safe-area-inset-top));
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }

  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar .brand .brand-text { font-size: 1rem; }

  .nav { flex-direction: column; flex-wrap: nowrap; }
  .nav-link { padding: 0.85rem 0.9rem; font-size: 1rem; }

  .grid-2,
  .hero,
  .live-stats,
  .stats-grid,
  .settings-grid,
  .form-grid-2 { grid-template-columns: 1fr; }
  .settings-actions { justify-content: stretch; }
  .settings-actions .btn { width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { width: 100%; }
  .main,
  .main-full { padding: 1rem; padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
  .hero { min-height: auto; gap: 1.2rem; }
  .hero-visual { min-height: 240px; }
  .hero-actions .btn { flex: 1 1 auto; min-width: 140px; }
  .inline-actions .btn { min-height: 38px; }
  .table-wrap { margin: 0 -0.15rem; }
  .auth-card { margin: 1rem auto; }
  .topbar-public .brand-text { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .alert-impersonate { flex-direction: column; align-items: stretch; }
  .alert-impersonate .btn { width: 100%; }
}

@media (min-width: 901px) {
  .app-header,
  .sidebar-backdrop,
  .sidebar-close { display: none !important; }
  body.nav-open { overflow: auto; }
}
