/* Remnawave Node Monitor - High-Contrast Adaptive Design System */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Telegram Theme Variable fallbacks mapping for contract test */
  --tg-theme-bg-color: #0b1120;
  --tg-theme-secondary-bg-color: #131c2e;
  --tg-theme-text-color: #f8fafc;
  --tg-theme-hint-color: #94a3b8;
  --tg-theme-button-color: #0284c7;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-section-bg-color: #182338;
  --tg-theme-section-separator-color: #2a3a54;

  --color-healthy-base: #10b981;
  --color-warning-base: #f59e0b;
  --color-down-base: #ef4444;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   THEME DEFINITIONS: DARK MODE (Default)
   ========================================================================== */
body.dark-mode {
  --bg-primary: #0b1120;
  --bg-secondary: #131c2e;
  --bg-tertiary: #223249;
  --bg-card: #182338;
  --bg-card-hover: #1f2e48;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --color-accent: #0284c7;
  --color-accent-hover: #0369a1;
  --color-accent-text: #ffffff;
  --border-color: #263852;

  --color-healthy: #34d399;
  --color-healthy-bg: rgba(16, 185, 129, 0.16);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(245, 158, 11, 0.16);
  --color-down: #f87171;
  --color-down-bg: rgba(239, 68, 68, 0.16);

  --badge-panel-bg: rgba(59, 130, 246, 0.2);
  --badge-panel-text: #60a5fa;
  --badge-core-bg: rgba(168, 85, 247, 0.2);
  --badge-core-text: #c084fc;
  --badge-bw-bg: rgba(14, 165, 233, 0.2);
  --badge-bw-text: #38bdf8;
  --badge-cpu-bg: rgba(16, 185, 129, 0.2);
  --badge-cpu-text: #34d399;
  --badge-ram-bg: rgba(168, 85, 247, 0.2);
  --badge-ram-text: #c084fc;
  --badge-throttled-bg: rgba(239, 68, 68, 0.25);
  --badge-throttled-text: #f87171;
  --badge-highload-bg: rgba(245, 158, 11, 0.25);
  --badge-highload-text: #fbbf24;

  --card-metrics-bg: rgba(11, 17, 32, 0.6);
  --card-metrics-border: rgba(255, 255, 255, 0.06);

  --modal-backdrop-bg: rgba(0, 0, 0, 0.75);
  --modal-bg: #131c2e;
  --action-box-bg: rgba(2, 132, 199, 0.12);
  --action-box-border: rgba(2, 132, 199, 0.35);
  --action-box-text: #7dd3fc;
  --diagnostic-box-bg: #182338;
  --diagnostic-box-text: #f8fafc;
  --protocol-shaping-bg: rgba(239, 68, 68, 0.16);
  --protocol-shaping-border: rgba(239, 68, 68, 0.45);
  --protocol-shaping-title: #f87171;
  --protocol-shaping-text: #e2e8f0;
  --protocol-shaping-rec: #fca5a5;
  --protocol-ok-text: #34d399;

  --table-border: #223249;
  --traceroute-bg: #182338;
  --traceroute-text: #f8fafc;
  --traceroute-ip: #e2e8f0;
  --traceroute-summary-bg: rgba(2, 132, 199, 0.15);
  --traceroute-summary-border: rgba(2, 132, 199, 0.35);

  --bar-normal: #38bdf8;
  --bar-peak: #f59e0b;
  --bar-high: #f87171;
  --bar-current: #0284c7;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* ==========================================================================
   THEME DEFINITIONS: LIGHT MODE (High Contrast WCAG AAA)
   ========================================================================== */
body.light-mode {
  --bg-primary: #f1f5f9; /* Slate 100 - soft high-end dashboard surface */
  --bg-secondary: #ffffff; /* Crisp white headers & containers */
  --bg-tertiary: #e2e8f0; /* Slate 200 - clean crisp borders */
  --bg-card: #ffffff; /* Pure white card surface */
  --bg-card-hover: #f8fafc; /* Slate 50 subtle hover */
  --text-primary: #0f172a; /* Slate 900 - maximum readability, 16:1 contrast */
  --text-secondary: #334155; /* Slate 700 - rich slate, 9:1 contrast */
  --text-muted: #64748b; /* Slate 500 - contrast > 4.5:1 */
  --color-accent: #0284c7; /* Sky 600 - rich deep blue */
  --color-accent-hover: #0369a1;
  --color-accent-text: #ffffff;
  --border-color: #cbd5e1; /* Slate 300 */

  --color-healthy: #15803d; /* Emerald 700 - deep visible green */
  --color-healthy-bg: #dcfce7; /* Emerald 100 */
  --color-warning: #b45309; /* Amber 700 - rich visible amber/brown, NO pale yellow! */
  --color-warning-bg: #fef3c7; /* Amber 100 */
  --color-down: #b91c1c; /* Red 700 - rich deep crimson */
  --color-down-bg: #fee2e2; /* Red 100 */

  --badge-panel-bg: #e0f2fe; /* Sky 100 */
  --badge-panel-text: #0369a1; /* Sky 700 */
  --badge-core-bg: #f3e8ff; /* Purple 100 */
  --badge-core-text: #6b21a8; /* Purple 800 */
  --badge-bw-bg: #e0f2fe; /* Sky 100 */
  --badge-bw-text: #0369a1; /* Sky 700 */
  --badge-cpu-bg: #dcfce7; /* Emerald 100 */
  --badge-cpu-text: #15803d; /* Emerald 700 */
  --badge-ram-bg: #f3e8ff; /* Purple 100 */
  --badge-ram-text: #6b21a8; /* Purple 800 */
  --badge-throttled-bg: #fee2e2; /* Red 100 */
  --badge-throttled-text: #991b1b; /* Red 800 */
  --badge-highload-bg: #fef3c7; /* Amber 100 */
  --badge-highload-text: #b45309; /* Amber 700 */

  --card-metrics-bg: #f8fafc; /* Slate 50 */
  --card-metrics-border: #e2e8f0; /* Slate 200 */

  --modal-backdrop-bg: rgba(15, 23, 42, 0.65);
  --modal-bg: #ffffff;
  --action-box-bg: #eff6ff; /* Blue 50 */
  --action-box-border: #bfdbfe; /* Blue 200 */
  --action-box-text: #1d4ed8; /* Blue 700 */
  --diagnostic-box-bg: #f8fafc;
  --diagnostic-box-text: #0f172a;
  --protocol-shaping-bg: #fef2f2; /* Red 50 */
  --protocol-shaping-border: #fca5a5; /* Red 300 */
  --protocol-shaping-title: #991b1b; /* Red 800 */
  --protocol-shaping-text: #1e293b; /* Slate 800 */
  --protocol-shaping-rec: #7f1d1d; /* Red 900 */
  --protocol-ok-text: #15803d;

  --table-border: #e2e8f0;
  --traceroute-bg: #f8fafc;
  --traceroute-text: #0f172a;
  --traceroute-ip: #0f172a;
  --traceroute-summary-bg: #e0f2fe;
  --traceroute-summary-border: #7dd3fc;

  --bar-normal: #0284c7;
  --bar-peak: #d97706;
  --bar-high: #dc2626;
  --bar-current: #0369a1;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.06);

  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* Global Body Settings */
body {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* App Container */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 14px 40px;
}

/* App Header */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bg-tertiary);
}

