/* ============================================================================
 * Last War Tracker — Tactical Command Center theme
 * Retro-futurism / dark mode, optimized for data-dense game intelligence.
 * ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@600;700;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* Material Symbols Outlined — self-hosted variable font (whole catalogue
   in one file, no CDN dependency). Variable axes: opsz / wght / FILL / GRAD.
   font-display: block holds painting until the font is ready, so ligatures
   like content_copy / shield_lock / gpp_bad render correctly on first paint
   instead of showing the literal text fallback. */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 100 700;
  font-display: block;
  src: url('/static/fonts/MaterialSymbolsOutlined.woff2') format('woff2-variations'),
       url('/static/fonts/MaterialSymbolsOutlined.woff2') format('woff2');
}

/* --- Design tokens --- */
:root {
  /* Surfaces */
  --bg:           #020617;
  --bg-grid:      #0a1020;
  --surface:      #0f172a;
  --surface-2:    #131c33;
  --elevated:     #1a253f;
  --border:       #1f2a44;
  --border-soft:  #15203a;

  /* Text */
  --text:         #e6edf7;
  --text-muted:   #8b9bb8;
  --text-dim:     #5a6a85;

  /* Accents */
  --accent:       #22d39a;          /* primary success / active */
  --accent-glow:  rgba(34, 211, 154, 0.35);
  --primary:      #38bdf8;          /* cyan info */
  --primary-glow: rgba(56, 189, 248, 0.35);
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --danger-glow:  rgba(239, 68, 68, 0.35);
  --gold:         #fbbf24;
  --silver:       #d4d4d8;
  --bronze:       #b45309;

  /* Effects */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow-soft:  0 1px 0 rgba(255,255,255,0.04) inset, 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 0 1px var(--border), 0 0 24px rgba(34, 211, 154, 0.06);
}

/* --- Base --- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.005em;
}
body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(34, 211, 154, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 95% 90%, rgba(56, 189, 248, 0.04) 0%, transparent 35%),
    linear-gradient(180deg, #020617 0%, #050b1c 100%);
  min-height: 100vh;
}

/* Subtle CRT scanlines — very faint overlay */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0, transparent 2px, rgba(255,255,255,0.012) 2px, rgba(255,255,255,0.012) 3px);
  z-index: 1;
  mix-blend-mode: overlay;
}
@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
}

/* --- Topbar --- */
.app-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  background: linear-gradient(180deg, rgba(15,23,42,0.92) 0%, rgba(15,23,42,0.84) 100%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(34, 211, 154, 0.15);
}
.app-brand {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--text);
  display: flex; align-items: center; gap: 12px;
  text-transform: uppercase;
}
.app-brand .brand-mark {
  display: inline-block; width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--accent-glow), 0 0 0 4px rgba(34, 211, 154, 0.1);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%     { transform: scale(1.15); opacity: 0.7; }
}
.app-brand .brand-sub {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  margin-left: 4px;
}
.topbar-spacer { flex: 1; }
.topbar-meta { display: flex; align-items: center; gap: 14px; }
.kingdom-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
/* --- Kingdom combobox + scan banner --- */
.kingdom-combobox { position: relative; }
.kingdom-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 500;
  padding: 4px;
}
.kingdom-dropdown-item {
  display: block; width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  border-radius: 3px;
}
.kingdom-dropdown-item:hover { background: var(--border); }
.kingdom-dropdown-item .text-dim { font-size: 11px; }
.kingdom-dropdown-empty {
  padding: 14px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.kingdom-dropdown-empty .btn-scan-from-search {
  margin-top: 8px;
}

.scan-banner {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 12px;
  padding: 12px 16px;
}
.scan-banner-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.scan-banner-title { font-weight: 600; font-size: 14px; }
.scan-banner-progress {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}
.scan-banner.is-running .btn { opacity: 0.6; cursor: progress; }

/* Onboarding banner — shown until config/local.json is wired up. */
.onboarding-banner {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-left: 4px solid #f5a524;
  background: rgba(245, 165, 36, 0.06);
}
.onboarding-banner-icon {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  border-radius: 50%;
  background: #f5a524;
  color: #1a1a1a;
}
.onboarding-banner-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.onboarding-banner-title { font-weight: 600; font-size: 14px; }
.onboarding-banner-text { font-size: 13px; line-height: 1.5; }
.onboarding-banner-text code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}
.onboarding-banner-actions {
  display: flex; align-items: center; gap: 12px;
  margin-top: 4px;
}

