/* ============================================================
   Sistema de Auditorias — Estilos principales
   Paleta y tipografia identica al modulo de RRHH
   ============================================================ */

:root {
  --bg:         #f4faf4;
  --surface:    #ffffff;
  --hdr:        #2E7D32;
  --hdr2:       #4CAF50;
  --accent:     #4CAF50;
  --accent-bg:  #E8F5E9;
  --border:     #C8E6C9;
  --text:       #1B5E20;
  --text2:      #2E7D32;
  --text3:      #6b7280;

  --c-dean:     #2563eb;
  --c-green:    #4CAF50;
  --c-cool:     #7c3aed;

  --up:         #1B5E20;
  --dn:         #991b1b;
  --warn:       #f59e0b;

  --red:        #dc2626;
  --red-l:      #fee2e2;
  --amber:      #d97706;
  --amb-l:      #fef3c7;
  --blue:       #2563eb;
  --blue-l:     #dbeafe;

  --sidebar-w:  220px;
  --topbar-h:   56px;
  --bottomnav-h: 0px;

  --font:      'General Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── Fonts ── */
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-Regular.otf') format('opentype'); font-weight:400; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-Italic.otf') format('opentype'); font-weight:400; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-Light.otf') format('opentype'); font-weight:300; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-Medium.otf') format('opentype'); font-weight:500; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-Semibold.otf') format('opentype'); font-weight:600; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-Bold.otf') format('opentype'); font-weight:700; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../../fonts/GeneralSans-BoldItalic.otf') format('opentype'); font-weight:700; font-style:italic; }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.layout { display: flex; min-height: 100vh; }

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--hdr);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; z-index: 200;
  transition: transform 0.25s ease, width 0.2s ease;
}
.sidebar-logo {
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 16px; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1); flex-shrink: 0;
}
.logo-box {
  width: 32px; height: 32px; background: var(--accent);
  border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: #fff; flex-shrink: 0;
}
.logo-text { font-weight: 600; font-size: 12px; color: #fff; line-height: 1.3; overflow: hidden; }
.logo-sub  { font-size: 10px; color: rgba(255,255,255,0.45); font-weight: 400; }
.sidebar-close { display: none; color: rgba(255,255,255,0.6); margin-left: auto; padding: 4px; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.nav-section-label {
  padding: 12px 16px 4px; font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,0.35); letter-spacing: 0.08em; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; margin: 1px 8px; border-radius: 7px;
  font-size: 13px; color: rgba(255,255,255,0.7);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover  { background: rgba(255,255,255,0.09); color: #fff; }
.nav-item.active { background: rgba(61,175,114,0.28); color: #fff; font-weight: 500; }
.nav-ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}

.sidebar-razones {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.razones-label {
  font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.32);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 6px;
}
.razon-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 11px; color: rgba(255,255,255,0.55);
}
.razon-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 190;
}

/* ==========================================================================
   MAIN
   ========================================================================== */
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 100; flex-shrink: 0;
}
.hamburger { display: none; flex-direction: column; gap: 4px; padding: 6px; border-radius: 6px; flex-shrink: 0; }
.hamburger span { display: block; width: 18px; height: 2px; background: var(--hdr); border-radius: 1px; }
.hamburger:hover { background: var(--accent-bg); }
.topbar-title { font-weight: 600; font-size: 15px; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-rol-badge { font-size: 11px; font-weight: 500; background: var(--accent-bg); color: var(--hdr2); padding: 3px 10px; border-radius: 20px; border: 1px solid var(--border); text-transform: capitalize; }

.user-menu { position: relative; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--hdr); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 0; min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08); z-index: 300;
}
.user-menu:focus-within .user-dropdown,
.user-menu:hover .user-dropdown { display: block; }
.user-name  { padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text); }
.user-email { padding: 0 14px 6px; font-size: 11px; color: var(--text3); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-item { display: block; padding: 7px 14px; font-size: 13px; color: var(--text2); transition: background 0.1s; }
.dropdown-item:hover { background: var(--accent-bg); color: var(--hdr2); }

.page-content { flex: 1; padding: 20px; overflow-x: hidden; }

/* Flash */
.flash-container { padding: 8px 20px 0; }
.flash { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; }
.flash-error   { background: #fee2e2; color: #991b1b; }
.flash-success { background: #d1f0de; color: #1a5c38; }
.flash-warning { background: #fef3c7; color: #92400e; }
.flash-close   { font-size: 16px; background: none; border: none; cursor: pointer; color: inherit; }

/* ==========================================================================
   KPI GRID
   ========================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi-label { font-size: 11px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing:.05em; margin-bottom:5px; }
.kpi-value { font-size: 26px; font-weight: 600; color: var(--text); line-height:1; margin-bottom:3px; }
.kpi-sub   { font-size: 10px; color: var(--text3); }
.kpi-value.red   { color: var(--red); }
.kpi-value.green { color: var(--hdr2); }
.kpi-value.amber { color: var(--amber); }

/* ==========================================================================
   CARDS
   ========================================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-sub   { font-size: 11px; color: var(--text3); font-weight: 400; }
.card-link  { font-size: 11px; color: var(--accent); font-weight: 400; }

/* ==========================================================================
   TABLAS
   ========================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align:left; color:var(--text3); font-size:11px; font-weight:500; padding:0 10px 8px; border-bottom:1px solid var(--border); white-space:nowrap; }
.data-table td { padding:9px 10px; border-bottom:1px solid var(--border); color:var(--text2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom:none; }
.data-table tr:hover td { background:var(--accent-bg); }

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; font-family: var(--font); transition: all .15s; text-decoration: none; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--hdr2); }
.btn-secondary { background: var(--surface); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--accent-bg); }
.btn-danger    { background: var(--red-l); color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ==========================================================================
   BADGES / PILLS
   ========================================================================== */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.badge-green { background: var(--accent-bg); color: var(--hdr2); }
.badge-red   { background: var(--red-l);     color: var(--red); }
.badge-amber { background: var(--amb-l);     color: var(--amber); }
.badge-blue  { background: var(--blue-l);    color: var(--blue); }
.badge-gray  { background: #f3f4f6;          color: var(--text3); }

/* ==========================================================================
   FILTROS
   ========================================================================== */
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; flex-wrap: wrap; }
.filter-label { font-size: 12px; color: var(--text3); font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.filter-btn {
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; color: var(--text2);
  white-space: nowrap; flex-shrink: 0; font-family: var(--font);
  transition: background 0.12s, border-color 0.12s;
}
.filter-btn:hover  { background: var(--accent-bg); border-color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500; }
.filter-select {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: 12px; color: var(--text2);
  background: var(--surface); cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

/* ==========================================================================
   FORMULARIOS
   ========================================================================== */
.form-group  { margin-bottom: 14px; }
.form-label  { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
.form-input, .form-select, .form-control {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; font-family: var(--font); color: var(--text); background: var(--surface);
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-control:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.15);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }

/* ==========================================================================
   CHECKLIST FORM
   ========================================================================== */
.seccion-block { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); margin-bottom: 14px; overflow: hidden; }
.seccion-header { background: var(--accent-bg); padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.seccion-name { font-size: 13px; font-weight: 600; color: var(--text); }
.seccion-pts  { font-size: 12px; font-weight: 600; color: var(--hdr2); }

.item-row { display: grid; grid-template-columns: 1fr 54px 170px 1fr; gap: 10px; align-items: center; padding: 9px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--accent-bg); }
.item-desc  { line-height: 1.4; color: var(--text2); }
.item-critico { color: var(--red); font-size: 11px; font-weight: 700; }
.item-pond  { font-size: 12px; color: var(--text3); text-align: center; }

.radio-group { display: flex; gap: 4px; }
.radio-opt input { display: none; }
.radio-opt label { display: block; padding: 4px 9px; border-radius: 5px; border: 1px solid var(--border); font-size: 11px; font-weight: 600; cursor: pointer; transition: all .12s; color: var(--text3); white-space: nowrap; }
.radio-opt input:checked + label.lbl-si  { background: var(--accent-bg); border-color: var(--accent); color: var(--hdr2); }
.radio-opt input:checked + label.lbl-no  { background: var(--red-l); border-color: var(--red); color: var(--red); }
.radio-opt input:checked + label.lbl-obs { background: var(--amb-l); border-color: var(--amber); color: var(--amber); }
.radio-opt input:checked + label.lbl-na  { background: #f3f4f6; border-color: var(--text3); color: var(--text3); }

.obs-input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 11px; font-family: var(--font); color: var(--text2); background: var(--surface); }
.obs-input:focus { outline: none; border-color: var(--accent); }

/* Score bar sticky */
.score-sticky { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px 20px; display: flex; align-items: center; gap: 20px; margin: 0 -20px; z-index: 40; }
.score-num  { font-size: 22px; font-weight: 700; font-family: var(--font-mono); color: var(--hdr); }
.score-lbl  { font-size: 11px; color: var(--text3); }
.progress-bar  { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 480px; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title  { font-weight: 600; font-size: 15px; color: var(--text); }
.modal-close  { font-size: 20px; color: var(--text3); padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 16px 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ==========================================================================
   ALERTS
   ========================================================================== */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-success { background: #d1f0de; color: #1a5c38; border: 1px solid #a7d7bc; }
.alert-error   { background: var(--red-l); color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: var(--blue-l); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--amb-l); color: #92400e; border: 1px solid #fde68a; }

/* ==========================================================================
   UTILIDADES
   ========================================================================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }

/* Heatmap secciones */
.hm-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hm-item  { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 7px; font-size: 12px; }
.hm-red   { background: var(--red-l); color: #7b1111; }
.hm-amber { background: var(--amb-l); color: #78350f; }
.hm-green { background: var(--accent-bg); color: var(--hdr); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: var(--hdr);
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 32px 34px;
  width: 460px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

.login-logo {
  width: 100%;
  text-align: center;
  overflow: hidden;
  margin-bottom: 20px;
}

.login-logo-box {
  width: 100%;
  max-width: 360px;
  height: 92px;
  margin: 0 auto 14px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.login-logo .icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 10px;
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--hdr);
  margin-top: 2px;
}

.login-logo p {
  font-size: 13px;
  color: var(--text3);
  margin-top: 4px;
}

.login-help {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 20px;
}

@media (max-width: 520px) {
  .login-card {
    width: 100%;
    padding: 28px 22px;
  }

  .login-logo-box {
    max-width: 300px;
    height: 78px;
  }

  .login-logo h1 {
    font-size: 19px;
  }

  .login-logo p {
    font-size: 12px;
  }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1023px) {
  :root { --sidebar-w: 52px; }
  .nav-label, .nav-section-label, .logo-text, .sidebar-razones { display: none; }
  .nav-item { justify-content: center; padding: 10px; margin: 2px 6px; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .logo-box { width: 28px; height: 28px; font-size: 11px; }
  .hamburger { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 767px) {
  :root { --sidebar-w: 260px; --bottomnav-h: 60px; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); height: 100%; box-shadow: 4px 0 20px rgba(0,0,0,0.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .nav-label, .nav-section-label, .logo-text, .sidebar-razones { display: revert; }
  .nav-item { justify-content: flex-start; padding: 8px 12px; margin: 1px 8px; }
  .sidebar-logo { justify-content: flex-start; padding: 0 16px; }
  .logo-box { width: 32px; height: 32px; font-size: 13px; }
  .sidebar-close { display: flex; }
  .hamburger { display: flex; }
  .topbar { padding: 0 14px; }
  .topbar-rol-badge { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .kpi-value { font-size: 22px; }
  .page-content { padding: 14px; }
  .item-row { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 379px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 20px; }
}
