:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --text: #18242c;
  --muted: #667984;
  --border: #d8dee2;
  --border-strong: #c3ccd2;
  --teal: #006d6b;
  --teal-dark: #005253;
  --teal-ink: #064f51;
  --amber: #f59e0b;
  --red: #dc2626;
  --green: #16a34a;
  --ring: rgba(0, 109, 107, 0.22);
  --shadow: 0 12px 28px rgba(22, 35, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  font-family: "Fira Sans", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

button:hover {
  border-color: var(--teal);
  background: #f2fbfa;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: #31444f;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--bg);
}

.login-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(160deg, #003d3e 0%, #00625f 55%, #00847e 100%);
  color: #fff;
  padding: 44px 48px;
}

.login-brand-photo {
  position: absolute;
  inset: -14px;
  z-index: 0;
  background:
    radial-gradient(440px 340px at 32% 66%, rgba(0, 16, 17, 0.26), transparent 72%),
    linear-gradient(165deg, rgba(0, 61, 62, 0.24) 0%, rgba(0, 98, 95, 0.22) 50%, rgba(0, 132, 126, 0.2) 100%),
    url("./assets/login-flood.jpg");
  background-repeat: no-repeat;
  background-position: center, center, center 30%;
  background-size: cover;
  filter: blur(3px) saturate(0.85);
  transform: scale(1.06);
}

.login-brand-mark {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.brand-mark .icon {
  width: 34px;
  height: 34px;
}

.brand-mark-logo {
  width: auto;
  min-width: 68px;
  height: 68px;
  border-color: rgba(255, 255, 255, 0.55);
  background: #fff;
  padding: 8px 12px;
}

.brand-mark-logo img {
  height: 52px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.login-brand-mark h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 16px rgba(0, 8, 9, 0.75), 0 1px 3px rgba(0, 8, 9, 0.6);
}

.login-brand-foot {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 28px;
  left: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 8, 9, 0.7);
}

.login-form-side {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 24px;
}

.login-panel {
  width: min(400px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 22px 50px rgba(16, 35, 44, 0.1);
  padding: 32px;
}

.login-panel .eyebrow,
.summary-panel h3,
.page-title h2 {
  margin: 0;
}

.login-panel h2 {
  margin: 4px 0 8px;
  font-size: 26px;
  line-height: 1.15;
}

.login-panel label {
  margin-top: 18px;
}

.login-panel .primary.full {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.login-panel .error {
  margin-top: 12px;
  line-height: 1.4;
}

.login-footnote {
  width: min(400px, 100%);
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 880px) {
  .login-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .login-brand {
    padding: 32px 24px;
  }

  .login-brand-mark h1 {
    font-size: 24px;
  }

  .login-brand-foot {
    display: none;
  }
}

/* Shared professional top navigation, used by the station list and analytics pages */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  background: linear-gradient(90deg, #005253, #00716d);
  color: #fff;
  padding: 12px 22px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.app-header-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.org-logo-badge {
  display: grid;
  flex: none;
  place-items: center;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  padding: 4px 7px;
}

.org-logo-badge img {
  height: 26px;
  width: auto;
  object-fit: contain;
}

.brand-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-pill-wrap {
  position: relative;
}

.team-pill {
  min-height: auto;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #fff;
  padding: 3px 10px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.team-pill:hover {
  background: #eafffd;
}

.team-pill:disabled {
  cursor: default;
  opacity: 1;
}

.team-members-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: max-content;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(13, 28, 36, 0.22);
  padding: 12px;
}

.team-members-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.team-members-pop ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.team-members-pop li {
  color: #17252d;
  font-size: 13px;
  font-weight: 600;
}

.primary-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0 16px;
  color: #d3efed;
  font-weight: 600;
  font-size: 13px;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-tab.active {
  background: #fff;
  color: var(--teal-dark);
}

.nav-tab .icon {
  width: 16px;
  height: 16px;
}

.app-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.app-header-actions button,
.app-header-actions select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.app-header-actions button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.app-header-actions button.primary {
  border-color: transparent;
  background: #fff;
  color: var(--teal-dark);
}

.app-header-actions button.primary:hover {
  background: #eafffd;
}

.app-header-actions select {
  width: auto;
  min-width: 150px;
  flex: none;
}

.app-header-actions select option {
  color: #10232c;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  flex: none;
}

.icon-button:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.editor-header .app-header-actions button {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--text);
}

.editor-header {
  background: linear-gradient(90deg, #005253, #00716d);
}

.editor-header .app-header-brand h1 {
  font-size: 22px;
}

.page-title {
  margin-bottom: 4px;
}

.page-title .eyebrow {
  margin: 0 0 4px;
}

.page-title .muted {
  margin: 4px 0 0;
}

/* Dashboard sub-tabs (Overview / NPA Report) */

.dash-tabs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 4px;
}

.dash-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: #eef1f1;
}

.dash-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0 16px;
  color: #52646d;
  font-weight: 600;
  font-size: 13px;
}

.dash-tab:hover {
  background: rgba(0, 109, 107, 0.08);
  color: var(--teal-dark);
}

.dash-tab.active {
  background: #fff;
  color: var(--teal-dark);
  box-shadow: 0 1px 3px rgba(16, 35, 44, 0.12);
}

/* NPA report */

.report-page {
  display: grid;
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 32px;
}

.report-header {
  border-bottom: 2px solid var(--teal);
  padding-bottom: 18px;
}

.report-header .eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
}

