/* Telemetrix Operaciones — panel interno */
:root {
  --primary: #ef4444;
  --primary-dark: #dc2626;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --ok: #10b981;
  --warn: #f59e0b;
  --critical: #dc2626;
  --ops-accent: #7c3aed;
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}

/* ═════ LOGIN ═════ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 1rem;
}
.login-card {
  background: white; padding: 2.5rem 2rem; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4); width: 100%; max-width: 400px;
}
.login-brand {
  text-align: center; margin-bottom: 2rem;
}
.login-brand img { height: 48px; margin-bottom: 0.75rem; }
.login-brand h1 { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.login-brand .ops-badge {
  display: inline-block; margin-top: 0.5rem; padding: 0.25rem 0.75rem;
  background: var(--ops-accent); color: white;
  border-radius: 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em;
}
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-card label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.login-card input {
  padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-card button {
  margin-top: 0.5rem; padding: 0.75rem; background: var(--primary); color: white;
  border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: 0.5; cursor: not-allowed; }
.login-card button:hover:not(:disabled) { background: var(--primary-dark); }
.login-error { color: var(--critical); font-size: 0.85rem; text-align: center; }

/* ═════ APP LAYOUT ═════ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: white; border-right: 1px solid var(--border);
  padding: 1.25rem 1rem; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { margin-bottom: 1.5rem; }
.sidebar-brand img { height: 36px; }
.sidebar-brand .ops-label {
  display: block; margin-top: 0.5rem;
  font-size: 0.7rem; font-weight: 700; color: var(--ops-accent);
  letter-spacing: 0.15em;
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-section {
  font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.1em; padding: 0.5rem 0.75rem; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.75rem; border-radius: 8px; text-decoration: none;
  color: var(--text); font-size: 0.9rem; font-weight: 500;
}
.sidebar-link:hover { background: #f1f5f9; }
.sidebar-link.active { background: var(--primary); color: white; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.sidebar-user { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; padding: 0 0.75rem; }
.sidebar-logout {
  width: 100%; background: none; border: none; padding: 0.5rem 0.75rem;
  text-align: left; cursor: pointer; color: var(--text-muted);
  font-size: 0.85rem; border-radius: 8px;
}
.sidebar-logout:hover { background: #f1f5f9; color: var(--text); }

.main { flex: 1; padding: 1.5rem 2rem; overflow: auto; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; }
.page-header .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; background: var(--ok);
  border-radius: 50%; margin-right: 0.4rem; animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.3; } }

/* ═════ SERVER CARDS ═════ */
.servers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.server-card {
  background: white; border: 1px solid var(--border); border-radius: 12px;
  padding: 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.server-card.status-ok { border-left: 4px solid var(--ok); }
.server-card.status-warning { border-left: 4px solid var(--warn); }
.server-card.status-critical { border-left: 4px solid var(--critical); }
.server-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.server-name { font-size: 1rem; font-weight: 700; margin: 0 0 0.25rem 0; }
.server-ip { font-size: 0.75rem; color: var(--text-muted); }
.server-role { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.server-status-pill {
  padding: 0.25rem 0.625rem; border-radius: 999px; font-size: 0.7rem;
  font-weight: 700; letter-spacing: 0.05em;
}
.status-ok .server-status-pill { background: #f0fdf4; color: var(--ok); }
.status-warning .server-status-pill { background: #fffbeb; color: var(--warn); }
.status-critical .server-status-pill { background: #fef2f2; color: var(--critical); }

.metric-row { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; }
.metric-label { font-size: 0.85rem; color: var(--text-muted); }
.metric-value { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.progress-bar {
  width: 120px; height: 8px; background: #e2e8f0; border-radius: 4px;
  overflow: hidden; margin-left: 0.75rem;
}
.progress-fill { height: 100%; background: var(--ok); transition: width 0.5s; }
.progress-fill.warn { background: var(--warn); }
.progress-fill.critical { background: var(--critical); }

.services-list {
  margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.3rem;
}
.service-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.2rem 0; font-size: 0.8rem;
}
.service-name { color: var(--text); font-size: 0.85rem; }
.service-status { font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 4px; }
.service-status.active { background: #f0fdf4; color: var(--ok); }
.service-status.down { background: #fef2f2; color: var(--critical); }
.service-status.unknown { background: #f1f5f9; color: var(--text-muted); }

.error-state { color: var(--critical); padding: 1rem; text-align: center; font-size: 0.9rem; }
.loading-state { color: var(--text-muted); text-align: center; padding: 3rem; font-size: 1rem; }

.footer-info {
  margin-top: 1rem; text-align: center; font-size: 0.75rem; color: var(--text-muted);
}

/* ═════ LEGEND — guía de umbrales ═════ */
.threshold-legend {
  margin-top: 1.5rem; background: white; border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.25rem;
}
.threshold-legend h3 {
  margin: 0 0 0.75rem; font-size: 0.85rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
}
.threshold-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.threshold-table th {
  text-align: left; padding: 0.4rem 0.5rem; font-weight: 600;
  color: var(--text-muted); font-size: 0.75rem; border-bottom: 1px solid var(--border);
}
.threshold-table td { padding: 0.5rem; border-bottom: 1px solid #f1f5f9; }
.threshold-table td:first-child { font-weight: 600; }
.threshold-table .th-ok { color: var(--ok); font-weight: 600; }
.threshold-table .th-warn { color: var(--warn); font-weight: 600; }
.threshold-table .th-critical { color: var(--critical); font-weight: 600; }
.threshold-table tr:last-child td { border-bottom: none; }
.stub-card {
  background: white; border: 2px dashed var(--border); border-radius: 12px;
  padding: 3rem 2rem; text-align: center; color: var(--text-muted);
}
.stub-card h2 { color: var(--text); margin-top: 0; }
.stub-card code { background: #f1f5f9; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.85rem; }

@media (max-width: 768px) {
  .servers-grid { grid-template-columns: 1fr; }
  .sidebar { width: 70px; padding: 1rem 0.5rem; }
  .sidebar-brand img { height: 28px; }
  .sidebar-link { justify-content: center; padding: 0.75rem; }
  .sidebar-link span, .sidebar-user, .sidebar-brand .ops-label, .sidebar-section { display: none; }
  .main { padding: 1rem; }
}
