:root {
  --bg: #07111d;
  --bg-elevated: #0a1422;
  --surface: #0f1c2d;
  --surface-soft: #14243a;
  --surface-strong: #182b44;
  --border: #26394f;
  --border-strong: #36536e;
  --text: #e7f3ff;
  --muted: #9fb4c8;
  --subtle: #71869b;
  --primary: #22d3ee;
  --primary-strong: #06b6d4;
  --primary-soft: rgba(34, 211, 238, 0.13);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.15);
  --focus: #67e8f9;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media screen {
  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brand-logo,
  .auth-brand-logo {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
    height: auto;
    object-fit: contain;
  }

  .brand .brand-logo {
    width: min(210px, 100%);
  }

  .auth-card .auth-brand-logo {
    margin-bottom: 4px;
    max-width: 300px;
    width: 82%;
  }

  .brand strong {
    display: none;
  }

  .brand span {
    color: var(--muted);
    display: block;
    font-size: 0.92rem;
    padding-left: 2px;
  }

  .segmented-control {
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: none;
    gap: 3px;
    padding: 3px;
  }

  .segmented-control button {
    background: transparent;
    border: 0;
    color: #405551;
    min-height: 30px;
    padding: 6px 10px;
  }

  .segmented-control button.active,
  .segmented-control button:focus-visible {
    background: var(--primary-soft);
    color: var(--primary-strong);
    outline: 1px solid rgba(8, 127, 140, 0.3);
  }

  .chart-frame {
    min-height: 0;
    overflow: visible;
  }

  .analytics-chart-block {
    min-height: 250px;
  }

  .usage-chart {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    height: auto;
    max-height: 300px;
    overflow: visible;
    padding: 8px;
  }

  .usage-chart .chart-bar {
    fill: var(--primary);
    filter: none;
  }

  .usage-chart .chart-bar.forecast {
    fill: #6ea8d9;
    opacity: 0.72;
    stroke: #2764b3;
  }

  .chart-title {
    fill: var(--text);
    font-size: 13px;
    font-weight: 800;
  }

  .chart-label,
  .chart-scale {
    fill: var(--muted);
    font-size: 12px;
  }

  .chart-guide {
    stroke: rgba(83, 103, 99, 0.22);
  }

  .chart-axis {
    stroke: rgba(83, 103, 99, 0.38);
  }

  .ai-response-text p,
  .ai-response-text li,
  .ai-response-text ul,
  .ai-output small {
    color: var(--text);
  }

  .ai-response-text li {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text);
  }

  .ai-response-text li::before {
    background: var(--primary);
    box-shadow: none;
  }

  .ai-response-text h4 {
    border-top-color: var(--border);
    color: var(--text);
  }

  .report-note-columns > div,
  .report-management-note,
  .report-callout,
  .report-explain-card {
    background: #ffffff;
    color: #172522;
  }

  .report-note-columns ul,
  .report-management-note p,
  .report-callout span {
    color: #172522;
  }

  .report-logo-mark {
    border: 0;
    border-radius: 0;
    height: auto;
    object-fit: contain;
    width: min(300px, 42vw);
  }

  .report-brand-row {
    align-items: center;
  }

  @media (max-width: 980px) {
    .brand {
      align-items: flex-start;
      gap: 6px;
    }

    .brand .brand-logo {
      width: 190px;
    }
  }

  @media (max-width: 680px) {
    .brand .brand-logo {
      width: 180px;
    }

    .auth-card .auth-brand-logo {
      width: 100%;
    }

    .segmented-control {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      width: 100%;
    }

    .segmented-control button {
      width: 100%;
    }
  }
}

@media screen {
  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brand-logo,
  .auth-brand-logo {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
    height: auto;
    object-fit: contain;
  }

  .brand .brand-logo {
    width: min(210px, 100%);
  }

  .auth-card .auth-brand-logo {
    margin-bottom: 4px;
    max-width: 300px;
    width: 82%;
  }

  .brand strong {
    display: none;
  }

  .brand span {
    color: var(--muted);
    display: block;
    font-size: 0.92rem;
    padding-left: 2px;
  }

  .segmented-control {
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: none;
    gap: 3px;
    padding: 3px;
  }

  .segmented-control button {
    background: transparent;
    border: 0;
    color: #405551;
    min-height: 30px;
    padding: 6px 10px;
  }

  .segmented-control button.active,
  .segmented-control button:focus-visible {
    background: var(--primary-soft);
    color: var(--primary-strong);
    outline: 1px solid rgba(8, 127, 140, 0.3);
  }

  .chart-frame {
    min-height: 0;
    overflow: visible;
  }

  .analytics-chart-block {
    min-height: 250px;
  }

  .usage-chart {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    height: auto;
    max-height: 300px;
    overflow: visible;
    padding: 8px;
  }

  .usage-chart .chart-bar {
    fill: var(--primary);
    filter: none;
  }

  .usage-chart .chart-bar.forecast {
    fill: #6ea8d9;
    opacity: 0.72;
    stroke: #2764b3;
  }

  .chart-title {
    fill: var(--text);
    font-size: 13px;
    font-weight: 800;
  }

  .chart-label,
  .chart-scale {
    fill: var(--muted);
    font-size: 12px;
  }

  .chart-guide {
    stroke: rgba(83, 103, 99, 0.22);
  }

  .chart-axis {
    stroke: rgba(83, 103, 99, 0.38);
  }

  .ai-response-text p,
  .ai-response-text li,
  .ai-response-text ul,
  .ai-output small {
    color: var(--text);
  }

  .ai-response-text li {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text);
  }

  .ai-response-text li::before {
    background: var(--primary);
    box-shadow: none;
  }

  .ai-response-text h4 {
    border-top-color: var(--border);
    color: var(--text);
  }

  .report-note-columns > div,
  .report-management-note,
  .report-callout,
  .report-explain-card {
    background: #ffffff;
    color: #172522;
  }

  .report-note-columns ul,
  .report-management-note p,
  .report-callout span {
    color: #172522;
  }

  .report-logo-mark {
    border: 0;
    border-radius: 0;
    height: auto;
    object-fit: contain;
    width: min(300px, 42vw);
  }

  .report-brand-row {
    align-items: center;
  }

  @media (max-width: 980px) {
    .brand {
      align-items: flex-start;
      gap: 6px;
    }

    .brand .brand-logo {
      width: 190px;
    }
  }

  @media (max-width: 680px) {
    .brand .brand-logo {
      width: 180px;
    }

    .auth-card .auth-brand-logo {
      width: 100%;
    }

    .segmented-control {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      width: 100%;
    }

    .segmented-control button {
      width: 100%;
    }
  }
}