@media (min-width: 640px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.header-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

/* Overall Status Badge */
.badge-overall {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-healthy {
  background: var(--color-healthy-bg);
  color: var(--color-healthy);
  border: 1px solid var(--color-healthy);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.badge-down {
  background: var(--color-down-bg);
  color: var(--color-down);
  border: 1px solid var(--color-down);
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: pulse-dot 2s infinite ease-in-out;
}

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

/* Refresh & Theme Controls */
.refresh-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
}

.countdown-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 24px;
  text-align: center;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

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

.btn-icon.spinning .icon-refresh {
  animation: spin 1s linear infinite;
}

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

/* Theme Toggle Button */
.btn-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-primary);
  padding: 5px 9px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

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

/* View Switcher */
.view-switch {
  display: flex;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-text);
}

/* Summary Pills Bar */
.summary-pills-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .summary-pills-bar {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
}

@media (min-width: 960px) {
  .summary-pills-bar {
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }
}

.summary-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.summary-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.pill-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.pill-content {
  display: flex;
  flex-direction: column;
}

.pill-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.pill-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Filter and Search Bar */
.filters-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  background: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.panel-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  color: var(--text-primary);
  border-color: var(--color-accent);
}

.filter-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-text);
  border-color: var(--color-accent);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (min-width: 640px) {
  .filter-row {
    grid-template-columns: 180px 180px 1fr;
    gap: 10px;
  }
}

