/* pws-watch: dashboard base layout and controls. */

:root {
  color-scheme: light;
  --ink: #1d252c;
  --muted: #66727f;
  --line: #d9dee3;
  --panel: #ffffff;
  --surface: #f5f7f8;
  --blue: #2f80ed;
  --green: #16805d;
  --amber: #f5a524;
  --red: #e5484d;
  --shadow: 0 10px 24px rgba(29, 37, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(115deg, rgba(15, 122, 90, 0.1), transparent 28%),
    linear-gradient(245deg, rgba(39, 100, 201, 0.1), transparent 32%),
    linear-gradient(90deg, rgba(23, 32, 42, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(23, 32, 42, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, #f4f7f4 0%, #e8f0f2 43%, #f6f1e9 100%);
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

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

.brand-mark {
  width: clamp(44px, 6vw, 58px);
  height: clamp(44px, 6vw, 58px);
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow:
    0 12px 24px rgba(23, 32, 42, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.brand-copy {
  min-width: 0;
}

.subhead {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button,
.primary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.icon-button {
  width: 40px;
  display: inline-grid;
  place-items: center;
}

.primary-button {
  padding: 0 14px;
  background: linear-gradient(135deg, #17202a, #0f5f70);
  color: white;
  border-color: var(--ink);
}

.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(23, 32, 42, 0.14);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.primary-button.icon-only {
  min-width: 42px;
  width: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.primary-button.icon-only svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.settings {
  display: grid;
  grid-template-columns:
    minmax(210px, 1.25fr)
    minmax(130px, 0.65fr)
    minmax(320px, 1.45fr);
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label,
.tracking-setting,
.email-setting {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.setting-label-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.email-setting.collapsed {
  align-content: center;
}

.email-setting.collapsed .email-options-body {
  display: none;
}

.email-options-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--panel-strong);
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
}

.email-options-toggle:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.email-options-toggle .icon {
  width: 13px;
  height: 13px;
  transition: transform 160ms ease;
}

.email-setting:not(.collapsed) .email-options-toggle .icon {
  transform: rotate(180deg);
}

.setting-note {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: none;
}

.setting-help {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: help;
}

.setting-help .icon {
  width: 12px;
  height: 12px;
}

.email-control-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(142px, auto);
  gap: 8px;
  align-items: stretch;
}

.email-options-body {
  display: grid;
  gap: 6px;
}

.email-alert-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-sizing: border-box;
  height: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
}

.email-alert-toggle .setting-help {
  width: 16px;
  height: 16px;
  border: 0;
}

.email-alert-note {
  margin-top: -2px;
}

.email-alert-toggle input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--cyan, #007e9a);
}

input,
select {
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-transform: none;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--cyan, #007e9a);
}

.tracking-copy {
  display: grid;
  align-items: center;
  min-height: 38px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  text-transform: none;
}

.provider-setting {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.provider-info-button {
  box-sizing: border-box;
  display: inline-grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  text-align: left;
}

.provider-info-button .icon {
  width: 16px;
  height: 16px;
}

.provider-popover {
  position: absolute;
  box-sizing: border-box;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 40px));
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(23, 32, 42, 0.18);
}

.provider-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: var(--panel);
  transform: rotate(45deg);
}

.provider-card .provider-popover {
  position: static;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  overflow: hidden;
  box-shadow: none;
}

.provider-card .provider-popover::before {
  display: none;
}

.provider-popover-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.provider-popover-head strong {
  font-size: 14px;
}

.provider-popover-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.provider-tabs {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.provider-tabs button {
  display: inline-flex;
  flex: 1 1 150px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  min-width: 0;
  max-width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.provider-tabs button.active {
  background: rgba(0, 147, 168, 0.14);
  color: var(--ink);
}

.provider-tabs button.provider-active {
  color: var(--ink);
}

.provider-tabs button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-tab-active-mark {
  position: relative;
  width: 18px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(22, 128, 93, 0.9);
}

.provider-tab-active-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.provider-tab-panel {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: none;
  overflow: visible;
  padding-top: 12px;
}

.provider-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.provider-item {
  box-sizing: border-box;
  display: grid;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.provider-item-active {
  border-color: rgba(22, 128, 93, 0.28);
  box-shadow: inset 3px 0 0 rgba(22, 128, 93, 0.38);
}

.provider-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.provider-item strong {
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.provider-badge {
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.provider-badge-active {
  background: rgba(22, 128, 93, 0.9);
  color: #fff;
}

.provider-badge-inactive {
  background: rgba(102, 114, 127, 0.16);
  color: var(--muted);
}

.provider-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.provider-capabilities {
  color: var(--ink) !important;
  font-weight: 850;
}

.provider-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.provider-meta span {
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 7px;
  background: rgba(102, 114, 127, 0.12);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.notice {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue);
  font-size: 14px;
  font-weight: 800;
}

.notice.visible {
  display: block;
}

.notice.error {
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(180, 35, 24, 0.08);
  color: var(--red);
}

.notice.ok {
  border-color: rgba(22, 128, 93, 0.25);
  background: rgba(22, 128, 93, 0.08);
  color: var(--green);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.4fr);
  gap: 22px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#currentPanel {
  padding: 18px;
  min-height: 300px;
  display: grid;
  align-content: space-between;
  gap: 18px;
}

.current-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.station {
  min-width: 0;
}

.station-name {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.freshness {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.freshness.fresh {
  color: var(--green);
  border-color: rgba(22, 128, 93, 0.35);
  background: rgba(22, 128, 93, 0.08);
}

.freshness.stale {
  color: var(--amber);
  border-color: rgba(161, 92, 7, 0.35);
  background: rgba(161, 92, 7, 0.08);
}

.freshness.expired,
.freshness.unavailable {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.35);
  background: rgba(180, 35, 24, 0.08);
}

.temp {
  font-size: clamp(70px, 13vw, 120px);
  font-weight: 850;
  line-height: 0.9;
}

.temp small {
  font-size: 28px;
  vertical-align: super;
}

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

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

.metric-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 800;
}

.chart-panel {
  min-height: 300px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chart-head > div:first-child {
  flex: 1 1 280px;
  min-width: 0;
}

.chart-title {
  font-size: 16px;
  font-weight: 850;
}

.segments {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 460px;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segments button {
  min-width: 54px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.segments button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(29, 37, 44, 0.1);
}

canvas {
  width: 100%;
  height: 100%;
  min-height: 230px;
}

.lower-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-top: 28px;
}

.spatial-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 28px;
}

.map-panel {
  min-height: 390px;
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.map-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.map-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-actions {
  display: flex;
  gap: 8px;
}

.map-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.map-button.active {
  border-color: rgba(39, 100, 201, 0.32);
  background: rgba(39, 100, 201, 0.12);
  color: var(--blue);
}

.map-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(23, 32, 42, 0.12);
}

.station-map {
  min-height: 310px;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 42, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(23, 32, 42, 0.035) 1px, transparent 1px),
    #e7eeed;
  background-size: 32px 32px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.45),
    0 14px 28px rgba(23, 32, 42, 0.08);
}

.leaflet-container {
  font: inherit;
  background: #e7eeed;
}

.leaflet-control-attribution {
  font-size: 10px;
  font-weight: 700;
}

.range-ring-label {
  pointer-events: none;
  border: 1px solid rgba(15, 95, 112, 0.28);
  border-radius: 999px;
  background: rgba(247, 252, 253, 0.92);
  color: #0f5f70;
  box-shadow: 0 8px 16px rgba(23, 32, 42, 0.12);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.leaflet-tooltip.range-ring-label::before {
  display: none;
}

.mini-panel {
  padding: 14px;
  min-height: 190px;
}

.mini-title {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 850;
}

.facts {
  display: grid;
  gap: 9px;
}

.fact {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.fact span:first-child {
  color: var(--muted);
}

.fact span:last-child {
  font-weight: 800;
  text-align: right;
}

.status-line {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.status-line.error {
  color: var(--red);
  font-weight: 800;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.page-footer span:last-child {
  font-weight: 800;
  text-align: right;
}

.empty {
  display: grid;
  min-height: 230px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  header,
  .hero-grid,
  .lower-grid,
  .settings {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

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

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

  .segments {
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
  }

  .page-footer {
    display: grid;
  }
}