@media screen {
  :root {
    --bg: #f4f7f8;
    --bg-elevated: #ffffff;
    --panel: #ffffff;
    --surface: #ffffff;
    --surface-soft: #eef5f4;
    --surface-strong: #dce9e6;
    --border: #cfdbd8;
    --border-strong: #9eb2ad;
    --text: #172522;
    --muted: #536763;
    --subtle: #748680;
    --primary: #087f8c;
    --primary-strong: #066873;
    --primary-soft: rgba(8, 127, 140, 0.12);
    --danger: #b42318;
    --danger-soft: rgba(180, 35, 24, 0.12);
    --warning: #b7791f;
    --warning-soft: rgba(183, 121, 31, 0.14);
    --success: #16845b;
    --success-soft: rgba(22, 132, 91, 0.12);
    --info: #2764b3;
    --info-soft: rgba(39, 100, 179, 0.12);
    --focus: #1f9fb0;
    --radius: 8px;
    --shadow: 0 12px 32px rgba(25, 48, 43, 0.08);
    color-scheme: light;
  }

  body {
    background: var(--bg);
    color: var(--text);
  }

  .auth-shell {
    background:
      linear-gradient(90deg, rgba(8, 127, 140, 0.08), rgba(22, 132, 91, 0.07)),
      var(--bg);
  }

  .auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(25, 48, 43, 0.14);
    max-width: 480px;
    padding: 32px;
  }

  .auth-card h1 {
    color: var(--text);
    font-size: 1.6rem;
  }

  .auth-card p {
    color: var(--muted);
  }

  .app-shell {
    background: var(--bg);
    grid-template-columns: 272px minmax(0, 1fr);
  }

  .sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 28px rgba(25, 48, 43, 0.04);
    color: var(--text);
    padding: 22px 16px;
  }

  .brand {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px;
  }

  .brand-logo {
    border: 1px solid var(--border);
    border-radius: 10px;
    height: 46px;
    width: 46px;
  }

  .brand strong {
    color: var(--text);
    font-size: 0.98rem;
  }

  .brand span,
  .sidebar-note {
    color: var(--muted);
  }

  .nav-list {
    gap: 4px;
  }

  .nav-section-label {
    color: var(--subtle);
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 12px 10px 4px;
    text-transform: uppercase;
  }

  .nav-item {
    border-radius: 8px;
    color: #344743;
    font-size: 0.94rem;
    font-weight: 700;
    min-height: 40px;
    padding: 10px 12px;
  }

  .nav-item:hover {
    background: #eef7f6;
    border-color: #c7dfdb;
    color: var(--primary-strong);
  }

  .nav-item.active {
    background: var(--primary-soft);
    border-color: rgba(8, 127, 140, 0.24);
    box-shadow: inset 3px 0 0 var(--primary);
    color: var(--primary-strong);
  }

  .status-dot {
    background: var(--success);
    box-shadow: none;
  }

  .main {
    padding: 22px 24px 36px;
  }

  .topbar {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    padding: 16px 18px;
    position: sticky;
    top: 12px;
    z-index: 20;
  }

  .topbar h1 {
    color: var(--text);
    font-size: 1.45rem;
  }

  .eyebrow {
    color: var(--primary);
    letter-spacing: 0;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .environment-badge {
    justify-content: center;
    min-width: 92px;
  }

  .section-heading {
    align-items: flex-end;
    margin: 12px 0 16px;
  }

  .section-heading h2 {
    color: var(--text);
    font-size: 1.35rem;
    margin-bottom: 4px;
  }

  .section-heading p,
  .panel-header p,
  .field-hint,
  .muted {
    color: var(--muted);
  }

  .view.active > * {
    animation: none;
  }

  .panel,
  .metric-card,
  .action-summary,
  .auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
  }

  .panel {
    padding: 18px;
  }

  .compact-panel {
    background: #ffffff;
    border-color: var(--border);
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    margin: -2px 0 14px;
    padding-bottom: 12px;
  }

  .panel-header h3 {
    color: var(--text);
    font-size: 1rem;
  }

  .filter-bar {
    align-items: end;
    gap: 12px;
  }

  .action-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 16px;
    padding: 14px;
  }

  .action-card {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 5px;
    min-height: 112px;
    padding: 14px;
  }

  .action-card span,
  .metric-card span,
  .status-cell span,
  .compliance-card span,
  .analytics-insight span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  .action-card strong {
    color: var(--text);
    font-size: 1.18rem;
    line-height: 1.2;
  }

  .action-card small {
    color: var(--muted);
    line-height: 1.45;
  }

  .action-card.success {
    background: var(--success-soft);
    border-color: rgba(22, 132, 91, 0.24);
  }

  .action-card.warning {
    background: var(--warning-soft);
    border-color: rgba(183, 121, 31, 0.28);
  }

  .action-card.danger {
    background: var(--danger-soft);
    border-color: rgba(180, 35, 24, 0.24);
  }

  .action-card.info {
    background: var(--info-soft);
    border-color: rgba(39, 100, 179, 0.22);
  }

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

  .metric-card {
    overflow: hidden;
    padding: 18px;
  }

  .metric-card::before {
    background: linear-gradient(180deg, var(--primary), var(--success));
    width: 4px;
  }

  .metric-card strong {
    color: var(--text);
    font-size: 1.6rem;
  }

  .metric-card small {
    color: var(--muted);
  }

  .metric-spark,
  .bar-track,
  .mini-progress {
    background: #e5eeeb;
  }

  .metric-fill,
  .mini-progress span,
  .bar-fill {
    background: var(--primary);
  }

  .analytics-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  }

  .visual-panel {
    background: #ffffff;
  }

  .chart-frame,
  .analytics-panel-content,
  .usage-chart,
  .analytics-insight,
  .status-cell,
  .source-card,
  .insight-card,
  .stack-item,
  .compliance-card,
  .report-preview {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
  }

  .chart-frame {
    min-height: 260px;
    padding: 14px;
  }

  .status-strip {
    gap: 10px;
  }

  .status-cell,
  .insight-card,
  .source-card,
  .stack-item,
  .compliance-card {
    box-shadow: none;
  }

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

  .source-card {
    padding: 14px;
  }

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

  .dashboard-grid .panel:nth-child(3) {
    grid-column: 1 / -1;
  }

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

  .button {
    border-radius: 7px;
    font-weight: 800;
    min-height: 38px;
    padding: 9px 14px;
  }

  .button.primary {
    background: var(--primary);
    color: #ffffff;
  }

  .button.primary:hover {
    background: var(--primary-strong);
  }

  .button.secondary {
    background: #ffffff;
    border-color: var(--border-strong);
    color: var(--text);
  }

  .button.secondary:hover {
    background: #f3faf8;
    border-color: var(--primary);
    color: var(--primary-strong);
  }

  .button.danger {
    background: var(--danger);
    color: #ffffff;
  }

  .button.link {
    color: var(--primary);
  }

  input,
  select,
  textarea {
    background: #ffffff;
    border: 1px solid #bdcbc8;
    border-radius: 7px;
    color: var(--text);
    min-height: 40px;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(31, 159, 176, 0.14);
    outline: none;
  }

  input::placeholder,
  textarea::placeholder {
    color: #8a9a96;
  }

  label {
    color: var(--text);
    font-weight: 800;
  }

  .form-grid {
    gap: 14px;
  }

  .form-section-heading {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
  }

  .nested-form {
    background: #f8fbfa;
    border-color: var(--border);
  }

  .toggle-label {
    background: #f8fbfa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
  }

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

  table {
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
    min-width: 760px;
  }

  th {
    background: #edf4f2;
    color: #405551;
    font-size: 0.72rem;
    letter-spacing: 0;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
  }

  td {
    border-top: 1px solid #e2ebe8;
  }

  tbody tr:hover {
    background: #f4faf8;
  }

  .badge {
    align-items: center;
    border-radius: 6px;
    display: inline-flex;
    font-weight: 800;
    gap: 6px;
    min-height: 26px;
  }

  .badge.neutral {
    background: #edf4f2;
    color: #405551;
  }

  .badge.info {
    background: var(--info-soft);
    color: #1f4f8f;
  }

  .badge.success {
    background: var(--success-soft);
    color: #116643;
  }

  .badge.warning {
    background: var(--warning-soft);
    color: #87530f;
  }

  .badge.danger {
    background: var(--danger-soft);
    color: #8a1c13;
  }

  .alert {
    background: #ffffff;
    border-radius: 8px;
  }

  .alert.success {
    background: var(--success-soft);
    color: #116643;
  }

  .alert.error {
    background: var(--danger-soft);
    color: #8a1c13;
  }

  .empty-state {
    background: #f8fbfa;
    border: 1px dashed var(--border-strong);
    color: var(--muted);
  }

  .ai-panel {
    background: linear-gradient(180deg, #ffffff, #f7fbfa);
  }

  .ai-actions {
    gap: 8px;
  }

  .ai-output {
    background: var(--surface-soft);
    border: 1px solid var(--border);
  }

  .report-preview {
    padding: 18px;
  }

  .report-document {
    background: #ffffff;
    color: #172522;
  }

  .report-cover,
  .report-section {
    background: #ffffff;
    border-color: #d8e1de;
  }

  .report-cover-band {
    background: #122823;
  }

  @media (max-width: 1180px) {
    .action-summary,
    .metric-grid,
    .source-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .dashboard-grid .panel:nth-child(3) {
      grid-column: auto;
    }

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

  @media (max-width: 980px) {
    .app-shell {
      display: block;
    }

    .sidebar {
      bottom: auto;
      height: auto;
      left: 0;
      padding: 12px;
      position: sticky;
      right: 0;
      top: 0;
      width: 100%;
      z-index: 30;
    }

    .brand {
      border-bottom: 0;
      padding-bottom: 0;
    }

    .sidebar-note,
    .nav-section-label {
      display: none;
    }

    .nav-list {
      display: flex;
      gap: 6px;
      overflow-x: auto;
      padding-bottom: 2px;
    }

    .nav-item {
      flex: 0 0 auto;
      white-space: nowrap;
    }

    .nav-item.active {
      box-shadow: inset 0 -3px 0 var(--primary);
    }

    .main {
      padding: 14px;
    }

    .topbar {
      position: static;
    }
  }

  @media (max-width: 680px) {
    .auth-card {
      padding: 22px;
    }

    .topbar,
    .section-heading,
    .panel-header,
    .form-actions,
    .button-row {
      align-items: stretch;
      flex-direction: column;
    }

    .topbar-actions {
      justify-content: stretch;
    }

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

    .action-summary,
    .metric-grid,
    .source-grid,
    .insight-grid,
    .form-grid,
    .nested-form {
      grid-template-columns: 1fr;
    }

    .span-2 {
      grid-column: auto;
    }

    .filter-bar {
      align-items: stretch;
      display: grid;
      grid-template-columns: 1fr;
    }

    table {
      min-width: 720px;
    }
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #07111d 0%, #0a1320 55%, #080f1a 100%);
  color: var(--text);
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

.auth-shell {
  align-items: center;
  background: radial-gradient(circle at top, rgba(34, 211, 238, 0.18), transparent 35%), var(--bg);
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 440px;
  padding: 28px;
  width: 100%;
}

.auth-form {
  display: grid;
  gap: 12px;
}

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

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-width: 0;
  overflow-x: hidden;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  height: 100vh;
  background: #081722;
  border-right: 1px solid rgba(103, 232, 249, 0.16);
  color: var(--text);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  overflow-x: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: block;
  border-radius: 14px;
  object-fit: cover;
}

.brand strong {
  display: block;
  line-height: 1.15;
}

.brand span,
.sidebar-note {
  color: #a7c3d7;
  font-size: 0.86rem;
}

.nav-list {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.nav-item {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c6d8e8;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.2);
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.7);
}

.main {
  grid-column: 2;
  min-width: 0;
  padding: 28px;
  overflow-x: hidden;
}

.topbar,
.section-heading,
.panel-header,
.form-actions,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.8rem;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

h4 {
  margin: 12px 0 8px;
  font-size: 0.95rem;
}

p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.view {
  display: none;
  min-width: 0;
}

.view.active {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.view.active > *,
.panel,
.metric-card {
  min-width: 0;
}

.section-heading {
  flex-wrap: wrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.panel {
  background: linear-gradient(180deg, rgba(15, 28, 45, 0.98), rgba(11, 22, 36, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 8px;
  overflow: hidden;
  position: relative;
}

.metric-card::before {
  background: linear-gradient(180deg, var(--primary), var(--info));
  content: "";
  inset: 0 auto 0 0;
  position: absolute;
  width: 4px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 1.8rem;
}

.metric-spark {
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.metric-fill,
.mini-progress span,
.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--info));
}

.metric-fill.success,
.bar-fill.irrigation,
.mini-progress .irrigation {
  background: linear-gradient(90deg, #34d399, #a7f3d0);
}

.metric-fill.info,
.bar-fill.river,
.mini-progress .river {
  background: linear-gradient(90deg, #60a5fa, #67e8f9);
}

.metric-fill.danger,
.bar-fill.danger,
.mini-progress .danger {
  background: linear-gradient(90deg, #fb7185, #fda4af);
}

.bar-fill.sewage,
.mini-progress .sewage {
  background: linear-gradient(90deg, #fbbf24, #fde68a);
}

.bar-fill.fresh,
.mini-progress .fresh {
  background: linear-gradient(90deg, #22d3ee, #14b8a6);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.compliance-panel {
  border-color: rgba(34, 211, 238, 0.22);
}

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

.compliance-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
}

.compliance-card.wide {
  grid-column: 1 / -1;
}

.compliance-card span,
.compliance-card small {
  color: var(--muted);
}

.compliance-card strong {
  font-size: 1.08rem;
}

.compliance-card.status-success {
  border-color: rgba(52, 211, 153, 0.32);
}

.compliance-card.status-warning {
  border-color: rgba(251, 191, 36, 0.36);
}

.compliance-card.status-danger {
  border-color: rgba(251, 113, 133, 0.38);
}

.analytics-grid {
  align-items: stretch;
  display: grid;
  grid-template-areas:
    "trend top"
    "signals source";
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.85fr);
  gap: 18px;
}

.trend-panel {
  grid-area: trend;
}

.analytics-heading-actions {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.segmented-control {
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}

.segmented-control button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 8px;
}

.segmented-control button.active,
.segmented-control button:focus-visible {
  background: rgba(34, 211, 238, 0.16);
  color: var(--text);
  outline: 1px solid rgba(34, 211, 238, 0.45);
}

.analytics-grid > .visual-panel:nth-child(2) {
  grid-area: signals;
}

.analytics-grid > .visual-panel:nth-child(3) {
  grid-area: source;
}

.analytics-grid > .visual-panel:nth-child(4) {
  grid-area: top;
}

.chart-frame {
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.analytics-panel-content {
  display: grid;
  gap: 14px;
}

.analytics-chart-block {
  min-height: 250px;
}

.usage-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-bar {
  fill: url("#chart-fill");
}

.usage-chart .chart-bar {
  fill: #22d3ee;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.25));
}

.usage-chart .chart-bar.forecast {
  fill: #93c5fd;
  opacity: 0.64;
  stroke: rgba(191, 219, 254, 0.7);
  stroke-dasharray: 4 3;
  stroke-width: 1;
}

.chart-guide {
  stroke: rgba(159, 180, 200, 0.18);
  stroke-dasharray: 5 6;
}

.chart-axis {
  stroke: rgba(159, 180, 200, 0.34);
}

.chart-label,
.chart-scale {
  fill: var(--muted);
  font-size: 12px;
}

.chart-title {
  fill: var(--text);
  font-size: 14px;
  font-weight: 800;
}

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

.analytics-insight {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
}

.analytics-insight span,
.analytics-insight small {
  color: var(--muted);
}

.analytics-insight strong {
  color: var(--text);
  font-size: 1rem;
}

.analytics-insight.warning {
  border-color: rgba(251, 191, 36, 0.4);
}

.analytics-insight.info {
  border-color: rgba(96, 165, 250, 0.38);
}

.bar-list {
  display: grid;
  gap: 12px;
}

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

.bar-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.bar-row-head span {
  color: var(--text);
  font-weight: 800;
}

.bar-row small {
  color: var(--muted);
}

.bar-track,
.mini-progress {
  height: 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.status-strip {
  display: grid;
  gap: 10px;
}

.status-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
}

.status-cell span,
.status-cell small {
  color: var(--muted);
}

.status-cell strong {
  font-size: 1.45rem;
}

.status-cell.success {
  border-color: rgba(52, 211, 153, 0.28);
}

.status-cell.info {
  border-color: rgba(96, 165, 250, 0.3);
}

.status-cell.warning {
  border-color: rgba(251, 191, 36, 0.32);
}

.status-cell.danger {
  border-color: rgba(251, 113, 133, 0.35);
}

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

.source-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.025);
  display: grid;
  gap: 10px;
}

.source-card .badge {
  justify-self: start;
}

.source-card strong {
  font-size: 1.2rem;
}

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

.source-metrics span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-bottom: 3px;
}

.source-metrics strong {
  display: block;
}

.panel {
  padding: 18px;
}

.compact-panel {
  padding: 14px;
}

.visual-panel {
  height: 100%;
  overflow: hidden;
}

.replacement-panel {
  border-color: rgba(34, 211, 238, 0.44);
}

.replacement-context {
  align-items: flex-start;
  background: var(--primary-soft);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 8px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
}

.replacement-context p {
  margin-bottom: 0;
}

.filter-bar {
  display: grid;
  grid-template-columns: 220px 240px minmax(220px, 1fr);
  gap: 12px;
}

.insight-grid {
  display: grid;
  gap: 10px;
}

.insight-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.insight-card span,
.insight-card small {
  color: var(--muted);
}

.insight-card strong {
  font-size: 1.1rem;
}

.panel-header {
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
  background: rgba(255, 255, 255, 0.018);
}

.review-note {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 8px;
  color: var(--muted);
  margin: 0;
  padding: 8px 10px;
}

.stack-item strong {
  display: block;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 700;
}

.button.primary {
  background: linear-gradient(180deg, #22d3ee, #0891b2);
  color: #03131d;
}

.button.primary:hover {
  background: linear-gradient(180deg, #67e8f9, #06b6d4);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text);
}

.button.secondary:hover {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.32);
}

.ai-panel {
  border-color: rgba(34, 211, 238, 0.28);
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.ai-actions .button {
  min-height: 40px;
}

.ai-output {
  background: rgba(10, 23, 38, 0.9);
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 18px;
}

.ai-output.loading {
  border-color: rgba(96, 165, 250, 0.42);
}

.ai-output.error {
  background: rgba(244, 63, 94, 0.09);
  border-color: rgba(244, 63, 94, 0.38);
}

.ai-output-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: space-between;
}

.ai-output-actions {
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
}

.ai-output-header span,
.ai-output small {
  color: var(--muted);
}

.ai-response-text {
  display: grid;
  gap: 14px;
  max-width: 1180px;
}

.ai-response-text p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.ai-response-text h4 {
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0.02em;
  margin: 4px 0 0;
  padding-top: 14px;
}

.ai-response-text h4:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.ai-response-text ul {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ai-response-text li {
  background: rgba(15, 32, 52, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
  padding: 10px 12px 10px 34px;
  position: relative;
}

.ai-response-text li::before {
  background: var(--primary);
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
  content: "";
  height: 7px;
  left: 14px;
  position: absolute;
  top: 18px;
  width: 7px;
}

.ai-response-text strong {
  color: var(--text);
  font-weight: 800;
}

.ai-response-text code {
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 5px;
  color: #a5f3fc;
  padding: 1px 5px;
}

.button.danger {
  background: var(--danger);
  color: #160308;
}

.button.danger:hover {
  background: #fda4af;
}

.button.link {
  background: transparent;
  color: var(--primary);
  padding-inline: 6px;
}

.danger-text {
  color: var(--danger) !important;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

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

.nested-form {
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.form-section-heading {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 16px;
}

.form-section-heading h3 {
  margin-bottom: 4px;
}

.form-section-heading p,
.toggle-label small {
  color: var(--muted);
}

.toggle-label {
  align-items: flex-start;
  display: flex;
  gap: 10px;
}

.toggle-label input {
  margin-top: 4px;
  width: auto;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.field-hint,
.muted {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.field-hint {
  line-height: 1.35;
  max-width: 68ch;
}

label:has(input[required]) > span.field-hint:first-of-type::before,
label:has(select[required]) > span.field-hint:first-of-type::before {
  content: "Required. ";
  color: var(--primary);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a1726;
  color: var(--text);
  padding: 10px 11px;
  min-height: 42px;
}

input::placeholder,
textarea::placeholder {
  color: #6f8598;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--subtle);
  background: rgba(148, 163, 184, 0.08);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  justify-content: flex-end;
}

.search {
  max-width: 360px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

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

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

th {
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  color: var(--text);
}

tbody tr:hover {
  background: rgba(34, 211, 238, 0.045);
}

.water-test-list {
  display: grid;
  gap: 10px;
}

.water-test-card {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(220px, 0.9fr) auto;
  column-gap: 20px;
  row-gap: 12px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
  padding: 14px 16px;
}

.water-test-doc {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.water-test-date {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.water-test-doc h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.water-test-doc p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.water-test-context {
  min-width: 0;
}

.water-test-context strong {
  display: block;
  margin-bottom: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.water-test-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  min-width: 0;
}

.water-test-meta > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.water-test-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  white-space: nowrap;
  padding-top: 2px;
}

.water-test-actions .admin-only {
  display: flex;
  align-items: center;
  gap: 12px;
}

.water-test-actions .button.secondary {
  min-height: 36px;
  padding: 8px 13px;
}

.water-test-actions .button.link {
  min-height: 0;
  padding: 0;
  line-height: 1.2;
}

.water-test-detail {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
  border-top: 1px solid var(--border);
  padding-top: 11px;
}

.water-test-detail span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.water-test-detail p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.water-test-facts {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: flex-start;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  white-space: nowrap;
}

.water-test-facts span {
  border-radius: 999px;
  background: rgba(15, 118, 128, 0.08);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 4px 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

.badge.info {
  background: var(--info-soft);
  color: #bfdbfe;
}

.badge.success {
  background: var(--success-soft);
  color: #bbf7d0;
}

.badge.warning {
  background: var(--warning-soft);
  color: #fde68a;
}

.badge.danger {
  background: var(--danger-soft);
  color: #fecdd3;
}

.alert-region {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.alert {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  background: var(--surface);
}

.alert.success {
  background: var(--success-soft);
  color: #bbf7d0;
  border-color: rgba(52, 211, 153, 0.28);
}

.alert.error {
  background: var(--danger-soft);
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.32);
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.report-preview {
  display: grid;
  gap: 16px;
}

.report-document {
  background: #eef4f8;
  border: 1px solid #c6d5e2;
  border-radius: 14px;
  color: #111827;
  display: grid;
  gap: 20px;
  padding: 24px;
}

.report-document .eyebrow {
  color: #047c91;
}

.report-cover,
.report-section {
  background: #ffffff;
  border: 1px solid #d7e1eb;
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  padding: 20px;
}

.report-cover {
  border-color: #b8ccd9;
  padding-top: 0;
}

.report-cover-band {
  align-items: center;
  background: linear-gradient(135deg, #061524 0%, #0d4252 55%, #0891b2 100%);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  margin: 0 -20px 18px;
  padding: 14px 20px;
}

.report-cover-band span {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report-cover-band strong {
  font-size: 1rem;
}

.report-brand-row {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.report-logo-mark {
  border: 0;
  border-radius: 12px;
  display: block;
  height: 72px;
  object-fit: contain;
  width: 72px;
}

.report-cover h3 {
  color: #0f172a;
  font-size: 2rem;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.report-section h4 {
  color: #0f172a;
}

.report-cover p,
.report-section p {
  color: #334155;
}

.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.report-meta-grid span {
  background: #f8fafc;
  border: 1px solid #d7e1eb;
  border-radius: 10px;
  color: #334155;
  display: grid;
  gap: 4px;
  min-height: 58px;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 11px 12px;
}

.report-meta-grid strong {
  color: #0f172a;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.report-meta-grid .report-id-cell code {
  color: #0f172a;
  display: block;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.report-status-band {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-top: 5px solid #0891b2;
  border-radius: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(120px, 0.8fr));
  margin: 16px 0;
  padding: 14px;
}

.report-status-band.success {
  border-top-color: #16a34a;
}

.report-status-band.warning {
  border-top-color: #d97706;
}

.report-status-band.danger {
  border-top-color: #dc2626;
}

.report-status-band span {
  color: #475569;
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.report-status-band strong {
  color: #0f172a;
  display: block;
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.report-status-primary {
  min-width: 0;
}

.report-status-primary strong {
  font-size: 0.96rem;
  line-height: 1.18;
}

.report-status-primary small {
  color: #475569;
  display: block;
  font-size: 0.75rem;
  line-height: 1.25;
  margin-top: 3px;
  text-transform: none;
}

.report-section-heading {
  align-items: start;
  background: linear-gradient(90deg, #f1f7fb, #ffffff);
  border-bottom: 1px solid #d7e1eb;
  display: grid;
  gap: 12px;
  grid-template-columns: 34px minmax(0, 1fr);
  margin: -20px -20px 16px;
  padding: 14px 20px;
}

.report-section-heading > span {
  align-items: center;
  background: #0b5e72;
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.report-section-heading h4 {
  color: #07111d;
  font-size: 1rem;
  letter-spacing: 0;
  margin: 0 0 4px;
}

.report-section-heading p,
.report-note {
  color: #475569;
  margin: 0;
}

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

.report-explain-card {
  background: #f8fafc;
  border: 1px solid #d7e1eb;
  border-radius: 8px;
  padding: 12px;
}

.report-explain-card strong,
.report-explain-card p {
  color: #0f172a;
}

.report-explain-card p {
  font-size: 1rem;
  font-weight: 800;
  margin: 5px 0;
}

.report-explain-card small {
  color: #475569;
  line-height: 1.35;
}

.report-callout {
  border: 1px solid #d7e1eb;
  border-radius: 10px;
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px;
}

.report-callout span {
  color: #334155;
}

.report-callout.success {
  background: #ecfdf5;
  border-color: #86efac;
  color: #14532d;
}

.report-callout.warning {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #78350f;
}

.report-callout.danger {
  background: #fff1f2;
  border-color: #fda4af;
  color: #881337;
}

.report-callout.neutral {
  background: #f8fafc;
  color: #334155;
}

.report-management-note {
  background: linear-gradient(180deg, #f8fafc, #eef7fb);
  border: 1px solid #c8d8e6;
  border-left: 5px solid #0891b2;
  border-radius: 12px;
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
}

.report-management-note-head {
  display: grid;
  gap: 2px;
}

.report-management-note-head strong {
  color: #0f172a;
  font-size: 0.98rem;
}

.report-management-note-head span {
  color: #64748b;
  font-size: 0.8rem;
}

.report-management-note p {
  color: #1f2937;
  line-height: 1.55;
  margin: 0;
  white-space: pre-line;
}

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

.report-note-columns > div {
  background: #ffffff;
  border: 1px solid #d7e1eb;
  border-radius: 9px;
  padding: 10px 12px;
}

.report-note-columns strong {
  color: #0f172a;
  display: block;
  font-size: 0.82rem;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.report-note-columns ul {
  color: #334155;
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
}

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

.report-stat {
  border: 1px solid #cbdceb;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #f8fafc, #edf6fb);
  display: grid;
  gap: 5px;
  min-width: 0;
}

.report-stat span {
  color: #475569;
  display: block;
  font-size: 0.82rem;
  line-height: 1.25;
}

.report-stat strong {
  color: #0f172a;
  display: block;
  font-size: 1.18rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

.report-visual-card {
  background: #f8fbfd;
  border: 1px solid #cbdceb;
  border-radius: 12px;
  display: grid;
  gap: 12px;
  min-height: 190px;
  padding: 14px;
}

.report-visual-head {
  align-items: start;
  border-bottom: 1px solid #dbe6ef;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-bottom: 10px;
}

.report-visual-head span {
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.report-visual-head strong {
  color: #0f172a;
  font-size: 0.92rem;
  max-width: 52%;
  text-align: right;
}

.report-bars,
.report-compliance-bars,
.report-priority-list {
  display: grid;
  gap: 10px;
}

.report-bar-row {
  display: grid;
  gap: 5px;
}

.report-bar-row > div:first-child,
.report-compliance-bars > div {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.report-bar-row span,
.report-compliance-bars span,
.report-priority-list span {
  color: #334155;
}

.report-bar-row strong,
.report-compliance-bars strong,
.report-priority-list strong {
  color: #0f172a;
}

.report-bar-track {
  background: #dbe6ef;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.report-bar-track span {
  background: #22c7d9;
  border-radius: inherit;
  display: block;
  height: 100%;
}

.report-bar-track .fresh,
.report-bar-track .success {
  background: #2dd4bf;
}

.report-bar-track .irrigation {
  background: #86efac;
}

.report-bar-track .river {
  background: #60a5fa;
}

.report-bar-track .sewage,
.report-bar-track .warning {
  background: #fbbf24;
}

.report-bar-track .danger {
  background: #fb7185;
}

.report-mini-chart {
  align-items: end;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  min-height: 128px;
}

.report-mini-column {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-rows: 112px auto;
}

.report-mini-column span {
  align-self: end;
  background: linear-gradient(180deg, #22d3ee, #0891b2);
  border-radius: 5px 5px 2px 2px;
  display: block;
  min-height: 3px;
  width: 100%;
}

.report-mini-column small {
  color: #475569;
  font-size: 0.68rem;
}

.report-compliance-bars p,
.report-muted {
  color: #475569;
  font-size: 0.82rem;
  margin: 0;
}

.report-priority-list span {
  background: #ffffff;
  border: 1px solid #d7e1eb;
  border-radius: 9px;
  display: flex;
  justify-content: space-between;
  padding: 9px 10px;
}

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

.report-signoff-grid span {
  border: 1px solid #d7e1eb;
  border-radius: 8px;
  min-height: 104px;
  padding: 10px;
}

.report-signoff-grid .signoff-comments {
  grid-column: 1 / -1;
  min-height: 140px;
}

.report-signoff-grid strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.report-footer {
  color: #475569;
  font-size: 0.78rem;
  text-align: center;
}

.report-preview table {
  background: #ffffff;
  border-collapse: collapse;
  color: #111827;
  width: 100%;
}

.report-preview th {
  background: #eaf1f8;
  color: #18324a;
}

.report-preview td,
.report-preview th {
  border-bottom: 1px solid #d7e1eb;
}

.report-preview td {
  color: #111827;
}

.report-preview tbody tr:hover {
  background: #f8fafc;
}

.report-preview .report-callout td,
.report-preview .report-callout th {
  color: #111827;
}

@media (max-width: 1120px) {
  .analytics-grid {
    grid-template-areas: none;
    grid-template-columns: 1fr;
  }

  .trend-panel,
  .analytics-grid > .visual-panel:nth-child(2),
  .analytics-grid > .visual-panel:nth-child(3),
  .analytics-grid > .visual-panel:nth-child(4) {
    grid-area: auto;
  }

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 16px;
  }

  .main {
    grid-column: auto;
  }

  .brand-logo {
    width: 64px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    white-space: nowrap;
  }

  .sidebar-note {
    display: none;
  }

  .metric-grid,
  .dashboard-grid,
  .source-grid,
  .filter-bar,
  .compliance-grid,
  .report-meta-grid,
  .report-brand-row,
  .report-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .water-test-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .water-test-actions {
    justify-content: flex-start;
  }

  .water-test-detail,
  .water-test-facts {
    grid-column: 1;
  }

  .water-test-facts {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .section-heading,
  .panel-header,
  .replacement-context,
  .form-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .dashboard-grid,
  .form-grid,
  .source-grid,
  .filter-bar,
  .compliance-grid,
  .report-meta-grid,
  .report-brand-row,
  .report-stat-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .button,
  .search,
  .source-metrics {
    width: 100%;
  }

  .source-metrics {
    grid-template-columns: 1fr;
  }

  .water-test-card,
  .water-test-doc,
  .water-test-detail,
  .water-test-actions,
  .water-test-actions .admin-only {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .water-test-card,
  .water-test-actions,
  .water-test-actions .admin-only {
    display: grid;
  }

  .water-test-doc h3,
  .water-test-doc p,
  .water-test-context strong,
  .water-test-meta > span:last-child {
    white-space: normal;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm 9mm 10mm;
  }

  :root {
    color-scheme: light;
  }

  body {
    background: white !important;
    color: #111827 !important;
  }

  .sidebar,
  .topbar,
  .section-heading,
  .filter-bar,
  .alert-region,
  #reportsView > .panel > .panel-header {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .view {
    display: none !important;
  }

  #reportsView {
    display: block !important;
  }

  .panel,
  .report-document,
  .report-stat,
  .report-cover,
  .report-section,
  .report-callout,
  .report-meta-grid span,
  .empty-state {
    background: white !important;
    border-color: #d1d5db !important;
    box-shadow: none !important;
    color: #111827 !important;
  }

  .report-document {
    gap: 14px;
    padding: 0;
  }

  .report-document,
  .report-document * {
    color: #111827 !important;
  }

  .report-document th {
    background: #e5edf5 !important;
    color: #0f172a !important;
  }

  .report-document td {
    color: #111827 !important;
  }

  .report-cover {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-section {
    break-inside: auto;
    page-break-inside: auto;
  }

  .report-brand-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .report-status-band,
  .report-explain-grid,
  .report-stat-grid,
  .report-meta-grid {
    break-inside: avoid;
  }

  .report-status-band {
    gap: 7px;
    grid-template-columns: minmax(0, 1.55fr) repeat(3, minmax(0, 0.82fr));
    padding: 10px 12px;
  }

  .report-status-band span {
    font-size: 7.2pt;
  }

  .report-status-band strong {
    font-size: 8.4pt;
    line-height: 1.18;
  }

  .report-status-primary small {
    font-size: 6.8pt;
  }

  .report-meta-grid .report-id-cell code {
    font-size: 7.4pt;
  }

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

  .report-logo-mark {
    display: none !important;
  }

  .report-preview table {
    font-size: 8.8pt;
    table-layout: fixed;
  }

  .report-preview th,
  .report-preview td {
    line-height: 1.25;
    overflow-wrap: anywhere;
    padding: 5px 6px;
    vertical-align: top;
  }

  .report-preview thead {
    display: table-header-group;
  }

  .report-preview tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-preview .table-wrap {
    overflow: visible;
  }

  .report-footer {
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  td,
  th,
  strong,
  span,
  small,
  .muted,
  .field-hint {
    color: #111827 !important;
  }

  th {
    background: #f3f4f6 !important;
  }

  .badge {
    border: 1px solid #d1d5db;
    background: #f9fafb !important;
    color: #111827 !important;
  }

  .report-document {
    background: #ffffff !important;
    border: 0 !important;
    display: block;
    font-size: 8.7pt;
    padding: 0 0 4mm !important;
  }

  .report-cover,
  .report-section {
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px;
    box-shadow: none !important;
    margin: 0 0 5mm;
    overflow: hidden;
    padding: 10px;
  }

  .report-cover {
    page-break-after: auto;
  }

  .report-cover-band {
    background: #0f2942 !important;
    color: #ffffff !important;
    margin: -10px -10px 10px;
    padding: 9px 10px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-cover-band span,
  .report-cover-band strong {
    color: #ffffff !important;
  }

  .report-section-heading {
    background: #edf6fb !important;
    border-bottom: 1px solid #cbd5e1;
    break-after: avoid;
    margin: -10px -10px 9px;
    page-break-after: avoid;
    padding: 8px 10px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-section-heading > span {
    background: #0b5e72 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-meta-grid span,
  .report-stat,
  .report-explain-card,
  .report-visual-card,
  .report-priority-list span {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-status-band {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    border-top-width: 5px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

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

  .report-visual-card {
    min-height: 150px;
    padding: 10px;
  }

  .report-mini-chart {
    min-height: 96px;
  }

  .report-mini-column {
    grid-template-rows: 82px auto;
  }

  .report-mini-column span,
  .report-bar-track span {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-logo-mark {
    display: none !important;
  }

  .report-brand-row {
    gap: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .report-cover-title-block {
    padding: 0 !important;
  }

  .report-cover-title-block .eyebrow {
    font-size: 8pt !important;
    margin: 0 0 3px !important;
  }

  .report-cover-title-block h3 {
    font-size: 22pt !important;
    line-height: 1.05 !important;
    margin: 4px 0 5px !important;
  }

  .report-cover-title-block p {
    margin: 0 !important;
  }

  .report-meta-grid {
    gap: 7px !important;
    margin: 10px 0 !important;
  }

  .report-meta-grid span {
    border-radius: 5px !important;
    min-height: 44px !important;
    padding: 8px 9px !important;
  }

  .report-status-band {
    margin: 10px 0 !important;
  }

  .report-callout {
    padding: 8px 10px !important;
  }

  .report-section:last-of-type {
    margin-bottom: 0 !important;
  }

  .report-auto-page-break {
    break-before: page;
    page-break-before: always;
  }

  .report-auto-keep,
  .report-signoff-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-section .table-wrap {
    break-inside: auto;
    page-break-inside: auto;
  }

  .report-preview table {
    border: 1px solid #cbd5e1;
  }

  .report-preview th {
    background: #e5edf5 !important;
    color: #0f172a !important;
    font-size: 8pt;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-preview td,
  .report-preview th {
    border-right: 1px solid #e5e7eb;
  }

  .report-footer {
    background: #ffffff !important;
    border-top: 1px solid #cbd5e1;
    color: #475569 !important;
    padding-top: 3mm;
  }
}

@media screen {
  :root {
    --bg: #f4f7f8;
    --bg-elevated: #ffffff;
    --panel: #ffffff;
    --surface: #ffffff;
    --surface-soft: #eef5f4;
    --surface-strong: #dce9e6;
    --border: #cfdbd8;
    --border-strong: #9eb2ad;
    --text: #172522;
    --muted: #536763;
    --subtle: #748680;
    --primary: #087f8c;
    --primary-strong: #066873;
    --primary-soft: rgba(8, 127, 140, 0.12);
    --danger: #b42318;
    --danger-soft: rgba(180, 35, 24, 0.12);
    --warning: #b7791f;
    --warning-soft: rgba(183, 121, 31, 0.14);
    --success: #16845b;
    --success-soft: rgba(22, 132, 91, 0.12);
    --info: #2764b3;
    --info-soft: rgba(39, 100, 179, 0.12);
    --focus: #1f9fb0;
    --radius: 8px;
    --shadow: 0 12px 32px rgba(25, 48, 43, 0.08);
    color-scheme: light;
  }

  body {
    background: var(--bg);
    color: var(--text);
  }

  .auth-shell {
    background: linear-gradient(90deg, rgba(8, 127, 140, 0.08), rgba(22, 132, 91, 0.07)), var(--bg);
  }

  .auth-card,
  .panel,
  .metric-card,
  .action-summary {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    color: var(--text);
  }

  .auth-card {
    max-width: 480px;
    padding: 32px;
  }

  .auth-card h1,
  .topbar h1,
  .section-heading h2,
  .panel-header h3,
  .metric-card strong,
  .action-card strong,
  .compliance-card strong,
  .source-card strong,
  .insight-card strong,
  .status-cell strong {
    color: var(--text);
  }

  .auth-card p,
  .section-heading p,
  .panel-header p,
  .metric-card small,
  .action-card small,
  .field-hint,
  .muted,
  .brand span,
  .sidebar-note,
  .bar-row small,
  .analytics-insight small,
  .status-cell small,
  .compliance-card small,
  .source-metrics span,
  .insight-card small,
  .stack-item .meta-row,
  .report-preview p {
    color: var(--muted);
  }

  .app-shell {
    background: var(--bg);
    grid-template-columns: 272px minmax(0, 1fr);
  }

  .sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 28px rgba(25, 48, 43, 0.04);
    color: var(--text);
    padding: 22px 16px;
  }

  .brand {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px;
  }

  .brand-logo {
    border: 1px solid var(--border);
    border-radius: 10px;
    height: 46px;
    width: 46px;
  }

  .brand strong {
    color: var(--text);
    font-size: 0.98rem;
  }

  .nav-section-label {
    color: var(--subtle);
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 12px 10px 4px;
    text-transform: uppercase;
  }

  .nav-item {
    border-radius: 8px;
    color: #344743;
    font-size: 0.94rem;
    font-weight: 700;
    min-height: 40px;
    padding: 10px 12px;
  }

  .nav-item:hover {
    background: #eef7f6;
    border-color: #c7dfdb;
    color: var(--primary-strong);
  }

  .nav-item.active {
    background: var(--primary-soft);
    border-color: rgba(8, 127, 140, 0.24);
    box-shadow: inset 3px 0 0 var(--primary);
    color: var(--primary-strong);
  }

  .main {
    padding: 22px 24px 36px;
  }

  .topbar {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    padding: 16px 18px;
    position: sticky;
    top: 12px;
    z-index: 20;
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .eyebrow {
    color: var(--primary);
    letter-spacing: 0;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .environment-badge {
    justify-content: center;
    min-width: 92px;
  }

  .section-heading {
    align-items: flex-end;
    margin: 12px 0 16px;
  }

  .section-heading h2 {
    font-size: 1.35rem;
    margin-bottom: 4px;
  }

  .view.active > * {
    animation: none;
  }

  .panel {
    padding: 18px;
  }

  .compact-panel,
  .filter-bar.panel {
    background: #ffffff;
    border-color: var(--border);
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    margin: -2px 0 14px;
    padding-bottom: 12px;
  }

  .action-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 16px;
    padding: 14px;
  }

  .action-card,
  .chart-frame,
  .analytics-panel-content,
  .usage-chart,
  .analytics-insight,
  .status-cell,
  .source-card,
  .insight-card,
  .stack-item,
  .compliance-card,
  .report-preview,
  .ai-output {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: none;
    color: var(--text);
  }

  .action-card {
    display: grid;
    gap: 5px;
    min-height: 112px;
    padding: 14px;
  }

  .action-card span,
  .metric-card span,
  .status-cell span,
  .compliance-card span,
  .analytics-insight span,
  .source-card .badge {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  .action-card.success,
  .status-cell.success,
  .compliance-card.status-success {
    background: var(--success-soft);
    border-color: rgba(22, 132, 91, 0.24);
  }

  .action-card.warning,
  .status-cell.warning,
  .compliance-card.status-warning {
    background: var(--warning-soft);
    border-color: rgba(183, 121, 31, 0.28);
  }

  .action-card.danger,
  .status-cell.danger,
  .compliance-card.status-danger {
    background: var(--danger-soft);
    border-color: rgba(180, 35, 24, 0.24);
  }

  .action-card.info,
  .status-cell.info {
    background: var(--info-soft);
    border-color: rgba(39, 100, 179, 0.22);
  }

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

  .metric-card {
    overflow: hidden;
    padding: 18px;
  }

  .metric-card::before {
    background: linear-gradient(180deg, var(--primary), var(--success));
    width: 4px;
  }

  .metric-card strong {
    font-size: 1.6rem;
  }

  .metric-spark,
  .bar-track,
  .mini-progress {
    background: #e5eeeb;
  }

  .metric-fill,
  .mini-progress span,
  .bar-fill {
    background: var(--primary);
  }

  .analytics-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  }

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

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

  .dashboard-grid .panel:nth-child(3) {
    grid-column: 1 / -1;
  }

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

  .button {
    border-radius: 7px;
    font-weight: 800;
    min-height: 38px;
    padding: 9px 14px;
  }

  .button.primary {
    background: var(--primary);
    color: #ffffff;
  }

  .button.primary:hover {
    background: var(--primary-strong);
  }

  .button.secondary {
    background: #ffffff;
    border-color: var(--border-strong);
    color: var(--text);
  }

  .button.secondary:hover {
    background: #f3faf8;
    border-color: var(--primary);
    color: var(--primary-strong);
  }

  .button.danger {
    background: var(--danger);
    color: #ffffff;
  }

  .button.link {
    color: var(--primary);
  }

  input,
  select,
  textarea {
    background: #ffffff;
    border: 1px solid #bdcbc8;
    border-radius: 7px;
    color: var(--text);
    min-height: 40px;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(31, 159, 176, 0.14);
    outline: none;
  }

  input::placeholder,
  textarea::placeholder {
    color: #8a9a96;
  }

  label {
    color: var(--text);
    font-weight: 800;
  }

  .form-grid {
    gap: 14px;
  }

  .form-section-heading,
  .toggle-label,
  .nested-form {
    background: #f8fbfa;
    border: 1px solid var(--border);
    border-radius: 8px;
  }

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

  table {
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
    min-width: 760px;
  }

  th {
    background: #edf4f2;
    color: #405551;
    font-size: 0.72rem;
    letter-spacing: 0;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
  }

  td {
    border-top: 1px solid #e2ebe8;
  }

  tbody tr:hover {
    background: #f4faf8;
  }

  .badge {
    align-items: center;
    border-radius: 6px;
    display: inline-flex;
    font-weight: 800;
    gap: 6px;
    min-height: 26px;
  }

  .badge.neutral {
    background: #edf4f2;
    color: #405551;
  }

  .badge.info {
    background: var(--info-soft);
    color: #1f4f8f;
  }

  .badge.success {
    background: var(--success-soft);
    color: #116643;
  }

  .badge.warning {
    background: var(--warning-soft);
    color: #87530f;
  }

  .badge.danger {
    background: var(--danger-soft);
    color: #8a1c13;
  }

  .alert,
  .empty-state {
    background: #ffffff;
    border-radius: 8px;
  }

  .empty-state {
    border: 1px dashed var(--border-strong);
    color: var(--muted);
  }

  .report-document {
    background: #ffffff;
    color: #172522;
  }

  .report-cover,
  .report-section {
    background: #ffffff;
    border-color: #d8e1de;
  }

  .report-cover-band {
    background: #122823;
  }

  @media (max-width: 1180px) {
    .action-summary,
    .metric-grid,
    .source-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .dashboard-grid .panel:nth-child(3) {
      grid-column: auto;
    }

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

  @media (max-width: 980px) {
    .app-shell {
      display: block;
    }

    .sidebar {
      bottom: auto;
      height: auto;
      left: 0;
      padding: 12px;
      position: sticky;
      right: 0;
      top: 0;
      width: 100%;
      z-index: 30;
    }

    .brand {
      border-bottom: 0;
      padding-bottom: 0;
    }

    .sidebar-note,
    .nav-section-label {
      display: none;
    }

    .nav-list {
      display: flex;
      gap: 6px;
      overflow-x: auto;
      padding-bottom: 2px;
    }

    .nav-item {
      flex: 0 0 auto;
      white-space: nowrap;
    }

    .nav-item.active {
      box-shadow: inset 0 -3px 0 var(--primary);
    }

    .main {
      padding: 14px;
    }

    .topbar {
      position: static;
    }
  }

  @media (max-width: 680px) {
    .auth-card {
      padding: 22px;
    }

    .topbar,
    .section-heading,
    .panel-header,
    .form-actions,
    .button-row {
      align-items: stretch;
      flex-direction: column;
    }

    .topbar-actions {
      justify-content: stretch;
    }

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

    .action-summary,
    .metric-grid,
    .source-grid,
    .insight-grid,
    .form-grid,
    .nested-form {
      grid-template-columns: 1fr;
    }

    .span-2 {
      grid-column: auto;
    }

    .filter-bar {
      align-items: stretch;
      display: grid;
      grid-template-columns: 1fr;
    }

    table {
      min-width: 720px;
    }
  }
}
