:root {
  --bg: #0b1220;
  --bg-glow: #122033;
  --sidebar: #0f172a;
  --panel: #131c2e;
  --panel-2: #1a2438;
  --border: #243044;
  --text: #e8eef7;
  --muted: #8fa3bf;
  --primary: #3dd6c6;
  --primary-dim: rgba(61, 214, 198, 0.15);
  --green: #3ecf8e;
  --orange: #f0a04b;
  --red: #f07178;
  --purple: #7c8cff;
  --idle: #f0a04b;
  --locked: #7c8cff;
  --off: #64748b;
  --active: #3ecf8e;
}

* { box-sizing: border-box; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a3a4a 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a2540 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, #101a2c 0%, #0c1422 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  position: fixed;
  height: 100vh;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3dd6c6, #2a9d8f);
  display: grid; place-items: center;
  color: #04201c;
  font-size: 1.25rem;
  box-shadow: 0 8px 24px rgba(61,214,198,0.25);
}
.sidebar-brand strong { display: block; letter-spacing: -0.02em; }
.sidebar-brand small { display: block; color: var(--muted); font-size: 0.7rem; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
  font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 1rem; }
.user-chip { display: flex; gap: 0.75rem; align-items: center; font-size: 0.875rem; }
.user-chip i { font-size: 1.5rem; color: var(--muted); }
.user-chip small { display: block; color: var(--muted); text-transform: uppercase; font-size: 0.65rem; }

.main-content {
  margin-left: 250px;
  flex: 1;
  padding: 2rem;
  max-width: 1500px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.7rem; font-weight: 700; margin: 0; letter-spacing: -0.03em; }

.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
}
.metric-label { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.metric-value { font-size: 1.85rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.accent-green .metric-value { color: var(--green); }
.accent-orange .metric-value { color: var(--orange); }
.accent-blue .metric-value { color: var(--primary); }
.accent-purple .metric-value { color: var(--purple); }
.accent-muted .metric-value { color: var(--off); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.panel-header {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.panel-body { padding: 1.25rem; }
.panel-footer { border-top: 1px solid var(--border); }

.search-bar { position: relative; max-width: 480px; }
.search-bar i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-bar input { padding-left: 2.5rem; background: var(--panel); border-color: var(--border); color: var(--text); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, #1a3a4a 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.5rem;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #3dd6c6, #2a9d8f);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #04201c;
  margin-bottom: 1rem;
}

.capture-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.capture-card:hover { border-color: var(--primary); color: var(--text); transform: translateY(-2px); }
.capture-card-icon {
  height: 100px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--muted);
}
.capture-card-body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; }
.capture-card-body small, .capture-card-body span { color: var(--muted); font-size: 0.75rem; }

.capture-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.75rem;
  gap: 0.5rem;
}
.capture-thumb:hover { border-color: var(--primary); color: var(--text); }
.capture-full { max-height: 80vh; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }

.form-control, .form-select {
  background: #0f172a;
  border-color: var(--border);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  background: #0f172a;
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 0 0 0.2rem rgba(61,214,198,0.2);
}

.breadcrumb-item a { color: var(--primary); text-decoration: none; }
.breadcrumb-item.active { color: var(--muted); }

/* Time Doctor timeline */
.td-legend { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin-bottom: 1rem; font-size: 0.8rem; color: var(--muted); }
.td-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.td-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.td-dot.active { background: var(--active); }
.td-dot.idle { background: var(--idle); }
.td-dot.locked { background: var(--locked); }
.td-dot.off { background: var(--off); }

.timeline-track {
  display: flex;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: #0a101c;
  border: 1px solid var(--border);
}
.timeline-seg {
  height: 100%;
  min-width: 2px;
  transition: filter 0.15s;
  cursor: default;
  position: relative;
}
.timeline-seg:hover { filter: brightness(1.25); z-index: 2; }
.timeline-seg.estado-Activo { background: var(--active); }
.timeline-seg.estado-Inactivo { background: var(--idle); }
.timeline-seg.estado-Bloqueado { background: var(--locked); }
.timeline-seg.estado-PantallaApagada { background: var(--off); }

.app-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.app-bar-name {
  width: 160px;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
}
.app-bar-track {
  flex: 1;
  height: 10px;
  background: #0a101c;
  border-radius: 999px;
  overflow: hidden;
}
.app-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2a9d8f, #3dd6c6);
  border-radius: 999px;
}
.app-bar-meta { width: 90px; text-align: right; font-size: 0.8rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; }

.usage-stack {
  display: flex;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0 0.35rem;
}
.usage-stack > div { height: 100%; }

.estado-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.estado-pill.Activo { background: rgba(62,207,142,0.15); color: var(--green); }
.estado-pill.Inactivo { background: rgba(240,160,75,0.15); color: var(--orange); }
.estado-pill.Bloqueado { background: rgba(124,140,255,0.15); color: var(--purple); }
.estado-pill.PantallaApagada { background: rgba(100,116,139,0.25); color: #94a3b8; }

.remote-stage {
  background: #05080f;
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.remote-stage img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}
.remote-badge {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(240,113,120,0.9);
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.btn-primary {
  --bs-btn-bg: #2a9d8f;
  --bs-btn-border-color: #2a9d8f;
  --bs-btn-hover-bg: #3dd6c6;
  --bs-btn-hover-border-color: #3dd6c6;
  --bs-btn-color: #04201c;
  --bs-btn-hover-color: #04201c;
}

.table { --bs-table-bg: transparent; --bs-table-color: var(--text); }
.table > :not(caption) > * > * { border-bottom-color: var(--border); }

@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; padding: 1rem; }
  .app-shell { flex-direction: column; }
  .app-bar-name { width: 100px; }
}


/* ---------- Gestión de activos ---------- */
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .9rem .9rem .25rem; opacity: .7; }
.pill { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pill-ok { background: rgba(62,207,142,.15); color: var(--green); }
.pill-warn { background: rgba(240,160,75,.18); color: var(--orange); }
.pill-crit { background: rgba(240,113,120,.18); color: var(--red); }
.pill-muted { background: rgba(143,163,191,.14); color: var(--muted); }
.tk-abierto { background: rgba(61,214,198,.15); color: var(--primary); }
.tk-en_progreso { background: rgba(124,140,255,.18); color: var(--purple); }
.tk-en_espera { background: rgba(240,160,75,.18); color: var(--orange); }
.tk-resuelto { background: rgba(62,207,142,.15); color: var(--green); }
.tk-cerrado { background: rgba(100,116,139,.25); color: #94a3b8; }
.pr-baja { background: rgba(100,116,139,.25); color: #94a3b8; }
.pr-media { background: rgba(61,214,198,.12); color: var(--primary); }
.pr-alta { background: rgba(240,160,75,.18); color: var(--orange); }
.pr-critica { background: rgba(240,113,120,.22); color: var(--red); }
.mini-bar { display: inline-block; width: 56px; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: .3rem; }
.mini-bar > div { height: 100%; }
.mini-bar .ok { background: var(--green); } .mini-bar .warn { background: var(--orange); } .mini-bar .crit { background: var(--red); }
.accent-red .metric-value { color: var(--red); }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.kv dt { color: var(--muted); font-weight: 500; font-size: .85rem; }
.kv dd { margin-bottom: .55rem; }
.comment { border-left: 3px solid var(--primary); padding: .5rem .8rem; margin-bottom: .8rem; background: var(--panel-2); border-radius: 0 6px 6px 0; }
.comment-sys { border-left-color: var(--muted); opacity: .85; font-size: .9rem; }
