:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #172033;
  --muted: #64748b;
  --line: #d8e0ea;
  --accent: #0f766e;
  --accent-2: #334155;
  --danger: #dc2626;
  --ok: #059669;
  --shadow: 0 12px 32px rgba(15, 23, 42, .07);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #141b24;
    --surface: #1a232e;
    --surface-2: #222d3a;
    --text: #e8eef5;
    --muted: #9aa8ba;
    --line: #314052;
    --accent: #2dd4bf;
    --accent-2: #cbd5e1;
    --shadow: 0 14px 34px rgba(0,0,0,.20);
  }
}

html[data-theme="dark"] {
  --bg: #141b24;
  --surface: #1a232e;
  --surface-2: #222d3a;
  --text: #e8eef5;
  --muted: #9aa8ba;
  --line: #314052;
  --accent: #2dd4bf;
  --accent-2: #cbd5e1;
  --shadow: 0 14px 34px rgba(0,0,0,.20);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
  line-height: 1.5;
}
body.has-compare-tray { padding-bottom: 88px; }
a { color: inherit; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
}
textarea { min-height: 110px; resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; font-weight: 700; }
.danger-btn { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
html[data-theme="dark"] .danger-btn { background: #3a171b; border-color: #7f1d1d; color: #fecaca; }

.site-bg {
  min-height: 100vh;
  background: var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: var(--surface);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  text-decoration: none;
}
.brand::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
}
.topbar nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar select { width: auto; min-width: 82px; padding: 8px 9px; background: var(--surface-2); }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.topbar nav a:hover { color: var(--text); }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 52px; }
.eyebrow { display: inline-flex; margin-bottom: 10px; color: var(--accent-2); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0; }
.breadcrumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs span { color: var(--text); font-weight: 700; }
.breadcrumbs b { color: var(--line); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 22px;
  align-items: center;
  min-height: 220px;
  padding: 8px 0 20px;
}
.hero h1 {
  margin: 0 0 14px;
  max-width: 720px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.08;
  font-weight: 800;
}
.hero p { margin: 0; max-width: 620px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.search-box { display: grid; gap: 12px; }
.search-box input { height: 46px; }
.quick-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.quick-stats div { padding: 12px; border-radius: 8px; background: var(--surface-2); }
.quick-stats strong { display: block; font-size: 20px; }
.quick-stats span { color: var(--muted); font-size: 13px; }

.section-head, .detail-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 22px 0 16px;
}
.section-head h1, .section-head h2, section h2 { margin: 0 0 8px; font-size: 24px; }
.section-head p { margin: 0; color: var(--muted); }
.filters { display: flex; gap: 10px; min-width: min(560px, 100%); }

