:root {
  --ink: #134e4a;
  --muted: #3f6864;
  --paper: #f0fdfa;
  --card: #ffffff;
  --line: #99f6e4;
  --line-strong: #5eead4;
  --primary: #0f766e;
  --accent: #14b8a6;
  --cta: #0d5c56;
  --wash: #ecfdf8;
  --danger: #b45309;
  --ok: #047857;
  --info: #0369a1;
  --warn: #b45309;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 118, 110, 0.08);
  --mono: Consolas, "Courier New", monospace;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); }
body { min-height: 100vh; display: flex; flex-direction: column; }
button, .cta, a, .nav a { cursor: pointer; transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease; }
@media (prefers-reduced-motion: reduce) {
  button, .cta, a, .nav a { transition: none; }
}

/* —— Shell —— */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border-bottom: 3px solid var(--cta);
}
.topbar a, .topbar .mark { color: #fff; text-decoration: none; font-weight: 700; }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark img { height: 28px; width: auto; }
.brand-meta { display: flex; flex-direction: column; gap: 0; line-height: 1.15; }
.brand-meta small {
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}
.nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nav a {
  color: #fff;
  text-decoration: none;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
}
.nav a:hover, .nav a:focus-visible { background: rgba(255,255,255,0.12); outline: none; }
.nav button, .topbar button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 14px;
}
.nav button:hover { background: rgba(255,255,255,0.12); }

.stage {
  flex: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.skin-portal .stage,
.skin-admin .stage { width: min(1280px, 100%); }

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.foot a { color: var(--muted); }

/* —— Page chrome —— */
.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head .lede { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 56ch; }
.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--wash);
}
.panel-head h2 { margin: 0; font-size: 0.95rem; letter-spacing: 0.02em; }
.panel-body { padding: 0; }
.panel-body.padded { padding: 16px; }

