
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('./fonts/SpaceGroteskLatin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('./fonts/SpaceGroteskLatinExt.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f5f7f7;
  --text: #111111;
  --muted: #535b63;
  --line: #111111;
  --accent: #00d9ff;
  --accent-dark: #006477;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --ok: #137333;
  --ok-bg: #e7f6ec;
  --warn: #9a6700;
  --warn-bg: #fff7d6;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 2.5rem;
  border: 2px solid var(--text);
  border-radius: 0;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #baf5ff;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

button.secondary:hover {
  background: var(--surface-soft);
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-shell {
  width: min(100%, 980px);
}

.login-panel {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.login-panel h1,
.topbar h1,
.section-head h2 {
  margin: 0;
}

.login-panel label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--text);
}

.login-panel input:focus {
  outline: 3px solid var(--accent-dark);
  border-color: var(--accent);
}

.alert {
  margin: 0;
  border: 1px solid #ffd0cc;
  border-radius: 0;
  padding: 0.75rem;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 2px solid var(--line);
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.user {
  overflow-wrap: anywhere;
  min-width: 0;
  color: var(--muted);
  font-weight: 700;
}

.dashboard {
  display: grid;
  gap: 1rem;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
}

.connection-status {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 800;
}

.connection-status.connected {
  background: var(--ok-bg);
  color: var(--ok);
}

.connection-status.unreachable {
  border-color: #ffd0cc;
  background: var(--danger-bg);
  color: var(--danger);
}

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

.panel {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 1rem;
  background: var(--surface);
}

.metric strong {
  font-size: 3.25rem;
  line-height: 1;
}

.panel strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.label,
.eyebrow,
.muted {
  color: var(--muted);
}

.label,
.eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 0.25rem;
}

.muted {
  font-size: 0.9rem;
}

.badge {
  justify-self: start;
  border-radius: 0;
  padding: 0.25rem 0.65rem;
  font-size: 0.86rem;
  font-weight: 800;
}

.badge.online {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.offline {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.stale {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.unknown {
  background: var(--surface-soft);
  color: var(--muted);
}

.chart-panel {
  min-height: 420px;
}

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

.chart-wrap {
  position: relative;
  min-height: 320px;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 320px;
}
.chart-periods, .chart-range-form { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; align-items: end; }
.chart-periods button[aria-pressed="false"] { background: var(--surface-soft); color: #005c67; }
.chart-range-form label { display: grid; gap: 6px; flex: 1 1 220px; min-width: 0; }
.chart-range-form input { min-width: 0; width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 0; }
.chart-tooltip { min-height: 3em; padding: 10px; background: var(--surface-soft); border-radius: 0; }

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

[hidden] {
  display: none !important;
}
.local-banner { margin: 12px auto; padding: 16px; max-width: 1360px; border: 2px solid var(--accent-dark); border-radius: 0; background: var(--surface-soft); }
.demo-banner { border-color: #986000; background: #fff4db; }
.local-banner p { margin: 8px 0; }
.local-actions, .local-actions form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.local-actions label { display: grid; gap: 6px; }
.local-actions select { font: inherit; padding: 10px; max-width: 100%; }
.auth-page:has(.local-banner) { display: block; }

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

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

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

  .metric strong {
    font-size: 2.5rem;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-wrap,
  .chart-wrap canvas {
    min-height: 260px;
    height: 260px;
  }
}
/* Fleet overview: horizontally scrollable on narrow screens. */
.fleet-dashboard { max-width: 1440px; display: grid; gap: 20px; }
.fleet-summary .metric strong { font-size: 2.5rem; }
.fleet-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin: 20px 0 12px; }
.fleet-controls label { display: grid; gap: 8px; flex: 1 1 220px; min-width: 0; }
.fleet-controls input, .fleet-controls select { width: 100%; min-width: 0; box-sizing: border-box; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: inherit; }
.fleet-owner { max-width: 220px; overflow-wrap: anywhere; }
.fleet-table-wrap { overflow-x: auto; }
.fleet-table { border-collapse: collapse; width: 100%; text-align: left; }
.fleet-table th, .fleet-table td { padding: 16px 12px; border-bottom: 1px solid #edf2f6; vertical-align: top; }
.fleet-table th { font-size: 0.8rem; color: var(--muted); }
.fleet-table a { color: var(--accent-dark); overflow-wrap: anywhere; }
.fleet-errors { max-width: 280px; overflow-wrap: anywhere; }
.fleet-temperature { white-space: nowrap; font-weight: 600; }
.fleet-age { display: block; margin-top: 6px; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 650px) {
  .fleet-table thead { display: none; }
  .fleet-table tbody { display: grid; gap: 16px; }
  .fleet-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid #edf2f6; border-radius: 0; padding: 8px; }
  .fleet-table td { border: 0; padding: 8px; overflow-wrap: anywhere; }
  .fleet-table td:first-child { grid-column: 1 / -1; }
  .fleet-table td::before { content: attr(data-label); display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 400; }
}
.management-dashboard { display: grid; gap: 20px; }
.customer-card { padding: 20px 0; border-bottom: 1px solid #dce7eb; }
.customer-card:last-child { border-bottom: 0; }
.customer-card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.customer-card-header > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.customer-pools { margin-top: 8px; padding-left: 16px; border-left: 3px solid #dce7eb; }
.customer-pools .management-row:last-child { border-bottom: 0; }
.diagnostics-panel { margin-top: 20px; }
.history-checkbox { display: flex !important; flex-direction: row; align-items: center; }
.history-checkbox input { width: auto; flex: 0 0 auto; }
.history-navigation { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.history-navigation button:disabled { opacity: 0.5; cursor: default; }
.history-chart-panel { min-width: 0; }
.history-statistics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.history-statistics dt { color: var(--muted); font-size: 0.85rem; }
.history-statistics dd { font-size: 1.5rem; font-weight: 700; margin: 6px 0 0; overflow-wrap: anywhere; }
#history-chart { display: block; width: 100%; height: 300px; }
.history-chart-panel summary { cursor: pointer; padding: 12px 0; }
@media (max-width: 650px) { .history-statistics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.diagnostic-table td, #device-owner { overflow-wrap: anywhere; }
.management-form { display: grid; gap: 10px; max-width: 440px; }
.management-form input, .management-actions select, #activation-link { padding: 12px; border: 1px solid var(--line); border-radius: 0; min-width: 0; width: 100%; box-sizing: border-box; font: inherit; }
.management-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid #dce7eb; }
.management-actions { display: flex; gap: 10px; align-items: center; }
.audit-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 0; border-bottom: 1px solid #dce7eb; overflow-wrap: anywhere; }
.management-error { color: #9c2424; }
.activation-panel { max-width: 580px; margin: 40px auto; }
@media (max-width: 650px) {
  .management-row, .management-actions, .customer-card-header { flex-direction: column; align-items: stretch; }
  .activation-panel { margin: 16px; }
}
.device-name { overflow-wrap: anywhere; }
.device-identifier { display: block; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.device-identifier[hidden] { display: none; }
.pool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.pool-card { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 0; background: var(--surface-soft); }
.pool-card h2 { margin: 0 0 16px; font-size: 1.35rem; }
.pool-card h2 a { color: var(--text); text-decoration: none; }
.pool-card h2 a:hover { text-decoration: underline; }
.pool-temperature { font-size: 2.8rem; font-weight: 750; margin: 12px 0 18px; }
.pool-time, .pool-note, .pool-age { line-height: 1.5; overflow-wrap: anywhere; }
.pool-age { margin-top: -8px; }
.pool-link { display: inline-block; margin-top: 12px; color: var(--accent-dark); font-weight: 650; }
.pool-profile-link { display: block; margin-top: 16px; color: var(--accent-dark); font-weight: 650; }
.pool-profile-status { border-left: 3px solid var(--line); padding-left: 10px; overflow-wrap: anywhere; }
.pool-profile-status.verified { border-color: var(--ok); }
.pool-profile-status.pending, .pool-profile-status.changes_requested { border-color: var(--warn); }
.pool-review-note { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.customer-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.customer-summary .metric strong { font-size: 2.8rem; }
.customer-details { margin-top: 20px; }
.customer-details summary { cursor: pointer; font-weight: 650; }
.customer-details dl { display: grid; gap: 8px; }
.customer-details dd { margin: 0 0 12px; overflow-wrap: anywhere; }
.pool-card a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 0; }
.chart-summary { margin: 24px 0; }
.chart-summary h3 { font-size: 1rem; margin-bottom: 12px; }
.chart-statistics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.chart-statistics > div { min-width: 0; padding: 12px; border-radius: 0; background: var(--surface-soft); }
.chart-statistics dt { color: var(--muted); font-size: .85rem; }
.chart-statistics dd { margin: 8px 0 0; font-size: 1.4rem; font-weight: 700; overflow-wrap: anywhere; }
@media (max-width: 650px) { .chart-statistics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .pool-grid, .customer-summary { grid-template-columns: minmax(0, 1fr); }
  .pool-card { padding: 20px; }
}
/* Profile input is independent of live monitoring and device configuration. */
.pool-profile-dashboard { max-width: 1000px; }
.pool-profile-dashboard h1, .pool-card h2, .profile-revision { overflow-wrap: anywhere; }
.pool-profile-form fieldset { min-width: 0; border: 0; padding: 0; display: grid; gap: 12px; }
.pool-profile-dashboard textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 0; }
.pool-profile-dashboard select { width: 100%; min-width: 0; box-sizing: border-box; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 0; background: white; }
.profile-revision { padding: 12px 0; border-bottom: 1px solid #e2e8ed; }
.profile-revision summary { cursor: pointer; font-weight: 600; }
.profile-revision dt { color: var(--muted); }
.profile-revision dd { margin: 0 0 8px; }
.profile-note { white-space: pre-wrap; }

/* AquaLama visual language, adapted to the existing Jinja views. */
::selection { background: var(--accent); color: var(--text); }
a { color: var(--accent-dark); text-underline-offset: .2em; }
a:hover { color: var(--text); }
button, select, textarea { font-family: inherit; }
button { text-transform: uppercase; letter-spacing: .06em; }
button:disabled { opacity: .55; cursor: not-allowed; }
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--accent-dark); outline-offset: 4px;
}
.topbar { border-top: 6px solid var(--accent); }
.topbar h1 { font-size: clamp(1.5rem, 3vw, 2.35rem); letter-spacing: -.045em; }
.topbar-actions a { color: var(--text); font-weight: 650; }
.eyebrow, .label, .fleet-table th { letter-spacing: .09em; }
.brand-mark { display: inline-flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.brand-name { border: 1px solid var(--text); padding: .3rem .5rem; color: var(--text); font-size: .72rem; }
.brand-version { font-size: .7rem; color: var(--muted); }
.panel, .pool-card { border: 2px solid var(--line); }
.metric { border-top: 5px solid var(--accent); padding: 1.4rem; }
.metric strong, .pool-temperature { letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.pool-card { background: var(--surface); border-top: 5px solid var(--accent); }
.pool-card h2 { letter-spacing: -.035em; }
.badge { border: 1px solid currentColor; }
.chart-periods button[aria-pressed="true"] { background: var(--text); color: white; }
.chart-periods button[aria-pressed="false"] { background: var(--surface); color: var(--text); }
.chart-statistics > div, .chart-tooltip { border: 1px solid #d3d8da; }
.local-banner { border: 2px solid var(--accent-dark); }
.demo-banner { border-color: var(--warn); }
.auth-page {
  background: var(--surface) url('./aqualama-pattern.svg') center / cover;
  padding: clamp(1rem, 4vw, 3rem); align-content: center; gap: 1.5rem;
}
.auth-page:has(.local-banner) { display: grid; }
.auth-shell { border: 2px solid var(--text); border-top: 8px solid var(--accent); background: white; }
.auth-frame { display: grid; grid-template-columns: .95fr 1.05fr; gap: 2.5rem; padding: clamp(1.5rem, 5vw, 3.5rem); }
.auth-intro h1 { margin: 1rem 0; font-size: clamp(2.4rem, 5vw, 3.8rem); text-transform: uppercase; letter-spacing: -.065em; line-height: 1; overflow-wrap: anywhere; }
.auth-intro p { line-height: 1.6; }
.auth-intro .eyebrow { margin-top: 1.5rem; }
.auth-frame .login-panel { border: 0; padding: 0; align-content: start; gap: 1.4rem; }
.auth-form-heading { padding: .8rem 1rem; background: var(--text); color: white; margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.login-panel label { color: var(--text); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.login-panel input { min-height: 3rem; border: 2px solid var(--line); }
.auth-frame button { min-height: 3.25rem; }
@media (max-width: 760px) {
  .auth-frame { grid-template-columns: minmax(0, 1fr); gap: 1.8rem; }
  .auth-intro h1 { font-size: 2.6rem; }
  .brand-mark { flex-wrap: wrap; gap: .4rem; }
  .topbar-actions { gap: .85rem; }
}
