/* Ripple - Pool care, simplified */

:root {
  --primary: #155080;
  --primary-dark: #0a2d4a;
  --primary-light: #ddeef8;
  --primary-hover: #0f3d63;
  --accent: #D97820;
  --accent-light: #FEF3E2;
  --bg: #eef5fb;
  --surface: #ffffff;
  --surface-alt: #e4f0f9;
  --text: #0a2038;
  --text-muted: #3d6e8f;
  --border: #c8dfee;
  --success: #2d9659;
  --success-light: #e3f5ec;
  --warning: #d4901a;
  --warning-light: #fdf0dc;
  --danger: #c43535;
  --danger-light: #fce8e8;
  --shadow: 0 2px 8px rgba(10, 45, 74, 0.12);
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* legacy accent aliases mapped into Ripple palette */
  --accent-acid: var(--danger);
  --accent-buffer: var(--success);
  --accent-chlorine: var(--primary);
  --accent-dilution: #6b5b95;
  --accent-other: var(--warning);
}

html[data-theme='dark'] {
  --bg: #0a1929;
  --surface: #0d2137;
  --surface-alt: #102840;
  --text: #e0eaf4;
  --text-muted: #7aabcc;
  --border: rgba(100, 180, 230, 0.15);
  --primary: #2a7ab5;
  --primary-hover: #3389c8;
  --shadow: 0 2px 10px rgba(0,0,0,0.5);
}

html[data-theme='dark'] body {
  background-color: #1a1a2e !important;
  color: #e0e0e0 !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.header {
  margin-bottom: 1.5rem;
  position: relative;
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.75rem;
}

.header-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 10px;
  background: #155080;
  color: #ffffff;
}

html[data-theme='dark'] .header-brand-mark {
  background: #0a2d4a;
  color: #ffffff;
}

.header-brand-word {
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: #0a2038;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Burger button */
.burger-btn {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.burger-btn:hover {
  background: #e8eef2;
}

.burger-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 126, 164, 0.3);
}

.burger-btn[aria-expanded="true"] {
  background: var(--primary);
  color: #fff;
}

.burger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.burger-btn[aria-expanded="true"] .burger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.burger-btn[aria-expanded="true"] .burger-bar:nth-child(2) {
  opacity: 0;
}

.burger-btn[aria-expanded="true"] .burger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Nav menu dropdown */
.nav-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin: 0.25rem 0 0;
  min-width: 180px;
  padding: 0.5rem 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  list-style: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: visibility 0.2s, opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.nav-menu.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.nav-link {
  display: block;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}

.nav-link:hover {
  background: var(--bg);
}

.nav-link:focus {
  outline: none;
  background: var(--bg);
}

.nav-link--signout {
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  padding-top: 0.6rem;
  color: var(--primary);
  font-weight: 600;
}

.main {
  flex: 1;
}

.form {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.field {
  margin-bottom: 1.25rem;
}

.form-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.form-section-title {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-section .field:last-of-type,
.field:last-of-type {
  margin-bottom: 1.5rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.field input,
.field select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

.field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6b7c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.field input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.field input:hover,
.field select:hover {
  border-color: #b8c8d4;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 126, 164, 0.15);
}

.form-touched input:invalid,
.form-touched select:invalid {
  border-color: var(--danger);
}

.hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.field-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-help-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.field-help-icon span {
  transform: translateY(-0.5px);
}

.field-tooltip {
  margin-top: 4px;
  max-width: 280px;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f5f7fa;
  border: 1px solid var(--border);
  color: var(--text-muted);
  position: relative;
  z-index: 10;
}

.field-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent var(--border) transparent;
}

.field-tooltip::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 16px;
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #f5f7fa transparent;
}

.btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
}

.btn:active {
  transform: scale(0.99);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 126, 164, 0.3);
}

.btn-secondary {
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.btn-outline {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.btn-outline:hover {
  background: #f5f7fa;
}

.btn-outline--small {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  width: auto;
  white-space: nowrap;
}

.btn-outline--danger {
  border-color: var(--accent-acid);
  color: var(--accent-acid);
}

.btn-outline--danger:hover {
  background: color-mix(in srgb, var(--accent-acid) 14%, var(--surface));
  color: var(--accent-acid);
}

.btn-outline--danger:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-acid) 35%, transparent);
}