.filter-select {
  width: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.filter-select:focus {
  border-color: var(--color-accent);
}

.search-input-wrapper {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
}

@media (min-width: 640px) {
  .search-input-wrapper {
    grid-column: auto;
  }
}

.search-input {
  width: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--bg-tertiary);
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input::placeholder {
  color: var(--text-muted);
}

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

.search-clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Nodes Grid */
.nodes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 680px) {
  .nodes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

@media (min-width: 1024px) {
  .nodes-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

/* Node Card */
.node-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.node-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.node-card.card-degraded {
  border-left: 4px solid var(--color-warning);
}

.node-card.card-down {
  border-left: 4px solid var(--color-down);
}

.node-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.node-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.node-flag {
  font-size: 1.25rem;
  line-height: 1;
}

.node-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Badges System - High Contrast */
.panel-badge {
  background: var(--badge-panel-bg);
  color: var(--badge-panel-text);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.7rem;
}

.core-badge {
  background: var(--badge-core-bg);
  color: var(--badge-core-text);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.7rem;
}

.ip-badge {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 0.75rem;
}

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

.status-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.latency-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.latency-good {
  background: var(--color-healthy-bg);
  color: var(--color-healthy);
  border: 1px solid var(--color-healthy);
}

.latency-warn {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.latency-bad {
  background: var(--color-down-bg);
  color: var(--color-down);
  border: 1px solid var(--color-down);
}

/* Adaptive High Contrast Metric Badges */
.badge-bw {
  background: var(--badge-bw-bg) !important;
  color: var(--badge-bw-text) !important;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-cpu {
  background: var(--badge-cpu-bg) !important;
  color: var(--badge-cpu-text) !important;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.72rem;
}

.badge-ram {
  background: var(--badge-ram-bg) !important;
  color: var(--badge-ram-text) !important;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.72rem;
}

.badge-udp-throttled {
  background: var(--badge-throttled-bg) !important;
  color: var(--badge-throttled-text) !important;
  border: 1px solid var(--badge-throttled-text) !important;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.badge-high-load {
  background: var(--badge-highload-bg) !important;
  color: var(--badge-highload-text) !important;
  border: 1px solid var(--badge-highload-text) !important;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 800;
}

/* Card Metrics Grid */
.card-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--card-metrics-bg);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-metrics-border);
}

.card-metric-item {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.metric-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-lbl {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Card Diagnostic Alert Box */
.card-alert-box {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-warning);
}

.card-alert-box.alert-down {
  background: var(--color-down-bg);
  color: var(--color-down);
  border-color: var(--color-down);
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop-bg);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 1000;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--bg-tertiary);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.country-flag {
  font-size: 1.8rem;
  line-height: 1;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-submeta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  margin-top: 2px;
}

.panel-tag {
  background: var(--badge-panel-bg);
  color: var(--badge-panel-text);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.ip-tag {
  color: var(--text-secondary);
  font-family: monospace;
}

.core-tag {
  background: var(--badge-core-bg);
  color: var(--badge-core-text);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

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

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

/* Modal State Banner */
.modal-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.banner-healthy {
  background: var(--color-healthy-bg);
  color: var(--color-healthy);
  border-color: var(--color-healthy);
}

.banner-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

.banner-down {
  background: var(--color-down-bg);
  color: var(--color-down);
  border-color: var(--color-down);
}

.banner-icon {
  font-size: 1.4rem;
  font-weight: 700;
}

.banner-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.banner-desc {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.95;
}

/* Section Titles */
.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.diagnostic-box {
  background: var(--diagnostic-box-bg);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--diagnostic-box-text);
  font-weight: 500;
}

.action-box {
  background: var(--action-box-bg);
  border: 1px solid var(--action-box-border);
  color: var(--action-box-text);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 600;
}

/* Ports Grid */
.ports-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

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

.port-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.port-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.port-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

.port-badge {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
}

.port-badge.up {
  background: var(--color-healthy-bg);
  color: var(--color-healthy);
  border: 1px solid var(--color-healthy);
}

.port-badge.down {
  background: var(--color-down-bg);
  color: var(--color-down);
  border: 1px solid var(--color-down);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.metric-card .metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-card .metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* History List */
.history-list {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--bg-tertiary);
  color: var(--text-primary);
}

.history-item:last-child {
  border-bottom: none;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--bg-tertiary);
  background: var(--bg-secondary);
}

.last-check-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn {
  padding: 6px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--color-accent);
  color: var(--color-accent-text);
}

/* Events Timeline */
.events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.events-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.events-badge {
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--bg-tertiary);
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.event-card.event-critical {
  border-left: 4px solid var(--color-down);
}

.event-card.event-warning {
  border-left: 4px solid var(--color-warning);
}

.event-card.event-recovery {
  border-left: 4px solid var(--color-healthy);
}

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

.event-node-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.event-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.event-details {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Utilities */
.hidden {
  display: none !important;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--bg-tertiary);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px;
}

.loading-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 10px;
  color: var(--text-muted);
}