.category-grid, .metric-grid, .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.category-card, .panel, .metric, .empty {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.category-card {
  padding: 14px;
  min-height: 72px;
  display: grid;
  align-content: space-between;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease;
}
.category-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.category-card strong { font-size: 18px; }
.category-card span, .empty p { color: var(--muted); line-height: 1.45; }
.category-card em { color: var(--accent-2); font-style: normal; font-weight: 800; }
.panel { padding: 16px; margin: 14px 0; overflow: auto; }
.empty { padding: 24px; border-style: dashed; }
.empty h3 { margin: 0 0 8px; }
.advanced-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(6, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.advanced-filters label, .search-box label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.advanced-filters input, .advanced-filters select { height: 42px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.compare-table, .admin-table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; background: var(--surface-2); }
.compare-table thead th { position: static; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 46%, transparent); }
td small { color: var(--muted); }
.package-title { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 10px; }
.provider-link { display: inline-flex; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; }
.package-link { display: block; margin-top: 3px; font-weight: 800; text-decoration: none; }
.provider-logo {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 86%, #ffffff);
  color: #fff;
  font-weight: 900;
  overflow: hidden;
}
.provider-logo.small { width: 34px; height: 34px; font-size: 14px; }
.provider-logo.large { width: 74px; height: 74px; font-size: 28px; }
.provider-logo img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); padding: 6px; }
.resource-list { display: flex; gap: 6px; flex-wrap: wrap; max-width: 260px; }
.resource-list span, .mini-badge, .pill, .status-dot {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}
.mini-badge { margin-top: 6px; color: #075985; background: #e0f2fe; }
.status-dot.on { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.score-pill { display: inline-flex; min-width: 58px; justify-content: center; padding: 5px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 800; }
.price { font-size: 26px; font-weight: 800; color: var(--accent); }
.features { display: grid; grid-template-columns: 160px 1fr; gap: 8px; }
.price-lines { display: grid; gap: 9px; }
.price-lines span { display: flex; justify-content: space-between; gap: 12px; padding: 10px; border-radius: 8px; background: var(--surface-2); }
.price-lines b { color: var(--muted); }
.history-chart { height: 160px; display: flex; align-items: end; gap: 6px; border: 1px solid var(--line); padding: 10px; border-radius: 8px; }
.history-chart span { width: 18px; min-height: 8px; background: var(--accent-2); border-radius: 4px 4px 0 0; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.provider-card {
  display: grid;
  gap: 9px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.provider-card strong { font-size: 18px; }
.provider-card span { color: var(--muted); }
.provider-card em { color: var(--accent); font-style: normal; font-weight: 800; }
.provider-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.provider-chip {
  min-width: 190px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
}
.provider-chip small { color: var(--accent); font-weight: 900; }
.provider-hero {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.package-hero { align-items: center; }
.warning-panel { border-color: color-mix(in srgb, #f59e0b 40%, var(--line)); background: color-mix(in srgb, #fef3c7 52%, var(--surface)); }
.deal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.deal-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.deal-card strong { font-size: 16px; }
.deal-card b { color: var(--accent); font-size: 20px; }
.deal-card span { color: var(--muted); font-size: 13px; }
.compare-grid {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.compare-row {
  display: grid;
  grid-template-columns: 180px repeat(var(--compare-cols), minmax(190px, 1fr));
  min-width: calc(180px + (190px * var(--compare-cols)));
}
.compare-row > * { padding: 13px; border-bottom: 1px solid var(--line); }
.compare-row > span { color: var(--muted); font-weight: 800; background: var(--surface-2); }
.compare-head { position: static; background: var(--surface); }
.compare-head a { text-decoration: none; }
.compare-tray {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.compare-tray div { display: flex; gap: 8px; }
.cookie-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  width: min(430px, calc(100% - 36px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner div { display: flex; gap: 8px; flex-wrap: wrap; }
body.has-compare-tray .cookie-banner { bottom: 112px; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid-form h2, .grid-form .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.alert { padding: 12px; border-radius: 8px; margin: 10px 0; background: var(--surface-2); }
.alert.danger { color: #fff; background: var(--danger); }
.alert.ok { color: #fff; background: var(--ok); }
.inline { display: inline; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-grid { display: grid; gap: 18px; }
.admin-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { padding: 16px; }
.metric span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; }
.metric-grid.mini { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.compact-list { display: grid; gap: 8px; }
.compact-list a, .compact-list > span {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
}
.compact-list span, .compact-list small { color: var(--muted); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.section-head.compact { margin: 0 0 14px; }
.feature-editor { padding: 14px; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface-2); }
.feature-editor h3 { margin: 0 0 10px; font-size: 16px; }
.feature-pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.honeypot { position: absolute; left: -9999px; }
.support-report { width: 100%; min-height: 180px; color: var(--text); }
.muted-note { color: var(--muted); font-size: 13px; font-weight: 700; }
.source-test-row { margin-top: 10px; }
.mobile-package-list { display: none !important; }
.mobile-package-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mobile-package-card summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}
.mobile-package-card summary::-webkit-details-marker { display: none; }
.mobile-package-card summary span { display: grid; gap: 3px; }
.mobile-package-card summary strong { color: var(--muted); font-size: 13px; }
.mobile-package-card summary b { color: var(--text); }
.mobile-package-card summary em { color: var(--accent); font-style: normal; font-weight: 900; white-space: nowrap; }
.mobile-package-body { display: grid; gap: 10px; padding: 0 14px 14px; }
.mobile-package-body > span { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.mobile-package-body b { color: var(--muted); }

.footer {
  padding: 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}
.footer-links { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.footer-links a { color: var(--muted); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; background: var(--bg); }
.auth-card { width: min(420px, 100%); padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }

/* Installer */
body.installer-page { margin: 0; min-height: 100vh; overflow-x: hidden; background: #f3f3f3; color: #1b1b1b; font-family: "Segoe UI", Arial, sans-serif; }
.installer-shell { width: 100%; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg,#edf6ff 0%,#fafafa 50%,#eef1ff 100%); }
.setup { width: min(560px, 100%); min-height: 520px; margin: auto; display: flex; flex-direction: column; justify-content: center; }
.step { display: none; }
.step.active { display: block; animation: stepIn .22s ease both; }
@keyframes stepIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }
.kicker { margin: 0 0 12px; color: #005fb8; font-size: 13px; font-weight: 600; }
.step h1 { margin: 0 0 14px; color: #1b1b1b; font-size: 34px; line-height: 1.18; font-weight: 600; }
.copy { margin: 0 0 26px; color: #555; font-size: 15px; line-height: 1.55; }
.checks { display: grid; gap: 8px; }
.checkrow { display: flex; align-items: center; gap: 12px; padding: 11px 12px; background: #fff; border: 1px solid #ddd; border-radius: 6px; }
.badge { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.ok .badge { background: #107c10; }
.bad .badge { background: #c42b1c; }
.checkrow b { display: block; font-weight: 600; }
.checkrow small { display: block; color: #666; }
.license { max-height: 180px; overflow: auto; padding: 13px; background: #fff; border: 1px solid #ddd; border-radius: 6px; color: #333; line-height: 1.48; }
.accept { display: flex; align-items: center; gap: 9px; margin-top: 14px; }
.accept input { width: 18px; height: 18px; accent-color: #0067c0; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fields.one { grid-template-columns: 1fr; }
.field { display: grid; gap: 6px; color: #333; font-size: 14px; min-width: 0; }
.field input { width: 100%; height: 38px; padding: 7px 9px; background: #fff; color: #1b1b1b; border: 1px solid #b8b8b8; border-radius: 3px; min-width: 0; }
.field input:focus { outline: 2px solid #0067c0; outline-offset: 1px; border-color: #0067c0; }
.summary { display: grid; gap: 10px; }
.summary div { padding: 12px; background: #fff; border: 1px solid #ddd; border-radius: 6px; }
.summary span { display: block; color: #666; font-size: 13px; }
.summary b { display: block; word-break: break-all; }
.error { margin: 0 0 18px; padding: 12px; border-radius: 6px; background: #fde7e9; border: 1px solid #f3b5bc; color: #442726; }
.error.warn { background: #fff4ce; border-color: #f4d47c; }
.error strong { display: block; margin-bottom: 4px; }
.error p { margin: 0; line-height: 1.45; }
.linkbtn { margin-top: 8px; padding: 0; border: 0; background: transparent; color: #005fb8; font-weight: 600; cursor: pointer; }
.progress { display: flex; gap: 8px; margin: 34px 0 20px; }
.progress i { width: 7px; height: 7px; border-radius: 50%; background: #c9c9c9; }
.progress i.on { background: #0067c0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn { height: 34px; min-width: 92px; padding: 0 18px; border-radius: 3px; border: 1px solid #b8b8b8; background: #fff; color: #1b1b1b; font-weight: 600; cursor: pointer; }
.btn.primary { background: #0067c0; border-color: #005a9e; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.install-done { width: min(620px, 100%); margin: auto; background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 30px; box-shadow: 0 18px 50px rgba(20, 32, 48, .12); }

@media (max-width: 760px) {
  .topbar, .section-head, .detail-head { align-items: stretch; flex-direction: column; }
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 20px; }
  .filters { flex-direction: column; min-width: 0; }
  .advanced-filters, .admin-grid.two, .admin-grid.three, .provider-hero { grid-template-columns: 1fr; }
  .feature-pairs { grid-template-columns: 1fr; }
  .compare-tray { align-items: stretch; flex-direction: column; }
  .compare-tray div { width: 100%; }
  .compare-tray .button, .compare-tray button { flex: 1; }
  .cookie-banner { left: 14px; right: 14px; bottom: 14px; width: auto; align-items: stretch; flex-direction: column; }
  .cookie-banner div { width: 100%; }
  .cookie-banner button { flex: 1; }
  .quick-stats { grid-template-columns: 1fr; }
  .package-table-wrap { display: none; }
  .mobile-package-list { display: grid !important; gap: 12px; }
  .package-title { grid-template-columns: 34px 1fr; text-align: left; }
  .resource-list { justify-content: flex-end; }
  .installer-shell { padding: 20px; }
  .setup { min-height: auto; }
  .fields { grid-template-columns: 1fr; }
  .step h1 { font-size: 28px; }
  .actions { justify-content: stretch; }
  .btn { flex: 1; }
}
