:root {
  color-scheme: light dark;
  --bg: #f6f6f5;
  --panel: #fff;
  --panel-strong: #fff;
  --text: #18181b;
  --muted: #52525b;
  --border: rgba(39, 39, 42, .12);
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --ok: #15803d;
  --warning: #b45309;
  --critical: #dc2626;
  --shadow: 0 1px 3px rgba(24, 24, 27, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --panel: #18181b;
    --panel-strong: #18181b;
    --text: #f4f4f5;
    --muted: #d4d4d8;
    --border: rgba(244, 244, 245, .12);
    --shadow: 0 1px 3px rgba(0, 0, 0, .28);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0;
  font-family: Inter, Geist, Satoshi, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.42;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid rgba(220, 38, 38, .3); outline-offset: 3px; }
.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px clamp(16px, 4vw, 36px);
  background: #0b0b0c;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 12px; border: 1px solid rgba(220, 38, 38, .45); }
.brand span { display: grid; line-height: 1.05; }
.brand strong { font-size: 16px; }
.brand small, .eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.topbar nav { display: flex; gap: 6px; justify-content: center; min-width: 0; }
.topbar nav a, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px;
  padding: 8px 12px;
  color: #f4f4f5;
  background: rgba(255, 255, 255, .06);
  font-weight: 800;
  white-space: nowrap;
}
.portal-menu-toggle {
  display: none;
  place-items: center;
  width: 42px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: #fff;
}
.portal-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.portal-menu-toggle span + span { margin-top: 4px; }
.topbar.menu-open .portal-menu-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar.menu-open .portal-menu-toggle span:nth-child(2) { opacity: 0; }
.topbar.menu-open .portal-menu-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
button, .button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  min-height: 44px;
  padding: 9px 13px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .button:hover { background: var(--accent-dark); }
