/* ==========================================================================
   CADDY PROXY MANAGER - DESIGN SYSTEM & STYLESHEET
   Inspirado en Linear, Cloudflare y Vercel. 
   Modo oscuro y claro mediante variables CSS puras.
   ========================================================================== */

:root {
  /* Paleta Base - Modo Claro */
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Acentos de Marca */
  --brand-cyan: #0284c7;
  --brand-cyan-glow: rgba(2, 132, 199, 0.15);
  --brand-blue: #2563eb;

  /* Estados Funcionales */
  --state-success: #10b981;
  --state-success-bg: rgba(16, 185, 129, 0.12);
  --state-warning: #f59e0b;
  --state-warning-bg: rgba(245, 158, 11, 0.12);
  --state-danger: #ef4444;
  --state-danger-bg: rgba(239, 68, 68, 0.12);

  /* Sombras y Radios */
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.12);

  --sidebar-width: 256px;
  --topbar-height: 56px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  /* Paleta Base - Modo Oscuro Técnico */
  --bg-app: #080b11;
  --bg-sidebar: #0d121c;
  --bg-card: #0f1726;
  --bg-subtle: #162032;
  --bg-hover: #1c283f;
  
  --border-color: #1e293b;
  --border-subtle: #334155;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #475569;

  /* Acentos Eléctricos */
  --brand-cyan: #00f2fe;
  --brand-cyan-glow: rgba(0, 242, 254, 0.18);
  --brand-blue: #38bdf8;

  --state-success: #10b981;
  --state-success-bg: rgba(16, 185, 129, 0.15);
  --state-warning: #fbbf24;
  --state-warning-bg: rgba(251, 191, 36, 0.15);
  --state-danger: #f87171;
  --state-danger-bg: rgba(248, 113, 113, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 20px -2px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 40px -4px rgba(0, 0, 0, 0.8);
}

/* ==========================================================================
   Reset y Fundamentos
   ========================================================================== */

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

code, .font-mono {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* ==========================================================================
   Layout Principal
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--brand-cyan), #3b82f6);
  color: #040914;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--brand-cyan-glow);
}

.brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--bg-subtle);
  color: var(--brand-cyan);
  font-weight: 600;
}

.nav-item.active svg {
  stroke: var(--brand-cyan);
}

.pill-count {
  margin-left: auto;
  font-size: 0.72rem;
  background-color: var(--bg-hover);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: auto;
}

.dot-cyan { background-color: var(--brand-cyan); box-shadow: 0 0 6px var(--brand-cyan); }
.dot-emerald { background-color: var(--state-success); }
.dot-rose { background-color: var(--state-danger); }
.dot-blue { background-color: var(--brand-blue); }
.dot-slate { background-color: var(--text-dim); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
}

.caddy-engine-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.status-indicator.live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--state-success);
  box-shadow: 0 0 8px var(--state-success);
}

.engine-meta {
  display: flex;
  flex-direction: column;
}

.engine-title {
  font-size: 0.75rem;
  font-weight: 600;
}

