:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --bg-app: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.96);
  --bg-surface-solid: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #e2e8f0;
  --bg-hover: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);

  --accent: #0f766e;
  --accent-strong: #0d9488;
  --accent-soft: rgba(15, 118, 110, 0.1);

  --col-available: #059669;
  --col-available-bright: #10b981;
  --col-saturated: #dc2626;
  --col-unknown: #64748b;
  --col-increased: #0d9488;
  --col-decreased: #d97706;
  --col-occupied: #3b82f6;
  --col-pending: #f59e0b;
  --col-transmission: #1e293b;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.18);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-w: 356px;
}

html[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: rgba(15, 23, 42, 0.94);
  --bg-surface-solid: #0f172a;
  --bg-subtle: #1e293b;
  --bg-muted: #334155;
  --bg-hover: #1e293b;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);

  --accent: #14b8a6;
  --accent-strong: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.15);

  --col-available: #10b981;
  --col-available-bright: #34d399;
  --col-saturated: #f87171;
  --col-unknown: #94a3b8;
  --col-increased: #2dd4bf;
  --col-decreased: #fbbf24;
  --col-occupied: #60a5fa;
  --col-pending: #fbbf24;
  --col-transmission: #f8fafc;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.6);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  width: 100vw;
  height: 100dvh;
  position: relative;
}

/* Mobile Header */
.mobile-header {
  display: none;
}

.mobile-only {
  display: none;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100%;
  background: var(--bg-surface-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  gap: 9px;
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-header-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

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

.brand-logo {
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.header-pill-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Share & Export Action Bar */
.action-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.action-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.action-btn.copied {
  border-color: var(--col-available);
  color: var(--col-available);
  background: rgba(5, 150, 105, 0.08);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.theme-icon::before {
  content: "☾";
  font-size: 14px;
  line-height: 1;
}

html[data-theme="dark"] .theme-icon::before {
  content: "☀";
}

.sidebar-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.kpi-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Control Blocks */
.control-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.control-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.meta-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.mt-8 {
  margin-top: 4px;
}

/* Segmented Controls */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
  white-space: nowrap;
}

.segmented-compact .seg-btn {
  padding: 6px 8px;
}

.segmented-xs .seg-btn {
  font-size: 11px;
  padding: 5px 6px;
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .seg-btn.active {
  background: var(--accent);
  color: #042f2e;
}

/* Search */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.text-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 28px 8px 31px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
}

.search-clear:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
}

.search-result-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-sans);
}

.search-result-item:hover {
  background: var(--bg-hover);
}

.search-result-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.search-result-title {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Filter Rows */
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

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

.num-input {
  width: 76px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.range-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 2px 0;
}

/* Diff Status Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.14s ease;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.chip.active {
  background: var(--text-primary);
  color: var(--bg-surface-solid);
  border-color: transparent;
}

.chip-opened.active {
  background: #16a34a;
  color: #ffffff;
}

.chip-increased.active {
  background: #0d9488;
  color: #ffffff;
}

.chip-decreased.active {
  background: #d97706;
  color: #ffffff;
}

.chip-saturated.active {
  background: #dc2626;
  color: #ffffff;
}

/* Operator Checklist */
.operator-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 8px;
  max-height: 158px;
  overflow-y: auto;
}

.op-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 5px;
}

.op-item:hover {
  background: var(--bg-hover);
}

.op-item-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.op-item input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.op-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.op-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.muted-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Movers list */
.mini-tabs {
  display: inline-flex;
  gap: 4px;
}

.mini-tab {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
}

.mini-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.movers-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mover-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.mover-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.mover-info {
  min-width: 0;
}

.mover-name {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mover-sub {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mover-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.delta-pos {
  color: var(--col-available);
}

.delta-neg {
  color: var(--col-saturated);
}

/* Footer */
.sidebar-footer {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.footer-note {
  margin: 0 0 6px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Map Stage */
.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
}

.map-canvas {
  width: 100%;
  height: 100%;
}

/* Floating Quick-Jump Toolbar */
.map-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.region-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.region-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.region-btn.active,
.region-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 30px;
  left: 14px;
  z-index: 10;
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-md);
  min-width: 204px;
  font-size: 11.5px;
}

.legend-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 7px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15);
}

.legend-swatch-tx {
  width: 13px;
  height: 13px;
  background: transparent;
  border: 2.5px solid var(--col-transmission);
  box-shadow: 0 0 0 1.5px var(--bg-surface-solid);
}

