@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg-primary:    #e5e8eb;
  --bg-secondary:  #f8fafc;
  --bg-card:       #ffffff;
  --bg-card-hover: #f2f4f7;
  --accent:        #3b82f6;
  --accent-dark:   #2563eb;
  --accent-glow:   rgba(59,130,246,0.14);
  --success:       #16a34a;
  --warning:       #f59e0b;
  --danger:        #dc2626;
  --text-primary:  #2b3440;
  --text-secondary:#5a6c7d;
  --text-muted:    #7a8897;
  --border:        rgba(30,41,59,0.06);
  --border-accent: rgba(59,130,246,0.2);
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 8px 24px rgba(30,41,59,0.04);
  --shadow-glow:   0 0 24px rgba(59,130,246,0.06);
  --shadow-lg:     0 12px 48px rgba(30,41,59,0.08);
  --transition:    0.2s ease;
  --user-panel-h: 64px;
}

body.dark-mode {
  --bg-primary:    #0f0f1a;
  --bg-secondary:  #1a1a2e;
  --bg-card:       #1e1e30;
  --bg-card-hover: #2a2a3e;
  --accent:        #4f8ef7;
  --accent-dark:   #3b7ed8;
  --accent-glow:   rgba(79,142,247,0.3);
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --text-primary:  #ffffff;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --border:        rgba(255,255,255,0.08);
  --border-accent: rgba(79,142,247,0.3);
  --shadow:        0 8px 24px rgba(0,0,0,0.4);
  --shadow-glow:   0 0 24px rgba(79,142,247,0.2);
  --shadow-lg:     0 12px 48px rgba(0,0,0,0.6);
}



/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
}
.sidebar-backdrop.open { display: block; }
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.sidebar-brand .logo-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 20px;
}
.sidebar-brand h1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-brand p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 0 8px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-accent);
}
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: white;
  font-size: 11px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0 6px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
  text-align: center;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-primary);
}
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page-content { padding: 28px; flex: 1; }
.section { display: none; }
.section.active { display: block; }

/* ── Cards/Grid ──────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative; overflow: hidden;
}
.kpi-card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glow); transform: translateY(-2px); }
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.kpi-card.verde::before { background: var(--success); }
.kpi-card.amarillo::before { background: var(--warning); }
.kpi-card.rojo::before { background: var(--danger); }
.kpi-card.azul::before { background: var(--accent); }
.kpi-icon { font-size: 28px; margin-bottom: 12px; }
.kpi-value { font-size: 36px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 13px; color: var(--text-secondary); }

.grid-maquinas { display: grid; grid-template-columns: 1fr; gap: 0; }
.grid-maquinas-inner { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.maquina-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.maquina-card:hover { border-color: var(--border-accent); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.maquina-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.maquina-nombre { font-size: 15px; font-weight: 700; }
.maquina-tipo { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.estado-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; white-space: nowrap;
}
.estado-badge.ok { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.estado-badge.proximo { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.estado-badge.vencido, .estado-badge.pendiente { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.estado-badge.azul { background: rgba(79,142,247,0.15); color: var(--accent); border: 1px solid rgba(79,142,247,0.3); }
.estado-badge.verde { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.estado-badge.gris, .estado-badge.inactiva { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); border: 1px solid rgba(107, 114, 128, 0.3); }
.estado-badge.naranja, .estado-badge.revision { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.maquina-info { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
.maquina-info span { display: block; margin-bottom: 2px; }
.maquina-actions { display: flex; gap: 8px; margin-top: auto; justify-content: space-between; align-items: flex-end; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); box-shadow: var(--shadow-glow); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control select { cursor: pointer; }
select.form-control { cursor: pointer; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.table-title { font-size: 15px; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--bg-secondary); text-align: left;
  padding: 12px 16px; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

/* ── Filtros ─────────────────────────────────────────────────────────────── */
.filtros-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
.filtro-item { flex: 1; min-width: 140px; max-width: 200px; }
.filtro-item select, .filtro-item input { padding: 8px 12px; font-size: 13px; }

