/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top, #1d2539 0, var(--bg) 52%);
}
.login-card {
  width: min(100%, 440px);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.login-brand { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 24px; }
.login-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  color: var(--primary);
  background: var(--primary-ghost);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 12px;
}
.login-eyebrow { margin-bottom: 2px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.login-brand h1 { font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.login-subtitle { margin-top: 6px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.login-message {
  min-height: 42px;
  margin-bottom: 20px;
  padding: 10px 12px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}
.login-message[data-state="error"] { color: #fecaca; background: var(--danger-bg); border-color: rgba(239, 68, 68, .45); }
.login-form fieldset { display: grid; gap: 18px; min-width: 0; border: 0; }
.login-form fieldset[hidden] { display: none; }
.login-form legend { margin-bottom: 2px; color: var(--text); font-size: 17px; font-weight: 600; }
.login-field { display: grid; gap: 6px; }
.login-field label { color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.login-field input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: #0d0d10;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
.login-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
.login-field input:disabled { cursor: wait; opacity: .65; }
.login-hint { color: var(--text-dim); font-size: 12px; line-height: 1.4; }
.login-submit { width: 100%; min-height: 42px; justify-content: center; margin-top: 2px; }
.login-submit .button-loading { display: none; }
.login-submit.is-loading .button-label { display: none; }
.login-submit.is-loading .button-loading { display: inline; }
@media (max-width: 480px) {
  .login-page { padding: 16px; place-items: start center; }
  .login-card { margin-top: 24px; padding: 24px 20px; }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #09090b;
  --surface: #131316;
  --surface-hover: #1a1a1f;
  --border: #27272a;
  --border-hover: #3f3f46;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-dim: #71717a;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-ghost: rgba(59,130,246,0.1);
  --success: #22c55e;
  --success-bg: rgba(34,197,94,0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.1);
  --sidebar-w: 220px;
  --radius: 8px;
  --radius-sm: 6px;
}

[data-theme="light"] {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-hover: #f1f3f5;
  --border: #dee2e6;
  --border-hover: #ced4da;
  --text: #212529;
  --text-secondary: #495057;
  --text-dim: #868e96;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-ghost: rgba(37,99,235,0.08);
  --success: #16a34a;
  --success-bg: rgba(22,163,74,0.1);
  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.08);
  --warning: #d97706;
  --warning-bg: rgba(217,119,6,0.08);
}
[data-theme="light"] .toast { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,0.5); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
#app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.app-logo-icon { color: var(--primary); flex-shrink: 0; }
.sidebar-logo svg { color: var(--primary); }
.mobile-topbar-logo { color: var(--primary); }
#sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: all 0.15s;
}
.nav-btn:hover { background: var(--surface-hover); color: var(--text); }
.nav-btn.active { background: var(--primary-ghost); color: var(--primary); font-weight: 500; }
.sidebar-footer { padding-top: 16px; border-top: 1px solid var(--border); }
.env-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 6px;
}
.env-badge.prod { background: var(--danger-bg); color: var(--danger); }
.env-badge.dev { background: var(--success-bg); color: var(--success); }
.env-detail { font-size: 11px; color: var(--text-dim); line-height: 1.6; padding: 0 4px; }

/* ===== Main ===== */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  width: calc(100vw - var(--sidebar-w));
  padding: 28px 32px;
  max-width: none;
}
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.view-header h1 { font-size: 22px; font-weight: 600; }
.view-actions { display: flex; gap: 8px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.reports-header-row { display: flex; align-items: center; gap: 8px; }
.reports-header-row .section-title { margin-bottom: 12px; }
.reports-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  margin-bottom: 12px;
}


/* ===== Buttons ===== */
button { cursor: pointer; font-family: inherit; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-success { background: var(--success); color: #000; border: none; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; }
.btn-danger { display: inline-flex; align-items: center; gap: 6px; background: var(--danger); color: #fff; border: none; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity 0.15s; }
.btn-danger:hover { opacity: 0.85; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }

/* ===== Progress ===== */
.hidden { display: none !important; }
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.progress-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.progress-info span:first-child { color: var(--text-secondary); }
#progress-pct { font-weight: 600; color: var(--primary); }
#progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}
.progress-sub { font-size: 12px; color: var(--text-dim); display: block; margin-top: 6px; }

/* ===== Quick Stats ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 360px;
}
.stat-card-action {
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.stat-card-action:hover {
  border-color: var(--danger);
  background: var(--surface-hover);
}
.stat-card-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-total { background: var(--primary-ghost); color: var(--primary); }
.stat-icon-ok { background: var(--success-bg); color: var(--success); }
.stat-icon-fail { background: var(--danger-bg); color: var(--danger); }
.stat-icon-time { background: var(--warning-bg); color: var(--warning); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-dim); }
.stats-explainer {
  font-size: 12px;
  color: var(--text-dim);
  margin: -12px 0 20px;
  line-height: 1.5;
}
.stats-audit-row {
  font-size: 12px;
  color: var(--text-dim);
  margin: -8px 0 20px;
  line-height: 1.5;
}
.stats-audit-row strong { color: var(--text); font-weight: 600; }

/* ===== Report Cards ===== */
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.report-select-checkbox {
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  margin: 0;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.report-select-checkbox:hover { border-color: var(--primary); }
.report-select-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.report-select-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}
.report-select-checkbox:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.report-select-checkbox:indeterminate { background: var(--primary); border-color: var(--primary); }
.report-select-checkbox:indeterminate::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 2px;
  background: #fff;
  transform: translate(-50%, -50%);
}
.report-card:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.reports-bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  font-size: 13px;
  color: var(--text-dim);
}
.reports-bulk-bar #reports-bulk-count { font-weight: 600; color: var(--text); }
.report-card .left { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.report-card-passbar {
  margin-top: 8px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  max-width: 280px;
  display: flex;
}
.report-card-passbar-fill {
  height: 100%;
  background: var(--success);
  flex-shrink: 0;
}
.report-card-passbar-fill.fail {
  background: var(--danger);
}
.report-card-passmeta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.report-card .right { display: flex; align-items: center; gap: 10px; }
.report-card .time { font-size: 14px; font-weight: 500; }
.report-card .meta { font-size: 12px; color: var(--text-dim); }
.report-card .time-ago { font-size: 12px; color: var(--text-dim); }
.badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--danger-bg); color: var(--danger); }
.badge-trigger { background: var(--primary-ghost); color: var(--primary); }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 4px;
  transition: all 0.15s;
  display: flex;
}
.btn-icon:hover { background: var(--danger-bg); color: var(--danger); }

