/* ================================================================
   IESTP NASCA - Sistema de Trámite Documentario
   CSS Principal - Diseño Moderno y Responsivo
   ================================================================ */

:root {
  --primary:    #1e3a5f;
  --primary-l:  #2d5282;
  --accent:     #e53e3e;
  --accent2:    #f6ad55;
  --success:    #38a169;
  --info:       #3182ce;
  --warning:    #d69e2e;
  --danger:     #e53e3e;
  --bg:         #f0f4f8;
  --bg-card:    #ffffff;
  --text:       #2d3748;
  --text-muted: #718096;
  --border:     #e2e8f0;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     12px;
  --shadow:     0 4px 20px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.12);
  --transition: .25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ────────── SIDEBAR ────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-l) 100%);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
}
.sidebar-logo i { font-size: 1.5rem; color: var(--accent2); }

.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: 1.1rem;
  padding: .25rem;
  border-radius: 6px;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .75rem 1.5rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .925rem;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  border-left: 3px solid transparent;
}
.nav-item:hover, .nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: var(--accent2);
}
.nav-item i { width: 20px; text-align: center; font-size: 1rem; }
.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 1rem 0;
  border-top: 1px solid rgba(255,255,255,.1);
}
.text-danger { color: #fc8181 !important; }
.text-danger:hover { background: rgba(229,62,62,.15) !important; }

/* ────────── TOPBAR ────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  transition: left var(--transition);
}

.btn-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: .4rem;
  border-radius: 8px;
}

.topbar-info { flex: 1; }
.topbar-title { font-weight: 600; font-size: .95rem; color: var(--text-muted); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.badge-rol {
  background: var(--primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .75rem;
  border-radius: 20px;
  text-transform: capitalize;
}

.notif-icon {
  position: relative;
  font-size: 1.2rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: .3rem;
  border-radius: 8px;
  transition: color var(--transition);
}
.notif-icon:hover { color: var(--primary); }
.notif-count {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

/* ────────── MAIN CONTENT ────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 2rem;
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left var(--transition);
}

/* ────────── PAGE HEADER ────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.page-header h1 i { color: var(--accent2); font-size: 1.4rem; }
.breadcrumb {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* ────────── CARDS ────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card-title i { color: var(--primary); }

/* ────────── STAT CARDS ────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.info    { border-left-color: var(--info); }

.stat-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(30,58,95,.1);
  color: var(--primary);
  flex-shrink: 0;
}
.stat-card.success .stat-icon { background: rgba(56,161,105,.1); color: var(--success); }
.stat-card.warning .stat-icon { background: rgba(214,158,46,.1);  color: var(--warning); }
.stat-card.danger  .stat-icon { background: rgba(229,62,62,.1);   color: var(--danger); }
.stat-card.info    .stat-icon { background: rgba(49,130,206,.1);  color: var(--info); }

.stat-info .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.stat-info .stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ────────── CHARTS GRID ────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.chart-container {
  position: relative;
  height: 280px;
}

/* ────────── TABLE ────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th {
  background: var(--bg);
  padding: .9rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(49,130,206,.04); }

.expediente-num {
  font-weight: 700;
  font-family: monospace;
  font-size: .9rem;
  color: var(--primary);
}

/* ────────── BADGES / STATUS ────────── */
.badge-estado {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-prioridad {
  font-size: .72rem;
  padding: .15rem .55rem;
  border-radius: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.prior-normal  { background: #ebf8ff; color: #2c5282; }
.prior-alta    { background: #fef3c7; color: #92400e; }
.prior-urgente { background: #fee2e2; color: #991b1b; }
.prior-baja    { background: #f0fff4; color: #276749; }

/* ────────── BOTONES ────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-l); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,58,95,.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #276749; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #c53030; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info    { background: var(--info);    color: #fff; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-icon { padding: .5rem; width: 36px; height: 36px; justify-content: center; border-radius: 8px; }

.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ────────── FORMULARIOS ────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}
.form-group label span.req { color: var(--danger); margin-left: 2px; }

.form-control {
  padding: .65rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
.form-control:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(49,130,206,.15);
}
.form-control.error { border-color: var(--danger); }
.form-error { font-size: .8rem; color: var(--danger); }

.form-hint { font-size: .78rem; color: var(--text-muted); }

/* Drag & drop area */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--info);
  background: rgba(49,130,206,.05);
}
.drop-zone i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: .5rem; }
.drop-zone p { color: var(--text-muted); font-size: .9rem; }

/* ────────── FILTROS ────────── */
.filter-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: .25rem; flex: 1; min-width: 140px; }
.filter-group label { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-control {
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color var(--transition);
}
.filter-control:focus { border-color: var(--info); }

/* ────────── PAGINACIÓN ────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.page-btn {
  padding: .4rem .75rem;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text);
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ────────── TOAST ────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: #fff;
  padding: .9rem 1.25rem;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  animation: slideIn .3s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 1.2rem; }
.toast.success i { color: var(--success); }
.toast.error   i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast-msg { flex: 1; font-size: .9rem; color: var(--text); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ────────── MODAL ────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  border-radius: 6px;
  padding: .1rem .4rem;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 1.5rem; }

/* ────────── TIMELINE ────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: .6rem;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 1.25rem;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.55rem;
  top: .4rem;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.timeline-date { font-size: .78rem; color: var(--text-muted); margin-bottom: .2rem; }
.timeline-title { font-weight: 700; font-size: .9rem; color: var(--text); }
.timeline-body { font-size: .875rem; color: var(--text-muted); margin-top: .2rem; }

/* ────────── SPINNER ────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--text-muted);
}

/* ────────── EMPTY STATE ────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3.5rem; opacity: .3; margin-bottom: 1rem; }
.empty-state p { font-size: 1rem; }

/* ────────── LOGIN PAGE ────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #2a4a7f 100%);
  padding: 1rem;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo i {
  font-size: 3rem;
  color: var(--primary);
  display: block;
  margin-bottom: .5rem;
}
.login-logo h1 { font-size: 1.4rem; color: var(--primary); font-weight: 800; }
.login-logo p  { font-size: .85rem; color: var(--text-muted); }
.login-link { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--text-muted); }
.login-link a { color: var(--info); text-decoration: none; font-weight: 600; }

/* ────────── INICIO / PÚBLICO ────────── */
.inicio-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #2a4a7f 100%);
  color: #fff;
  padding: 4rem 2rem;
  text-align: center;
  border-radius: var(--radius);
  margin-bottom: 2rem;
}
.inicio-hero h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: .75rem; }
.inicio-hero p  { font-size: 1.1rem; opacity: .85; max-width: 600px; margin: 0 auto 1.5rem; }
.inicio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.inicio-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: var(--text);
}
.inicio-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.inicio-card i { font-size: 2.5rem; color: var(--primary); margin-bottom: 1rem; }
.inicio-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; color: var(--primary); }
.inicio-card p  { font-size: .875rem; color: var(--text-muted); }