/* —— KPI strip —— */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.kpi .value {
  margin-top: 6px;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.kpi .hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* —— Badges —— */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-ok { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.badge-info { background: #eff6ff; color: var(--info); border-color: #bfdbfe; }
.badge-warn { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.badge-neutral { background: var(--wash); color: var(--primary); border-color: var(--line); }
.badge-electric { background: #f0fdfa; color: var(--primary); border-color: var(--line-strong); }
.badge-water { background: #eff6ff; color: var(--info); border-color: #bfdbfe; }

.mono { font-family: var(--mono); font-size: 12px; }

/* —— Tables —— */
.data-table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--wash); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .empty { color: var(--muted); padding: 20px 14px; }

@media (max-width: 720px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }
  .data-table td {
    border: 0;
    padding: 4px 14px;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
  }
  .data-table .num { text-align: left; }
}

/* —— Marketing site —— */
.hero, .proof, .offer, .legal, .auth-card, .capabilities {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.utilities {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.utility-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.utility-card.electric { border-top: 3px solid var(--primary); }
.utility-card.water { border-top: 3px solid var(--info); }
.utility-card ul { margin: 12px 0 0; padding-left: 1.1rem; }
.hero { display: grid; gap: 20px; }
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 8px;
}
h1, h2 { margin-top: 0; line-height: 1.2; }
.cta, .auth-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--cta);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.cta:hover, .auth-card button:hover { background: var(--primary); }
.cta.ghost {
  background: transparent;
  color: var(--cta);
  border: 1px solid var(--cta);
  margin-left: 8px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.proof { display: grid; gap: 20px; }
.proof article img, .hero img { border-radius: 6px; }
.capabilities {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 16px;
}
.cap { border-left: 3px solid var(--accent); padding-left: 12px; }
.cap strong { display: block; font-size: 13px; margin-bottom: 4px; }
.cap span { font-size: 13px; color: var(--muted); }

.auth-card { max-width: 420px; margin: 48px auto; }
.auth-card .product-chip {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--wash);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
}
label { display: block; margin: 12px 0; font-size: 13px; font-weight: 600; }
input {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.error { color: var(--danger); font-weight: 600; }

.invoice-lines {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}
.invoice-lines li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

@media (min-width: 840px) {
  .hero { grid-template-columns: 1.05fr 0.95fr; align-items: center; }
  .proof { grid-template-columns: 1fr 1fr; }
  .utilities { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .topbar, .foot, .stage { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 1.45rem; }
  .cta.ghost { margin-left: 0; }
}

/* —— Ops / MDM chrome —— */
.ops-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ops-nav a {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.ops-nav a:hover, .ops-nav a.is-active {
  background: var(--wash);
  color: var(--primary);
}
.badge-suspect { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.badge-estimated { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.badge-verified { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.badge-tamper { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
  gap: 2px;
  padding: 12px 16px 16px;
}
.heatmap .cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: #ccfbf1;
  min-height: 10px;
}
.heatmap .cell.q-verified { background: #5eead4; }
.heatmap .cell.q-estimated { background: #fbbf24; }
.heatmap .cell.q-suspect,
.heatmap .cell.q-tamper { background: #f87171; }
.heatmap .cell.q-empty { background: #e2e8f0; }
.meta-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 16px;
}
.meta-grid dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0; }
.meta-grid dd { margin: 2px 0 0; font-size: 14px; }
.burn-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 8px;
}
.burn-bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
}
.notice-trail { font-size: 13px; color: var(--muted); }
.notice-trail li { margin: 4px 0; }
.field-expand {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 10px 16px 14px;
  padding: 10px 12px;
  background: #fff;
}
.field-expand > summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
}
.field-expand .muted { color: var(--muted); font-weight: 500; font-size: 13px; }
.btn-secondary {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: not-allowed;
  opacity: 0.7;
}
.panel-body.padded { padding: 16px; }
@media (max-width: 640px) {
  .ops-nav a { flex: 1 1 calc(50% - 6px); justify-content: center; }
  .heatmap { grid-template-columns: repeat(auto-fill, minmax(8px, 1fr)); }
}

/* —— Setup console + day-2 forms —— */
.setup-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 20px;
}
.setup-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
}
.setup-step.is-active {
  background: var(--wash);
  color: var(--primary);
  border-color: #99f6e4;
}
.setup-step.is-done {
  color: var(--ok);
  border-color: #a7f3d0;
}
.setup-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.setup-checklist li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-height: 44px;
}
.setup-checklist .ok { color: var(--ok); font-weight: 700; }
.setup-checklist .bad { color: #be123c; font-weight: 700; }
.stack-form {
  display: grid;
  gap: 12px;
}
.stack-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.stack-form input,
.stack-form select,
.stack-form textarea {
  min-height: 44px;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-family: inherit;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.stack-form button,
.btn-sm {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-sm { font-size: 12px; min-height: 36px; }
.btn-sm.btn-warn { background: var(--warn); }
.grid-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}
.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.check-row input { width: auto; min-height: 20px; }
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 16px;
  margin-top: 20px;
}
.action-row form {
  margin: 0;
  display: flex;
}
.action-row button,
.action-row .cta {
  min-height: 44px;
  padding: 10px 16px;
  box-sizing: border-box;
}
.golive-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 280px;
  gap: 16px;
}
.golive-actions form {
  width: 100%;
  margin: 0 0 16px;
}
.golive-actions form:last-child {
  margin-bottom: 0;
}
.golive-actions button,
.golive-actions .cta {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin: 0 0 14px;
  font-size: 14px;
}
.flash.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash.err { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.flash.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.portal-estimate-banner { margin-top: 0; }
.pay-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.pay-inline select {
  min-height: 44px;
  font-size: 16px;
  max-width: 100%;
}
.pay-inline .cta {
  min-height: 44px;
}
.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;
}
.row-critical { background: #fff7f7; }
.badge-hold { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.invoice-print .meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.invoice-print .meta-grid dt { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 0; }
.invoice-print .meta-grid dd { margin: 4px 0 0; font-weight: 600; }
@media print {
  .topbar, .ops-nav, .no-print, .page-head .action-row { display: none !important; }
  .stage { max-width: none; padding: 0; }
  .panel { border: 0; box-shadow: none; }
}
@media (max-width: 640px) {
  .grid-form { grid-template-columns: 1fr; }
  .action-row { max-width: none; }
  .action-row form { flex: 1 1 100%; }
  .action-row button,
  .action-row .cta { width: 100%; }
  .golive-actions { max-width: none; }
  .pay-inline { flex-direction: column; align-items: stretch; }
  .pay-inline select,
  .pay-inline .cta { width: 100%; }
}

/* —— Portal PWA install sheet (website never installs) —— */
.pwa-install {
  z-index: 40;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.18);
}
.pwa-install-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  transform: translateY(110%);
  transition: transform 280ms ease;
}
.pwa-install-sheet.is-open { transform: translateY(0); }
.pwa-install[hidden] { display: none; }
.pwa-install-handle {
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--line-strong);
}
.pwa-install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.pwa-install-actions .cta,
.pwa-install-actions .btn-ghost {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 16px;
}
.pwa-install-actions .btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}
.pwa-install-ios { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
#pwa-notice-badge:empty,
#pwa-notice-badge[hidden] { display: none; }
#pwa-notice-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.portal-notices-list { list-style: none; margin: 0; padding: 0; }
.portal-notices-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.portal-notices-list li:last-child { border-bottom: 0; }
.portal-notices-list .unread { font-weight: 600; }
.downlink-queue table { width: 100%; }
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}
.status-pill.ok { background: #ecfdf5; color: var(--ok); }
.status-pill.warn { background: #fff7ed; color: var(--warn); }
.status-pill.err { background: #fef2f2; color: #b91c1c; }
@media (min-width: 720px) {
  .pwa-install-sheet {
    left: 50%;
    right: auto;
    width: min(420px, calc(100% - 32px));
    bottom: 24px;
    border-radius: 12px;
    transform: translate(-50%, 110%);
  }
  .pwa-install-sheet.is-open { transform: translate(-50%, 0); }
  .pwa-install-sheet .pwa-install-handle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pwa-install-sheet { transition: none; }
}