/* ── Modal / Overlay ─────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 2000; display: none;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}
.overlay.open { display: grid; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px; width: 100%; max-width: 550px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Scroll interno para el contenido del modal */
.modal > div:not(.modal-header):not(.modal-footer) {
  overflow-y: auto;
  padding-right: 8px;
  flex: 1;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 20px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 20px; }

.btn-text {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 12px;
  padding: 0;
  min-width: auto;
  cursor: pointer;
}

.btn-text:hover {
  color: #ff8b8f;
}

/* ── QR Modal ────────────────────────────────────────────────────────────── */
.qr-container { text-align: center; padding: 10px 0; }
.qr-container img { border-radius: 12px; border: 3px solid white; max-width: 220px; width: 100%; }
.qr-url { font-size: 11px; color: var(--text-muted); margin-top: 12px; word-break: break-all; background: var(--bg-secondary); padding: 8px 12px; border-radius: 6px; }
.qr-maquina-nombre { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.qr-maquina-sala { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

/* ── Chart ───────────────────────────────────────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text-secondary); }
.chart-bar-wrap { display: flex; flex-direction: column; gap: 8px; }
.chart-bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.chart-bar-label { width: 90px; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.chart-bar-track { flex: 1; height: 8px; background: var(--bg-secondary); border-radius: 99px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); transition: width 0.6s ease; }
.chart-bar-val { width: 30px; color: var(--text-primary); font-weight: 600; flex-shrink: 0; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; background: var(--bg-secondary); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; width: fit-content; }
.tab-btn {
  padding: 8px 18px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; background: transparent; color: var(--text-secondary);
  font-family: inherit;
}
.tab-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.tab-btn:hover:not(.active) { color: var(--text-primary); }

/* ── Alertas inline ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  animation: fadeIn 0.3s ease;
}
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Loader desactivado */
.loader-overlay { display: none !important; }

/* ── Top Loading Indicator ───────────────────────────────────────────────── */
/* ── Admin Login Overlay ────────────────────────────────────────────────── */
.admin-login-overlay {
  position: fixed;
  inset: 0;
  background: #ffffff;
  backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.admin-login-overlay.show {
  opacity: 1;
  visibility: visible;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  padding: 40px;
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 142, 247, 0.1);
  transform: translateY(20px);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.admin-login-overlay.show .login-card {
  transform: translateY(0);
}

.login-icon {
  font-size: 48px;
  margin-bottom: 24px;
  display: block;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.2));
}

.login-card h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.pin-input-group {
  position: relative;
  margin-bottom: 24px;
}

.pin-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 12px;
  color: white;
  font-size: 24px;
  text-align: center;
  letter-spacing: 0.5em;
  font-weight: 700;
  outline: none;
  transition: all 0.3s;
}
.pin-input:focus {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.05);
  box-shadow: 0 0 20px rgba(79, 142, 247, 0.15);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
  font-weight: 500;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.login-card.shake {
  animation: shakeError 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Animaciones ─────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ── Roles & Permisos ────────────────────────────────────────────────────── */
.role-badge {
  font-size: 10px; font-weight: 700; padding: 3px 6px;
  border-radius: 6px; margin-left: 8px; flex-shrink: 0;
}
.role-badge.admin { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.nav-item.locked { opacity: 0.6; cursor: not-allowed; }
.nav-item.locked:hover { background: transparent; color: var(--text-secondary); }

.role-selector {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border-accent);
  padding: 6px 12px; border-radius: 20px; font-size: 13px;
}
.role-selector select {
  background: transparent; border: none; color: white;
  font-weight: 700; outline: none; cursor: pointer;
}
.role-selector select option { background: var(--bg-card); color: white; }

.restricted-screen {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.restricted-screen .icon { font-size: 64px; margin-bottom: 20px; opacity: 0.8; }
.restricted-screen h2 { font-size: 24px; font-weight: 800; color: var(--text-primary); margin-bottom: 12px; }
.restricted-screen p { font-size: 14px; max-width: 400px; margin: 0 auto 24px; line-height: 1.6; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-card-hover); border-radius: 3px; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.section-title { font-size: 22px; font-weight: 800; }
.section-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,0.5); }

  /* Backdrop cuando sidebar abierto */
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 299;
  }
  .sidebar.open ~ .sidebar-backdrop { display: block; }

  /* Main */
  .main { margin-left: 0; }

  /* Topbar */
  .topbar { padding: 12px 16px; }
  .topbar-title { font-size: 16px; }
  #btnMenuMobile { display: flex !important; }
  #serverInfo { display: none; }

  /* Contenido */
  .page-content { padding: 14px 12px; }

  /* KPIs */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi-value { font-size: 28px; }
  .kpi-label { font-size: 12px; }

  /* Charts */
  .chart-grid { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }

  /* Tables – Mobile Cards */
  .table-wrap { border-radius: 10px; background: transparent; border: none; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; /* Ocultar cabeceras reales */ }
  tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }
  tr:last-child { margin-bottom: 0; border-bottom: 1px solid var(--border); }
  td {
    border-bottom: 1px dashed var(--border);
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
  }
  td:last-child { border-bottom: none; justify-content: flex-end; }
  
  /* Insertar seudo-etiquetas con datos thead - Requiere el uso del atributo data-label en el HTML */
  td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    flex-shrink: 0;
  }

  /* Filtros */
  .filtros-bar { padding: 12px; gap: 8px; }
  .filtro-item { min-width: 120px; flex: 1 1 45%; max-width: 100%; }

  /* Sección header */
  .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-title { font-size: 18px; }

  /* Grid 2 */
  .grid-2 { grid-template-columns: 1fr; }

  /* Máquinas */
  .grid-maquinas-inner { grid-template-columns: 1fr; }

  /* Modal */
  .overlay { align-items: flex-end; padding: 0; }
  .modal {
    padding: 20px 16px 32px;
    width: 100%;
    max-width: 100% !important;
    border-radius: 24px 24px 0 0;
    margin: 0;
    max-height: 85vh;
  }

  /* Botones en máquinas */
  .maquina-actions { flex-wrap: wrap; gap: 6px; }
}

