/* ============================================================
   Hydra Proxy Admin Panel — Flat Contrast Design System
   Sharp edges, no shadows, no gradients, high contrast
   ============================================================ */

/* ============================================================
   1. CSS CUSTOM PROPERTIES — Dark + Light Themes
   ============================================================ */

:root,
[data-theme="dark"] {
  --bg-base:        #0a0a0a;
  --bg-surface:     #111;
  --bg-elevated:    #1a1a1a;
  --border:         #2a2a2a;
  --border-strong:  #444;
  --text-primary:   #f5f5f5;
  --text-secondary: #999;
  --text-dim:       #666;
  --accent:         #ff3366;
  --success:        #00d4aa;
  --warning:        #ffcc00;
  --danger:         #ff3333;
  --info:           #00d4aa;

  /* Derived / convenience */
  --accent-subtle:    rgba(255, 51, 102, 0.12);
  --success-subtle:   rgba(0, 212, 170, 0.12);
  --warning-subtle:   rgba(255, 204, 0, 0.12);
  --danger-subtle:    rgba(255, 51, 51, 0.12);
  --info-subtle:      rgba(0, 212, 170, 0.12);

  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;

  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

[data-theme="light"] {
  --bg-base:        #f5f5f5;
  --bg-surface:     #fff;
  --bg-elevated:    #eee;
  --border:         #ddd;
  --border-strong:  #bbb;
  --text-primary:   #111;
  --text-secondary: #555;
  --text-dim:       #888;
  --accent:         #e6204d;
  --success:        #00b894;
  --warning:        #d4a700;
  --danger:         #e02020;
  --info:           #00b894;

  --accent-subtle:    rgba(230, 32, 77, 0.1);
  --success-subtle:   rgba(0, 184, 148, 0.1);
  --warning-subtle:   rgba(212, 167, 0, 0.1);
  --danger-subtle:    rgba(224, 32, 32, 0.1);
  --info-subtle:      rgba(0, 184, 148, 0.1);
}

/* ============================================================
   2. RESET + BASE
   ============================================================ */

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  list-style: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg-base);
}

/* ============================================================
   3. LAYOUT — Header, Tab Bar, Content Area
   ============================================================ */

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border-strong);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 100;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  font-size: 1rem;
  font-weight: 900;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Pulse dot */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: pulse 2.4s ease-in-out infinite;
}

/* Header buttons */
.header-btn,
.lang-toggle,
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  gap: 4px;
}

.header-btn:hover,
.lang-toggle:hover,
.theme-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}

.header-btn svg,
.lang-toggle svg,
.theme-toggle svg {
  width: 14px;
  height: 14px;
}