.legend-line-swatch {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-line-swatch-220 {
  height: 2px;
}

.legend-line-swatch-subtx {
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    currentColor 0,
    currentColor 5px,
    transparent 5px,
    transparent 8px
  );
}

.legend-swatch-tender {
  width: 13px;
  height: 13px;
  background: rgba(245, 158, 11, 0.18);
  border: 2.5px solid #d97706;
  box-shadow: 0 0 0 1.5px var(--bg-surface-solid);
}

html[data-theme="dark"] .legend-swatch-tender {
  border-color: #fbbf24;
}

.legend-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Status Overlay (Missing data / error) */
.status-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.status-overlay[hidden] {
  display: none;
}

.status-card {
  max-width: 520px;
  width: 100%;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
}

.status-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.status-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.status-card p {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.code-snippet {
  margin: 0 0 16px;
  padding: 11px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-x: auto;
  color: var(--text-primary);
}

.primary-btn {
  border: 0;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

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

/* Node Detail Drawer */
.detail-drawer {
  position: absolute;
  top: 14px;
  right: 54px;
  width: 360px;
  max-height: calc(100% - 28px);
  z-index: 15;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-drawer[hidden] {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.badge-tx {
  background: rgba(30, 41, 59, 0.1);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.badge-kv {
  font-family: var(--font-mono);
}

.badge-opened {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.3);
}

.badge-increased {
  background: rgba(13, 148, 136, 0.14);
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.3);
}

.badge-decreased {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.3);
}

.badge-saturated {
  background: rgba(220, 38, 38, 0.14);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.3);
}

.badge-tender {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.35);
}