/* ===== Report Detail Header ===== */
#report-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.report-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
}
.rds { text-align: center; padding: 12px; background: var(--bg); border-radius: var(--radius-sm); }
.rds-value { font-size: 26px; font-weight: 700; }
.rds-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.report-metrics-explainer {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}
.report-metrics-explainer .kpi-hint {
  text-decoration: underline dotted;
  cursor: help;
}
.stats-audit-row .kpi-hint {
  text-decoration: underline dotted;
  cursor: help;
}

/* ===== Type Breakdown ===== */
.breakdown-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.breakdown-zone {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.breakdown-zone-special {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.breakdown-zone-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.breakdown-zone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breakdown-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.breakdown-chip:hover { border-color: var(--border-hover); }
.breakdown-chip.active { border-color: var(--primary); background: var(--primary-ghost); }
.breakdown-chip.active .bc-label { color: var(--primary); font-weight: 600; }
.breakdown-chip .bc-label { color: var(--text-secondary); }
.breakdown-chip .bc-ok { color: var(--success); font-weight: 600; }
.breakdown-chip .bc-fail { color: var(--danger); font-weight: 600; }

/* ===== Filters ===== */
.filters-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.filters-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filters-row-status {
  justify-content: space-between;
}
.filters-row-status #search-input {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}
.filter-scope-group { flex-wrap: wrap; }
.filter-group {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.filter-btn:hover { color: var(--text-secondary); }
.filter-btn.active { background: var(--primary); color: #fff; }
.filter-btn .count { opacity: 0.7; margin-left: 2px; }
.filter-scope-group .filter-btn {
  padding: 6px 10px;
}
#search-input {
  background: var(--surface);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 280px;
  transition: border-color 0.15s;
}
#search-input:focus { outline: none; border-color: var(--primary); }
#search-input::placeholder { color: var(--text-dim); }

.campaign-filter-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  min-width: 220px;
  max-width: 320px;
}
.campaign-filter-input:focus { outline: none; border-color: var(--primary); }
.campaign-filter-input::placeholder { color: var(--text-dim); }

.results-count { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }

/* ===== Result Rows ===== */
.result-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 4px;
  display: grid;
  grid-template-columns: 36px minmax(210px, 1fr) 160px 90px 70px 112px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  transition: background 0.1s;
}
.result-row:hover { background: var(--surface-hover); }
.result-row.fail { border-left: 3px solid var(--danger); }
.result-row.ok { border-left: 3px solid var(--success); }
.result-status {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.result-status.ok { background: var(--success-bg); color: var(--success); }
.result-status.fail { background: var(--danger-bg); color: var(--danger); }
.result-row .url { color: var(--primary); text-decoration: none; font-weight: 500; }
.result-row .url:hover { text-decoration: underline; }
.result-row .type-tag {
  display: inline-block;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 6px;
}
.result-row .publisher-tag { font-size: 11px; color: var(--text-dim); }
.result-row .campaign-tag { font-size: 11px; color: var(--text-dim); }
.result-failure-reason {
  font-size: 11px;
  color: var(--danger);
  font-weight: 500;
  margin-top: 2px;
}
.result-row-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.result-row-actions .btn-row-action {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.result-row-actions .btn-row-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-row-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.health-codes { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.health-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.health-badge.ok, .health-badge.clean { color: var(--success); background: var(--success-bg); }
.health-badge.fail, .health-badge.error { color: var(--danger); background: var(--danger-bg); }
.health-badge.warning { color: var(--warning); background: var(--warning-bg); }
.health-badge.unknown { color: var(--text-dim); background: var(--bg); }
.result-row .assets { color: var(--text-dim); font-size: 12px; }
.result-row .time { color: var(--text-dim); font-size: 12px; text-align: right; }
.result-row .thumb img {
  width: 104px;
  height: 64px;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.result-row .thumb img:hover { transform: scale(1.1); }
.no-screenshot { font-size: 10px; color: var(--text-dim); }

/* Expandable details */
.result-details { grid-column: 1 / -1; margin-top: 4px; }
.errors-list { font-size: 11px; color: var(--danger); }
.errors-list div {
  padding: 3px 8px;
  background: var(--danger-bg);
  border-radius: 3px;
  margin-bottom: 2px;
}
.console-detail { font-size: 11px; margin-top: 4px; }
.console-detail details { background: var(--bg); border-radius: var(--radius-sm); padding: 8px 12px; }
.console-detail summary { cursor: pointer; color: var(--text-secondary); font-weight: 500; font-size: 12px; }
.console-entry {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.console-entry:last-child { border-bottom: none; }
.console-type { color: var(--warning); font-family: monospace; }
.console-entry.error .console-type,
.console-entry.pageerror .console-type { color: var(--danger); }
.console-text { color: var(--text-secondary); word-break: break-word; font-family: monospace; }
.console-text small { color: var(--text-dim); }
.failed-assets-detail { font-size: 11px; margin-top: 4px; }
.failed-assets-detail details { background: var(--bg); border-radius: var(--radius-sm); padding: 8px 12px; }
.failed-assets-detail summary {
  cursor: pointer;
  color: var(--warning);
  font-weight: 500;
  font-size: 12px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.failed-assets-detail summary::before { content: "▸"; transition: transform 0.15s; }
.failed-assets-detail details[open] summary::before { transform: rotate(90deg); }
.failed-assets-detail .asset-entry {
  padding: 4px 0;
  display: grid;
  grid-template-columns: 50px 140px 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.failed-assets-detail .asset-entry:last-child { border-bottom: none; }
.asset-status { color: var(--danger); font-weight: 600; font-size: 11px; }
.asset-field { color: var(--warning); font-weight: 500; font-size: 11px; }
.asset-url { color: var(--text-dim); word-break: break-all; font-size: 11px; }

/* ===== Scheduler ===== */
.scheduler-panel {
  max-width: 520px;
}
.scheduler-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.scheduler-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.scheduler-indicator.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.scheduler-indicator.off { background: var(--text-dim); }
#scheduler-status-text { font-size: 14px; font-weight: 500; }
.scheduler-cron { font-size: 12px; color: var(--text-dim); font-family: monospace; }
.scheduler-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.scheduler-form label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.scheduler-form input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-bottom: 10px;
}
.scheduler-form input:focus { outline: none; border-color: var(--primary); }
.cron-presets { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:hover { border-color: var(--primary); color: var(--primary); }
.scheduler-actions { display: flex; gap: 8px; }

/* ===== Screenshot Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.screenshot-dialog { position: relative; max-width: 90vw; max-height: 90vh; }
.screenshot-dialog img { display: block; max-width: 90vw; max-height: 90vh; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.screenshot-close { position: absolute; top: 8px; right: 8px; z-index: 1; min-width: 32px; padding: 2px 8px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 24px; line-height: 1; }
.screenshot-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.screenshot-trigger { display: block; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: zoom-in; }
.screenshot-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.screenshot-trigger img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }

.results-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
}
.results-pagination.hidden { display: none; }
.results-pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.results-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.results-pagination .page-info {
  font-size: 12px;
  color: var(--text-dim);
}

.sse-banner {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.sse-banner.hidden { display: none; }

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.mobile-topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.mobile-menu-btn { padding: 8px; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9;
}
.sidebar-backdrop:not(.hidden) { display: block; }

.modal-overlay .lightbox-caption {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  max-width: 90vw;
  text-align: center;
}

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-dim);
  font-size: 14px;
}
.empty svg { margin-bottom: 12px; color: var(--border-hover); }

/* ===== Loading ===== */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 12px;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }
.logout-button { width: 100%; justify-content: center; margin-bottom: 12px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ===== Settings ===== */
.settings-panel { max-width: 720px; }
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.settings-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.settings-row {
  display: flex;
  gap: 12px;
}
.settings-field { flex: 1; margin-bottom: 10px; }
.settings-field:last-child { margin-bottom: 0; }
.settings-field-sm { flex: 0 0 140px; }
.settings-field label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}
.settings-field input,
.settings-field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.settings-field input:focus,
.settings-field select:focus { outline: none; border-color: var(--primary); }
.settings-field input:focus-visible,
.settings-field select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.settings-field select { cursor: pointer; }
.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.settings-saved { font-size: 12px; color: var(--success); font-weight: 500; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.env-switch-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.env-switch-btn {
  min-width: 130px;
  justify-content: center;
}
.settings-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Users ===== */
.users-panel { display: grid; max-width: 960px; gap: 16px; }
.users-view-header { align-items: flex-start; }
.view-eyebrow { margin-bottom: 4px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.view-description { margin-top: 6px; color: var(--text-secondary); font-size: 14px; }
.user-card { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.user-card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.user-card-heading h2 { font-size: 16px; font-weight: 600; }
.user-card-heading p { margin-top: 4px; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.user-count { flex: 0 0 auto; margin: 0 !important; padding: 4px 8px; color: var(--text-secondary) !important; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; font-size: 12px !important; }
.user-form { display: grid; gap: 14px; }
.create-user-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(130px, .55fr); gap: 12px; }
.user-form .settings-field { margin: 0; }
.user-form .settings-field input,
.user-form .settings-field select,
.user-control select { width: 100%; min-height: 38px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; }
.user-form .settings-field input,
.user-control select { padding: 8px 10px; }
.user-form .settings-field select { padding: 8px 10px; }
.user-form .settings-field input:focus,
.user-form .settings-field select:focus,
.user-control select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
.user-form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.user-form-actions .settings-hint { margin: 0; }
.users-list { display: grid; gap: 10px; }
.user-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(130px, 160px) auto auto; align-items: end; gap: 14px; padding: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.user-identity { min-width: 0; align-self: center; }
.user-name { overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.user-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.user-role-badge, .user-status-badge { display: inline-flex; align-items: center; min-height: 21px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.user-role-badge { color: var(--primary); background: var(--primary-ghost); }
.user-status-badge.is-active { color: var(--success); background: var(--success-bg); }
.user-status-badge.is-disabled { color: var(--danger); background: var(--danger-bg); }
.user-status-badge.is-pending { color: var(--warning); background: var(--warning-bg); text-transform: none; }
.user-control { display: grid; gap: 5px; color: var(--text-dim); font-size: 11px; font-weight: 600; }
.user-enabled { display: inline-flex; align-items: center; min-height: 38px; gap: 7px; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.user-enabled input { accent-color: var(--primary); }
.user-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.user-row-actions button { width: 132px; min-height: 38px; justify-content: center; white-space: nowrap; }
/* Keep role/status/actions aligned whether Delete is available or not. */
.user-delete-slot { display: block; width: 132px; min-height: 38px; flex: 0 0 132px; }
.user-row[data-busy="true"] { opacity: .65; }
.reset-password-form { max-width: 440px; }

/* ===== Confirm Modal ===== */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  backdrop-filter: blur(2px);
}
.confirm-overlay.hidden { display: none; }
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(360px, calc(100vw - 32px));
  min-width: 0;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}
.confirm-box p { font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Next Run Countdown ===== */
.next-run-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.next-run-bar svg { color: var(--primary); flex-shrink: 0; }
.next-run-bar strong { color: var(--text); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .mobile-topbar { display: flex; }
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }
  #sidebar.open { transform: translateX(0); }
  #main {
    margin-left: 0;
    width: 100vw;
    padding: 16px;
    padding-top: 0;
  }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat-card { max-width: none; }
  .report-detail-stats { grid-template-columns: repeat(2, 1fr); }
  .result-row { grid-template-columns: 30px 1fr 130px; }
  .result-row .assets, .result-row .time, .result-row .thumb { display: none; }
  .filters-row-status { flex-direction: column; align-items: stretch; }
  .filters-row-status #search-input { max-width: none; width: 100%; }
  .settings-row { flex-direction: column; }
  .settings-field-sm { flex: 1; }
  .create-user-fields { grid-template-columns: 1fr 1fr; }
  .create-user-fields .role-field { grid-column: span 2; }
  .user-row { grid-template-columns: minmax(0, 1fr) minmax(130px, 160px) auto; }
  .user-row-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 560px) {
  .view-header.users-view-header { margin-bottom: 18px; }
  .user-card { padding: 16px; }
  .user-card-heading { flex-direction: column; gap: 8px; }
  .create-user-fields { grid-template-columns: 1fr; }
  .create-user-fields .role-field { grid-column: auto; }
  .user-row { grid-template-columns: 1fr; gap: 12px; }
  .user-control { max-width: none; }
  .user-row-actions { grid-column: auto; }
  .user-row-actions button { width: auto; flex: 1 1 auto; justify-content: center; }
  .user-delete-slot { display: none; }
  .user-form-actions .btn-primary { width: 100%; justify-content: center; }
}

/* ===== Authentication ===== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% -10%, rgba(59,130,246,.18), transparent 38%),
    var(--bg);
}
.auth-card {
  width: min(100%, 440px);
  padding: 32px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,.32);
}
.auth-brand { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 24px; }
.auth-mark { width: 46px; height: 46px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--primary); border-radius: 12px; box-shadow: 0 8px 18px rgba(59,130,246,.25); }
.auth-kicker { margin-bottom: 3px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.auth-brand h1 { color: var(--text); font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.auth-subtitle { margin-top: 5px; color: var(--text-secondary); font-size: 14px; }
.auth-message { min-height: 22px; margin-bottom: 18px; color: var(--text-secondary); font-size: 13px; }
.auth-message[data-state="error"] { color: var(--danger); }
.auth-message[data-state="info"] { color: var(--text-secondary); }
.auth-form fieldset { display: grid; gap: 16px; border: 0; min-width: 0; }
.auth-form fieldset[hidden] { display: none; }
.auth-field { display: grid; gap: 7px; }
.auth-field label { color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.auth-field input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font: inherit; transition: border-color .15s, box-shadow .15s;
}
.auth-field input:hover { border-color: var(--border-hover); }
.auth-field input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-color: var(--primary); }
.auth-help { color: var(--text-dim); font-size: 12px; line-height: 1.45; }
.auth-submit { width: 100%; min-height: 44px; justify-content: center; font-size: 14px; }
.auth-form[aria-busy="true"] .auth-submit { cursor: progress; }
.auth-form[aria-busy="true"] .auth-submit::after { content: ""; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }

@media (max-width: 480px) {
  .auth-page { padding: 16px; align-items: start; padding-top: 12vh; }
  .auth-card { padding: 24px 20px; border-radius: 12px; }
  .auth-brand { gap: 12px; }
  .auth-mark { width: 42px; height: 42px; }
  .auth-brand h1 { font-size: 22px; }
}
