:root {
  --bg: #061325;
  --bg-elevated: #0b1c34;
  --bg-card: rgba(14, 31, 56, 0.88);
  --bg-card-hover: rgba(19, 41, 74, 0.94);
  --bg-soft: rgba(56, 189, 248, 0.08);
  --border: rgba(148, 189, 232, 0.16);
  --border-strong: rgba(56, 189, 248, 0.38);

  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --cyan: #38bdf8;
  --cyan-strong: #0ea5e9;
  --teal: #2dd4bf;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --gold: #fcd34d;
  --silver: #cbd5e1;
  --bronze: #fdba74;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.65);
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(14, 165, 233, 0.18), transparent 60%),
    radial-gradient(800px 450px at 85% 5%, rgba(45, 212, 191, 0.12), transparent 60%),
    radial-gradient(700px 500px at 50% 100%, rgba(14, 165, 233, 0.08), transparent 70%);
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(6, 19, 37, 0.85);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.header-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-badge.is-stale {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--amber);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse 2s infinite;
}

.live-badge.is-stale .live-dot {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.comp-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.comp-title {
  margin: 0;
  font-size: clamp(1.22rem, 2.4vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.swimmer-strip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.swimmer-trigger {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 10px 6px 6px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  width: fit-content;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.swimmer-trigger:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--border-strong);
}

.strip-edit-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
}

.swimmer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan-strong), var(--teal));
  color: #031528;
  font-weight: 800;
  font-size: 0.82rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.swimmer-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.swimmer-info strong {
  font-size: 0.95rem;
  color: #fff;
}

.swimmer-info span {
  font-size: 0.82rem;
  color: var(--cyan);
  font-weight: 600;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sync-box {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sync-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-line strong {
  color: var(--text);
}

.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(14, 165, 233, 0.6);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--border-strong);
}

.icon-spin,
.icon-sm {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.is-spinning {
  animation: spin 0.8s linear infinite;
}

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

/* Main */
.main-content {
  padding-top: 22px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Alert Banners */
.alert-banner {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.86rem;
  border: 1px solid;
}

.alert-warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

.alert-info {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.changes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--cyan);
}

.changes-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Spotlight */
.spotlight {
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.17), rgba(11, 28, 52, 0.95) 62%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.spotlight-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spotlight-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
}

.spotlight-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  font-weight: 800;
  color: #fff;
}

.spotlight-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(6, 19, 37, 0.65);
  border: 1px solid var(--border);
  color: var(--text);
}

.chip-accent {
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}

.spotlight-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.countdown-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.countdown-value {
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  font-weight: 700;
  color: var(--teal);
}

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

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.pill.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--cyan);
  color: var(--cyan);
}

.legend-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-upcoming { background: var(--cyan); }
.dot-live { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dot-finished { background: var(--emerald); }

/* Sessions & Race Cards */
.races-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.session-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.session-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.race-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.race-card:hover {
  border-color: rgba(56, 189, 248, 0.34);
}

.race-card.status-in_progress {
  border-color: rgba(251, 191, 36, 0.45);
}

.race-card.status-finished {
  border-color: rgba(52, 211, 153, 0.32);
}

.race-main {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) repeat(3, minmax(130px, 1fr)) auto;
  align-items: center;
  gap: 16px;
}

.race-ident {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.race-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill.upcoming {
  background: rgba(56, 189, 248, 0.14);
  color: var(--cyan);
}

.status-pill.in_progress {
  background: rgba(251, 191, 36, 0.16);
  color: var(--amber);
}

.status-pill.finished {
  background: rgba(52, 211, 153, 0.16);
  color: var(--emerald);
}

.time-pill {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 9px;
  border-radius: 6px;
}

.race-name {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: #fff;
}

.race-placement-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.slot-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
}

.slot-tag strong {
  color: var(--cyan);
}

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

.metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.18rem;
  font-weight: 700;
  color: #fff;
}

.metric-value.is-muted {
  color: var(--text-dim);
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  width: fit-content;
}

.delta-better {
  background: rgba(52, 211, 153, 0.16);
  color: var(--emerald);
}

.delta-slower {
  background: rgba(251, 113, 133, 0.15);
  color: var(--rose);
}

.delta-same {
  background: rgba(148, 163, 184, 0.15);
  color: var(--silver);
}

.rank-highlight {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.rank-num {
  font-size: 1.24rem;
  font-weight: 800;
}

.rank-1 { color: var(--gold); }
.rank-2 { color: var(--silver); }
.rank-3 { color: var(--bronze); }

.rank-gain {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
}

.rank-gain.up {
  background: rgba(52, 211, 153, 0.16);
  color: var(--emerald);
}

.rank-gain.down {
  background: rgba(251, 113, 133, 0.15);
  color: var(--rose);
}

.race-expand-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.race-expand-btn:hover {
  background: rgba(56, 189, 248, 0.14);
  border-color: var(--border-strong);
  color: var(--cyan);
}

.chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.race-card.is-open .chevron {
  transform: rotate(180deg);
}

/* Drawer */
.race-drawer {
  border-top: 1px solid var(--border);
  background: rgba(5, 14, 28, 0.72);
  padding: 16px 20px 20px;
}

.drawer-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.drawer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.drawer-tab.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--cyan);
  color: #fff;
}

.drawer-links {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
}

.drawer-links a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
}

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