html[data-theme="dark"] .badge-opened { color: #4ade80; }
html[data-theme="dark"] .badge-increased { color: #2dd4bf; }
html[data-theme="dark"] .badge-decreased { color: #fbbf24; }
html[data-theme="dark"] .badge-saturated { color: #f87171; }
html[data-theme="dark"] .badge-tender { color: #fbbf24; }

.drawer-content {
  padding: 14px 16px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.drawer-id {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.capacity-hero {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.capacity-hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.hero-number {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.hero-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}

.status-available {
  background: rgba(5, 150, 105, 0.14);
  color: var(--col-available);
}

.status-saturated {
  background: rgba(220, 38, 38, 0.14);
  color: var(--col-saturated);
}

.status-unknown {
  background: rgba(100, 116, 139, 0.16);
  color: var(--col-unknown);
}

.stacked-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
  display: flex;
}

.bar-seg {
  height: 100%;
  transition: width 0.25s ease;
}

.bar-avail { background: var(--col-available-bright); }
.bar-occ { background: var(--col-occupied); }
.bar-pend { background: var(--col-pending); }

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

.cap-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cap-stat-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-avail { background: var(--col-available-bright); }
.dot-occ { background: var(--col-occupied); }
.dot-pend { background: var(--col-pending); }

.cap-stat-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.diff-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12px;
}

.diff-callout strong {
  font-family: var(--font-mono);
}

.meta-table {
  margin: 0;
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 7px 10px;
  font-size: 12px;
}

.meta-table dt {
  color: var(--text-muted);
  font-weight: 500;
}

.meta-table dd {
  margin: 0;
  color: var(--text-primary);
  word-break: break-word;
}

.unit-note {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.source-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.source-link-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  color: var(--accent);
}

/* Monthly History Sparkline Card */
.sparkline-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sparkline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sparkline-title-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.sparkline-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.sparkline-count {
  font-size: 10.5px;
  color: var(--text-muted);
}

.sparkline-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.sparkline-delta.delta-pos {
  background: rgba(5, 150, 105, 0.14);
  color: var(--col-available);
}

.sparkline-delta.delta-neg {
  background: rgba(220, 38, 38, 0.14);
  color: var(--col-saturated);
}

.sparkline-delta.delta-flat {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.sparkline-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.sparkline-guide {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.sparkline-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-dot {
  stroke: var(--bg-subtle);
  stroke-width: 1.5;
  transition: r 0.12s ease;
}

.sparkline-axis {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.sparkline-range {
  text-align: center;
  color: var(--text-secondary);
}

.sparkline-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 10px 12px;
}

/* Methodology Modal (<dialog>) */
.methodology-dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  max-width: min(760px, calc(100vw - 24px));
  width: 100%;
  max-height: calc(100dvh - 32px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

.methodology-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.modal-shell {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-header .status-badge {
  margin-bottom: 5px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-section h3 {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.modal-section p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.modal-lead {
  margin-bottom: 10px !important;
}

.modal-section code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-primary);
}

.modal-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.modal-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.modal-table th,
.modal-table td {
  padding: 7px 9px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.modal-table th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-surface-solid);
}

.modal-table tbody tr:last-child td {
  border-bottom: 0;
}

.modal-table td.num,
.modal-table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.modal-links {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.modal-link-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.modal-link-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.modal-link-card strong {
  font-size: 12px;
  font-weight: 600;
}

.modal-link-card span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .modal-links {
    grid-template-columns: 1fr;
  }
}

/* MapLibre Hover Popup */
.maplibregl-popup-content {
  background: var(--bg-surface-solid) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md) !important;
  padding: 8px 10px !important;
  box-shadow: var(--shadow-md) !important;
  font-family: var(--font-sans);
  font-size: 12px;
  pointer-events: none;
}

.maplibregl-popup-tip {
  display: none;
}

.popup-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.popup-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.popup-metric {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
}

.sidebar-backdrop {
  display: none;
}

/* Mobile & Tablet Responsive Layout */
@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 12px;
    background: var(--bg-surface-solid);
    border-bottom: 1px solid var(--border);
    z-index: 30;
    flex-shrink: 0;
  }

  .brand-compact {
    display: flex;
    align-items: center;
    gap: 7px;
  }

  .brand-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
  }

  .brand-name {
    font-weight: 700;
    font-size: 14.5px;
  }

  .brand-domain {
    font-size: 11px;
    color: var(--text-muted);
  }

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 88vw);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    z-index: 40;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .map-stage {
    height: calc(100dvh - 48px);
  }

  .map-toolbar {
    top: 10px;
    left: 10px;
    right: 52px;
    overflow-x: auto;
    max-width: calc(100% - 62px);
  }

  .map-legend {
    bottom: 24px;
    left: 10px;
    padding: 8px 10px;
    min-width: 170px;
    font-size: 10.5px;
  }

  .detail-drawer {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    max-height: 62dvh;
  }

  .finder-pick-banner {
    top: 58px;
    max-width: calc(100vw - 24px);
    font-size: 11.5px;
  }
}

@media (max-width: 520px) {
  .brand-domain {
    display: none;
  }
}

/* ── Language Switcher (EN | ES | PT) ──────────────────────────────────────── */

.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.1;
  transition: background 0.14s ease, color 0.14s ease;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--accent);
  color: #ffffff;
}

html[data-theme="dark"] .lang-btn.active {
  color: #042f2e;
}

.lang-switcher-compact .lang-btn {
  padding: 4px 5px;
  font-size: 10px;
}

/* ── Sidebar Views & 3-Column Action Bar ──────────────────────────────────── */

.sidebar-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-view[hidden] {
  display: none;
}

.action-bar-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.action-bar-3 .action-btn {
  padding: 7px 6px;
  font-size: 11.5px;
  gap: 4px;
  white-space: nowrap;
}

/* ── Proximity Finder CTA & Panel ─────────────────────────────────────────── */

.finder-cta-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 118, 110, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.finder-cta-btn:hover {
  background: rgba(15, 118, 110, 0.16);
  border-color: var(--accent);
}

html[data-theme="dark"] .finder-cta-btn {
  border-color: rgba(20, 184, 166, 0.38);
}

html[data-theme="dark"] .finder-cta-btn:hover {
  background: rgba(20, 184, 166, 0.24);
}

.finder-cta-btn span {
  flex: 1;
  text-align: left;
}

.finder-cta-arrow {
  flex-shrink: 0;
  opacity: 0.85;
}

.finder-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.finder-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.finder-heading-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.finder-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.finder-subtitle {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.finder-coords-input {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.finder-loc-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.finder-loc-actions .action-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

html[data-theme="dark"] .finder-loc-actions .action-btn[aria-pressed="true"] {
  color: #042f2e;
}

.finder-loc-msg {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--col-saturated);
}

.finder-loc-msg.info {
  color: var(--text-muted);
}

.finder-csv-btn {
  width: 100%;
}

.finder-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.finder-result-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.finder-result-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.finder-result-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.finder-result-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.finder-result-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.finder-result-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.finder-result-cap {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--col-available);
}

.finder-result-dist {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.finder-empty-state {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 10px 11px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: var(--bg-subtle);
}

/* Floating Pick-on-Map Banner */
.finder-pick-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

.finder-pick-banner[hidden] {
  display: none;
}

.finder-pick-cancel {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.finder-pick-cancel:hover {
  background: rgba(255, 255, 255, 0.25);
}

.map-canvas.picking-mode,
.map-canvas.picking-mode .maplibregl-canvas {
  cursor: crosshair !important;
}

/* ── Editorial Cross-Links ────────────────────────────────────────────────── */

.footer-editorial-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.footer-editorial-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.footer-editorial-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.footer-editorial-links a:hover {
  text-decoration: underline;
}

.modal-links-editorial {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .modal-links-editorial {
    grid-template-columns: 1fr;
  }
}

/* ── Embed Modal ──────────────────────────────────────────────────────────── */

.embed-dialog {
  max-width: min(560px, calc(100vw - 24px));
}

.embed-height-seg {
  margin-top: 6px;
}

.embed-code-area {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.embed-code-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.embed-modal-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.embed-preview-link {
  text-decoration: none;
}

/* ── Embed Press Widget Mode (/embed/) ────────────────────────────────────── */

.embed-shell {
  width: 100vw;
  height: 100dvh;
}

.embed-stage {
  width: 100%;
  height: 100% !important;
}

.embed-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  max-width: calc(100% - 64px);
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.embed-badge .brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.embed-bottom-left {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 130px);
}

.embed-legend {
  position: static !important;
  min-width: 0 !important;
  padding: 6px 10px !important;
  font-size: 11px !important;
}

.embed-legend .legend-items {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.embed-legend .legend-title {
  display: none;
}

.embed-attribution-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.embed-attribution-link:hover {
  background: var(--bg-surface-solid);
  border-color: var(--accent);
  text-decoration: underline;
}

.embed-drawer {
  top: 10px;
  right: 48px;
  width: min(330px, calc(100vw - 60px));
  max-height: calc(100% - 20px);
}

@media (max-width: 640px) {
  .embed-drawer {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: 62dvh;
  }
}

/* ── Subscriber Alerts (Header Pill, Drawer Card & Native Modal) ──────────── */

.header-sub-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.header-pill-accent {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.header-pill-accent:hover {
  background: rgba(15, 118, 110, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}

html[data-theme="dark"] .header-pill-accent {
  border-color: rgba(20, 184, 166, 0.38);
}

html[data-theme="dark"] .header-pill-accent:hover {
  background: rgba(20, 184, 166, 0.24);
}

/* Inline Contextual Alert Card in Detail Drawer */
.drawer-alert-card {
  background: var(--bg-subtle);
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

html[data-theme="dark"] .drawer-alert-card {
  border-color: rgba(20, 184, 166, 0.32);
}

.drawer-alert-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
}

.drawer-alert-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.drawer-alert-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.drawer-alert-sub {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

.drawer-alert-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
}

.drawer-alert-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.drawer-alert-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font-size: 12px;
  background: var(--bg-surface-solid);
}

.drawer-alert-btn {
  flex: 0 0 auto;
  padding: 7px 11px;
  font-size: 11.5px;
  white-space: nowrap;
}

.drawer-alert-btn:disabled,
.alerts-submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Alerts Modal (<dialog id="alerts-dialog">) */
.alerts-dialog {
  max-width: min(500px, calc(100vw - 24px));
}

.alerts-modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alerts-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.alerts-input {
  padding: 8px 11px;
  font-size: 13px;
}

.alerts-field-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

.alerts-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.alerts-input-row .alerts-input {
  flex: 1 1 auto;
  min-width: 0;
}

.alerts-submit-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  white-space: nowrap;
}

.alert-status {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  min-height: 0;
}

.alert-status:empty {
  margin: 0;
  padding: 0;
  min-height: 0;
}

.alert-status.is-sending {
  color: var(--text-muted);
}

.alert-status.is-success {
  color: var(--col-available);
  font-weight: 600;
}

.alert-status.is-error {
  color: var(--col-saturated);
  font-weight: 500;
}

.alert-status a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.alerts-modal-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.alerts-privacy-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
}

.alerts-rss-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.alerts-rss-link:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .alerts-input-row,
  .drawer-alert-row {
    flex-direction: column;
  }

  .alerts-submit-btn,
  .drawer-alert-btn {
    width: 100%;
  }

  .mobile-header-actions {
    gap: 4px;
  }
}
