/* ================================================
   PQRS DCM - Comfacor | Estilos principales
   Línea gráfica: Portal Especialistas
   ================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --primary-50:     #eff6ff;
  --secondary:      #f59e0b;
  --success:        #22c55e;
  --success-light:  #dcfce7;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --info:           #3b82f6;
  --purple:         #8b5cf6;
  --gray-50:        #f8fafc;
  --gray-100:       #f1f5f9;
  --gray-200:       #e2e8f0;
  --gray-300:       #cbd5e1;
  --gray-400:       #94a3b8;
  --gray-500:       #64748b;
  --gray-600:       #475569;
  --gray-700:       #334155;
  --gray-800:       #1e293b;
  --gray-900:       #0f172a;
  --white:          #ffffff;
  --shadow-sm:      0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius-sm:      6px;
  --radius:         8px;
  --radius-md:      10px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --nav-width:      240px;
  --topbar-h:       64px;
  --transition:     all .2s ease;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

/* ==============================
   LAYOUT - APP SHELL
   ============================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ==============================
   SIDEBAR / NAVEGACIÓN LATERAL
   ============================== */
.sidebar {
  width: var(--nav-width);
  min-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  gap: .75rem;
}

.sidebar-brand img { height: 36px; width: auto; }

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-brand-text .brand-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.01em;
}

.sidebar-brand-text .brand-sub {
  font-size: .65rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  padding: .75rem 1.25rem .25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  color: var(--gray-600);
  font-size: .85rem;
  font-weight: 500;
  border-radius: var(--radius);
  margin: .1rem .5rem;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-item .badge-count {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200);
}

/* ==============================
   TOPBAR
   ============================== */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 99;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  padding: .4rem .75rem;
  border-radius: var(--radius);
  transition: var(--transition);
}

.user-menu:hover { background: var(--gray-100); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { line-height: 1.2; }
.user-info .user-name  { font-size: .82rem; font-weight: 600; color: var(--gray-800); }
.user-info .user-role  { font-size: .7rem; color: var(--gray-500); }
.user-info .user-dept  { font-size: .65rem; color: var(--primary); font-weight: 500; }

/* ==============================
   MAIN CONTENT
   ============================== */
.main-content {
  margin-left: var(--nav-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;       /* evita que un hijo flex expanda el layout */
  overflow-x: hidden; /* el scroll horizontal solo existe dentro de los elementos que lo necesiten */
}

.page-content {
  flex: 1;
  padding: 1.5rem;
}

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

.page-header-left h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
}

.page-header-left .page-subtitle {
  font-size: .82rem;
  color: var(--gray-500);
  margin-top: .2rem;
}

.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ==============================
   CARDS
   ============================== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ==============================
   STAT CARDS (Dashboard)
   ============================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.stat-meta {
  font-size: .75rem;
  color: var(--gray-500);
}

.stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: var(--purple); }

/* ==============================
   TABLA
   ============================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  background: var(--white);
  min-height: calc(100vh - 260px);
}

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

thead th {
  background: var(--gray-50);
  padding: .7rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 1rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

.ticket-num {
  font-weight: 700;
  color: var(--primary);
  font-size: .85rem;
}

/* ==============================
   BADGES / PILLS
   ============================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: var(--success-light); color: #15803d; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-yellow { background: #fefce8; color: #a16207; }
.badge-blue   { background: var(--primary-light);  color: var(--primary-dark); }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-red    { background: var(--danger-light);   color: #b91c1c; }
.badge-gray   { background: var(--gray-100);       color: var(--gray-600); }

/* ==============================
   BOTONES
   ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; color: white; }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: #16a34a; color: white; }

.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: .9rem; }
.btn-icon { padding: .45rem; border-radius: var(--radius-sm); }

/* ==============================
   FORMULARIOS
   ============================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group.half { grid-column: span 1; }

label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: .25rem;
}

label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled     { background: var(--gray-50); color: var(--gray-500); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: .72rem;
  color: var(--gray-500);
  margin-top: .15rem;
}

.form-error {
  font-size: .72rem;
  color: var(--danger);
  margin-top: .15rem;
}

.form-control.is-invalid { border-color: var(--danger); }

/* ==============================
   ALERTS
   ============================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .9rem 1.1rem;
  border-radius: var(--radius);
  font-size: .83rem;
  margin-bottom: 1rem;
  position: relative;
}

.alert-success { background: var(--success-light); color: #14532d; border: 1px solid #bbf7d0; }
.alert-error,
.alert-danger  { background: var(--danger-light);  color: #7f1d1d; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #78350f; border: 1px solid #fde68a; }
.alert-info    { background: var(--primary-50);    color: #1e3a8a; border: 1px solid #bfdbfe; }

.alert-icon { font-weight: 700; flex-shrink: 0; }

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  margin-left: auto;
  opacity: .7;
  padding: 0;
}
.alert-close:hover { opacity: 1; }

/* ==============================
   SLA INDICATORS
   ============================== */