/* ────────── NOTIFICACIONES ────────── */
.notif-list { display: flex; flex-direction: column; gap: .75rem; }
.notif-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  transition: background var(--transition);
}
.notif-item.no-leida { background: #ebf8ff; border-color: #bee3f8; }
.notif-item i { font-size: 1.3rem; color: var(--info); margin-top: .1rem; flex-shrink: 0; }
.notif-content { flex: 1; }
.notif-titulo { font-weight: 700; font-size: .9rem; color: var(--text); }
.notif-msg    { font-size: .85rem; color: var(--text-muted); }
.notif-fecha  { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* ────────── TRACKING PÚBLICO ────────── */
.tracking-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 1rem;
  margin: 1.5rem 0;
}
.tracking-step {
  flex: 1;
  text-align: center;
  position: relative;
  min-width: 100px;
}
.tracking-step::after {
  content: '';
  position: absolute;
  top: 18px; right: -50%;
  width: 100%; height: 2px;
  background: var(--border);
  z-index: 0;
}
.tracking-step:last-child::after { display: none; }
.step-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--border);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto .5rem;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  position: relative;
  z-index: 1;
}
.step-dot.done { background: var(--success); box-shadow-color: var(--success); }
.step-dot.current { background: var(--info); animation: pulse 1.5s infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(49,130,206,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(49,130,206,.2); }
}
.step-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; }