/* Tab bar */
.tab-bar {
  display: flex;
  overflow-x: auto;
  border-bottom: 2px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 52px;
  z-index: 90;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn, .tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

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

.tab-btn.active, .tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn svg, .tab svg {
  width: 13px;
  height: 13px;
  opacity: 0.8;
}

/* Main content offset for fixed header + tab bar */
.main-wrapper,
.main-content {
  margin-top: 90px;  /* header (52px) + tab bar (~38px) */
}

/* Page content */
.page-content {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 28px;
  animation: fadeIn 200ms ease;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.page-header h2,
.page-header h3 {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Stat grid — fill page width */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* Force 5 columns when there are 5 stat cards (dashboard) */
.stat-grid.stat-grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

/* Section spacing */
.section {
  margin-bottom: 14px;
}

/* ============================================================
   4. LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 16px;
}

.login-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
}

.login-card h1,
.login-card h2 {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
}

/* ============================================================
   5. CARDS
   ============================================================ */

.card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.card-title {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Stat cards */
.stat-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 14px 18px;
  transition: border-color var(--transition-base);
  cursor: default;
}

.stat-card:hover {
  border-color: var(--text-secondary);
}

.stat-card.accent  .stat-card-value { color: var(--accent); }
.stat-card.success .stat-card-value { color: var(--success); }
.stat-card.warning .stat-card-value { color: var(--warning); }
.stat-card.danger  .stat-card-value { color: var(--danger); }
.stat-card.info    .stat-card-value { color: var(--info); }

.stat-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  font-family: 'JetBrains Mono', Consolas, 'SF Mono', monospace;
}

.stat-card-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================================
   6. TABLES
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border: 2px solid var(--border);
  border-radius: 0;
  background: var(--bg-surface);
}

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

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  color: var(--text-primary);
  /* Intentionally 1px (not 2px) — lighter row separators vs. 2px header border */
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tbody tr:hover td {
  background: var(--bg-elevated);
}

.data-table tbody tr.selected td {
  background: var(--accent-subtle);
}

.data-table .col-actions {
  text-align: right;
  white-space: nowrap;
}

/* Empty state */
.table-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

/* ============================================================
   7. BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 0;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  gap: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-success {
  background: var(--success);
  color: #000;
}

.badge-danger {
  background: var(--danger);
  color: #fff;
}

.badge-warning {
  background: var(--warning);
  color: #000;
}

.badge-info {
  background: var(--info);
  color: #000;
}

.badge-secondary {
  background: var(--text-dim);
  color: var(--bg-base);
}

.badge-accent {
  background: var(--accent);
  color: #fff;
}

/* ============================================================
   8. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border: 2px solid transparent;
  border-radius: 0;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
  user-select: none;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}

/* Success */
.btn-success {
  background: var(--success);
  color: #000;
  border-color: var(--success);
}

.btn-success:hover {
  background: #000;
  color: var(--success);
  border-color: var(--success);
}

/* Warning */
.btn-warning {
  background: var(--warning);
  color: #000;
  border-color: var(--warning);
}

.btn-warning:hover {
  background: #000;
  color: var(--warning);
  border-color: var(--warning);
}

/* Info */
.btn-info {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}

.btn-info:hover {
  background: transparent;
  color: var(--info);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--text-secondary);
  color: var(--bg-base);
  border-color: var(--text-secondary);
}

/* Small */
.btn-sm {
  padding: 4px 9px;
  font-size: 0.75rem;
}

.btn-sm svg {
  width: 11px;
  height: 11px;
}

/* Icon button */
.btn-icon {
  padding: 5px;
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

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

/* Button group */
.btn-group {
  display: inline-flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: 0;
}

.btn-group .btn:last-child {
  border-radius: 0;
}

.btn-group .btn:not(:last-child) {
  border-right-color: transparent;
}

.btn-group .btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   9. FILTERS — Filter Bar
   ============================================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
}

.filter-bar label {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
}

.filter-bar input[type="text"] {
  width: auto;
  min-width: 120px;
  max-width: 200px;
  flex: 1 1 120px;
}

.filter-bar .filter-spacer {
  flex: 1;
  min-width: 8px;
}

/* ============================================================
   10. PAGINATION
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pagination button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================
   11. MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  animation: fadeIn var(--transition-slow);
}

.modal {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideInUp var(--transition-slow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-body .form-row label {
  flex: 0 0 130px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 2px solid var(--border);
  flex-shrink: 0;
}

/* ============================================================
   12. TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0;
  min-width: 260px;
  max-width: 380px;
  pointer-events: auto;
  animation: slideIn var(--transition-slow) ease both;
  font-size: 0.82rem;
  color: var(--text-primary);
  word-break: break-word;
}

.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-info    { border-left-color: var(--info); }
.toast-warning { border-left-color: var(--warning); }

/* ============================================================
   13. CONFIRM DIALOG
   ============================================================ */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 16px;
  animation: fadeIn var(--transition-base);
}

.confirm-dialog {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  animation: slideInUp var(--transition-base);
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.confirm-actions .btn {
  flex: 1;
}

/* ============================================================
   14. AGENT CARDS
   ============================================================ */

.agent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.agent-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: 0;
  padding: 10px 14px;
  transition: border-color var(--transition-base);
}

.agent-card:hover {
  border-color: var(--text-secondary);
  border-left-color: var(--success);
}

.agent-card.offline {
  border-left-color: var(--danger);
  opacity: 0.75;
}

.agent-card.warning {
  border-left-color: var(--warning);
}

