:root {
  --bg: #0f172a;
  --panel: #f8fafc;
  --panel-dark: #1e293b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #eef2f7;
  color: var(--text);
}

header.topbar {
  background: var(--bg);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

header.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}
header.topbar h1 span { font-weight: 300; opacity: .7; display: block; font-size: 11px; }

.estado-conexion {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
}
.estado-conexion .punto {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok);
}
.estado-conexion.offline .punto { background: var(--warn); animation: pulse 1.5s infinite; }
.estado-conexion .badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

nav.tabs {
  display: flex;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 19;
}
nav.tabs button {
  flex: 0 0 auto;
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
nav.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main { padding: 14px; max-width: 900px; margin: 0 auto 60px; }

.vista { display: none; }
.vista.active { display: block; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card h2 { font-size: 14px; margin: 0 0 12px; color: var(--text); }
.card h3 { font-size: 13px; margin: 18px 0 8px; color: var(--text-light); text-transform: uppercase; letter-spacing: .05em; }

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

label { font-size: 12px; font-weight: 600; color: var(--text-light); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 10px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn:active { background: var(--accent-dark); }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.small { width: auto; padding: 6px 12px; font-size: 12px; }

.lista-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.lista-item:active { background: #f1f5f9; }
.lista-item .info b { font-size: 13px; }
.lista-item .info div { font-size: 12px; color: var(--text-light); }

.pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.Activo, .pill.Bueno, .pill.Vigente, .pill.Bajo, .pill.Completado { background: #dcfce7; color: #166534; }
.pill.Baja, .pill.EnPrestamo, .pill.Regular, .pill.Medio, .pill.Programado, .pill.Pendiente { background: #fef9c3; color: #854d0e; }
.pill.Malo, .pill.Extraviado, .pill.Obsoleto, .pill.Critico, .pill.Alta, .pill.Vencido { background: #fee2e2; color: #991b1b; }
.pill.EnReparacion, .pill.Alto, .pill.ProximoARenovar { background: #ffedd5; color: #9a3412; }
.pill.pendiente-sync { background: #dbeafe; color: #1e40af; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: #fff; border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.stat-box .num { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-box .label { font-size: 11px; color: var(--text-light); margin-top: 2px; }

.buscador { display: flex; gap: 8px; margin-bottom: 12px; }
.buscador input { margin-bottom: 0; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p { font-size: 12px; color: var(--text-light); margin: 0 0 20px; }
.error-msg { color: var(--danger); font-size: 12px; margin-bottom: 10px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

canvas { max-width: 100%; }