.account-sign-out-wrap {
  margin-top: 1.5rem;
  margin-bottom: 0.25rem;
  width: 100%;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.import-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface, #EEF5FB);
  border-radius: 10px;
  border: 1.5px dashed #155080;
}

.import-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 0;
}

#import-loading {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: white;
  font-size: 16px;
}

.import-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #155080;
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.results {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.results h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

/* Dashboard table */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 960px;
}

.history-table th,
.history-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.history-table thead th {
  font-weight: 600;
  background: #f5f7fa;
}

.history-table tbody tr:nth-child(even) {
  background: #f9fbfd;
}

html[data-theme='dark'] table {
  color: var(--text);
  border-color: var(--border);
}

html[data-theme='dark'] th {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

html[data-theme='dark'] td {
  border-color: var(--border);
  color: var(--text);
}

html[data-theme='dark'] tr:nth-child(even) {
  background: var(--surface-alt);
}

html[data-theme='dark'] tr:nth-child(odd) {
  background: var(--surface);
}

html[data-theme='dark'] tr:hover {
  background: var(--bg);
}

.table-delete-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid #d6dde6;
  background: #ffffff;
  cursor: pointer;
}

.table-delete-btn:hover {
  background: #f0f4f8;
}

.dashboard-history {
  margin-bottom: 0.75rem;
}

.dashboard-ai {
  margin-bottom: 0.9rem;
  background: #eef5fb;
  border: 1px solid var(--border);
}

.dashboard-ai__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #155080;
  color: #fff;
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  margin-bottom: 0.75rem;
}

.dashboard-ai__title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.dashboard-ai__icon {
  display: inline-flex;
  color: #fff;
  flex-shrink: 0;
}

.dashboard-ai__title-wrap h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.dashboard-ai__run-btn {
  width: auto;
  flex-shrink: 0;
  background: #d97820;
  color: #fff;
  padding: 0.5rem 0.8rem;
}

.dashboard-ai__run-btn:hover {
  background: #c26b1c;
}

.dashboard-ai__last {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dashboard-ai__loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.dashboard-ai__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: dashboard-ai-spin 0.8s linear infinite;
}

@keyframes dashboard-ai-spin {
  to {
    transform: rotate(360deg);
  }
}

.dashboard-ai__score {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: center;
  box-shadow: var(--shadow);
}

.dashboard-ai__score-ring {
  width: 80px;
  height: 80px;
  min-width: 80px;
  min-height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
  background: var(--surface);
  border: 6px solid var(--border);
}

.dashboard-ai__score-ring--good {
  color: var(--success);
  border-color: var(--success);
}

.dashboard-ai__score-ring--warn {
  color: var(--warning);
  border-color: var(--warning);
}

.dashboard-ai__score-ring--bad {
  color: var(--danger);
  border-color: var(--danger);
}

.dashboard-ai__score-label {
  margin: 0 0 0.2rem;
  font-weight: 900;
  color: var(--text);
}

.dashboard-ai__score-summary {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.dashboard-ai__trend {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text);
}

.dashboard-ai__insights {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.65rem;
}

.dashboard-ai__insight {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
}

.dashboard-ai__insight--success {
  border-left-color: var(--success);
}

.dashboard-ai__insight--warning {
  border-left-color: var(--warning);
}

.dashboard-ai__insight--danger {
  border-left-color: var(--danger);
}

.dashboard-ai__insight--info {
  border-left-color: var(--primary);
}

.dashboard-ai__insight h3 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  color: var(--text);
}

.dashboard-ai__insight p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.dashboard-ai__what {
  margin-top: 0.5rem;
  background: color-mix(in srgb, #d97820 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #d97820 30%, var(--border));
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}

.dashboard-ai__what strong {
  color: #d97820;
}

.dashboard-ai__maint {
  margin-top: 0.8rem;
  border: 1px solid color-mix(in srgb, #d97820 28%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, #d97820 8%, var(--surface));
  padding: 0.7rem;
}

.dashboard-ai__maint-title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  color: #d97820;
  font-weight: 900;
}

.dashboard-ai__maint-list {
  display: grid;
  gap: 0.55rem;
}

.dashboard-ai__maint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
}