/* 🖼️ GALERÍA DE FOTOS (ADMIN) */
.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 24px;
  padding: 20px 0;
}

.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.gallery-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: var(--primary);
}

.gallery-card::after {
  content: '👁️ Ver detalles';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.gallery-card:hover::after {
  opacity: 1;
}

.gallery-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
  display: block;
}

.gallery-info {
  padding: 16px;
  background: var(--bg-card);
}

.gallery-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.gallery-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 📑 VISOR DE DETALLES PREMIUM */
.detail-container { display: flex; flex-direction: column; gap: 20px; }
.detail-header-info {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-secondary); padding: 16px; border-radius: 12px; border: 1px solid var(--border);
}
.detail-machine { display: flex; align-items: center; gap: 12px; }
.machine-icon {
  font-size: 24px; background: white; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center; border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.machine-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.machine-sala { font-size: 0.85rem; color: var(--text-muted); }
.detail-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-stat { background: var(--bg-card); padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); }
.detail-stat .label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.detail-stat .value { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); word-break: break-word; }
.detail-section { display: flex; flex-direction: column; gap: 8px; }
.section-label { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.detail-notes {
  background: rgba(255,255,255,0.03); padding: 16px; border-radius: 12px;
  border: 1px solid var(--border); font-size: 0.95rem; line-height: 1.6; color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-photos { display: flex; flex-wrap: wrap; gap: 12px; }
.detail-photo-wrapper {
  position: relative; width: 140px; height: 140px; border-radius: 12px;
  overflow: hidden; cursor: pointer; border: 1px solid var(--border);
}
.detail-photo-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.detail-photo-wrapper:hover img { transform: scale(1.1); }
.photo-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.4); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;
  opacity: 0; transition: opacity 0.3s;
}
.detail-photo-wrapper:hover .photo-overlay { opacity: 1; }

/* Tooltips de información */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 11px;
  margin-left: 6px;
  cursor: help;
  border: 1px solid var(--border);
  position: relative;
  vertical-align: middle;
}

.info-icon:hover {
  background: var(--accent);
  color: white;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 150%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  width: 220px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1000;
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
}

.info-icon:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-5px);
}