.sla-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .73rem;
  font-weight: 500;
  padding: .2rem .5rem;
  border-radius: 999px;
}
.sla-ok        { color: #15803d; background: var(--success-light); }
.sla-advertencia { color: #a16207; background: #fefce8; }
.sla-critico   { color: #c2410c; background: #fff7ed; }
.sla-vencido   { color: #b91c1c; background: var(--danger-light); }
.sla-none      { color: var(--gray-500); background: var(--gray-100); }
.sla-finalizado { color: #6b7280; background: #f3f4f6; }

/* ==============================
   PROGRESO SLA
   ============================== */
.sla-progress {
  height: 4px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
  width: 60px;
}
.sla-progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}
.sla-progress-bar.ok          { background: var(--success); }
.sla-progress-bar.advertencia { background: var(--warning); }
.sla-progress-bar.critico     { background: #f97316; }
.sla-progress-bar.vencido     { background: var(--danger); }

/* ==============================
   TABS
   ============================== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.25rem;
  gap: 0;
}

.tab-item {
  padding: .6rem 1.1rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: .4rem;
}

.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ==============================
   MODAL
   ============================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--gray-800); }

.modal-body    { padding: 1.25rem 1.5rem; }
.modal-footer  { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: .5rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
}
.modal-close:hover { color: var(--gray-800); }

/* ==============================
   FILTROS / SEARCH BAR
   ============================== */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrapper svg {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--gray-400);
}

.search-input-wrapper input {
  width: 100%;
  padding: .5rem .75rem .5rem 2.2rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .83rem;
  background: var(--gray-50);
  outline: none;
  transition: var(--transition);
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ==============================
   TICKET DETAIL
   ============================== */
.ticket-detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  align-items: start;
}

.ticket-meta-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.ticket-meta-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .82rem;
}

.ticket-meta-item .meta-label {
  color: var(--gray-500);
  font-weight: 500;
  min-width: 110px;
  flex-shrink: 0;
}

.ticket-meta-item .meta-value { color: var(--gray-800); font-weight: 500; }

.conversation-thread { display: flex; flex-direction: column; gap: 1rem; }

.message-bubble {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.message-bubble.interna {
  background: #fefce8;
  border-color: #fde68a;
}

.message-bubble.sistema {
  background: var(--primary-50);
  border-color: var(--primary-light);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
  font-size: .75rem;
  color: var(--gray-500);
}

.message-meta .author { font-weight: 600; color: var(--gray-700); }

/* ==============================
   UPLOAD ZONE
   ============================== */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-50);
}

.upload-zone input[type="file"] { display: none; }

.upload-zone-icon {
  width: 40px; height: 40px;
  margin: 0 auto .75rem;
  color: var(--gray-400);
}

.upload-zone p { font-size: .82rem; color: var(--gray-600); margin-bottom: .25rem; }
.upload-zone small { font-size: .72rem; color: var(--gray-400); }

.file-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .75rem; }

.file-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .7rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .78rem;
}

.file-item .file-name { flex: 1; min-width: 0; font-weight: 500; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .file-size { color: var(--gray-500); }
.file-item .file-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

/* ==============================
   LOGIN PAGE
   ============================== */
.login-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.login-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem 4rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.login-logo { margin-bottom: 2rem; }
.login-logo img { height: 48px; }

.login-left h1 { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); margin-bottom: .25rem; }
.login-left .login-sub { font-size: .85rem; color: var(--gray-500); margin-bottom: 2rem; }

.login-right {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #1d4ed8 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-right::before {
  content: '';
  position: absolute;
  width: 350px; height: 350px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  top: -80px; right: -80px;
}

.login-right::after {
  content: '';
  position: absolute;
  width: 250px; height: 250px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  bottom: -50px; left: -50px;
}

.login-right-content { position: relative; z-index: 1; max-width: 380px; width: 100%; }

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  padding: .3rem .8rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.login-badge-dot {
  width: 6px; height: 6px;
  background: #4ade80;
  border-radius: 50%;
}

.login-right h2 {
  font-size: 2.2rem;
  font-weight: 800;
  color: white;
  line-height: 1.15;
  margin-bottom: .5rem;
}