main { width: min(1180px, 100%); margin: 0 auto; padding: clamp(16px, 3.4vw, 34px); }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: clamp(22px, 4vw, 38px);
  border-radius: 20px;
  color: #fff;
  background: #18181b;
  box-shadow: var(--shadow);
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(32px, 4.2vw, 54px); line-height: 1; letter-spacing: 0; max-width: 700px; }
h2 { margin-bottom: 0; font-size: clamp(21px, 2.2vw, 28px); line-height: 1.08; }
.hero p { color: #d4d4d8; max-width: 620px; margin-bottom: 0; }
.hero-status {
  min-width: 180px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, .08);
}
.hero-status span, article span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.hero-status strong { font-size: 38px; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stats article, .panel, .report-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.stats article { padding: 16px; }
.metric-grid article { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel-strong); }
.stats strong { font-size: 26px; }
.metric-grid strong { display: block; margin-top: 4px; font-size: 22px; }
.panel { padding: clamp(15px, 2.4vw, 21px); margin-top: 14px; }
main > section:not(.hero):not(.page-head) {
  content-visibility: auto;
  contain-intrinsic-size: 1px 520px;
}
.hero, .page-head {
  content-visibility: visible;
  contain-intrinsic-size: auto;
}
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; background: var(--panel-strong); }
th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td strong, td small { display: block; overflow-wrap: anywhere; }
td small { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.ok, .OK { color: var(--ok); }
.warning, .WARNING { color: var(--warning); }
.critical, .CRITICAL { color: var(--critical); }
.alert-list { display: grid; gap: 10px; }
.alert-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel-strong); }
.alert-row p { margin-bottom: 4px; }
.alert-row small, .empty { color: var(--muted); }
.alert-tree { margin-top: 12px; }
.alert-tree summary {
  width: max-content;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
}
.alert-branches {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.alert-branch {
  position: relative;
  padding: 12px 12px 12px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-strong);
}
.alert-branch::before {
  content: "";
  position: absolute;
  inset: 44px auto 14px 20px;
  width: 1px;
  background: var(--border);
}
.alert-branch h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.2;
}
.alert-branch ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.alert-branch li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding-left: 16px;
}
.alert-branch p { margin-bottom: 2px; overflow-wrap: anywhere; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.report-card { padding: 16px; display: grid; gap: 8px; }
.report-card strong { font-size: 21px; }
.pro-list { display: grid; gap: 12px; }
.pro-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-strong);
}
.pro-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}
.pro-card-head strong, .pro-card-head small { display: block; overflow-wrap: anywhere; }
.pro-card-head small, .pro-modules small { color: var(--muted); }
.pro-modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.pro-modules div {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.finding-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}
.finding-list li { margin: 4px 0; }
.ghost-light { background: transparent; border: 1px solid var(--border); color: var(--text); }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 16px; padding: clamp(20px, 3.2vw, 30px); border-radius: 20px; color: #fff; background: #18181b; box-shadow: var(--shadow); }
.page-head h1 { margin-bottom: 8px; }
.page-head p:not(.eyebrow) { color: #d4d4d8; margin-bottom: 0; }
.page-head .button { white-space: nowrap; }
.spacious { gap: 12px; }
.subscription-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.featured-plan { border-color: rgba(220, 38, 38, .38); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.login-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .75fr); gap: 24px; align-items: center; width: min(1060px, 100%); padding: 0; }
.login-copy { color: #fff; border-radius: 20px; padding: clamp(24px, 4.2vw, 42px); background: #18181b; box-shadow: var(--shadow); }
.login-copy img { border-radius: 18px; margin-bottom: 20px; border: 1px solid rgba(220, 38, 38, .45); }
.login-title {
  margin-bottom: 10px;
  font-size: clamp(32px, 4.2vw, 54px);
  font-weight: 950;
  line-height: 1;
}
.login-copy p:last-child { color: #d4d4d8; max-width: 560px; }
.login-card { display: grid; gap: 12px; padding: 24px; border: 1px solid var(--border); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 4px; font-size: 24px; line-height: 1.12; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; background: var(--panel-strong); color: var(--text); font: inherit; }
input[readonly] { opacity: .72; cursor: not-allowed; }
button:disabled { opacity: .52; cursor: not-allowed; background: #71717a; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
.alert { padding: 10px 12px; border-radius: 10px; color: #991b1b; background: rgba(220, 38, 38, .1); border: 1px solid rgba(220, 38, 38, .25); }
.success { padding: 10px 12px; border-radius: 10px; color: #166534; background: rgba(22, 163, 74, .1); border: 1px solid rgba(22, 163, 74, .25); }
.form-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}
.form-link:hover { color: var(--accent); }
.login-page .eyebrow { color: #e4e4e7; }
.muted-text { color: var(--muted); }
.account-panel { max-width: 720px; margin-inline: auto; }
.account-panel h1 { color: var(--text); font-size: clamp(30px, 3.8vw, 46px); }
.account-form { display: grid; gap: 12px; max-width: 520px; margin-top: 18px; }
.site-grid { display: grid; gap: 16px; }
.site-card {
  display: grid;
  gap: 14px;
  padding: clamp(15px, 2.4vw, 20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.site-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}
.site-card h2 { margin: 8px 0 4px; font-size: 22px; line-height: 1.12; overflow-wrap: anywhere; }
.site-card p { overflow-wrap: anywhere; }
.site-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.site-metrics div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
}
.site-metrics span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.site-metrics strong { display: block; margin-top: 3px; font-size: 18px; overflow-wrap: anywhere; }
.audit-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
}
.audit-bar strong, .audit-bar small { display: block; }
.audit-bar small { color: var(--muted); overflow-wrap: anywhere; }
.audit-bar form { min-width: 142px; }
.audit-bar button { width: 100%; }
.site-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.wide { grid-column: 1 / -1; }
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--text);
}
.switch-row input {
  appearance: none;
  width: 44px;
  min-width: 44px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  background: #a1a1aa;
  border: 0;
  position: relative;
}
.switch-row input::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 999px;
  background: #fff;
  transition: none;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(20px); }
.switch-row span { overflow-wrap: anywhere; }
.profile-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.profile-layout .panel { margin-top: 0; }
.compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.ig-reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity 420ms ease, transform 420ms ease;
  will-change: opacity, transform;
}
.ig-reveal.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}
.ig-reveal.ig-fast {
  transform: translate3d(0, 8px, 0);
  transition-duration: 280ms;
}
@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 12px;
  }
  .brand strong { font-size: 16px; }
  .brand small { font-size: 10px; }
  .topbar nav {
    grid-column: 1 / -1;
    justify-content: start;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
  }
  .topbar nav a {
    min-height: 42px;
    padding-inline: 12px;
  }
  .topbar form {
    grid-column: 2;
    grid-row: 1;
  }
  .ghost {
    min-height: 42px;
    padding-inline: 11px;
  }
  .hero { grid-template-columns: 1fr; border-radius: 18px; }
  .page-head { display: grid; border-radius: 18px; }
  h1 { font-size: clamp(34px, 12vw, 54px); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subscription-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-metrics, .site-edit-form, .profile-layout { grid-template-columns: 1fr; }
  .audit-bar { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-copy { padding: 28px; }
}
@media (min-width: 1100px) {
  .hero p, .page-head p:not(.eyebrow) { font-size: 15px; }
  th, td { padding: 10px 12px; }
  input, select { min-height: 42px; padding: 9px 11px; }
}
@media (max-width: 540px) {
  main { padding: 12px; }
  .stats { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .site-card-head { display: grid; }
  .site-card h2 { font-size: 22px; }
  .table-wrap { overflow: visible; border: 0; }
  table, thead, tbody, tr, td { display: block; width: 100%; min-width: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tr { border: 1px solid var(--border); border-radius: 14px; background: var(--panel-strong); overflow: hidden; }
  td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
}
@media (prefers-reduced-motion: reduce) {
  .ig-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Layout density pass for the client portal. The goal is a cleaner operational
   dashboard on desktop while keeping mobile readable and fast. */
body {
  font-size: 14px;
  line-height: 1.4;
}

.topbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 10px clamp(18px, 3vw, 34px);
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.brand strong {
  font-size: 15px;
}

.brand small,
.eyebrow {
  font-size: 11px;
}

.topbar nav {
  gap: 5px;
  justify-content: center;
}

.topbar nav a,
.ghost {
  min-height: 44px;
  padding: 7px 10px;
  font-size: 13px;
}

button,
.button {
  min-height: 44px;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 13px;
}

main {
  width: min(1240px, 100%);
  padding: clamp(14px, 2.4vw, 28px);
}

.hero,
.page-head {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: clamp(18px, 2.8vw, 28px);
  border-radius: 16px;
}

h1 {
  max-width: 680px;
  margin-bottom: 7px;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.03;
}

h2 {
  font-size: clamp(19px, 1.7vw, 24px);
  line-height: 1.08;
}

.hero p,
.page-head p:not(.eyebrow) {
  max-width: 640px;
  font-size: 14px;
}

.hero-status {
  min-width: 150px;
  padding: 13px;
  border-radius: 12px;
}

.hero-status strong {
  font-size: 31px;
}

.stats,
.metric-grid {
  gap: 10px;
}

.stats {
  margin: 12px 0;
}

.stats article,
.metric-grid article,
.report-card,
.pro-card,
.site-card {
  border-radius: 12px;
}

.stats article {
  padding: 13px;
}

.stats strong {
  font-size: 23px;
}

.metric-grid article {
  padding: 12px;
}

.metric-grid strong {
  font-size: 20px;
}

.panel {
  margin-top: 12px;
  padding: clamp(13px, 1.9vw, 18px);
  border-radius: 14px;
}

.section-head {
  margin-bottom: 10px;
  gap: 14px;
}

.table-wrap {
  border-radius: 12px;
}

th,
td {
  padding: 9px 10px;
}

th {
  font-size: 11px;
}

.badge {
  padding: 3px 8px;
  font-size: 11px;
}

.alert-row {
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
}

.report-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.report-card {
  padding: 14px;
}

.report-card strong {
  font-size: 19px;
}

.pro-list,
.site-grid {
  gap: 12px;
}

.pro-card,
.site-card {
  gap: 12px;
  padding: clamp(13px, 1.8vw, 17px);
}

.pro-modules {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.pro-modules div {
  min-height: 66px;
  padding: 9px;
  border-radius: 10px;
}

.page-head {
  margin-bottom: 12px;
}

.page-head .button {
  white-space: nowrap;
}

.subscription-grid {
  gap: 10px;
}

.login-page {
  padding: 14px;
}

.login-shell {
  width: min(1000px, 100%);
  grid-template-columns: minmax(0, .95fr) minmax(320px, .68fr);
  gap: 18px;
}

.login-copy,
.login-card {
  border-radius: 16px;
}

.login-copy {
  padding: clamp(22px, 3.4vw, 34px);
}

.login-copy img {
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  border-radius: 14px;
}

.login-card {
  gap: 10px;
  padding: 20px;
}

input,
select {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 10px;
}

.alert,
.success {
  padding: 9px 10px;
  border-radius: 9px;
}

.account-panel {
  max-width: 680px;
}

.account-panel h1 {
  font-size: clamp(26px, 3vw, 38px);
}

.account-form {
  gap: 10px;
  margin-top: 14px;
}

.site-card-head {
  gap: 12px;
}

.site-card h2 {
  margin: 7px 0 3px;
  font-size: 19px;
}

.site-card p {
  margin-bottom: 0;
}

.site-metrics {
  gap: 8px;
}

.site-metrics div {
  padding: 10px;
  border-radius: 10px;
}

.site-metrics span {
  font-size: 11px;
}

.site-metrics strong {
  font-size: 16px;
}

.audit-bar {
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
}

.audit-bar form {
  min-width: 126px;
}

.site-edit-form {
  gap: 10px;
}

.switch-row {
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 10px;
}

.profile-layout {
  gap: 12px;
}

.compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

@media (min-width: 980px) {
  .site-grid {
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
    align-items: start;
  }

  .site-card:only-child {
    max-width: none;
  }

  .site-edit-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .site-edit-form .wide,
  .site-edit-form .muted-text.wide {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1180px) {
  .stats,
  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .panel + .panel {
    margin-top: 12px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 12px;
  }

  .topbar {
    padding: 9px 10px;
  }

  .hero,
  .page-head {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }

  h1 {
    font-size: clamp(30px, 10vw, 44px);
  }

  .stats,
  .metric-grid {
    gap: 8px;
  }
}

@media (max-width: 540px) {
  .panel,
  .site-card,
  .login-card,
  .login-copy {
    border-radius: 14px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats article {
    padding: 11px;
  }

  .stats strong {
    font-size: 20px;
  }

  td {
    grid-template-columns: 96px minmax(0, 1fr);
    padding: 9px;
  }
}

/* Login mobile pass: keep this after the density rules so the auth page cannot
   inherit the desktop two-column shell on small screens. */
body.login-page {
  min-height: 100dvh;
  overflow-x: hidden;
}

.login-page .login-shell {
  max-width: 100%;
}

@media (max-width: 760px) {
  body.login-page {
    display: block;
    min-height: 100dvh;
    padding: max(clamp(14px, 5dvh, 34px), env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .login-page .login-shell {
    width: 100%;
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 12px;
  }

  .login-page .login-copy,
  .login-page .login-card {
    width: 100%;
    min-width: 0;
  }

  .login-page .login-copy {
    padding: 18px;
  }

  .login-page .login-copy img {
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    border-radius: 12px;
  }

  .login-page h1 {
    max-width: none;
    margin-bottom: 8px;
    font-size: clamp(26px, 8vw, 34px);
    line-height: 1.04;
  }

  .login-page .login-title {
    max-width: none;
    margin-bottom: 8px;
    font-size: clamp(26px, 8vw, 34px);
    line-height: 1.04;
  }

  .login-page .login-copy p:last-child {
    max-width: none;
    margin-bottom: 0;
    font-size: 13px;
  }

  .login-page .login-card {
    gap: 10px;
    padding: 16px;
  }

  .login-page .login-card h1 {
    font-size: 20px;
  }

  .login-page input,
  .login-page button {
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  body.login-page {
    padding: 10px;
  }

  .login-page .login-shell {
    min-height: auto;
  }

  .login-page .login-copy {
    padding: 15px;
  }

  .login-page .login-card {
    padding: 14px;
  }

  .login-page .login-title {
    font-size: 25px;
  }
}

/* Portal UX pass: clearer navigation, better mobile wrapping, and denser
   operational screens without reintroducing expensive scroll effects. */
.topbar nav a[aria-current="page"] {
  background: #fff;
  color: #0b0b0c;
  border-color: #fff;
}

.text-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

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

.actions form {
  margin: 0;
}

.page-head,
.hero {
  overflow: hidden;
}

.topbar {
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(220, 38, 38, .62), transparent);
  opacity: .72;
}

.hero h1,
.page-head h1 {
  max-width: 760px;
}

.section-head h2 {
  overflow-wrap: anywhere;
}

.stats article,
.metric-grid article,
.report-card,
.site-card,
.alert-row {
  min-width: 0;
}

.stats span,
.metric-grid span,
.report-card span,
.site-metrics span {
  overflow-wrap: anywhere;
}

.report-card small,
.muted-text,
.empty {
  line-height: 1.45;
}

.site-card-head > div {
  min-width: 0;
}

.site-card-head > .badge {
  flex-shrink: 0;
}

.site-edit-form label {
  min-width: 0;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 9px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
  }

  .brand {
    gap: 8px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small {
    display: none;
  }

  .topbar form {
    grid-column: 3;
    grid-row: 1;
  }

  .topbar.has-mobile-menu .portal-menu-toggle {
    display: grid;
    grid-column: 2;
    grid-row: 1;
  }

  .topbar.has-mobile-menu nav {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    justify-content: stretch;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    order: 3;
    pointer-events: none;
    transform: translateY(-4px);
    transition: max-height 180ms ease, opacity 160ms ease, transform 160ms ease, padding 160ms ease;
  }

  .topbar.has-mobile-menu.menu-open nav {
    max-height: 260px;
    opacity: 1;
    padding-top: 6px;
    pointer-events: auto;
    transform: translateY(0);
  }

  .topbar nav a,
  .ghost {
    min-width: 0;
    min-height: 36px;
    justify-content: center;
    padding: 7px 8px;
    border-radius: 10px;
    font-size: 12px;
    text-align: center;
    white-space: normal;
    line-height: 1.1;
  }

  .ghost {
    white-space: nowrap;
  }

  main {
    padding: 12px;
  }

  .hero,
  .page-head {
    padding: 15px;
    border-radius: 14px;
  }

  h1 {
    font-size: clamp(26px, 8vw, 36px);
    line-height: 1.05;
  }

  h2 {
    font-size: 20px;
  }

  .hero p,
  .page-head p:not(.eyebrow) {
    font-size: 13px;
  }

  .hero-status {
    min-width: 0;
    width: 100%;
  }

  .section-head {
    align-items: start;
  }

  .button-row,
  .actions {
    width: 100%;
  }

  .button-row .button,
  .actions form,
  .actions button {
    width: 100%;
  }

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

/* 2026-06 polish: the portal should feel like a compact product UI on desktop
   and a clear control panel on mobile. Keep motion cheap: opacity/transform only. */
.stats article,
.metric-grid article,
.panel,
.site-card,
.report-card,
.login-card,
.login-copy {
  transition: border-color 180ms ease, transform 180ms ease, background-color 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .stats article:hover,
  .metric-grid article:hover,
  .report-card:hover,
  .site-card:hover {
    border-color: rgba(220, 38, 38, .22);
    transform: translateY(-1px);
  }
}

@media (min-width: 980px) {
  .topbar nav {
    max-width: 760px;
    margin-inline: auto;
  }

  .hero {
    min-height: 172px;
  }

  .panel.dashboard-focus {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, .38fr);
  }
}

@media (max-width: 900px) {
  .topbar {
    background: #111113;
  }

  .topbar nav a[aria-current="page"] {
    box-shadow: inset 0 -2px 0 rgba(220, 38, 38, .82);
  }
}

@media (max-width: 520px) {
  body {
    font-size: 13px;
  }

  .topbar {
    gap: 8px;
  }

  .topbar.has-mobile-menu nav,
  .topbar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .topbar nav a,
  .ghost {
    min-height: 40px;
    font-size: 12px;
    padding: 8px 7px;
  }

  main {
    padding: 10px;
  }

  .hero-status {
    width: 100%;
  }

  .section-head {
    display: grid;
    align-items: start;
  }

  .button-row,
  .actions {
    width: 100%;
  }

  .button-row .button,
  .actions .button,
  .actions button {
    flex: 1 1 100%;
  }

  .alert-row {
    grid-template-columns: 1fr;
  }

  .alert-row .badge {
    width: max-content;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .topbar {
    margin: 0;
  }

  .topbar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats article,
  .metric-grid article {
    padding: 10px;
  }

  .stats strong,
  .metric-grid strong {
    font-size: 18px;
  }

  .panel {
    padding: 13px;
    border-radius: 13px;
  }

  .section-head {
    display: grid;
    gap: 6px;
    margin-bottom: 9px;
  }

  .text-link {
    width: max-content;
  }

  .alert-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 11px;
  }

  .alert-row .badge {
    width: max-content;
  }

  .alert-tree summary {
    width: 100%;
    text-align: center;
  }

  .alert-branch {
    padding: 11px;
  }

  .alert-branch::before {
    display: none;
  }

  .alert-branch li {
    grid-template-columns: 1fr;
    padding-left: 0;
  }

  .site-card {
    padding: 13px;
    border-radius: 13px;
  }

  .site-card-head {
    gap: 9px;
  }

  .site-card-head > .badge {
    width: max-content;
  }

  .site-card h2 {
    font-size: 18px;
  }

  .site-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audit-bar {
    padding: 10px;
  }

  .audit-bar form {
    min-width: 0;
  }

  .site-edit-form {
    gap: 9px;
  }

  input,
  select,
  button,
  .button {
    min-height: 42px;
  }
}

@media (max-width: 390px) {
  .topbar nav {
    grid-template-columns: 1fr 1fr;
  }

  .topbar nav a,
  .ghost {
    font-size: 11px;
    padding-inline: 6px;
  }

  .stats,
  .site-metrics {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 82px minmax(0, 1fr);
  }
}

/* 2026-06 portal polish: consistent compact navigation and clearer mobile
   control surfaces, still limited to cheap opacity/transform transitions. */
.topbar nav a {
  position: relative;
}

.topbar nav a[aria-current="page"] {
  font-weight: 950;
}

.portal-menu-toggle span {
  transition: transform 160ms ease, opacity 140ms ease;
}

.hero-status,
.stats article,
.metric-grid article {
  overflow: hidden;
}

.hero-status strong,
.stats strong,
.metric-grid strong {
  font-variant-numeric: tabular-nums;
}

.panel,
.site-card,
.report-card,
.alert-row {
  scroll-margin-top: 14px;
}

.alert-tree[open] summary {
  border-color: rgba(220, 38, 38, .32);
}

@media (min-width: 1120px) {
  main {
    width: min(1160px, 100%);
  }

  .hero {
    min-height: 158px;
  }

  .panel {
    margin-top: 10px;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .report-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar.has-mobile-menu nav {
    border-top: 1px solid rgba(255, 255, 255, .08);
  }

  .topbar.has-mobile-menu.menu-open nav {
    padding-top: 9px;
  }

  .topbar nav a[aria-current="page"] {
    background: rgba(255, 255, 255, .96);
    color: #111113;
    box-shadow: none;
  }

  .portal-menu-toggle {
    border-radius: 12px;
  }
}

@media (max-width: 620px) {
  .hero,
  .page-head {
    padding: 14px;
  }

  .hero-status strong {
    font-size: 26px;
  }

  .stats {
    margin: 10px 0;
  }

  .report-card {
    padding: 13px;
  }

  .button-row {
    gap: 7px;
  }

  .login-page .login-copy {
    display: none;
  }
}

@media (max-width: 420px) {
  .topbar.has-mobile-menu nav,
  .topbar nav {
    grid-template-columns: 1fr;
  }

  .topbar nav a,
  .ghost {
    min-height: 38px;
  }

  .brand strong {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Final mobile polish: the portal nav is a drawer-style control, not a
   horizontal strip. These rules intentionally sit last to override older
   density passes above. */
@media (max-width: 900px) {
  .topbar {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto auto;
    overflow: visible;
  }

  .topbar.has-mobile-menu nav {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    background: rgba(255, 255, 255, .055);
  }

  .topbar.has-mobile-menu.menu-open nav {
    padding: 8px;
  }

  .topbar.has-mobile-menu nav a {
    min-height: 42px;
    border-radius: 9px;
    line-height: 1.15;
  }

  .portal-menu-toggle {
    min-width: 42px;
    min-height: 40px;
  }
}

@media (max-width: 620px) {
  .topbar.has-mobile-menu nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar form .ghost {
    min-width: 54px;
  }
}

@media (max-width: 390px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) 40px 52px;
    gap: 6px;
  }

  .brand strong {
    font-size: 13px;
  }

  .topbar nav a,
  .ghost {
    font-size: 11px;
  }
}

/* 2026-06-01 final portal polish: stable mobile chrome and clearer dense cards. */
.topbar nav a,
.button,
button,
.ghost { -webkit-tap-highlight-color: transparent; }

.stats article,
.metric-grid article,
.panel,
.report-card,
.site-card,
.login-card { overflow-wrap: anywhere; }

.alert-row p,
.report-card small,
.site-card p,
td { overflow-wrap: anywhere; }

@media (min-width: 1120px) {
  .topbar { padding-block: 9px; }
  main { width: min(1120px, 100%); }
  .hero, .page-head { min-height: 142px; }
  .stats article { min-height: 88px; }
  .panel { padding: 16px; }
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: minmax(0, 1fr) 42px minmax(52px, auto); }
  .topbar.has-mobile-menu nav { box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
  .topbar.has-mobile-menu.menu-open nav { max-height: 360px; }
  .portal-menu-toggle { width: 42px; height: 40px; }
  .topbar form .ghost { min-width: 52px; }
  .hero, .page-head { margin-bottom: 0; }
}

@media (max-width: 520px) {
  .brand { min-width: 0; }
  .brand strong { max-width: calc(100vw - 150px); }
  .topbar.has-mobile-menu nav { grid-template-columns: 1fr 1fr; }
  .hero, .page-head, .panel, .site-card, .report-card { border-radius: 12px; }
  .hero-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; }
  .hero-status strong { font-size: 24px; }
  .stats article, .metric-grid article { min-width: 0; }
  .stats span, .metric-grid span { line-height: 1.2; }
  .button-row .button { min-width: 0; }
  .login-page .login-card { box-shadow: none; }
}

@media (max-width: 360px) {
  .topbar { grid-template-columns: minmax(0, 1fr) 40px 48px; }
  .topbar nav a, .ghost { font-size: 10.5px; }
  .brand img { width: 32px; height: 32px; }
  .brand strong { max-width: calc(100vw - 138px); }
}