/* Estilos para Driver.js (Tour) */
.driver-popover.driverjs-theme {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 12px;
}

.driver-popover.driverjs-theme .driver-popover-title {
  color: var(--accent);
  font-family: inherit;
  font-weight: 700;
}

.driver-popover.driverjs-theme .driver-popover-description {
  color: var(--text-secondary);
  font-family: inherit;
}

.driver-popover.driverjs-theme .driver-popover-btn {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  text-shadow: none;
  border-radius: 6px;
  transition: all 0.2s;
}

.driver-popover.driverjs-theme .driver-popover-btn:hover {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

.driver-popover.driverjs-theme .driver-popover-progress-text {
  color: var(--text-muted);
}

.driver-popover.driverjs-theme .driver-popover-arrow-side-left::after { border-left-color: var(--bg-card); }
.driver-popover.driverjs-theme .driver-popover-arrow-side-right::after { border-right-color: var(--bg-card); }
.driver-popover.driverjs-theme .driver-popover-arrow-side-top::after { border-top-color: var(--bg-card); }
.driver-popover.driverjs-theme .driver-popover-arrow-side-bottom::after { border-bottom-color: var(--bg-card); }

/* ── Galería Agrupada & Badges ────────────────────────────────────────────── */
.photo-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  z-index: 10;
  border: 1px solid rgba(255,255,255,0.2);
  pointer-events: none;
}

.photo-img-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
}

.photo-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-info {
  padding: 16px;
  background: var(--bg-card);
}

.gallery-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.gallery-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Timeline de Seguimiento ────────────────────────────────────────────── */
.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  padding-left: 12px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 6px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.timeline-item.resolucion::before {
  background: var(--success);
}

.timeline-content {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.timeline-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.timeline-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}

.add-note-box textarea:focus {
  background: rgba(79, 142, 247, 0.05);
}

/* ── Panel de Tickets de Incidencias ─────────────────────────────────────── */
.tickets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.ticket-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.ticket-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

.ticket-card.urgente { border-left: 5px solid var(--danger); }
.ticket-card.seguimiento { border-left: 5px solid var(--warning); }
.ticket-card.resuelto { border-left: 5px solid var(--success); opacity: 0.8; }

.ticket-header {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-body {
  padding: 16px;
  flex: 1;
}

.ticket-footer {
  padding: 12px 16px;
  background: rgba(0,0,0,0.1);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-machine-name { font-weight: 800; font-size: 15px; color: var(--text-primary); }
.ticket-sala { font-size: 12px; color: var(--text-muted); }
.ticket-desc { font-size: 13px; color: var(--text-secondary); margin: 12px 0; line-height: 1.5; }
.ticket-date { font-size: 11px; color: var(--text-muted); }


.ticket-last-note {
  font-size: 11px;
  font-style: italic;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 8px;
  border-radius: 8px;
  margin-top: 8px;
}

/* ── Mejoras de Usabilidad y Feedback (Nuevos) ─────────────────────────── */
#modalDetalle .modal {
  max-width: 850px;
}

.detail-layout-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
}

@media (max-width: 800px) {
  .detail-layout-grid { grid-template-columns: 1fr; gap: 16px; }
  #modalDetalle .modal { max-width: 100%; }
}

.timeline-compact {
  padding-right: 8px;
  margin-bottom: 16px;
}

/* Scrollbar específico para el timeline compacto */
.timeline-compact::-webkit-scrollbar { width: 4px; }
.timeline-compact::-webkit-scrollbar-thumb { background: var(--border-accent); }

/* Feedback modal animado */
#modalFeedback #feedbackIcon {
  animation: bounceIn 0.6s cubic-bezier(0.17, 0.67, 0.83, 0.67);
  display: block;
  text-align: center;
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

/* Prompt modal ajustes */
#promptInput {
  background: var(--bg-card);
  font-family: inherit;
  line-height: 1.6;
  border-color: var(--border-accent);
  padding: 16px;
  font-size: 15px;
}

/* Mejoras de legibilidad en tablas */
td {
  transition: background 0.2s;
}

.estado-badge {
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 10px !important;
}