.dashboard-ai__maint-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.dashboard-ai__maint-head h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.dashboard-ai__maint-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.4;
}

.dashboard-ai__urgency {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-ai__urgency--high {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
}

.dashboard-ai__urgency--medium {
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
}

.dashboard-ai__urgency--low {
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
}

.dashboard-charts {
  margin-top: 0.75rem;
}

.chart-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.dashboard-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dashboard-tab {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f5f7fa;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
}

.dashboard-tab--active {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(26, 43, 60, 0.18);
}

.dashboard-maintenance h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.dashboard-maint-history .history-table {
  min-width: 520px;
}

.chart-section {
  margin-top: 1rem;
}

.chart-canvas {
  height: 200px;
}

.chart-canvas--markers {
  height: 220px;
}

.chart-section canvas {
  width: 100%;
  max-width: 100%;
  height: 100%;
}

.charts-grid {
  margin-top: 0.75rem;
}

@media (min-width: 480px) {
  .charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.charts-toggle {
  margin-top: 0.75rem;
  display: inline-flex;
  border-radius: 999px;
  background: #e3e9f0;
  padding: 2px;
}

/* Pool page: full-width equal segments, aligned with main content width */
.charts-toggle.charts-toggle--equal {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
}

.charts-toggle.charts-toggle--equal .charts-toggle-btn {
  flex: 1;
  padding: 10px 0;
  text-align: center;
}

.charts-toggle-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
}

.charts-toggle-btn--active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(26, 43, 60, 0.15);
}

html[data-theme='dark'] .charts-toggle-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

html[data-theme='dark'] .charts-toggle-btn.charts-toggle-btn--active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Also support generic toggle classes if used */
html[data-theme='dark'] .toggle-btn,
html[data-theme='dark'] .view-toggle button {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme='dark'] .toggle-btn.active,
html[data-theme='dark'] .view-toggle button.active {
  background: var(--primary);
  color: #ffffff;
}