.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.agent-card-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.agent-card-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.agent-hostname {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

/* Agent card key-value grid (Dashboard) — 3 pairs per row */
.agent-kv-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  gap: 5px 12px;
  font-size: 0.8rem;
  margin: 8px 0;
}

.agent-kv-grid .kv-label {
  color: var(--text-dim);
  white-space: nowrap;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}

.agent-kv-grid .kv-value {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 2px solid var(--border);
  gap: 8px;
}

/* ============================================================
   15. POOL STATUS BAR
   ============================================================ */

.pool-bar-wrapper {
  margin-bottom: 10px;
}

.pool-bar-labels {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.pool-bar-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.pool-bar-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 0;
  flex-shrink: 0;
}

.pool-bar {
  display: flex;
  height: 12px;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  gap: 1px;
}

.pool-bar-segment {
  height: 100%;
  transition: width var(--transition-slow);
  min-width: 2px;
}

.pool-bar-segment.healthy    { background: var(--success); }
.pool-bar-segment.cooldown   { background: var(--warning); }
.pool-bar-segment.assigned   { background: var(--accent); }
.pool-bar-segment.disabled   { background: var(--text-secondary); }

/* Pool table — fixed layout like logs table */
#poolIpv6Section .data-table {
  table-layout: fixed;
  width: 100%;
}

#poolIpv6Section .data-table th:nth-child(1) { width: 120px; }  /* Block */
#poolIpv6Section .data-table th:nth-child(2) { width: auto; }   /* IPv6 — takes remaining */
#poolIpv6Section .data-table th:nth-child(3) { width: 170px; }  /* Source */
#poolIpv6Section .data-table th:nth-child(4) { width: 80px; }   /* Status */
#poolIpv6Section .data-table th:nth-child(5) { width: 70px; }   /* Fail Count */
#poolIpv6Section .data-table th:nth-child(6) { width: 80px; }   /* Total Requests */
#poolIpv6Section .data-table th:nth-child(7) { width: 100px; }  /* Last Used */
#poolIpv6Section .data-table th:nth-child(8) { width: 80px; }   /* Assigned To */
#poolIpv6Section .data-table th:nth-child(9) { width: 70px; }   /* Actions */

#poolIpv4Section .data-table {
  table-layout: fixed;
  width: 100%;
}

#poolIpv4Section .data-table th:nth-child(1) { width: 160px; }  /* IPv4 */
#poolIpv4Section .data-table th:nth-child(2) { width: 170px; }  /* Source */
#poolIpv4Section .data-table th:nth-child(3) { width: 80px; }   /* Status */
#poolIpv4Section .data-table th:nth-child(4) { width: 100px; }  /* Assigned To */
#poolIpv4Section .data-table th:nth-child(5) { width: 70px; }   /* Fail Count */
#poolIpv4Section .data-table th:nth-child(6) { width: 80px; }   /* Total Requests */
#poolIpv4Section .data-table th:nth-child(7) { width: 100px; }  /* Last Used */
#poolIpv4Section .data-table th:nth-child(8) { width: 70px; }   /* Actions */

#poolIpv6Section .data-table td,
#poolIpv4Section .data-table td {
  padding: 8px 14px;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pool stat cards: fixed 5-col */
#poolCards,
#ipv4PoolCards {
  grid-template-columns: repeat(5, 1fr);
}

/* ============================================================
   16. SETTINGS
   ============================================================ */

/* Settings page: 2-column grid */
#page-settings {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-content: start;
}

/* Save button and alert history span full width */
#page-settings > .btn,
#page-settings > .settings-group:last-child {
  grid-column: 1 / -1;
}

.settings-group {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 16px 18px;
}

/* Compact settings rows */
.settings-group .setting-row,
.settings-group .form-row {
  margin-bottom: 10px;
}

.settings-group .form-row label {
  flex: 0 0 140px;
}

.settings-group h3 {
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.settings-group h3 svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row label {
  flex: 0 0 160px;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================
   17. STRESS TEST
   ============================================================ */

/* Stress test: chart row (RPS + errors side by side) */
.stress-chart-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

/* Stress test: target info grid — single row of items */
.target-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.target-info-item {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 8px 10px;
}

.target-info-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
  font-weight: 700;
}

.target-info-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', Consolas, 'SF Mono', monospace;
}