/* Evening Peak and Hourly Trends */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.badge-evening-stat {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.badge-evening-stat.peak-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.badge-evening-stat.peak-normal {
  background: var(--color-healthy-bg);
  color: var(--color-healthy);
  border: 1px solid var(--color-healthy);
}

.hourly-chart-container {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hourly-bars-track {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 90px;
  gap: 2px;
  padding-bottom: 4px;
}

.hourly-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}

.hourly-bar-col:hover {
  transform: scaleY(1.05);
}

.hourly-bar-col.col-evening {
  background: var(--color-warning-bg);
  border-radius: 3px;
}

.hourly-bar-col.col-current {
  outline: 1px dashed var(--color-accent);
  border-radius: 3px;
}

.bar-fill-wrapper {
  width: 100%;
  height: calc(100% - 16px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.hourly-bar-fill {
  width: 70%;
  max-width: 10px;
  border-radius: 2px 2px 0 0;
  transition: height 0.3s ease;
}

.hourly-bar-fill.bar-normal {
  background: var(--bar-normal);
}

.hourly-bar-fill.bar-peak {
  background: var(--bar-peak);
}

.hourly-bar-fill.bar-peak-high {
  background: var(--color-down);
}

.hourly-bar-fill.bar-high {
  background: var(--bar-high);
}

.hourly-bar-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.hourly-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--bg-tertiary);
  padding-top: 6px;
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.legend-dot.dot-normal { background: var(--bar-normal); }
.legend-dot.dot-peak { background: var(--bar-peak); }
.legend-dot.dot-current { background: var(--color-accent); }

/* Resources Grid */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.resource-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.resource-val {
  font-weight: 700;
  color: var(--text-primary);
}

.val-speed {
  color: var(--color-accent) !important;
}

.fill-speed {
  background: var(--color-accent) !important;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-healthy);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Protocol Split Box */
.protocol-box {
  background: var(--bg-card);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.protocol-shaping-box {
  background: var(--protocol-shaping-bg);
  border: 1px solid var(--protocol-shaping-border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.protocol-shaping-title {
  font-weight: 700;
  color: var(--protocol-shaping-title);
  margin-bottom: 4px;
}

.protocol-shaping-desc {
  font-size: 12px;
  color: var(--protocol-shaping-text);
  line-height: 1.4;
}

.protocol-shaping-rec {
  font-size: 11px;
  color: var(--protocol-shaping-rec);
  margin-top: 6px;
  font-weight: 700;
}

.protocol-ok-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--protocol-ok-text);
  font-size: 12px;
  font-weight: 600;
}

/* Traceroute Styles */
.btn-traceroute {
  background: var(--color-accent);
  color: var(--color-accent-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-traceroute:hover {
  opacity: 0.9;
}

.btn-traceroute:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.traceroute-container {
  background: var(--traceroute-bg);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.traceroute-summary-box {
  background: var(--traceroute-summary-bg);
  border: 1px solid var(--traceroute-summary-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.traceroute-summary-box.has-jump {
  background: var(--color-warning-bg);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.traceroute-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.traceroute-ip-highlight {
  font-family: monospace;
  color: var(--traceroute-ip);
  font-weight: 700;
}

.traceroute-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.traceroute-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.traceroute-table th,
.traceroute-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--table-border);
  color: var(--text-primary);
}

.traceroute-table th {
  color: var(--text-muted);
  font-weight: 700;
  text-align: left;
}

.hop-bottleneck-row {
  background: var(--color-warning-bg);
}

.text-danger { color: var(--color-down) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-success { color: var(--color-healthy) !important; }