.charts-legend {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.charts-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.charts-legend-color {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.chart-badges {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chart-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.result-card {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border-left: 4px solid var(--border);
}

.result-card:last-of-type {
  margin-bottom: 1rem;
}

.result-acid {
  border-left-color: var(--accent-acid);
  background: rgba(196, 92, 38, 0.06);
}

.result-buffer {
  border-left-color: var(--accent-buffer);
  background: rgba(45, 125, 94, 0.06);
}

.result-chlorine {
  border-left-color: var(--accent-chlorine);
  background: rgba(13, 126, 164, 0.06);
}

.result-chlorine .result-value {
  color: var(--accent-chlorine);
}

.result-dilution {
  border-left-color: var(--accent-dilution);
  background: rgba(107, 91, 149, 0.06);
}

.result-dilution .result-value {
  color: var(--accent-dilution);
}

.result-other {
  border-left-color: var(--accent-other);
  background: rgba(139, 105, 20, 0.06);
}

.result-other .result-value {
  color: var(--accent-other);
}

.result-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.result-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.result-acid .result-value {
  color: var(--accent-acid);
}

.result-buffer .result-value {
  color: var(--accent-buffer);
}

.result-detail {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.disclaimer {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.footer {
  margin-top: auto;
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer p {
  margin: 0;
}

/* Calculator defaults link */
.defaults-row {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.defaults-link {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

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

.defaults-link:focus {
  outline: none;
  text-decoration: underline;
  color: var(--primary);
}

.defaults-message {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Login page */
.form-links {
  margin-top: 0.75rem;
}

.form-links--top {
  margin-top: 0.5rem;
}

.form-links--bottom {
  margin-top: 1.25rem;
  text-align: center;
}

.form-link {
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
}

.form-link:hover {
  text-decoration: underline;
}

.form-link:focus {
  outline: none;
  text-decoration: underline;
}

.form-message {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.dark-mode-toggle-label {
  cursor: pointer;
  display: flex;
  align-items: center;
}
.dark-mode-toggle-track {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  background: var(--border);
  border-radius: 14px;
  transition: background 0.3s;
}
.dark-mode-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.3s;
}
#dark-mode-toggle:checked + .dark-mode-toggle-track {
  background: var(--primary);
}
#dark-mode-toggle:checked + .dark-mode-toggle-track .dark-mode-toggle-thumb {
  transform: translateX(24px);
}

/* Home page tweaks */
.home-section h2 {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.home-section--welcome {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.home-greeting {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.home-date {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.home-status-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-border-tertiary, var(--border)) 25%,
    var(--color-background-secondary, var(--surface-alt)) 50%,
    var(--color-border-tertiary, var(--border)) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
  height: 20px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.home-skeleton-name {
  width: 180px;
  margin: 0.1rem 0 0;
}

.home-skeleton-value {
  width: 70%;
}

.home-skeleton-date {
  width: 72px;
  display: inline-block;
}

.home-skeleton-detail {
  width: 130px;
  display: inline-block;
}

.home-status-cards .result-card h3 {
  font-size: 0.75rem;
}

.home-status-cards .result-value {
  font-size: 1.125rem;
}

.home-actions-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.home-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  min-height: 90px;
  padding-inline: 0.25rem;
  text-decoration: none;
}

.home-action-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.home-action-icon path {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-action-label {
  font-size: 0.8rem;
  text-align: center;
  white-space: nowrap;
}

.home-recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.home-recent-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  padding: 0.2rem 0;
}

.home-recent-date {
  color: var(--text-muted);
}

.home-recent-detail {
  text-align: right;
}

.home-section--maintenance h2 {
  margin-bottom: 0.5rem;
}

.home-maint-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.home-maint-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.2rem 0;
}

.home-maint-task {
  font-weight: 500;
}

.home-maint-status {
  text-align: right;
}

.home-maint-status--ok {
  color: var(--text-muted);
}

.home-maint-status--warn {
  color: #d29b2c;
}

.home-maint-status--alert {
  color: #c45c26;
}

/* Home — maintenance schedule */
.home-section--schedule h2 {
  margin-bottom: 0.5rem;
}

.home-schedule-edit-wrap {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.home-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.home-schedule-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-schedule-card__title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.home-schedule-card__freq {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.home-schedule-card__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
  text-align: right;
}

.home-schedule-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  border: 1px solid var(--border);
  line-height: 1.3;
}

.home-schedule-pill--ok {
  background: color-mix(in srgb, var(--accent-buffer) 22%, var(--surface));
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent-buffer) 45%, var(--border));
}

.home-schedule-pill--warn {
  background: color-mix(in srgb, var(--accent-other) 25%, var(--surface));
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent-other) 50%, var(--border));
}

.home-schedule-pill--late {
  background: color-mix(in srgb, var(--accent-acid) 22%, var(--surface));
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent-acid) 45%, var(--border));
}

.home-schedule-pill--muted {
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
}

.home-schedule-card__when {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.home-schedule-card--tappable {
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.home-schedule-card--tappable:hover {
  background: var(--surface-alt);
  box-shadow: 0 3px 10px rgba(26, 43, 60, 0.18);
  transform: translateY(-1px);
}

.home-schedule-card--tappable:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

/* Home – quick log modal */
.home-schedule-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}

.home-schedule-modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
}

.home-schedule-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.home-schedule-modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.home-schedule-modal__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.home-schedule-modal__body .field {
  margin-bottom: 0.75rem;
}

.home-schedule-modal__footer {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.home-schedule-modal__footer .btn {
  flex: 1;
}

.home-schedule-modal__message {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (min-width: 480px) {
  .home-schedule-modal-overlay {
    align-items: center;
  }

  .home-schedule-modal {
    border-radius: 14px;
    max-width: 340px;
  }
}

/* Dashboard — schedule editor */
.dashboard-schedule-save-all {
  width: 100%;
  margin-bottom: 0.75rem;
}

.dashboard-schedule-intro {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.dashboard-schedule-rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dashboard-schedule-row {
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-schedule-row__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.dashboard-schedule-row__name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.dashboard-schedule-row__active-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.dashboard-schedule-row__default {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dashboard-schedule-row__controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dashboard-schedule-row--inactive {
  opacity: 0.5;
}

.dashboard-schedule-row__save-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.dashboard-schedule-row__feedback {
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 1.25em;
  line-height: 1.25;
}

.dashboard-schedule-row__feedback--ok {
  color: var(--accent-buffer);
}

.dashboard-schedule-row__feedback--err {
  color: var(--accent-acid);
}

.dashboard-schedule-row__freq {
  width: 100%;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.dashboard-schedule-row__save {
  width: auto;
  min-width: 4.5rem;
  flex-shrink: 0;
}

.dashboard-schedule-actions {
  margin-top: 1rem;
}

.dashboard-schedule .form-message {
  margin-top: 0.75rem;
}

@media (min-width: 400px) {
  .dashboard-schedule-row__controls {
    flex-direction: row;
    align-items: center;
  }

  .dashboard-schedule-row__freq {
    flex: 1;
    min-width: 0;
  }

  .dashboard-schedule-row__save-row {
    width: auto;
    flex-shrink: 0;
  }
}

.result-card span {
  overflow: hidden;
  word-wrap: break-word;
  font-size: 11px;
  padding: 2px 6px;
}

/* Volume calculator */
.volume-calc {
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.75rem 0.85rem;
  border-radius: 8px;
  background: #f5f7fa;
}

.volume-calc__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

.volume-calc__arrow {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.volume-calc__arrow::before {
  content: '';
  border-style: solid;
  border-width: 4px 4px 0 4px;
  border-color: var(--text-muted) transparent transparent transparent;
  transform: translateY(1px);
  transition: transform 0.15s;
}

.volume-calc__toggle--open .volume-calc__arrow::before {
  transform: rotate(180deg) translateY(-1px);
}

.volume-calc__label {
  font-size: 0.9rem;
}

.volume-calc__body {
  margin-top: 0.5rem;
}

.volume-calc__shapes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.volume-calc__shape {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
}

.volume-calc__shape--active {
  border-width: 2px;
  border-color: var(--primary);
  background: rgba(13, 126, 164, 0.06);
  color: var(--primary);
}

.volume-calc__icon {
  width: 48px;
  height: 36px;
}

.volume-calc__shape-label {
  font-size: 11px;
  color: var(--text-muted);
}

.volume-calc__shape--active .volume-calc__shape-label {
  color: var(--primary);
  font-weight: 500;
}

.volume-calc__dimensions .field {
  margin-bottom: 0.5rem;
}

.volume-calc__btn {
  margin-top: 0.25rem;
}

.volume-calc__result {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

@media (min-width: 480px) {
  .volume-calc__shapes {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Dark mode for pool volume calculator */
html[data-theme='dark'] .volume-calc,
html[data-theme='dark'] .volume-calculator,
html[data-theme='dark'] .pool-volume-section,
html[data-theme='dark'] .calculator-section {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

html[data-theme='dark'] .volume-calc__shape,
html[data-theme='dark'] .shape-btn {
  background: var(--surface-alt) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

html[data-theme='dark'] .volume-calc__shape.volume-calc__shape--active,
html[data-theme='dark'] .shape-btn.active,
html[data-theme='dark'] .shape-btn.selected {
  background: var(--surface) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

html[data-theme='dark'] .volume-calc label,
html[data-theme='dark'] .volume-calculator label,
html[data-theme='dark'] .pool-volume-section label {
  color: var(--text) !important;
}

/* Bottom tab bar */
body {
  padding-bottom: 72px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
}

.bottom-nav__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.bottom-nav__brand-mark {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 10px;
  background: #155080;
  color: #ffffff;
}

.bottom-nav__brand-word {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-dark);
}

.bottom-nav__tabs {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 60px;
}

.bottom-nav__item {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding-top: 0.25rem;
}

.bottom-nav__item--active {
  color: var(--primary);
}

.bottom-nav__icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.bottom-nav__icon path {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav__label {
  display: block;
}

/* Slightly larger on desktop */
@media (min-width: 480px) {
  .app {
    padding: 2rem;
  }
  .header h1 {
    font-size: 1.75rem;
  }
  .form,
  .results {
    padding: 1.75rem;
  }
}