.login-right h2 span { color: #f59e0b; }

.login-right p {
  font-size: .88rem;
  color: rgba(255,255,255,.75);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.login-features { display: flex; flex-direction: column; gap: .75rem; }

.login-feature {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: rgba(255,255,255,.85);
  font-size: .83rem;
}

.login-feature-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.12);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-footer {
  margin-top: 2.5rem;
  font-size: .75rem;
  color: var(--gray-400);
  text-align: center;
}

.login-security {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .73rem;
  color: var(--gray-500);
  margin-top: 1rem;
}

/* ==============================
   PUBLIC FORM
   ============================== */
.public-wrapper {
  min-height: 100vh;
  background: var(--gray-50);
  padding: 2rem 1rem;
}

.public-card {
  max-width: 860px;
  margin: 0 auto;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.public-header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.public-header img { height: 42px; filter: brightness(0) invert(1); }
.public-header h1 { font-size: 1.1rem; font-weight: 700; color: white; }
.public-header p  { font-size: .78rem; color: rgba(255,255,255,.75); }

.public-body { padding: 2rem; }

.public-sidebar {
  max-width: 360px;
  margin: 0 auto 1.5rem;
}

.denuncia-box {
  background: #fff;
  border: 1px solid #fca5a5;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  font-size: .8rem;
  color: var(--gray-700);
  line-height: 1.5;
}

.denuncia-box strong { color: var(--danger); font-size: .85rem; }
.denuncia-box h4 { margin: .5rem 0 .4rem; font-size: .82rem; }

/* ==============================
   DASHBOARD GRID
   ============================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.dashboard-grid .full { grid-column: 1 / -1; }

/* ==============================
   PROGRESS BARS
   ============================== */
.progress-bar-list { display: flex; flex-direction: column; gap: .9rem; }

.progress-item { display: flex; flex-direction: column; gap: .35rem; }

.progress-item-header {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
}

.progress-item-label { font-weight: 500; color: var(--gray-700); }
.progress-item-value { color: var(--gray-500); }

.progress-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .8s ease;
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .ticket-detail-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-right { display: none; }
  .login-left { padding: 2rem 1.5rem; max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 1rem; }
}

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

/* ==============================
   UTILITIES
   ============================== */
.d-flex     { display: flex; }
.align-center { align-items: center; }
.gap-1      { gap: .5rem; }
.gap-2      { gap: 1rem; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }
.mt-3       { margin-top: 1.5rem; }
.mb-1       { margin-bottom: .5rem; }
.mb-2       { margin-bottom: 1rem; }
.mb-3       { margin-bottom: 1.5rem; }
.text-sm    { font-size: .78rem; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==============================
   TOGGLE SIDEBAR MOBILE
   ============================== */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  color: var(--gray-700);
}

@media (max-width: 1024px) {
  .menu-toggle { display: flex; }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-backdrop.open { display: block; }

/* CAPTCHA personalizado (estilo portal) */
.captcha-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.captcha-text {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .3em;
  font-family: 'Courier New', monospace;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: none;
}

.captcha-refresh {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .3rem;
}

/* Divisor */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 1.25rem 0;
}

/* Paginación */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  margin-top: 1.25rem;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  background: var(--white);
  transition: var(--transition);
}

.page-link:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary); }
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 1rem; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--gray-600); margin-bottom: .5rem; }
.empty-state p  { font-size: .83rem; }

/* ============================================================
   A11y — Skip to content (visualmente oculto, visible al :focus)
   ============================================================ */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--white);
  padding: 8px 16px;
  z-index: 100;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

/* ============================================================
   A11y — Focus visible global para navegación por teclado.
   No afecta clicks (mouse no dispara :focus-visible).
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.btn:focus-visible,
button:focus-visible,
.nav-item:focus-visible,
a:focus-visible {
  outline-offset: 3px;
}

/* ============================================================
   UX — Hover más perceptible en filas clickables (data-href)
   ============================================================ */
tbody tr[data-href] {
  cursor: pointer;
  transition: background .12s ease;
}
tbody tr[data-href]:hover {
  background: var(--primary-50);
}

/* ============================================================
   UX — Loading state para botones submit (clase .is-loading)
   Manejado por app.js cuando form se envía.
   ============================================================ */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  opacity: .85;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1rem; height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  top: 50%; left: 50%;
  margin: -.5rem 0 0 -.5rem;
  animation: spin .6s linear infinite;
  color: var(--white);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   A11y — Respetar prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   A11y — Contraste mejorado en labels uppercase pequeños
   (anteriormente --gray-500 daba ~4.07:1, ahora --gray-600 da ~6.5:1)
   ============================================================ */
.stat-label,
.section-label,
.nav-section-label {
  color: var(--gray-600);
}