.report-header h2 {
  margin: 0 0 14px;
  color: #10232c;
  font-size: 24px;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.report-meta div {
  display: grid;
  gap: 2px;
}

.report-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.report-meta dd {
  margin: 0;
  color: #10232c;
  font-weight: 700;
}

.report-section h3 {
  margin: 0 0 12px;
  color: var(--teal-ink);
  font-size: 16px;
  border-left: 3px solid var(--teal);
  padding-left: 10px;
}

.report-section h4 {
  margin: 16px 0 8px;
  color: #10232c;
  font-size: 13px;
  text-transform: uppercase;
}

.report-stat-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.report-stat {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.report-stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.report-stat strong {
  color: #10232c;
  font-family: "Fira Code", monospace;
  font-size: 20px;
}

.report-table {
  min-width: 0;
  width: 100%;
}

.report-findings {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: #263942;
  font-size: 14px;
  line-height: 1.5;
}

.report-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.report-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media print {
  .no-print,
  .app-header,
  .page-title,
  .kpi-grid,
  .analytics-columns,
  .analytics-panel,
  .section-heading {
    display: none !important;
  }

  body,
  .analytics-page,
  .analytics-page-body {
    background: #fff !important;
  }

  .report-page {
    border: 0;
    padding: 0;
  }

  .report-table {
    min-width: 0 !important;
  }

  .mini-table-wrap {
    overflow: visible;
  }

  .report-section {
    break-inside: avoid;
  }
}

/* Station list page */

.station-list-body,
.editor-body {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 22px 24px 40px;
}

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

.search-label {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-label .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-label input {
  padding-left: 36px;
}

.list-toolbar select {
  width: auto;
  min-width: 150px;
}

.text-button {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
  font-size: 12px;
}

.station-table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.station-table-head {
  display: grid;
  grid-template-columns: 64px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 120px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: #f4f7f7;
  padding: 10px 16px;
  color: #4c5c66;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.station-table-body {
  display: grid;
}

.station-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 120px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  padding: 12px 16px;
  text-align: left;
}

.station-row:last-child {
  border-bottom: 0;
}

.station-row:hover {
  background: #f6fbfb;
}

.station-row-no {
  color: var(--muted);
  font-family: "Fira Code", monospace;
  font-size: 13px;
}

.station-row-name {
  overflow: hidden;
  min-width: 0;
  color: #17252d;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-row-omc {
  overflow: hidden;
  min-width: 0;
  color: #4c5c66;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-row-mmda {
  overflow: hidden;
  min-width: 0;
  color: #4c5c66;
  font-size: 13px;
  line-height: 1.3;
}

.station-row-mmda small {
  display: block;
  color: var(--muted);
}

.station-row > b {
  justify-self: start;
  border-radius: 999px;
  padding: 3px 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.station-row > b.low {
  background: var(--green);
}

.station-row > b.medium {
  background: var(--amber);
}

.station-row > b.high {
  background: var(--red);
}

.station-row > b.not-started {
  background: #9ca3af;
}

.tabs {
  display: flex;
  gap: 42px;
  align-items: center;
  min-height: 44px;
}

.tabs a {
  position: relative;
  color: #1d2d36;
  text-decoration: none;
  font-weight: 600;
}

.tabs a.active {
  color: var(--teal-ink);
}

.tabs a.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -13px;
  left: 0;
  height: 3px;
  background: var(--teal);
}

.summary-panel button {
  padding: 0 18px;
}

.primary {
  border-color: var(--teal);
  background: linear-gradient(180deg, #007b76, #00625f);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 100, 96, 0.18);
}

.primary:hover {
  border-color: var(--teal-dark);
  background: linear-gradient(180deg, #006f6b, #005856);
}

.danger {
  border-color: #fecaca;
  background: #fff5f5;
  color: var(--red);
}

.ghost {
  background: transparent;
}

.full {
  width: 100%;
}

.station-summary-strip {
  display: grid;
  grid-template-columns: 120px repeat(5, minmax(0, 1fr));
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.station-summary-strip div {
  min-width: 0;
  border-right: 1px solid var(--border);
  padding: 14px 22px;
}

.station-summary-strip div:last-child {
  border-right: 0;
}

.station-summary-strip span {
  display: block;
  margin-bottom: 6px;
  color: #5d6d76;
  font-size: 12px;
}

.station-summary-strip strong {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  color: #17252d;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 16px;
  align-items: start;
}

.form-surface {
  display: grid;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.section-title {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.section-title:first-child {
  border-top: 0;
  padding-top: 0;
}

.section-title h3 {
  margin: 0;
  color: var(--teal-ink);
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  gap: 12px 28px;
}

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

.field-grid.three,
.decision-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.decision-row {
  display: grid;
  gap: 28px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 6px;
  color: #31444f;
  font-size: 13px;
  font-weight: 600;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-right: 0;
  background: #fff;
  color: #384b56;
  font-weight: 600;
}

.segmented label:first-of-type span {
  border-radius: 4px 0 0 4px;
}

.segmented label:last-of-type span {
  border-right: 1px solid var(--border-strong);
  border-radius: 0 4px 4px 0;
}

.segmented input:checked + span {
  border-color: var(--teal);
  background: linear-gradient(180deg, #007b76, #00625f);
  color: #fff;
}

.tank-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tank-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.tank-table th,
.tank-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.tank-table thead th {
  background: #f5f7f8;
  color: #33454f;
  font-size: 12px;
  font-weight: 700;
}

.tank-table tbody th {
  width: 86px;
  color: #33454f;
  font-family: "Fira Code", monospace;
  font-size: 13px;
}

.tank-table input {
  min-width: 110px;
  min-height: 30px;
  padding: 4px 8px;
  text-align: center;
}

.tank-table .checkbox {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
}

.summary-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

.side-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 16px;
}

.side-card h3 {
  color: var(--teal-ink);
  font-size: 16px;
  text-transform: uppercase;
}

.score-ring {
  display: grid;
  width: 132px;
  height: 132px;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--score), #d7dcdf 0);
}

.score-ring span {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--teal-ink);
  font-family: "Fira Code", monospace;
  font-size: 26px;
  font-weight: 700;
}

.legend {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend b {
  margin-left: auto;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.sync-actions-main {
  grid-template-columns: 1fr 1fr;
}

.sync-actions button {
  min-width: 0;
  padding: 0 8px;
}

.sync-status {
  margin: 0;
  border-left: 3px solid var(--teal);
  background: #eef8f7;
  color: #31515a;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.sync-setup {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.water-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: -6px 0 4px;
}

.water-hint,
.water-result {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
}

.water-result {
  font-weight: 700;
}

.water-result.tone-critical { color: var(--red); }
.water-result.tone-warning { color: #b06f04; }
.water-result.tone-good { color: var(--green); }

.sync-setup summary {
  color: var(--teal-ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.sync-setup label {
  margin-top: 10px;
}

.sync-setup button {
  width: 100%;
  margin-top: 10px;
}

.risk-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #9ca3af;
}

.risk-dot.low {
  background: var(--green);
}

.risk-dot.medium {
  background: var(--amber);
}

.risk-dot.high {
  background: var(--red);
}

.risk-dot.not-started {
  background: #c8cdd1;
}

.summary-panel dl {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.summary-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.summary-panel dl div:last-child {
  border-bottom: 0;
}

.summary-panel dt {
  color: var(--muted);
  font-weight: 600;
}

.summary-panel dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

/* ---------- Analytics Dashboard (standalone page) ---------- */

.analytics-page {
  --tone-critical: var(--red);
  --tone-critical-soft: #fdecec;
  --tone-warning: var(--amber);
  --tone-warning-soft: #fef3e2;
  --tone-good: var(--green);
  --tone-good-soft: #e9f8ee;
  --tone-neutral: #64748b;
  --tone-neutral-soft: #eef1f4;
  --tone-brand: var(--teal);
  --tone-brand-soft: #e3f5f4;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f4f8f8 0, var(--bg) 260px);
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.icon.inline {
  width: 15px;
  height: 15px;
  margin-right: 4px;
  vertical-align: -2px;
}

.analytics-page-body {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 22px 24px 40px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-tile {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  text-align: left;
  box-shadow: 0 1px 0 rgba(16, 35, 44, 0.03);
}

.kpi-tile:hover,
.kpi-tile.active {
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(0, 109, 107, 0.14);
  transform: translateY(-1px);
}

.kpi-icon-badge {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--tone-brand-soft);
  color: var(--tone-brand);
}

.kpi-tile.tone-critical .kpi-icon-badge { background: var(--tone-critical-soft); color: var(--tone-critical); }
.kpi-tile.tone-warning .kpi-icon-badge { background: var(--tone-warning-soft); color: #b06f04; }
.kpi-tile.tone-good .kpi-icon-badge { background: var(--tone-good-soft); color: var(--tone-good); }
.kpi-tile.tone-neutral .kpi-icon-badge { background: var(--tone-neutral-soft); color: var(--tone-neutral); }

.kpi-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.kpi-value {
  color: #10232c;
  font-family: "Fira Code", monospace;
  font-size: 26px;
  line-height: 1.05;
}

.kpi-value small {
  color: var(--muted);
  font-size: 13px;
}

.kpi-helper {
  color: #5f717a;
  font-size: 12px;
  line-height: 1.3;
}

.analytics-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

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

.analytics-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 16px;
}

.analytics-panel h4 {
  display: flex;
  align-items: center;
  margin: 0;
  color: var(--teal-ink);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.panel-count {
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  background: var(--tone-critical-soft);
  padding: 1px 9px;
  color: var(--tone-critical);
  font-family: "Fira Code", monospace;
  font-size: 12px;
  text-transform: none;
}

button.panel-count {
  min-height: auto;
  cursor: pointer;
}

.panel-count.tone-good {
  background: var(--tone-good-soft);
  color: var(--tone-good);
}

/* Section headings between dashboard groups */

.section-heading {
  margin: 4px 0 -6px;
}

.section-heading h2 {
  margin: 0 0 2px;
  color: #10232c;
  font-size: 18px;
  line-height: 1.2;
}

.section-heading .muted {
  margin: 0;
}

/* Donut / pie charts */

.donut-panel {
  align-content: start;
}

.donut-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.donut-chart {
  position: relative;
  flex: none;
  width: 180px;
  height: 180px;
}

.donut {
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
}

.donut-track {
  fill: none;
  stroke: var(--tone-neutral-soft);
  stroke-width: 20;
}

.donut-seg {
  fill: none;
  stroke-width: 20;
  stroke-linecap: butt;
  cursor: pointer;
  transition: filter 150ms ease, stroke-width 150ms ease;
}

.donut-seg:hover {
  filter: brightness(1.08);
  stroke-width: 22;
}

.donut-seg.tone-critical { stroke: var(--tone-critical); }
.donut-seg.tone-warning { stroke: var(--tone-warning); }
.donut-seg.tone-good { stroke: var(--tone-good); }
.donut-seg.tone-neutral { stroke: var(--tone-neutral); }
.donut-seg.tone-brand { stroke: var(--tone-brand); }

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 3px;
  place-items: center;
  text-align: center;
  pointer-events: none;
}

.donut-center strong {
  display: block;
  color: #10232c;
  font-family: "Fira Code", monospace;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.donut-center small {
  display: block;
  max-width: 96px;
  color: #10232c;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow-wrap: break-word;
  hyphens: auto;
}

.donut-legend {
  display: grid;
  flex: none;
  width: 180px;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: #263942;
  font-size: 13px;
  cursor: pointer;
}

.donut-legend li:hover .donut-legend-label {
  text-decoration: underline;
}

.donut-legend .swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.donut-legend li.tone-critical .swatch { background: var(--tone-critical); }
.donut-legend li.tone-warning .swatch { background: var(--tone-warning); }
.donut-legend li.tone-good .swatch { background: var(--tone-good); }
.donut-legend li.tone-neutral .swatch { background: var(--tone-neutral); }
.donut-legend li.tone-brand .swatch { background: var(--tone-brand); }

.donut-legend-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend b {
  margin-left: auto;
  font-family: "Fira Code", monospace;
}

.donut-legend small {
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}

.chart-subhead {
  margin: 4px 0 -4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bar-track i.tone-critical { background: var(--tone-critical); }

.bar-row b small {
  color: var(--muted);
  font-family: "Fira Code", monospace;
  font-weight: 400;
}

/* KPI / chart drill-down modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(9, 20, 25, 0.55);
  padding: 24px;
}

.modal-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(760px, 100%);
  max-height: min(600px, 84vh);
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 30px 60px rgba(9, 20, 25, 0.35);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 16px 18px;
}

.modal-head .eyebrow {
  margin: 0 0 2px;
}

.modal-head h3 {
  margin: 0;
  color: #10232c;
  font-size: 18px;
  line-height: 1.2;
}

.modal-close-btn {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #52646d;
  flex: none;
}

.modal-close-btn:hover {
  border-color: var(--teal);
  background: #f2fbfa;
  color: var(--teal-dark);
}

.modal-body {
  overflow: auto;
  padding: 12px 18px 18px;
}

.modal-body .mini-table-wrap {
  border: 0;
}

@media (max-width: 560px) {
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-panel {
    width: 100%;
    max-height: 88vh;
    border-radius: 12px 12px 0 0;
  }
}

.risk-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
}

.risk-chip.tone-critical { background: var(--tone-critical-soft); color: var(--tone-critical); }
.risk-chip.tone-warning { background: var(--tone-warning-soft); color: #b06f04; }
.risk-chip.tone-good { background: var(--tone-good-soft); color: #0f7d31; }
.risk-chip.tone-neutral { background: var(--tone-neutral-soft); color: var(--tone-neutral); }

/* Priority action list */

.priority-panel {
  border-left: 3px solid var(--tone-critical);
}

.priority-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.priority-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 10px 4px;
  cursor: pointer;
}

.priority-row:last-child {
  border-bottom: 0;
}

.priority-row:hover {
  background: #fbfafa;
}

.priority-risk {
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.priority-row.tone-critical .priority-risk { background: var(--tone-critical-soft); color: var(--tone-critical); }
.priority-row.tone-warning .priority-risk { background: var(--tone-warning-soft); color: #b06f04; }

.priority-name {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.priority-name strong {
  overflow: hidden;
  color: #10232c;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-name small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-issue {
  overflow: hidden;
  color: #5f717a;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Meter rows (data gaps) */

.meter-row {
  display: grid;
  gap: 6px;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  color: #263942;
  font-size: 13px;
}

.meter-head b {
  font-family: "Fira Code", monospace;
  font-weight: 700;
}

.meter-head small {
  color: var(--muted);
  font-weight: 400;
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--tone-neutral-soft);
}

.meter-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.meter-track i.tone-warning { background: var(--tone-warning); }
.meter-track i.tone-neutral { background: var(--tone-neutral); }
.meter-track i.tone-critical { background: var(--tone-critical); }
.meter-track i.tone-good { background: var(--tone-good); }

.jump-row {
  cursor: pointer;
}

.jump-row:hover {
  background: #f6fbfb;
}


.mini-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.mini-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.mini-table thead th {
  background: #f1f5f6;
  color: #31444f;
  font-size: 12px;
  text-transform: uppercase;
}

.mini-table tbody tr:last-child th,
.mini-table tbody tr:last-child td {
  border-bottom: 0;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 10px;
  color: #263942;
  font-size: 13px;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row b {
  color: #10232c;
  font-family: "Fira Code", monospace;
  font-size: 12px;
  text-align: right;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: #dfe7ea;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--teal);
}

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

.heat-cell {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 88px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfb;
  color: #10232c;
  text-align: left;
  cursor: pointer;
}

.heat-cell::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--heat);
  opacity: 0.18;
}

.heat-cell.tone-critical::before { background: var(--tone-critical); }
.heat-cell.tone-warning::before { background: var(--tone-warning); }
.heat-cell.tone-watch::before { background: var(--teal); }
.heat-cell.tone-clear::before { background: var(--tone-good); }

.heat-cell span,
.heat-cell strong,
.heat-cell small {
  position: relative;
}

.heat-cell span {
  overflow: hidden;
  color: #31444f;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.heat-cell strong {
  font-family: "Fira Code", monospace;
  font-size: 24px;
}

.heat-cell small {
  color: var(--muted);
  font-size: 12px;
}

.comparison-chart,
.tank-water-chart,
.quality-meters {
  display: grid;
  gap: 12px;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 1fr) 48px;
  gap: 12px;
  align-items: center;
}

.comparison-label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.comparison-label strong,
.priority-table th strong {
  overflow: hidden;
  color: #10232c;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-label small,
.priority-table th small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.comparison-bars {
  position: relative;
  height: 14px;
  overflow: hidden;
  border-radius: 3px;
  background: #dfe7ea;
}

.comparison-bars span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.comparison-bars .bar-total {
  background: #aac3c6;
}

.comparison-bars .bar-affected {
  background: var(--tone-critical);
}

.comparison-row b {
  color: #10232c;
  font-family: "Fira Code", monospace;
  text-align: right;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 8px;
  border-radius: 2px;
}

.legend-total { background: #aac3c6; }
.legend-affected,
.legend-critical { background: var(--tone-critical); }
.legend-warning { background: var(--tone-warning); }

.tank-water-row {
  display: grid;
  grid-template-columns: 108px minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: #263942;
  font-size: 13px;
}

.tank-water-row strong {
  font-family: "Fira Code", monospace;
}

.tank-water-bars {
  display: grid;
  gap: 4px;
}

.tank-water-bars span {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 2px;
  background: #dfe7ea;
}

.tank-water-bars i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.tank-water-bars i.tone-warning { background: var(--tone-warning); }
.tank-water-bars i.tone-critical { background: var(--tone-critical); }

.tank-water-row small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.quality-scorecard {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.quality-score {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
  border: 1px solid rgba(0, 109, 107, 0.2);
  border-radius: 8px;
  background: #eefafa;
}

.quality-score span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.quality-score strong {
  color: #10232c;
  font-family: "Fira Code", monospace;
  font-size: 34px;
}

.quality-score small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.priority-table {
  min-width: 840px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-family: "Fira Code", monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--red);
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
}

@media (max-width: 1280px) {
  .summary-panel {
    position: static;
    height: auto;
  }

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

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

  .analytics-columns,
  .analytics-columns.two {
    grid-template-columns: 1fr;
  }

  .priority-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .priority-risk {
    justify-self: start;
  }
}

@media (max-width: 880px) {
  .station-list-body,
  .editor-body {
    padding: 14px;
  }

  .tabs {
    gap: 16px;
    overflow-x: auto;
  }

  .station-summary-strip {
    grid-template-columns: 1fr 1fr;
  }

  .station-summary-strip div {
    border-bottom: 1px solid var(--border);
  }

  .field-grid.four,
  .field-grid.three,
  .decision-row {
    grid-template-columns: 1fr;
  }

  .analytics-page-body {
    padding: 16px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header-brand {
    margin-right: 0;
  }

  .primary-nav {
    justify-content: center;
  }

  .app-header-actions {
    justify-content: center;
  }

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

  .station-table-head {
    display: none;
  }

  .station-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name status"
      "meta meta";
  }

  .station-row-no {
    display: none;
  }

  .station-row-name {
    grid-area: name;
  }

  .station-row > b {
    grid-area: status;
  }

  .station-row-omc {
    grid-area: meta;
  }

  .station-row-mmda {
    display: none;
  }
}

@media (max-width: 560px) {
  body {
    overflow-x: hidden;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .app-header {
    padding: 10px 14px;
    gap: 10px;
  }

  .app-header-brand h1 {
    overflow: hidden;
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .primary-nav {
    width: 100%;
    justify-content: center;
  }

  .nav-tab span {
    display: none;
  }

  .app-header-actions {
    width: 100%;
    justify-content: center;
  }

  .app-header-actions button span,
  .app-header-actions select {
    font-size: 13px;
  }

  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .list-toolbar select,
  .list-toolbar button {
    width: 100%;
  }

  .search-label input {
    min-height: 46px;
    border-radius: 10px;
  }

  .station-summary-strip {
    grid-template-columns: 1fr;
  }

  .tabs {
    gap: 18px;
    min-height: 40px;
    padding-bottom: 2px;
    white-space: nowrap;
  }

  .editor-body {
    scroll-margin-top: 8px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .editor-header .app-header-actions button span {
    display: none;
  }

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

  .kpi-tile {
    min-height: auto;
  }

  .donut-chart {
    width: 150px;
    height: 150px;
  }

  .donut-center strong {
    font-size: 26px;
  }

  .donut-center small {
    font-size: 11px;
  }

  .donut-body {
    justify-content: center;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-row b {
    text-align: left;
  }

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

  .comparison-row,
  .tank-water-row,
  .quality-scorecard {
    grid-template-columns: 1fr;
  }

  .comparison-row b {
    text-align: left;
  }

  .tank-water-row small {
    white-space: normal;
  }

  .form-surface,
  .side-card {
    border-radius: 8px;
    padding: 12px;
  }

  .tank-table {
    min-width: 680px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