/* Tables inside Drawer */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th {
  text-align: left;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(148, 189, 232, 0.08);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.is-target {
  background: rgba(56, 189, 248, 0.15);
}

.data-table tr.is-target td {
  color: #fff;
  font-weight: 700;
}

.lane-pill {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
  font-size: 0.8rem;
}

.is-target .lane-pill {
  background: var(--cyan);
  color: #031528;
}

.splits-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.split-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 0.78rem;
}

.split-chip span {
  color: var(--text-muted);
  margin-right: 4px;
}

/* Loading & Empty States */
.loading-state,
.empty-state {
  text-align: center;
  padding: 46px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 32px;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.footer-inner p {
  margin: 0;
}

.footer-inner a {
  color: var(--cyan);
  text-decoration: none;
}

/* Responsive */
@media (max-width: 960px) {
  .race-main {
    grid-template-columns: 1fr 1fr;
  }
  .race-ident {
    grid-column: 1 / -1;
  }
  .race-expand-btn {
    grid-column: 1 / -1;
    justify-content: center;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .header-main {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
  }
  .brand-row {
    flex-shrink: 0;
  }
  .comp-meta,
  .comp-title,
  .swimmer-avatar,
  .swimmer-info span,
  .strip-edit-tag,
  #liveBadgeText,
  .sync-box,
  #liveffnLink {
    display: none;
  }
  .live-badge {
    padding: 0;
    border: none;
    background: transparent;
  }
  .swimmer-trigger {
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }
  .swimmer-trigger:hover {
    background: transparent;
  }
  .swimmer-info {
    min-width: 0;
    overflow: hidden;
    flex-wrap: nowrap;
  }
  .swimmer-info strong {
    display: block;
    max-width: 100%;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-actions {
    width: auto;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
  }
  .btn-row {
    width: auto;
    gap: 6px;
  }
  #alertsBtn,
  #openSelectorBtn,
  #refreshBtn {
    width: 36px;
    height: 36px;
    padding: 0;
    flex: none;
  }
  #alertsBtn span:not(.alert-active-dot),
  #openSelectorBtn span,
  #refreshBtn span {
    display: none;
  }
  .main-content {
    padding-top: 14px;
  }
  .spotlight-right {
    align-items: flex-start;
    text-align: left;
  }
  .race-main {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 15px 16px;
  }
  .race-drawer {
    padding: 14px 14px 16px;
  }
}

/* Selector Modal */
body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 10, 22, 0.76);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-dialog {
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  background: #0a192f;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: rgba(14, 31, 56, 0.65);
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

.modal-subtitle {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.modal-close:hover {
  color: #fff;
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.1);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.recents-bar {
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.05);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.recents-label {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cyan);
}

.recents-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.recent-chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.recent-chip:hover {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.14);
}

.recent-chip.active {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.22);
  color: #fff;
}

.selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  min-height: 0;
  flex: 1;
}

.selector-col {
  background: #0a192f;
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.col-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.col-step {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--cyan-strong), var(--teal));
  color: #031528;
  font-weight: 800;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.col-head h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  color: #fff;
}

.col-count {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 999px;
}

.selected-comp-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 35px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(6, 19, 37, 0.85);
  color: #fff;
  font-family: inherit;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-box input:focus {
  border-color: var(--cyan);
}

.direct-id-btn {
  border: 1px dashed var(--cyan);
  background: rgba(56, 189, 248, 0.12);
  color: #e0f2fe;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.direct-id-btn:hover {
  background: rgba(56, 189, 248, 0.2);
}

.selector-list {
  flex: 1;
  overflow-y: auto;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 4px;
}

.selector-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(14, 31, 56, 0.65);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.selector-item:hover {
  border-color: var(--border-strong);
  background: rgba(19, 41, 74, 0.88);
}

.selector-item.active {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.15);
}

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

.selector-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.selector-item-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
  flex-shrink: 0;
}

.selector-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.list-status {
  text-align: center;
  padding: 28px 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

@media (max-width: 780px) {
  .modal-backdrop {
    padding: 10px;
  }
  .modal-dialog {
    max-height: 94vh;
  }
  .selector-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .selector-list {
    max-height: 28vh;
  }
}

/* Alerts Button & Modal */
#alertsBtn {
  position: relative;
}

.alert-active-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.modal-dialog.modal-sm {
  max-width: 480px;
}

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

.alert-status-box {
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.08);
  color: #bae6fd;
}

.alert-status-box.is-ok {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
  color: #a7f3d0;
}

.alert-status-box.is-warn {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(14, 31, 56, 0.65);
  cursor: pointer;
}

.toggle-row strong {
  display: block;
  font-size: 0.9rem;
  color: #fff;
}

.toggle-row span {
  display: block;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.toggle-input {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.3);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.toggle-input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.toggle-input:checked {
  background: var(--cyan-strong);
}

.toggle-input:checked::after {
  transform: translateX(20px);
}

.alerts-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alerts-note {
  margin: 0;
  font-size: 0.77rem;
  color: var(--text-dim);
  line-height: 1.45;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(9, 23, 44, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  animation: toastIn 0.22s ease-out;
}

.toast.toast-result {
  border-left-color: var(--emerald);
}

.toast.toast-soon {
  border-left-color: var(--amber);
}

.toast-body strong {
  display: block;
  font-size: 0.88rem;
  color: #fff;
  margin-bottom: 2px;
}

.toast-body p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast-close:hover {
  color: #fff;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}
