:root {
  --primary: #1a1a2e;
  --accent: #e94560;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --bg: #f8f9fa;
  --card-bg: #fff;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

/* Navigation */
.nav {
  background: var(--primary);
  padding: 0 2rem;
  display: flex;
  gap: 0;
}

.nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 0.85rem 1.2rem;
  display: inline-block;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover,
.nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* Header */
header {
  background: var(--primary);
  color: #fff;
  padding: 1rem 2rem 0;
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  padding-bottom: 0.85rem;
}

/* Main */
main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2, .card h3 {
  margin-top: 0;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.stat-card .stat-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-recibido { background: #cfe2ff; color: #084298; }
.badge-en_inspeccion { background: #fff3cd; color: #664d03; }
.badge-en_reparacion { background: #ffe5d0; color: #7d3c04; }
.badge-listo { background: #d1e7dd; color: #0a3622; }
.badge-entregado { background: #e2e3e5; color: #41464b; }
.badge-aprobado { background: #d1e7dd; color: #0a3622; }
.badge-rechazado { background: #f8d7da; color: #58151c; }
.badge-pendiente { background: #fff3cd; color: #664d03; }
.badge-en_progreso { background: #cfe2ff; color: #084298; }
.badge-completada { background: #d1e7dd; color: #0a3622; }
.badge-exterior { background: #e8d5f5; color: #5e3380; }
.badge-interior { background: #d0f0fd; color: #0a4967; }
.badge-mecanica { background: #ffe5d0; color: #7d3c04; }
.badge-electrica { background: #fff3cd; color: #664d03; }
.badge-otro { background: #e2e3e5; color: #41464b; }

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

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

.table th {
  background: #f1f3f5;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.table tr:hover td {
  background: #f8f9fa;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Inline form panel */
.inline-form {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.inline-form h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-header h2 {
  margin: 0;
}

/* Status bar */
.status-bar {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  height: 24px;
  margin-bottom: 1rem;
}

.status-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  transition: flex 0.3s;
  min-width: 0;
  overflow: hidden;
}

/* Loading / empty */
.loading { color: var(--text-muted); padding: 2rem; text-align: center; }
.empty { color: var(--text-muted); padding: 1.5rem; text-align: center; font-style: italic; }

/* Checks grid */
.checks-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.check-item {
  font-size: 0.8rem;
  padding: 0.2em 0.5em;
  border-radius: 4px;
}

.check-ok { background: #d1e7dd; color: #0a3622; }
.check-fail { background: #f8d7da; color: #58151c; }

/* Responsive */
@media (max-width: 768px) {
  header { padding: 0.75rem 1rem 0; }
  header h1 { font-size: 1.2rem; }
  .nav { padding: 0 0.5rem; flex-wrap: wrap; }
  main { padding: 0 0.75rem; margin: 1rem auto; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

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

/* ── Dashboard Filters ────────────────────────────────── */
.dashboard-filters {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.dashboard-filters label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.dashboard-filters select,
.dashboard-filters input[type="month"] {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
}

.dashboard-filters select:focus,
.dashboard-filters input[type="month"]:focus {
  border-color: var(--accent);
}

/* ── Dashboard Grid ───────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── Horizontal Bar Chart ─────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 0.6rem; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bar-label {
  width: 110px;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
  color: var(--text-muted);
}

.bar-track {
  flex: 1;
  background: #f1f3f5;
  border-radius: 4px;
  height: 28px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  transition: width 0.4s ease;
  min-width: 4px;
}

.bar-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Semáforo ─────────────────────────────────────────── */
.semaforo-list { display: flex; flex-direction: column; gap: 0.25rem; }

.semaforo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.semaforo-item:last-child { border-bottom: none; }

.semaforo-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.semaforo-dot.verde { background: var(--success); }
.semaforo-dot.amarillo { background: var(--warning); }
.semaforo-dot.rojo { background: var(--danger); }

.semaforo-nombre { flex: 1; font-size: 0.9rem; }
.semaforo-valor { font-size: 0.9rem; font-weight: 600; color: var(--text); }

/* ── Alert Panel ──────────────────────────────────────── */
.alert-panel {
  max-height: 280px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.alert-item:last-child { border-bottom: none; }

.alert-icon { font-size: 0.9rem; flex-shrink: 0; margin-top: 0.1rem; }
.alert-mensaje { flex: 1; }
.alert-fecha { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; }

.alert-empty {
  text-align: center;
  color: var(--success);
  padding: 1.5rem;
  font-size: 0.9rem;
  margin: 0;
}

/* ── Auto-refresh indicator ───────────────────────────── */
.refresh-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

/* ── Hamburger menu ───────────────────────────────────── */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  line-height: 1;
  position: absolute;
  top: 0.9rem;
  right: 1rem;
}

/* ── Mobile (≤ 700px) ─────────────────────────────────── */
@media (max-width: 700px) {
  header { position: relative; flex-direction: column; align-items: flex-start; padding-bottom: 0; }
  .hamburger { display: block; }
  .nav { display: none; flex-direction: column; width: 100%; padding: 0.5rem 0 0.75rem; gap: 0; }
  .nav.open { display: flex; }
  .nav a { padding: 0.6rem 1rem; border-radius: 0; border-top: 1px solid rgba(255,255,255,0.1); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-filters { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .bar-label { width: 80px; font-size: 0.78rem; }
}