.engine-uptime {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.breadcrumb-item {
  color: var(--text-muted);
}

.breadcrumb-item.current {
  color: var(--text-main);
  font-weight: 600;
}

.breadcrumb-separator {
  color: var(--text-dim);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.search-box input {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.8125rem;
  padding: 6px 42px 6px 32px;
  border-radius: var(--radius-sm);
  width: 260px;
  outline: none;
  transition: all 0.15s ease;
}

.search-box input:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 2px var(--brand-cyan-glow);
  width: 300px;
}

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

.shortcut-hint {
  position: absolute;
  right: 8px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #334155);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #f8fafc;
  cursor: pointer;
}

/* ==========================================================================
   Botones y Elementos Interactivos
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--brand-cyan);
  color: #030712;
  box-shadow: 0 2px 10px var(--brand-cyan-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

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

.btn-text {
  background: none;
  border: none;
  color: var(--brand-cyan);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

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

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

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

/* Toggle tema iconos */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ==========================================================================
   Página Dashboard
   ========================================================================== */

.page-content {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

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

.alert-banner.warning {
  background-color: var(--state-warning-bg);
  border-color: rgba(245, 158, 11, 0.3);
}

.alert-icon svg {
  stroke: var(--state-warning);
}

.alert-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 0.8125rem;
}

.alert-title {
  font-weight: 600;
  color: var(--text-main);
}

.alert-desc {
  color: var(--text-muted);
}

.alert-desc code {
  color: var(--text-main);
  background-color: rgba(0, 0, 0, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
}

/* Grid de Métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-subtle);
}

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

.metric-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.metric-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.metric-badge.trend-up {
  background-color: var(--state-success-bg);
  color: var(--state-success);
}

.metric-badge.info {
  background-color: var(--brand-cyan-glow);
  color: var(--brand-cyan);
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.metric-value {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-family: var(--font-mono);
}

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

.metric-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

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

/* Gráfico */
.dashboard-graph-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

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

.card-header.border-bottom {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

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

.time-range-selector {
  display: flex;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.pill-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.chart-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.native-chart {
  width: 100%;
  height: 180px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border-color);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-color.cyan { background-color: var(--brand-cyan); }
.legend-color.blue { background-color: #3b82f6; }

/* Grid Split Inferior */
.dashboard-split-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

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

.badge-count {  font-size: 0.7rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
}

.input-xs {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}

.input-xs:focus {
  border-color: var(--brand-cyan);
}

/* ==========================================================================
   Tablas Modernas
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.data-table th {
  padding: 12px 18px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.6875rem;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

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

.data-table tbody tr.row-warning {
  background-color: rgba(239, 68, 68, 0.04);
}

.domain-cell {
  display: flex;
  flex-direction: column;
}

.domain-name {
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
}

.domain-name:hover {
  color: var(--brand-cyan);
  text-decoration: underline;
}

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

.code-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.code-tag.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--state-danger);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.badge-tls {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-online {
  background-color: var(--state-success-bg);
  color: var(--state-success);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--state-success);
  box-shadow: 0 0 6px var(--state-success);
}

.badge-danger {
  background-color: var(--state-danger-bg);
  color: var(--state-danger);
}

.dot-solid {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--state-danger);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.text-right { text-align: right; }

.card-footer-simple {
  padding: 12px 18px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.text-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand-cyan);
  text-decoration: none;
}

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

/* ==========================================================================
   Activity Stream / Timeline
   ========================================================================== */

.activity-card {
  padding: 0;
}

.activity-card .card-header {
  padding: 18px 20px 14px 20px;
}

.live-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--state-success);
  background-color: var(--state-success-bg);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.timeline {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  gap: 18px;
  flex: 1;
}

.timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: -18px;
  width: 1px;
  background-color: var(--border-color);
}

.timeline-item:last-child::after {
  display: none;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.timeline-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.timeline-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.timeline-body {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.timeline-body code {
  color: var(--text-main);
  background-color: var(--bg-subtle);
  padding: 1px 3px;
  border-radius: 3px;
}

/* ==========================================================================
   Modales & Formularios Premium
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.modal-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  padding: 0 24px;
  gap: 18px;
}

.tab-item {
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.tab-item:hover {
  color: var(--text-main);
}

.tab-item.active {
  color: var(--brand-cyan);
  border-bottom-color: var(--brand-cyan);
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.tab-pane.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row-grid {
  display: flex;
  gap: 12px;
}

.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.flex-5 { flex: 5; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.required {
  color: var(--state-danger);
}

.form-control {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease;
}

.form-control:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 2px var(--brand-cyan-glow);
}

.form-control.is-invalid {
  border-color: var(--state-danger);
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Switches / Toggles */
.toggles-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle-control input {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background-color: var(--border-subtle);
  border-radius: 999px;
  position: relative;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-control input:checked + .toggle-switch {
  background-color: var(--brand-cyan);
}

.toggle-control input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.toggle-label strong {
  font-size: 0.8125rem;
  font-weight: 600;
}

.toggle-label small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   Responsividad & Vista Móvil
   ========================================================================== */

.mobile-only {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 35;
  display: none;
}

@media (max-width: 1024px) {
  .dashboard-split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .search-box input {
    width: 180px;
  }

  .search-box input:focus {
    width: 200px;
  }

  .form-row-grid {
    flex-direction: column;
  }

  .topbar {
    padding: 0 16px;
  }

  .page-content {
    padding: 16px;
  }
}

/* ==========================================================================
   EXTENSIONES DEL SISTEMA VISUAL: GESTIÓN DE PROXY HOSTS
   ========================================================================== */

/* Barra de Herramientas y Filtros */
.table-toolbar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.table-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.table-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-select {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.8125rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.filter-select:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 2px var(--brand-cyan-glow);
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Modales con Variaciones de Tamaño */
.modal-dialog-lg {
  max-width: 680px;
}

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

/* Botón Destructivo */
.btn-danger {
  background-color: var(--state-danger);
  color: #ffffff;
  border: 1px solid transparent;
}

.btn-danger:hover {
  filter: brightness(1.15);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
}

.text-danger {
  color: var(--state-danger);
}

/* Validaciones y Errores de Formulario */
.field-error-msg {
  font-size: 0.72rem;
  color: var(--state-danger);
  display: none;
}

.form-group.has-error .form-control {
  border-color: var(--state-danger);
}

.form-group.has-error .field-error-msg {
  display: block;
}

/* Estados Vacíos (Zero State) */
.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  text-align: center;
}

.empty-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

.empty-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 380px;
  margin: 6px 0 20px 0;
}

/* Estado de Carga (Skeletons) */
.table-loading-state {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-row {
  height: 44px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-hover) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shimmer 1.5s infinite linear;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Resumen del Pie de Tabla */
.card-footer-toolbar {
  padding: 10px 18px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Contenedor de Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-success {  border-left: 3px solid var(--state-success);
}

.toast.toast-warning {
  border-left: 3px solid var(--state-warning);
}

.toast.toast-error {
  border-left: 3px solid var(--state-danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Switch compacto para filas de tabla */
.table-switch-wrap {
  display: inline-flex;
  align-items: center;
}

.table-switch-wrap input {
  display: none;
}

.table-switch {
  width: 30px;
  height: 16px;
  background-color: var(--border-subtle);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.table-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.table-switch-wrap input:checked + .table-switch {
  background-color: var(--state-success);
}

.table-switch-wrap input:checked + .table-switch::after {
  transform: translateX(14px);
}

.domain-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* Controles de Proxy Hosts: foco de teclado y estados responsivos. */
.table-switch-wrap { position: relative; min-width: 34px; min-height: 28px; cursor: pointer; }
.table-switch-wrap input {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.table-switch-wrap input:focus-visible + .table-switch {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 3px;
}
.table-switch-wrap input:disabled + .table-switch { opacity: 0.55; }
.alert-banner.danger { background: var(--state-danger-bg); border-color: var(--state-danger); }
#modal-host .modal-tabs { overflow-x: auto; }
.table-empty-state[style*="display: none"] { display: none !important; }
@media (max-width: 768px) {
  .table-toolbar-left, .table-toolbar-right, .table-toolbar-container { width: 100%; }
  .table-toolbar-left .search-box, #host-search { width: 100%; }
  .table-toolbar-left .search-box { margin-bottom: 8px; }
  .table-toolbar-left .select-wrapper { flex: 1; }
  .table-toolbar-left .filter-select { width: 100%; }
  #modal-host .modal-dialog { max-height: calc(100vh - 32px); overflow: auto; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: 0; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-row, .toast { animation: none; }
}

/* Secciones administrativas integradas con el sistema visual principal. */
.section-bar {display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap;margin-bottom:18px;color:var(--text-muted);font-size:.86rem}
.section-bar .form-control {max-width:410px}
.section-bar button {white-space:nowrap}
.section-form {padding:22px;margin-bottom:22px;display:flex;flex-direction:column;gap:14px}
.section-form[hidden] {display:none}
.section-form h3 {font-size:1rem;font-weight:600;color:var(--text-main)}
.section-form .form-group {display:flex;flex-direction:column;gap:7px;font-size:.84rem;font-weight:500;color:var(--text-muted)}
.section-form .form-control {margin-top:3px;color:var(--text-main)}
.section-form textarea {resize:vertical}
.section-fields {display:grid;grid-template-columns:1fr 1.45fr .95fr;gap:12px}
.section-checkbox {display:flex;align-items:center;gap:9px;font-size:.85rem}
.section-checkbox input {width:17px;height:17px;accent-color:var(--brand-cyan)}
.section-actions {display:flex;gap:10px;flex-wrap:wrap;margin-top:4px}
.section-row-actions {display:flex;align-items:center;gap:6px}
.section-row-actions .btn {padding:5px 9px;font-size:.76rem}
.section-footnote {color:var(--text-muted);font-size:.78rem;margin:14px 0}
.section-empty {padding:38px 14px;text-align:center;color:var(--text-muted);font-size:.9rem}
.section-explanation {padding:16px 18px;border:1px solid var(--border-color);background:var(--bg-subtle);border-radius:var(--radius-md);color:var(--text-muted);font-size:.85rem;line-height:1.6;margin-bottom:20px}
.section-summary-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-bottom:20px}
.section-stat {padding:22px;display:flex;flex-direction:column;gap:8px}
.section-stat strong {font-size:1.8rem;line-height:1.2;letter-spacing:-.03em;font-variant-numeric:tabular-nums}
.section-stat-label {font-size:.79rem;color:var(--text-muted);font-weight:500}
.section-details {display:grid;grid-template-columns:1fr 1fr;gap:10px;border-top:1px solid var(--border-color);padding-top:12px}
.section-details dt {font-size:.8rem;color:var(--text-muted)}
.section-details dd {font-family:var(--font-mono);font-size:.82rem;text-align:right;overflow-wrap:anywhere}
.section-account {font-size:1.07rem;font-weight:650}
#section-notice[hidden] {display:none}
.section-form button:disabled {opacity:.55;cursor:wait}
@media(max-width:800px) {
 .section-fields {grid-template-columns:1fr}
 .section-summary-grid {grid-template-columns:1fr 1fr}
 .section-bar .form-control {width:100%;max-width:none}
}
@media(max-width:480px) {
 .section-summary-grid {grid-template-columns:1fr}
 .section-form {padding:16px}
 .section-row-actions {flex-wrap:wrap}
}


/* Access Control: compact per-host cards and an explicitly opened editor. */
.access-cards {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,275px),1fr));gap:16px;margin-bottom:20px}
.access-card {padding:22px;display:flex;flex-direction:column;align-items:flex-start;gap:16px;min-width:0}
.access-card-top {display:flex;gap:10px;align-items:flex-start;justify-content:space-between;width:100%;flex-wrap:wrap}
.access-card-title {font-size:.97rem;font-weight:650;line-height:1.45;overflow-wrap:anywhere;max-width:100%;color:var(--text-main)}
.access-card-badge {border-radius:999px;padding:5px 10px;font-size:.72rem;background:var(--bg-subtle);color:var(--text-muted);border:1px solid var(--border-color);white-space:nowrap}
.access-card-badge.access-restricted {color:var(--brand-cyan);border-color:var(--brand-cyan)}
.access-card-desc {font-size:.83rem;color:var(--text-muted);line-height:1.55}
.access-networks {display:flex;flex-wrap:wrap;gap:6px}
.access-network {padding:5px 7px;background:var(--bg-subtle);border:1px solid var(--border-color);border-radius:6px;font-size:.74rem;overflow-wrap:anywhere}
.access-card>.btn {margin-top:auto}
.access-modal-body {padding:22px 24px;display:grid;gap:12px}
.access-modal-body .form-group {display:block;font-size:.84rem;font-weight:550;color:var(--text-main)}
.access-modal-body textarea {width:100%;resize:vertical;line-height:1.55}
.access-close {border:0;background:transparent;color:var(--text-muted);font-size:1.6rem;cursor:pointer;line-height:1;padding:0 5px}
.access-close:hover {color:var(--text-main)}
.activity-toolbar {justify-content:flex-start}
.activity-toolbar #events-search {flex:1;min-width:180px}
.activity-toolbar #events-size {width:80px;flex:0 0 80px}
.activity-size-label {white-space:nowrap;font-size:.81rem}
.activity-toolbar #events-total {white-space:nowrap;margin-left:auto}
.activity-pager {display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-top:18px;color:var(--text-muted);font-size:.81rem}
.activity-controls {display:flex;align-items:center;gap:10px}
.activity-page-label {font-variant-numeric:tabular-nums;white-space:nowrap}
.activity-controls button:disabled {opacity:.5;cursor:not-allowed}
@media(max-width:520px){.access-modal-body{padding:16px}.activity-toolbar #events-search{min-width:100%;max-width:none}.activity-pager{justify-content:center}}