/* ============================================================
   18. STATISTICS + CHARTS
   ============================================================ */

.stats-section-title {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

.stats-chart-wrap {
  position: relative;
  height: 300px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 1rem;
}

/* Stats KPI cards: 4 equal columns */
#stats-kpi-grid {
  grid-template-columns: repeat(4, 1fr);
}

.stats-entity-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.page-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   19. FORM INPUTS (Global)
   ============================================================ */

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="search"],
input[type="url"],
textarea,
select {
  background: var(--bg-base);
  border: 2px solid var(--border);
  border-radius: 0;
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  width: 100%;
  transition: border-color var(--transition-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23999' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Keyboard focus / accessibility */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab-btn:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   20. UTILITIES
   ============================================================ */

.hidden { display: none !important; }

.mono {
  font-family: 'JetBrains Mono', Consolas, 'SF Mono', monospace;
  font-size: 0.82em;
}

.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }
.mb-3  { margin-bottom: 1.5rem; }
.ml-1  { margin-left: 0.5rem; }
.mr-1  { margin-right: 0.5rem; }
.p-1   { padding: 0.5rem; }
.p-2   { padding: 1rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

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

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.flex-wrap {
  flex-wrap: wrap;
}

.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--danger) !important; }
.text-warning   { color: var(--warning) !important; }
.text-info      { color: var(--info) !important; }
.text-accent    { color: var(--accent) !important; }

.text-sm   { font-size: 0.78rem; }
.text-xs   { font-size: 0.7rem; }
.text-mono { font-family: 'JetBrains Mono', Consolas, 'SF Mono', monospace; }

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

.divider {
  border: none;
  border-top: 2px solid var(--border);
  margin: 14px 0;
}

/* ============================================================
   21. MULTI-SELECT (Allowed Agents Checkbox List)
   ============================================================ */

.multi-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-base);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 6px;
}

/* ============================================================
   22. ANIMATIONS + KEYFRAMES
   ============================================================ */

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

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

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

/* ============================================================
   23. RESPONSIVE — Mobile (<=768px)
   ============================================================ */

@media (max-width: 1024px) {
  #poolCards {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  #stats-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  /* Tab bar: allow horizontal scroll, hide scrollbar */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 10px 12px;
    font-size: 0.78rem;
  }

  /* Agent cards: single column */
  .agent-grid {
    grid-template-columns: 1fr;
  }

  /* Stat grid: auto 2-col on small screens */
  .stat-grid,
  .stat-grid.stat-grid-5 {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  #poolCards,
  #ipv4PoolCards {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  #stats-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #page-settings {
    grid-template-columns: 1fr;
  }

  /* Stress test layout */
  .stress-chart-row {
    flex-direction: column;
  }

  /* Page content: tighter padding */
  .page-content {
    padding: 10px;
  }

  /* Page header: wrap */
  .page-header {
    flex-wrap: wrap;
  }

  /* Filter bar: stack on mobile */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar select,
  .filter-bar input,
  .filter-bar input[type="text"] {
    width: 100% !important;
    max-width: none !important;
    flex: none !important;
  }

  /* Modal: take more screen on mobile */
  .modal,
  .confirm-dialog {
    max-width: 100%;
    max-height: 95vh;
  }

  .modal-overlay,
  .confirm-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  /* Header: truncate title on small screens */
  .header-title {
    display: none;
  }

  .header {
    padding: 0 10px;
  }

  /* Form rows: stack label above input */
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-row label {
    flex: none;
    width: auto;
  }

  /* Table wrapper: allow horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Toast: narrower on mobile */
  .toast-container {
    right: 8px;
    left: 8px;
  }

  .toast {
    max-width: 100%;
    min-width: 0;
  }

  .agent-kv-grid {
    grid-template-columns: auto 1fr auto 1fr;
  }

  /* Target info grid: 1 col */
  .target-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card-value {
    font-size: 1.1rem;
  }

  .btn-group {
    flex-wrap: wrap;
  }

  .pagination {
    gap: 2px;
  }

  .pagination button {
    min-width: 26px;
    height: 26px;
    font-size: 0.72rem;
  }
}
