.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}
body { line-height: 1.5; }

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}
header h1 span {
  color: var(--accent);
}
.meta-info {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.meta-info .value {
  color: var(--text);
  font-weight: 500;
}

/* Alerts */
.alerts {
  margin-bottom: 1.5rem;
}
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  border-left: 4px solid;
}
.alert-warning {
  background: rgba(255, 167, 38, 0.1);
  border-color: var(--yellow);
}
.alert-info {
  background: rgba(66, 165, 245, 0.1);
  border-color: var(--blue);
}

/* Network diagram */
.network-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  justify-content: space-evenly;
}
.net-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  transition: background 0.2s;
  gap: 0.15rem;
}
.net-node:hover {
  background: rgba(79, 195, 247, 0.1);
}
.net-node.active {
  background: rgba(79, 195, 247, 0.15);
}
.net-trend {
  font-size: 0.85rem;
  line-height: 1;
  background: none !important;
}
.net-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}
.net-river {
  font-size: 0.6rem;
  color: #888;
  text-align: center;
  white-space: nowrap;
}
.net-height {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

/* Station grid */
.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1rem;
}
.station-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem;
  transition: border-color 0.2s;
  display: flex;
  flex-direction: column;
}
.station-card:hover {
  border-color: var(--accent);
}
.station-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.station-title {
  font-size: 1.1rem;
  font-weight: 600;
}
.station-meta {
  font-size: 0.75rem;
  font-weight: 400;
  color: #888;
}
.station-current {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.current-height {
  font-size: 2rem;
  font-weight: 700;
}
.current-unit {
  font-size: 1rem;
  color: var(--muted);
}
.current-age {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Trend */
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.8rem;
}
.trend-up {
  background: rgba(239, 83, 80, 0.15);
  color: var(--red);
}
.trend-down {
  background: rgba(66, 187, 106, 0.15);
  color: var(--green);
}
.trend-stable {
  background: rgba(79, 195, 247, 0.18);
  color: var(--accent);
}
.trend-unknown {
  background: rgba(122, 138, 154, 0.1);
  color: var(--muted);
}

/* Forecast table */
.forecast-table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
  margin-bottom: 0.8rem;
}
.forecast-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.forecast-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(42, 58, 74, 0.5);
}
.confidence-high {
  color: var(--green);
}
.confidence-medium {
  color: var(--yellow);
}
.confidence-low {
  color: var(--red);
}
.confidence-very_low {
  color: var(--red);
  opacity: 0.6;
}

/* Chart */
.chart-container {
  height: 120px;
  position: relative;
  margin-top: 0.5rem;
}
canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Propagation info */
.prop-info {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Quality bar */
.quality-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  margin-top: 0.3rem;
}
.quality-fill {
  height: 4px;
  border-radius: 2px;
  flex: 1;
  background: var(--border);
  overflow: hidden;
}
.quality-fill-inner {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}
.quality-label {
  font-size: 0.7rem;
  color: var(--muted);
  min-width: 2rem;
}

/* Refresh bar */
.refresh-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  font-size: 0.8rem;
}
.refresh-left,
.refresh-right {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  white-space: nowrap;
}
.refresh-left {
  align-items: flex-start;
}
.refresh-right {
  align-items: flex-end;
  text-align: right;
}
.refresh-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.refresh-value {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.refresh-countdown {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}
.refresh-countdown.imminent {
  color: var(--green);
  animation: pulse-text 1s ease-in-out infinite;
}
@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.refresh-center {
  flex: 1;
  padding: 0 0.5rem;
}
.refresh-progress-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.refresh-progress {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 1s linear;
}
.refresh-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.85rem;
}
.refresh-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.refresh-status.connected::before {
  background: var(--green);
}
.refresh-status.disconnected::before {
  background: var(--red);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translateX(120%);
  opacity: 0;
  animation: toast-in 0.4s ease-out forwards;
  pointer-events: auto;
  max-width: 340px;
}
.toast.toast-out {
  animation: toast-out 0.3s ease-in forwards;
}
.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.toast-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.toast-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.toast-message {
  font-size: 0.75rem;
  color: var(--muted);
}
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 10px 10px;
  animation: toast-progress-shrink linear forwards;
}
@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}
@keyframes toast-progress-shrink {
  from { width: 100%; }
  to { width: 0%; }
}

/* Footer */
.footer-disclaimer {
  margin-bottom: 0.5rem;
}
.footer-links {
  margin-bottom: 0.5rem;
}
.footer-credits {
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

/* Tidal notice */
.tidal-notice {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  padding: 0.5rem;
  background: rgba(122, 138, 154, 0.1);
  border-radius: 6px;
  margin-top: 0.5rem;
}

/* Loading / Error */
.loading {
  text-align: center;
  padding: 4rem;
  color: var(--muted);
  font-size: 1.1rem;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Topology */
.topology-section {
  margin-top: 2rem;
}
.topology-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.8rem;
}
.topology-flow {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem 0.5rem;
}
.topo-row {
  display: flex;
  align-items: center;
}
.topo-side {
  flex: 1;
  min-height: 1px;
}
.topo-side.left {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.topo-side.right {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.topo-branch {
  color: var(--muted);
  font-family: monospace;
  font-size: 0.85rem;
  gap: 0.3rem;
  white-space: nowrap;
}
.topo-center {
  width: auto;
  display: flex;
  justify-content: center;
  padding: 0 0.5rem;
}
.topo-node {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}
.topo-node.garonne {
  background: rgba(79, 195, 247, 0.12);
  color: var(--accent);
  border: 1px solid rgba(79, 195, 247, 0.25);
}
.topo-node.affluent {
  background: rgba(255, 167, 38, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(255, 167, 38, 0.25);
}
.topo-arrow {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}

/* Responsive */
@media (max-width: 600px) {
  .station-grid {
    grid-template-columns: 1fr;
  }
  .meta-info {
    flex-direction: column;
    gap: 0.3rem;
  }
  .current-height {
    font-size: 1.5rem;
  }
}