/* --- Sortable table headers --- */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
}
.data-table th.sortable::after {
  content: "↕";
  position: absolute;
  right: 6px;
  opacity: 0.3;
  font-size: 10px;
}
.data-table th.sortable:hover { color: var(--accent); }
.data-table th.sortable.sort-asc::after  { content: "▲"; opacity: 1; color: var(--accent); }
.data-table th.sortable.sort-desc::after { content: "▼"; opacity: 1; color: var(--accent); }

/* --- Player row expand --- */
.btn-expand-row {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  padding: 0 4px;
  margin-right: 4px;
  border-radius: 3px;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s;
}
.btn-expand-row:hover { color: var(--accent); border-color: var(--border); }
.btn-expand-row.expanded { color: var(--accent); }

.player-detail-row > td {
  background: var(--bg);
  border-bottom: 1px solid var(--accent-glow, rgba(0,255,170,0.1));
  padding: 14px 18px !important;
}
.player-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 24px;
}
.player-detail-section {
  background: var(--bg-elev, rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.player-detail-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.player-detail-list {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
}
.player-detail-list dt {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.player-detail-list dd {
  margin: 0;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  word-break: break-all;
}

.kingdom-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  min-width: 280px;
  transition: border-color 150ms, box-shadow 150ms;
  cursor: pointer;
}
.kingdom-select:hover { border-color: var(--accent); }
.kingdom-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- User badge (topbar, post-login) --- */
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text, #e6edf3);
}
.user-tier {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
/* Role tier styling — distinct color per role for at-a-glance ID */
.user-tier-superadmin { background: rgba(248, 81, 73, 0.15); color: #f85149; border: 1px solid rgba(248, 81, 73, 0.4); }
.user-tier-vip        { background: rgba(253, 191, 25, 0.15); color: #fdbf19; border: 1px solid rgba(253, 191, 25, 0.4); }
.user-tier-user       { background: rgba(139, 148, 158, 0.15); color: #8b949e; border: 1px solid rgba(139, 148, 158, 0.4); }
.user-logout {
  background: transparent;
  border: none;
  color: var(--text-muted, #8b949e);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  font-weight: 700;
}
.user-logout:hover { color: var(--text, #e6edf3); }
/* Read-only mode for the User role: hide all action buttons */
body.role-user .action-only { display: none !important; }

/* --- Recipient chips (Fire-In-Chat multi-recipient picker) --- */
.recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 16px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text, #e6edf3);
}
.recipient-chip-name { font-weight: 600; }
.recipient-chip-meta { color: var(--text-muted, #8b949e); font-size: 10px; }
.recipient-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted, #8b949e);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.recipient-chip-remove:hover { color: #f85149; }

/* --- Scheduled Alerts tab table --- */
.alerts-table { width: 100%; border-collapse: collapse; }
.alerts-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface, #161b22);
  border-bottom: 1px solid var(--border, #30363d);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted, #8b949e);
}
.alerts-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft, #1f242c);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.alerts-table tr:hover { background: rgba(88, 166, 255, 0.04); }
.alert-status-pending  { color: #fdbf19; }
.alert-status-firing   { color: #58a6ff; }
.alert-status-fired    { color: #3fb950; }
.alert-status-failed   { color: #f85149; }
.alert-status-cancelled { color: var(--text-muted, #8b949e); }
.alerts-filter-bar {
  display: flex; gap: 8px; margin-bottom: 12px; align-items: center;
}
.alerts-filter-bar .btn-status { font-size: 11px; }



/* --- Tabs --- */
.tabbar {
  display: flex; gap: 2px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 60px; z-index: 40;
}
.tab-link {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-decoration: none;
  position: relative;
  transition: color 150ms;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab-link::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 200ms ease-out;
  box-shadow: 0 0 12px var(--accent-glow);
}
.tab-link:hover { color: var(--text); }
.tab-link.active { color: var(--accent); }
.tab-link.active::after { transform: scaleX(1); }
.tab-link .tab-icon { font-family: 'JetBrains Mono', monospace; font-size: 11px; opacity: 0.6; }

/* --- Content --- */
.content {
  padding: 24px 28px 64px;
  max-width: 1800px;
  margin: 0 auto;
  position: relative; z-index: 2;
}
.tab-pane.d-none { display: none !important; }
.d-none { display: none !important; }
.section-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 12px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
}

/* --- Grid system --- */
.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1024px) { .grid-cols-4, .grid-cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 640px)  { .grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-6 { grid-template-columns: 1fr; } }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  transition: border-color 200ms, transform 200ms;
}
.card:hover { border-color: var(--border-soft); }
.card-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 12px;
}

/* Stat tiles */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color 200ms, transform 200ms;
}
.stat-tile::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.stat-tile.is-warning::before { background: var(--warning); box-shadow: 0 0 12px rgba(245, 158, 11, 0.4); }
.stat-tile.is-danger::before  { background: var(--danger); box-shadow: 0 0 12px var(--danger-glow); }
.stat-tile.is-info::before    { background: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
.stat-tile:hover { transform: translateY(-1px); border-color: var(--border-soft); }
.stat-tile .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.stat-tile .stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.stat-tile .stat-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

/* --- Toolbar (filters) --- */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar input,
.toolbar select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: border-color 150ms, box-shadow 150ms;
}
.toolbar input::placeholder { color: var(--text-dim); }
.toolbar input:focus, .toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.toolbar input { min-width: 180px; }
.toolbar input[type=number] { min-width: 120px; }
.toolbar .spacer { flex: 1; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #052012;
  box-shadow: 0 0 16px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-danger {
  background: var(--danger);
  color: #2a0808;
  box-shadow: 0 0 16px var(--danger-glow);
}
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-copy-uid {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  margin-left: 6px;
  font-size: 12px;
  line-height: 1;
  border-radius: 3px;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-copy-uid:hover { color: var(--text); border-color: var(--border); }
.btn-copy-uid.copied { color: var(--accent); border-color: var(--accent); }
.btn-copy-uid.failed { color: #e57373; border-color: #e57373; }

/* Per-row refresh button (refresh this player's data via their alliance). */
.btn-refresh-row {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 5px;
  margin-left: 4px;
  font-size: 12px;
  line-height: 1;
  border-radius: 3px;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-refresh-row:hover { color: var(--accent); border-color: var(--border); }
.btn-refresh-row.copied { color: var(--accent); border-color: var(--accent); }
.btn-refresh-row.failed { color: #e57373; border-color: #e57373; }
.btn-refresh-row:disabled { cursor: progress; opacity: 0.7; }

/* Spin animation for refresh buttons during a scan request. */
@keyframes spin-cw { to { transform: rotate(360deg); } }
.spinning { animation: spin-cw 1s linear infinite; display: inline-block; }
.btn-refresh-row.spinning,
.btn-refresh-alliance.spinning,
.btn-refresh-alliance .spinning {
  animation: spin-cw 1s linear infinite;
  display: inline-block;
}

/* Dim a table while it's being refreshed, so the row reload feels intentional. */
.is-refreshing tbody { opacity: 0.45; transition: opacity 0.15s; pointer-events: none; }
.is-refreshing tbody::after { content: ""; }   /* placeholder for future overlay */

/* Larger inline spinner used in toolbar status lines (e.g. alliance scan). */
.spinner-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin-cw 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.btn-alert-row {
  background: transparent;
  border: 1px solid transparent;
  color: var(--gold, #facc15);
  cursor: pointer;
  padding: 0 5px;
  margin-left: 4px;
  font-size: 13px;
  line-height: 1;
  border-radius: 3px;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-alert-row:hover { color: var(--gold, #facc15); border-color: var(--gold, #facc15); }

/* Trailing per-row "actions" cell — keeps refresh/copy/share grouped together
 * with consistent spacing instead of trailing the player name.
 */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.row-actions .btn-refresh-row,
.row-actions .btn-copy-uid {
  margin-left: 0;
}

/* --- Send tab --- */
.form-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px 16px;
  align-items: center;
}
.form-row {
  display: contents;
}
.form-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.form-control {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: border-color 150ms, box-shadow 150ms;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea.form-control { font-family: 'Inter', sans-serif; min-height: 70px; resize: vertical; }

.send-results {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.send-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  transition: border-color 150ms, background 150ms;
}
.send-result-row:hover { border-color: var(--accent); background: var(--bg-elev, var(--bg)); }
.send-result-name { font-weight: 600; flex: 1; min-width: 100px; }

.send-target {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
}
.send-target-header { display: flex; align-items: center; gap: 10px; }
.send-target-name { font-weight: 600; font-size: 14px; }
.send-target-uid { margin-top: 6px; font-size: 12px; color: var(--text-muted); }

.send-stages { font-size: 13px; color: var(--text); }
.send-stage { display: flex; align-items: center; gap: 8px; }
.send-stage-active .send-stage-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: send-pulse 1.4s ease-out infinite;
}
@keyframes send-pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

.send-result { margin-top: 12px; }
.send-result-ok   { color: var(--accent); font-size: 14px; font-weight: 600; }
.send-result-fail { color: #e57373; font-size: 14px; font-weight: 600; }
.status-ok   { color: var(--accent); }
.status-fail { color: #e57373; }

/* --- Share-coords per-row button + modal --- */
.btn-share-row {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
  border-radius: 3px;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.btn-share-row:hover { color: var(--accent); border-color: var(--accent); }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: min(560px, 95vw);
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}
.modal-target { font-size: 12px; }
.btn-icon {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 3px;
}
.btn-icon:hover { color: var(--text); background: var(--border); }

/* --- Tables --- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.data-table tbody tr:hover td { background: rgba(34, 211, 154, 0.04); }
.data-table .num { font-family: 'JetBrains Mono', monospace; text-align: right; }
.data-table .mono { font-family: 'JetBrains Mono', monospace; }
.data-table .text-end { text-align: right; }
.data-table .text-nowrap { white-space: nowrap; }

/* Scrollable table region */
.table-scroll {
  max-height: 70vh;
  overflow: auto;
}

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-alliance {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  font-weight: 700;
}
.badge-success { background: rgba(34, 211, 154, 0.12); color: var(--accent); border-color: rgba(34, 211, 154, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
.badge-danger  { background: rgba(239, 68, 68, 0.12);  color: var(--danger);  border-color: rgba(239, 68, 68, 0.3); }
.badge-info    { background: rgba(56, 189, 248, 0.12); color: var(--primary); border-color: rgba(56, 189, 248, 0.3); }
.badge-muted   { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge-running { background: rgba(34, 211, 154, 0.12); color: var(--accent); border-color: var(--accent); animation: badge-pulse 1.6s ease-in-out infinite; }
@keyframes badge-pulse {
  0%,100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%     { box-shadow: 0 0 0 6px rgba(34, 211, 154, 0); }
}

/* Mission rarity badges */
.rarity-Blue     { background: rgba(56, 189, 248, 0.15); color: var(--primary); border-color: rgba(56, 189, 248, 0.4); }
.rarity-Purple   { background: rgba(167, 139, 250, 0.15); color: #a78bfa; border-color: rgba(167, 139, 250, 0.4); }
.rarity-Gold     { background: rgba(251, 191, 36, 0.15); color: var(--gold);   border-color: rgba(251, 191, 36, 0.4); }
.rarity-GoldStar { background: rgba(251, 191, 36, 0.25); color: var(--gold); border: 1px solid rgba(251, 191, 36, 0.7); box-shadow: 0 0 6px rgba(251, 191, 36, 0.3); font-weight: 800; }
.rarity-Silver   { background: rgba(212, 212, 216, 0.12); color: var(--silver); border-color: rgba(212, 212, 216, 0.3); }
.rarity-Bronze   { background: rgba(180, 83, 9, 0.15);   color: #fbbf24; border-color: rgba(180, 83, 9, 0.4); }
.rarity-Iron     { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

/* --- Status icons in player table --- */
.status-icons { display: inline-flex; gap: 6px; align-items: center; }
.status-icons span { font-size: 11px; font-family: 'JetBrains Mono', monospace; }
.status-shield   { color: var(--accent); }
.status-gather   { color: var(--gold); }
.status-mud      { color: var(--danger); }
.status-march    { color: var(--primary); }

/* Always-rendered shield icon — green when ON (active), gray when OFF.
 * Used for both the Players tab and the Alliance Roster member rows. */
.shield-icon {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}
.shield-icon.on {
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent-glow);
}
.shield-icon.off {
  color: var(--text-muted);
  opacity: 0.55;
  filter: grayscale(1);
}

.alliance-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 24px;
  font-size: 12px;
}
.alliance-meta-grid .text-dim { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Alliance grid (clickable cards) */
.alliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.alliance-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  font-family: 'Inter', sans-serif;
  text-align: left;
}
.alliance-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.alliance-card .ac-abbr {
  font-size: 18px; font-weight: 700; color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
.alliance-card .ac-row {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-top: 6px; color: var(--text-muted);
}
.alliance-card .ac-row strong { color: var(--text); font-weight: 600; }
.alliance-card .ac-row.ac-row-meta {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
}
.alliance-card .ac-row.ac-row-meta strong {
  color: var(--text-muted);
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

/* Rank badge in the top-right corner of each card. Top 3 get medals. */
.alliance-card { position: relative; }
.alliance-rank-badge {
  position: absolute;
  top: 8px; right: 10px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 4px;
}
.alliance-rank-badge .medal { font-size: 14px; line-height: 1; }
.alliance-rank-badge.gold {
  color: #FFD700; border-color: #FFD700;
  background: rgba(255,215,0,0.10);
  text-shadow: 0 0 6px rgba(255,215,0,0.4);
}
.alliance-rank-badge.silver {
  color: #C0C0C0; border-color: #C0C0C0;
  background: rgba(192,192,192,0.08);
}
.alliance-rank-badge.bronze {
  color: #CD7F32; border-color: #CD7F32;
  background: rgba(205,127,50,0.10);
}
.alliance-card.podium-gold   { border-color: rgba(255,215,0,0.55); }
.alliance-card.podium-silver { border-color: rgba(192,192,192,0.55); }
.alliance-card.podium-bronze { border-color: rgba(205,127,50,0.55); }
.alliance-card.podium-gold .ac-abbr,
.alliance-card.podium-silver .ac-abbr,
.alliance-card.podium-bronze .ac-abbr { padding-right: 60px; }
.alliance-card .ac-abbr { padding-right: 50px; }

.alliance-grid-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 16px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}
.alliance-grid-footer .footer-count {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Alliance summary stat row inside the roster view */
.alliance-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 24px;
}
.alliance-stat {
  display: flex; flex-direction: column; gap: 2px;
}
.alliance-stat .stat-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.alliance-stat .stat-value {
  font-size: 18px; font-weight: 700; color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
.alliance-stat .stat-sub {
  font-size: 11px; color: var(--text-muted);
}

.thp-rank {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 8px;
  background: var(--accent-glow, rgba(0,255,170,0.12));
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  vertical-align: middle;
}

/* --- Map --- */
#map {
  height: 76vh;
  background: #050b1c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.leaflet-container { background: #020617 !important; }
.leaflet-popup-content-wrapper {
  background: var(--elevated) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
}
.leaflet-popup-tip { background: var(--elevated) !important; }

/* --- Bulk Scan progress --- */
.progress-shell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 28px;
  position: relative;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
  box-shadow: 0 0 16px var(--accent-glow);
  transition: width 600ms ease-out;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #052012;
  letter-spacing: 0.1em;
}
.progress-fill.is-running::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* --- Raw log block --- */
.raw-log {
  background: #050b1c;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
}

/* --- Empty / loading states --- */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 13px;
}
.empty .empty-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* --- Form switch (Bootstrap-compatible) --- */
.switch {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.switch input { accent-color: var(--accent); }

/* --- Pill-style ON/OFF toggle --- */
.toggle-switch {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  font-size: 12px; color: var(--text-muted);
}
.toggle-switch input { display: none; }
.toggle-switch .toggle-track {
  position: relative;
  width: 36px; height: 18px;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.toggle-switch .toggle-track::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::after { left: 20px; }
.toggle-switch .toggle-state {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 10px; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--border-soft); color: var(--text-dim);
}
.toggle-switch input:checked ~ .toggle-state {
  background: var(--accent); color: #0b1426;
}

/* --- Filter chip group (multi-select checkboxes) --- */
.filter-group {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.filter-group-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding-right: 4px;
  border-right: 1px solid var(--border-soft);
  margin-right: 2px;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.filter-chip input { display: none; }
.filter-chip:hover { background: var(--border-soft); color: var(--text); }
.filter-chip:has(input:checked) {
  background: var(--accent);
  color: #0b1426;
  border-color: var(--accent);
}

/* Mission rarity color hints inside chips */
.filter-chip[data-mfilter="rarity"] { /* base styling via CSS attr */ }

/* --- Status filter (segmented button group) --- */
.status-filter {
  display: inline-flex; gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
.status-filter .btn-status {
  border: 0; background: transparent; color: var(--text-muted);
  padding: 6px 12px; font-size: 11px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px; cursor: pointer;
  border-right: 1px solid var(--border-soft);
  transition: background 0.1s, color 0.1s;
}
.status-filter .btn-status:last-child { border-right: 0; }
.status-filter .btn-status:hover { background: var(--border-soft); color: var(--text); }
.status-filter .btn-status.active { background: var(--accent); color: #0b1426; }

/* --- Health monitor cards --- */
.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 200ms;
}
.health-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--text-dim);
}
.health-card.health-up::before { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.health-card.health-degraded::before { background: var(--warning); box-shadow: 0 0 12px rgba(245, 158, 11, 0.4); }
.health-card.health-down::before { background: var(--danger); box-shadow: 0 0 12px var(--danger-glow); }

.health-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.health-card-title {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
  text-transform: uppercase;
}
.health-card-body { display: flex; flex-direction: column; gap: 8px; }
.health-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
  gap: 12px;
}
.health-row-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10.5px;
  flex-shrink: 0;
}
.health-row-value {
  color: var(--text);
  text-align: right;
  word-break: break-all;
}
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }

/* Utility */
.text-end { text-align: right; }
.text-nowrap { white-space: nowrap; }
.text-muted { color: var(--text-muted) !important; }
.text-dim { color: var(--text-dim) !important; }
.flex { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Stat-tile success variant — for fresh snapshot indicator */
.stat-tile.is-success::before {
  background: var(--accent);
  box-shadow: 0 0 16px rgba(34, 211, 154, 0.6);
}

/* Freshness dot for "Last seen" column */
.freshness-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.freshness-fresh {
  background: #22d39a;
  box-shadow: 0 0 6px rgba(34, 211, 154, 0.7);
  animation: fresh-pulse 1.6s ease-in-out infinite;
}
.freshness-stale { background: #5a6a85; }
.text-fresh { color: #22d39a; font-weight: 600; }

@keyframes fresh-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(34, 211, 154, 0.5); transform: scale(1); }
  50%      { box-shadow: 0 0 12px rgba(34, 211, 154, 1);   transform: scale(1.15); }
}

/* --- Celebration banner --- */
.celebration-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-180%);
  z-index: 9999;
  min-width: 380px;
  max-width: 560px;
  padding: 16px 56px 16px 24px;
  border-radius: 14px;
  background: linear-gradient(120deg, #22d39a 0%, #38bdf8 25%, #a78bfa 50%, #f472b6 75%, #fbbf24 100%);
  background-size: 300% 300%;
  animation: celebration-shimmer 4s linear infinite;
  color: #0b1224;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.25) inset,
              0 0 40px rgba(34, 211, 154, 0.5);
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.2, 0.85, 0.3, 1.4), opacity 0.35s ease;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.celebration-banner-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.celebration-content { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.celebration-text {
  font-size: 15px;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.celebration-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.78;
  font-family: 'JetBrains Mono', monospace;
}
.celebration-emoji {
  font-size: 28px;
  display: inline-block;
  animation: celebration-bounce 0.9s ease-in-out infinite alternate;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}
.celebration-emoji-r { animation-delay: 0.4s; }
.celebration-close {
  position: absolute;
  top: 8px; right: 10px;
  background: transparent;
  border: 0;
  color: rgba(11, 18, 36, 0.55);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.celebration-close:hover { color: #0b1224; }

.celebration-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 14px;
}
.celebration-confetti::before,
.celebration-confetti::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  opacity: 0;
}
.celebration-banner-show .celebration-confetti::before {
  left: 12%; top: -10%;
  background: #fff;
  animation: confetti-fall 2.6s ease-in 0.2s 2;
}
.celebration-banner-show .celebration-confetti::after {
  left: 78%; top: -10%;
  background: #ffe066;
  animation: confetti-fall 2.4s ease-in 0.5s 2;
}

@keyframes celebration-shimmer {
  0%   { background-position:   0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}
@keyframes celebration-bounce {
  from { transform: translateY(0)  rotate(-6deg); }
  to   { transform: translateY(-6px) rotate(8deg); }
}
@keyframes confetti-fall {
  0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(120px) rotate(540deg); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Squad lineup cards (Player Details → Squads section) */
.squad-block {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.squad-block-header {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.squad-heroes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.squad-hero {
  background: rgba(34,211,154,0.08);
  border: 1px solid rgba(34,211,154,0.25);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
}
.squad-hero-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.squad-hero-meta {
  color: var(--text-dim);
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}

/* "Scouted" indicator — set on rows whose uid has cached squad data in
   player_squads. Lives in the row-actions cell, immediately left of Share,
   so intel + action icons cluster together. Material Symbols chess_knight
   with a gold glow that breathes once every ~2.4s. */
.scouted-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  margin: 0 2px;
  color: #ffd54a;
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  text-shadow: 0 0 3px rgba(255, 213, 74, 0.4);
  cursor: help;
  vertical-align: middle;
  animation: scouted-glow 3.2s ease-in-out infinite;
}
@keyframes scouted-glow {
  0%, 100% { text-shadow: 0 0 3px rgba(255, 213, 74, 0.35); }
  50%      { text-shadow: 0 0 5px rgba(255, 213, 74, 0.55); }
}
/* Invisible spacer matching .scouted-badge dimensions — emitted on rows
   that don't have cached squads, so the Share button stays aligned with
   rows that do. Same width/height/margin as the real badge. */
.scouted-badge-empty {
  display: inline-block;
  width: 24px;
  height: 24px;
  margin: 0 2px;
  vertical-align: middle;
}

/* Material Symbols sizing inside row buttons + shield indicator. The
   default font-size of the parent button/span is much smaller than the
   Material default 24px, so we constrain it here to match the existing
   layout density. */
.btn-copy-uid .material-symbols-outlined {
  font-size: 14px;
  vertical-align: -3px;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}
.btn-alert-row .material-symbols-outlined {
  font-family: 'Material Symbols Outlined' !important;
  font-feature-settings: 'liga' !important;
  font-size: 14px;
  vertical-align: -3px;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}
.shield-icon .material-symbols-outlined {
  /* Explicitly re-state font-family + ligature here — the parent
     .shield-icon sets font-family: 'JetBrains Mono', and although the
     general .material-symbols-outlined rule should override, some browsers
     prefer the parent's font when the inner rule doesn't restate it. */
  font-family: 'Material Symbols Outlined' !important;
  font-feature-settings: 'liga' !important;
  -webkit-font-feature-settings: 'liga' !important;
  font-size: 14px;
  vertical-align: -3px;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 20;
}
.shield-icon.on .material-symbols-outlined {
  color: var(--accent, #22d39a);
  text-shadow: 0 0 4px rgba(34, 211, 154, 0.6);
}
.shield-icon.off .material-symbols-outlined {
  color: rgba(255,255,255,0.25);
}

/* ---------------------------------------------------------------------------
 * Material Symbols icon system
 * --------------------------------------------------------------------------
 * Use <span class="lw-icon">refresh</span> for a generic icon. Modifiers:
 *   .lw-icon-sm / .lw-icon-md / .lw-icon-lg → 14 / 18 / 24 px
 *   .lw-icon-fill                          → filled variant (FILL=1)
 *   .lw-icon-bold                          → wght=700
 *   .lw-icon-accent / .lw-icon-danger / .lw-icon-warn / .lw-icon-dim → tint
 *   .lw-icon-glow                          → soft accent halo (active state)
 *
 * Material Symbols requires the special `material-symbols-outlined` class
 * to apply the right ligature font + opsz axis. .lw-icon adds it implicitly
 * via its descendant rule, but you can also write
 * `<span class="material-symbols-outlined lw-icon-md">refresh</span>` if
 * you prefer to spell the font class out (legacy markup uses this form).
 * ------------------------------------------------------------------------ */
.lw-icon, .material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal;
  font-size: 18px;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: -4px;
  user-select: none;
  -webkit-user-select: none;
}
.lw-icon-sm   { font-size: 14px; vertical-align: -3px; font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20; }
.lw-icon-md   { font-size: 18px; vertical-align: -4px; font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.lw-icon-lg   { font-size: 24px; vertical-align: -5px; font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

/* Filled variant — give a visual emphasis (active states, primary actions). */
.lw-icon-fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.lw-icon-bold { font-variation-settings: 'FILL' 0, 'wght' 700, 'GRAD' 0, 'opsz' 24; }

/* Color tints — keep a small palette so the dashboard feels consistent. */
.lw-icon-accent  { color: var(--accent, #22d39a); }
.lw-icon-primary { color: var(--primary, #38bdf8); }
.lw-icon-warn    { color: var(--warning, #f59e0b); }
.lw-icon-danger  { color: var(--danger, #ef4444); }
.lw-icon-gold    { color: var(--gold, #fbbf24); }
.lw-icon-dim     { color: rgba(255,255,255,0.35); }

/* Soft glow halo — pair with -accent or -gold for an "alive" look on
   things like the chess_knight scouted badge or active shield. */
.lw-icon-glow {
  filter: drop-shadow(0 0 4px currentColor);
  text-shadow: 0 0 8px rgba(255,255,255,0.15);
}

/* When an icon sits inside a button as the only label, equalize the click
   target to a square and remove text-baseline drift. Use <button> with
   class="btn-icon-only" + a single .lw-icon child. */
.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, #8b9bb8);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-icon-only:hover {
  color: var(--accent, #22d39a);
  border-color: var(--border, #1f2a44);
  background: rgba(34, 211, 154, 0.06);
}
.btn-icon-only > .lw-icon, .btn-icon-only > .material-symbols-outlined {
  font-size: 16px;
  vertical-align: 0;
}

/* Big squad-power total — the headline number per squad (matches the
   "47.4M" lwatlas shows). Drawn in accent green so it stands out from
   secondary metadata like soldier count and UAV power. */
.squad-power-total {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
}

/* Squad source badge — indicates whether the row came from
   kof.battle.preview (rich, arena bracket only) or
   train.record.detail (lighter, captured passively from any clicked truck). */
.squad-source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-right: 6px;
  cursor: help;
}
.squad-source-badge.arena {
  background: rgba(255, 213, 74, 0.12);
  border: 1px solid rgba(255, 213, 74, 0.4);
  color: #ffd54a;
}
.squad-source-badge.train {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

/* march source badge — passive captures from kingdom-sweep pushes. */
.squad-source-badge.march {
  background: rgba(244, 114, 182, 0.12);
  border: 1px solid rgba(244, 114, 182, 0.4);
  color: #f472b6;
}

/* ============================================================================
 * Mobile responsive overrides
 * Pure CSS — desktop layout (>768px) is untouched.
 * ========================================================================== */

@media (max-width: 768px) {

  /* --- Topbar: brand+user-badge on row 1, kingdom dropdown on row 2 --- */
  .app-topbar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px 10px;
    position: static;   /* drop sticky on mobile so the wrapped 2-row topbar
                           doesn't overlap the sticky tabbar below */
  }
  .topbar-spacer { display: none; }
  .topbar-meta {
    display: contents;  /* flatten kingdom-count/select/user-badge into the
                            topbar flex so each can be ordered independently */
  }
  .app-brand {
    font-size: 14px;
    letter-spacing: 0.05em;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .app-brand .brand-sub { display: none; }
  .kingdom-count { display: none; }   /* info text, not critical on mobile */
  #user-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 4px 8px;
  }
  .kingdom-select {
    flex: 1 1 100%;     /* forces wrap to row 2, full width */
    min-width: 0;
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
  }

  /* --- Tab nav: scroll horizontally, hide numeric badges --- */
  .tabbar {
    padding: 0 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    top: 0;             /* desktop pinned at 60px below topbar; topbar is no
                            longer sticky on mobile, so pin at viewport top */
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab-link {
    padding: 12px 10px;
    font-size: 12px;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }
  .tab-link .tab-icon { display: none; }
  .tab-link::after { left: 6px; right: 6px; }

  /* --- Content padding tighter --- */
  .content { padding: 16px 12px 48px; }
  .section-title { font-size: 13px; gap: 8px; }

  /* --- Stack 2-col grids at 768 (existing rule was at 640) --- */
  .grid-cols-2 { grid-template-columns: 1fr; }

  /* --- Toolbar: tighter, inputs flex to row, no spacer push --- */
  .toolbar {
    padding: 10px;
    gap: 8px;
  }
  .toolbar input,
  .toolbar select {
    min-width: 0;
    flex: 1 1 140px;
  }
  .toolbar .spacer { display: none; }
  .toolbar .status-filter,
  .toolbar .filter-group { flex-wrap: wrap; }

  /* --- Data tables: tighter cells, sticky first column, horiz scroll --- */
  .table-wrap { overflow-x: auto; }   /* covers alerts-table which has no
                                         inner .table-scroll wrapper */
  .data-table thead th {
    padding: 9px 8px;
    font-size: 10px;
    letter-spacing: 0.08em;
  }
  .data-table tbody td {
    padding: 8px;
    font-size: 12px;
  }
  .data-table thead th:first-child,
  .data-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
  }
  .data-table thead th:first-child {
    background: var(--surface-2);
    z-index: 3;
  }
  .data-table tbody tr:hover td:first-child {
    background: var(--elevated);   /* avoid the alpha-hover ghosting through */
  }
  .alerts-table th:first-child,
  .alerts-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
  }

  /* --- Modals: fit viewport, stack form labels above inputs --- */
  .modal-card {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: 90vh;
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 12px 14px;
  }
  .modal-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .spacer { display: none; }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 6px 0;
  }
  .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
  }
  .form-label { font-size: 11px; }

  /* --- Misc: header bars / filter strips wrap --- */
  .alerts-filter-bar { flex-wrap: wrap; }
  #health-services { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  /* Even tighter on phones — values intentionally below the tablet rules. */
  .app-brand { font-size: 13px; }
  .content { padding: 12px 10px 40px; }

  #user-badge-name { display: none; }   /* tier pill + logout only */

  .tab-link { padding: 10px 10px; font-size: 11.5px; }

  .data-table thead th { padding: 8px 6px; }
  .data-table tbody td { padding: 7px 6px; font-size: 11.5px; }

  .modal-card {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }
  .modal-header h3 { font-size: 14px; }

  .stat-tile { padding: 12px 14px; }
  .stat-tile .stat-value { font-size: 18px; }
}