/* ────────── ALERTAS INLINE ────────── */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  font-size: .9rem;
  margin-bottom: 1rem;
}
.alert-success { background: #f0fff4; border: 1px solid #9ae6b4; color: #276749; }
.alert-error   { background: #fff5f5; border: 1px solid #feb2b2; color: #c53030; }
.alert-info    { background: #ebf8ff; border: 1px solid #90cdf4; color: #2a4a7f; }
.alert-warning { background: #fffbeb; border: 1px solid #fbd38d; color: #744210; }

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile-first, todos los dispositivos
   ═══════════════════════════════════════════ */

/* ── Tablet grande (≤1100px) ── */
@media (max-width: 1100px) {
  .charts-grid        { grid-template-columns: 1fr; }
  .stats-grid         { grid-template-columns: repeat(3, 1fr); }
}

/* ── Tablet (≤900px) ── */
@media (max-width: 900px) {
  .stats-grid         { grid-template-columns: repeat(2, 1fr); }
  .form-grid          { grid-template-columns: 1fr; }
  .table th:nth-child(n+5),
  .table td:nth-child(n+5) { display: none; }  /* Ocultar cols extra */
  .table th:last-child,
  .table td:last-child { display: table-cell; } /* Siempre mostrar acciones */
}

/* ── Móvil (≤768px) ── */
@media (max-width: 768px) {
  /* Layout sidebar */
  .sidebar            { transform: translateX(-260px); transition: transform .25s ease; z-index: 1100; }
  .sidebar.open       { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .topbar             { left: 0; }
  .main-content       { margin-left: 0; padding: .875rem; }
  .btn-menu           { display: flex !important; }

  /* Overlay para cerrar sidebar en móvil */
  .sidebar-overlay    { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
                        z-index: 1099; }
  .sidebar-overlay.show { display: block; }

  /* Page header */
  .page-header        { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .page-header .btn   { width: 100%; justify-content: center; }

  /* Stats */
  .stats-grid         { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .stat-card          { padding: .75rem; }
  .stat-number        { font-size: 1.5rem; }

  /* Tablas: scroll horizontal */
  .card               { overflow-x: auto; }
  .table              { min-width: 500px; }
  .table th, .table td{ padding: .5rem .6rem; font-size: .8rem; }
  /* Mostrar todas las columnas en móvil con scroll */
  .table th, .table td { display: table-cell !important; }

  /* Filtros */
  .filter-bar         { flex-direction: column; gap: .5rem; }
  .filter-group       { min-width: 100%; }
  .filter-bar .btn    { width: 100%; }

  /* Formularios */
  .form-grid          { grid-template-columns: 1fr !important; }
  .form-grid > [style*="grid-column"] { grid-column: 1 !important; }

  /* Modales */
  .modal-box          { width: 96vw !important; max-width: 96vw !important;
                        margin: .5rem; border-radius: 12px; }
  [id*="modal"] > div { width: 96vw !important; max-width: 96vw !important;
                        border-radius: 12px; }

  /* Topbar */
  .topbar-title       { font-size: .85rem; }
  .topbar-actions .btn span { display: none; } /* Solo icono en acciones topbar */

  /* Cards detalle */
  .detalle-grid       { grid-template-columns: 1fr !important; }

  /* Botones de acción en tabla */
  .btn-sm             { padding: .3rem .5rem; font-size: .78rem; }

  /* Hilo de respuestas */
  .mensaje-burbuja    { max-width: 90% !important; }

  /* TUPA stats */
  .tupa-stats         { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard charts */
  .charts-grid        { grid-template-columns: 1fr; }
}

/* ── Móvil pequeño (≤480px) ── */
@media (max-width: 480px) {
  .main-content       { padding: .625rem; }
  .stats-grid         { grid-template-columns: 1fr 1fr; gap: .4rem; }
  .stat-card          { padding: .6rem .5rem; }
  .stat-number        { font-size: 1.35rem; }
  .stat-label         { font-size: .68rem; }
  .login-card         { padding: 1.5rem 1rem; margin: 1rem; }
  .page-title         { font-size: 1.1rem; }
  .card               { border-radius: 10px; }
  .tupa-stats         { grid-template-columns: 1fr 1fr; }

  /* Botones modo derivación en 1 col */
  #modoDerivBtns      { grid-template-columns: 1fr !important; }

  /* Comprobante */
  #comprobante        { font-size: 12px; }
}

/* ── Touch devices — quitar hover effects ── */
@media (hover: none) {
  .nav-item:hover     { background: transparent; }
  .btn:hover          { opacity: 1; transform: none; }
}


/* ────────── UTILIDADES ────────── */
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.w-100 { width: 100%; }
.fw-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: .82rem; }
.rounded { border-radius: var(--radius); }
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }

/* ── Prioridad 'media' (alias de normal) ── */
.prior-media { background: #ebf8ff; color: #2c5282; }
