:root {
  --bg: #0b1020;
  --panel: #11182d;
  --panel-soft: #18233f;
  --panel-alt: #0f172a;
  --text: #e5edf7;
  --muted: #93a4bf;
  --line: #24324f;
  --brand: #14b8a6;
  --brand-dark: #0f766e;
  --red: #ef4444;
  --amber: #f59e0b;
  --green: #22c55e;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(180deg, #0b1020 0%, #0f172a 100%); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
pre { overflow: auto; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; border-radius: 8px; background: #09101f; color: #dbe7ff; padding: 14px; font-size: 12px; line-height: 1.5; border: 1px solid #1f2a44; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); background: #0d1529; }
button { font: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
/* overlay is position:fixed so it's out of grid flow; hidden by default */
.sidebar-overlay { position: fixed; display: none; inset: 0; z-index: 199; background: rgba(0,0,0,0.45); }
/* hamburger toggle hidden on desktop */
.sidebar-toggle { display: none; }
.sidebar { background: rgba(9, 16, 31, 0.92); color: #e5edf7; padding: 24px 18px; border-right: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: linear-gradient(135deg, var(--brand) 0%, #06b6d4 100%); color: #06231f; font-weight: 800; }
.brand-title { font-weight: 800; letter-spacing: 0; }
.brand-version { margin-top: 4px; color: var(--brand); font-size: 12px; font-weight: 700; }
.brand-subtitle, .eyebrow, .muted, .subhead, .timestamp { color: var(--muted); font-size: 13px; }
.nav { display: grid; gap: 8px; }
.nav-link { padding: 11px 12px; border-radius: 8px; color: #c7d4e9; border: 1px solid transparent; }
.nav-link:hover { background: #18233f; color: white; border-color: #24324f; }
.workspace { min-width: 0; }
.topbar { min-height: 84px; display: flex; justify-content: space-between; align-items: center; padding: 20px 28px; border-bottom: 1px solid var(--line); background: rgba(11, 16, 32, 0.84); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 2; }
h1 { margin: 4px 0 0; font-size: 26px; }
h2 { margin: 0; font-size: 18px; }
.top-actions, .action-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.content { padding: 24px 28px 40px; display: grid; gap: 18px; }
.card { background: linear-gradient(180deg, rgba(17, 24, 45, 0.98) 0%, rgba(13, 21, 41, 0.98) 100%); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 18px; }
.hero-card h2 { margin-top: 12px; font-size: 24px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { display: grid; gap: 8px; }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 700; }
.kpi strong { font-size: 24px; }
.good, .green { color: var(--green); }
.bad, .red { color: var(--red); }
.amber { color: var(--amber); }
.grid.two, .wizard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid.four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #101a32; border: 1px solid var(--line); }
.chip.green { color: #0f3; background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.3); }
.chip.red { color: #ffb0b0; background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.3); }
.chip.amber { color: #ffd589; background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.3); }
.chip.slate { color: #d7dfef; background: rgba(148, 163, 184, 0.14); border-color: rgba(148, 163, 184, 0.3); }
.metric-row, .status-line { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid rgba(148, 163, 184, 0.1); }
.metric-row:last-child, .status-line:last-child { border-bottom: 0; }
a.status-line.alert-link { text-decoration: none; color: inherit; cursor: pointer; border-radius: 6px; transition: background .15s; }
a.status-line.alert-link:hover { background: rgba(148, 163, 184, 0.08); }
.status-list { display: grid; gap: 0; }
.clean-list { margin: 12px 0 0; padding-left: 18px; }
.clean-list li { margin: 8px 0; }
.button { border: 1px solid transparent; border-radius: 8px; padding: 10px 14px; font-weight: 700; cursor: pointer; transition: transform .12s ease, opacity .12s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .6; cursor: wait; transform: none; }
.button.primary { color: #022c28; background: linear-gradient(135deg, #2dd4bf, #14b8a6); }
.button.secondary { color: #dbe7ff; background: #15213d; border-color: #28385a; }
.button.danger { color: white; background: #b91c1c; }
.button.warn { color: #241200; background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.button.full { width: 100%; }
.button.compact {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(21, 33, 61, 0.96), rgba(13, 21, 41, 0.96));
  border-color: rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.button.compact:hover {
  border-color: rgba(45, 212, 191, 0.32);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid rgba(20, 184, 166, 0.28);
  color: #b7fff2;
  font-size: 12px;
  font-weight: 700;
}
.license-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(21, 33, 61, 0.92);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}
.license-pill.green { color: #b7fff2; border-color: rgba(20, 184, 166, 0.28); }
.license-pill.amber { color: #ffe0a3; border-color: rgba(245, 158, 11, 0.28); }
.license-pill.red { color: #ffb0b0; border-color: rgba(239, 68, 68, 0.28); }
.output { min-height: 90px; max-width: 100%; max-height: 420px; overflow: auto; }
.table { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tr { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); background: rgba(17, 24, 45, 0.85); }
.tr:last-child { border-bottom: 0; }
.tr.head { background: rgba(24, 35, 63, 0.9); font-weight: 800; color: var(--muted); }
.tr.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tr.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tr.five { grid-template-columns: 1fr 1.4fr 0.9fr 1.2fr 1.1fr; }
.tr.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tr.seven { grid-template-columns: 0.7fr 1fr 1fr 1.2fr 1fr 1.5fr 1.2fr; }
.tr.eight { grid-template-columns: 0.55fr 0.8fr 1fr 1fr 1fr 1fr 1.2fr 1.2fr; }
.table.compact .tr { padding: 10px 12px; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #0b1020, #0f172a); }
.login-card { width: min(420px, calc(100vw - 32px)); display: grid; gap: 14px; padding: 24px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.alert.danger { border-radius: 8px; padding: 10px 12px; background: rgba(239, 68, 68, 0.14); color: #ffb0b0; }
.api-form { display: grid; gap: 12px; margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.insight { font-size: 15px; line-height: 1.6; }
.wizard-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 20; }
.toast { min-width: 280px; max-width: 440px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: #0d1529; box-shadow: var(--shadow); }
.toast.ok { border-color: rgba(34, 197, 94, 0.35); }
.toast.error { border-color: rgba(239, 68, 68, 0.35); }
.field-error { min-height: 16px; color: #ffb0b0; font-size: 12px; }
.alert-inline { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #0d1529; }
.alert-inline.ok { border-color: rgba(34, 197, 94, 0.35); color: #d9ffe6; }
.alert-inline.warn { border-color: rgba(245, 158, 11, 0.35); color: #ffe0a3; }
.alert-inline.error { border-color: rgba(239, 68, 68, 0.35); color: #ffb0b0; }
.advanced-panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: rgba(9, 16, 31, 0.7); }
.advanced-panel summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.dev-banner { margin-top: 10px; display: inline-flex; align-items: center; min-height: 28px; padding: 6px 10px; border-radius: 8px; background: rgba(245, 158, 11, 0.14); color: #ffe0a3; border: 1px solid rgba(245, 158, 11, 0.35); font-size: 13px; font-weight: 700; }
.dev-scenario-bar { margin-top: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dev-scenario-label { display: flex; gap: 10px; align-items: center; color: var(--text); }
.dev-scenario-label select, .dev-scenario-mirror { min-width: 240px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row input { width: auto; }
.output-block { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: rgba(9, 16, 31, 0.7); white-space: pre-wrap; max-width: 100%; overflow-wrap: anywhere; }
.wizard-span-two { grid-column: 1 / -1; }
.panel-inset { padding: 16px; background: rgba(9, 16, 31, 0.72); box-shadow: none; }
.status-pass { border-left: 3px solid rgba(34, 197, 94, 0.7); padding-left: 12px; }
.status-warn { border-left: 3px solid rgba(245, 158, 11, 0.7); padding-left: 12px; }
.status-fail { border-left: 3px solid rgba(239, 68, 68, 0.7); padding-left: 12px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); background: #101a32; color: #dbe7ff; }
.badge-blue { background: rgba(59, 130, 246, 0.14); border-color: rgba(59, 130, 246, 0.32); color: #bfdbfe; }
.badge-slate { background: rgba(148, 163, 184, 0.14); border-color: rgba(148, 163, 184, 0.32); color: #cbd5e1; }
.kpi-link { transition: transform .12s ease, border-color .12s ease; }
.kpi-link:hover { border-color: rgba(45, 212, 191, 0.4); }
.log-accordion { display: grid; gap: 10px; }
.log-entry { border: 1px solid var(--line); border-radius: 8px; background: rgba(9, 16, 31, 0.7); overflow: hidden; }
.log-entry summary { cursor: pointer; padding: 12px 14px; font-weight: 700; }
.log-entry pre { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.log-ok summary { color: #d9ffe6; }
.log-warn summary { color: #ffe0a3; }
.log-fail summary { color: #ffb0b0; }
.repair-steps { margin-top: 14px; }
.provider-setup-shell { display: grid; gap: 18px; }
.provider-hero {
  background:
    radial-gradient(circle at top right, rgba(45, 212, 191, 0.16), transparent 32%),
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(17, 24, 45, 0.98), rgba(13, 21, 41, 0.98));
}
.provider-layout { align-items: start; }
.setup-stepper { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.step-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(9, 16, 31, 0.72);
  display: grid;
  gap: 6px;
}
.step-card.done { border-color: rgba(34, 197, 94, 0.32); background: rgba(34, 197, 94, 0.08); }
.step-card.active { border-color: rgba(45, 212, 191, 0.42); box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.18) inset; }
.step-index {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #022c28;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
}
.provider-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.provider-grid-span { grid-column: 1 / -1; }
.provider-section-head { margin-top: 20px; }
.provider-actions { margin-top: 18px; }
.status-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.summary-tile {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(9, 16, 31, 0.72);
  display: grid;
  gap: 8px;
}
.summary-tile strong { font-size: 18px; }
.upload-button { position: relative; overflow: hidden; }
.toolbar-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-strip {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 0.9fr 1.4fr;
  gap: 12px;
  align-items: end;
  margin: 14px 0;
}
.toolbar-right { justify-content: flex-end; }
.pagination-bar {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.license-shell {
  display: grid;
  grid-template-columns: minmax(0, 960px);
  justify-content: start;
  gap: 16px;
}
.comparison-wrap {
  margin-top: 14px;
  overflow-x: auto;
}
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.comparison-table th,
.comparison-table td {
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  text-align: left;
  vertical-align: top;
}
.comparison-table th {
  background: rgba(24, 35, 63, 0.75);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
.comparison-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.license-compare-panel {
  margin-top: 14px;
}
.modal-dialog {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: linear-gradient(180deg, rgba(17, 24, 45, 0.98) 0%, rgba(13, 21, 41, 0.98) 100%);
  color: var(--text);
  box-shadow: var(--shadow);
}
.modal-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
}
.modal-head,
.modal-body,
.modal-actions {
  padding: 18px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.modal-actions {
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}
.modal-note {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(9, 16, 31, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.12);
  white-space: pre-wrap;
}
.modal-compare-wrap {
  margin-top: 16px;
}

@media (max-width: 1080px) {
  .kpi-grid, .grid.two, .wizard-grid, .form-grid, .setup-stepper, .status-summary-grid, .toolbar-strip { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    width: 260px;
    z-index: 200;
    overflow-y: auto;
    transition: left 0.22s ease;
  }
  .shell.sidebar-open .sidebar { left: 0; box-shadow: var(--shadow); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0,0,0,0.45);
  }
  .shell.sidebar-open .sidebar-overlay { display: block; }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
  }
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .tr, .tr.four { grid-template-columns: 1fr; }
  .tr.five, .tr.six, .tr.seven, .tr.eight { min-width: max-content; }
}

/* Active nav link */
.nav-link.active {
  background: rgba(20, 184, 166, 0.14);
  color: #e5edf7;
  border-color: rgba(20, 184, 166, 0.32);
}

/* Nav section labels */
.nav-section-label {
  padding: 14px 12px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(147, 164, 191, 0.45);
  margin-top: 4px;
}

/* Nav icons */
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
}
.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
  opacity: 1;
}

/* Locked nav items */
.nav-link-locked {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* Empty state */
.empty-state {
  padding: 36px 16px;
  text-align: center;
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.empty-state strong {
  color: var(--text);
  font-size: 15px;
}
.empty-state p {
  margin: 0;
  font-size: 13px;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, rgba(36,50,79,0.7) 25%, rgba(55,75,115,0.5) 50%, rgba(36,50,79,0.7) 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
  border-radius: 6px;
  min-height: 18px;
}
@keyframes skeleton-sweep {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { min-height: 120px; }

/* Action dropdown */
.action-dropdown {
  position: relative;
  display: inline-block;
}
.action-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  min-width: 180px;
  background: #0d1529;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.action-dropdown.open .action-dropdown-menu {
  display: grid;
}
.action-dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid rgba(148,163,184,0.08);
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  font: inherit;
}
.action-dropdown-item:last-child { border-bottom: none; }
.action-dropdown-item:hover { background: #18233f; }

/* Dashboard async loading state */
.dash-loading .kpi strong,
.dash-loading .chip,
.dash-loading .status-line span:last-child {
  opacity: 0.3;
}

/* alert.success variant */
.alert.success { border-radius: 8px; padding: 10px 12px; background: rgba(34, 197, 94, 0.12); color: #86efac; }

/* status-grid — compact metric list */
.status-grid { display: grid; gap: 0; }
.status-grid.compact .status-line { padding: 8px 0; font-size: 13px; }
.status-grid.compact .status-line .chip { font-size: 11px; padding: 2px 7px; }

/* mode-card — selectable provider mode buttons */
.mode-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 1rem; }
.mode-card {
  padding: 16px 14px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 14px;
  line-height: 1.5;
}
.mode-card:hover { border-color: rgba(20, 184, 166, 0.5); background: var(--panel-soft); }
.mode-card.active { border-color: var(--brand); background: rgba(20, 184, 166, 0.1); }
.mode-card strong { display: block; font-size: 15px; margin-bottom: 4px; color: var(--text); }
.mode-card p { margin: 0; color: var(--muted); font-size: 13px; }
@media (max-width: 600px) { .mode-card-grid { grid-template-columns: 1fr; } }

/* H5: password toggle active state */
.button.secondary.active {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.4);
  color: var(--brand);
}

/* H7: show/hide password field in login */
.password-field { position: relative; }
.password-field input { padding-right: 80px; }
.show-password-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
