/* ============================================================
   SISTEMA RRHH — Identidad visual
   Paleta institucional: petróleo profundo + acento ámbar
   ============================================================ */

:root {
  --petrol:        #0d5c63;
  --petrol-dark:   #093e43;
  --petrol-tint:   #e6f0f0;
  --amber:         #e0922f;
  --amber-dark:    #b9741d;
  --success:       #2e8b57;
  --warning:       #d98a13;
  --danger:        #c0392b;

  --bg:            #eef1f3;
  --surface:       #ffffff;
  --border:        #dce3e6;
  --text:          #16282b;
  --text-muted:    #5e6f73;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(9, 62, 67, .08), 0 1px 2px rgba(9, 62, 67, .06);
  --shadow-lg:     0 8px 24px rgba(9, 62, 67, .12);

  --sidebar-w:     248px;
  --sidebar-collapsed: 68px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--petrol); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(224,146,47,.12), transparent),
    linear-gradient(135deg, var(--petrol-dark), var(--petrol));
  padding: 20px;
}
.login-card {
  background: var(--surface);
  width: 100%;
  max-width: 380px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
}
.login-card .brand { text-align: center; margin-bottom: 26px; }
.login-card .brand .mark {
  width: 64px; height: 64px; border-radius: 15px;
  background: #fff; border: 1px solid var(--border);
  display: grid; place-items: center; margin: 0 auto 12px; overflow: hidden;
}
.login-card .brand .mark img { width: 52px; height: 52px; object-fit: contain; }
.login-card h1 { font-size: 19px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.login-hint {
  margin-top: 18px; text-align: center; font-size: 12px; color: var(--text-muted);
  background: var(--petrol-tint); border-radius: var(--radius-sm); padding: 9px;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--petrol-dark);
  color: #cfe3e4;
  position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  z-index: 20;
}
.sidebar .logo {
  padding: 20px 22px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .logo .mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: #fff;
  display: grid; place-items: center; overflow: hidden;
}
.sidebar .logo .mark img { width: 30px; height: 30px; object-fit: contain; }
.sidebar .logo { align-items: center; }
.sidebar .logo strong { color: #fff; font-size: 21px; line-height: 1.05; letter-spacing: .5px; display:block; }
.sidebar .logo span { font-size: 11px; color: #8fb6b8; }

.nav { padding: 12px 0; overflow-y: auto; flex: 1; }
.nav .group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: #6e979a; padding: 14px 22px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 22px; color: #cfe3e4; font-size: 13.5px;
  border-left: 3px solid transparent; transition: background .12s;
}
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.nav a.active {
  background: rgba(224,146,47,.14);
  border-left-color: var(--amber);
  color: #fff; font-weight: 600;
}
.nav a .ico { width: 18px; text-align: center; opacity: .9; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  transition: margin-left .2s ease;
}

/* ---------- SIDEBAR ABATIBLE (escritorio) ---------- */
.sidebar { transition: width .2s ease; }
.layout.collapsed .sidebar { width: var(--sidebar-collapsed); }
.layout.collapsed .main { margin-left: var(--sidebar-collapsed); }
.layout.collapsed .nav .group { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.layout.collapsed .nav a { justify-content: center; padding: 13px 0; gap: 0; font-size: 0; }
.layout.collapsed .nav a span:not(.ico),
.layout.collapsed .nav a .badge { display: none; }
.layout.collapsed .sidebar .logo { justify-content: center; padding: 20px 0; }
.layout.collapsed .sidebar .logo > div { display: none; }
.layout.collapsed .nav a .ico { width: auto; font-size: 27px; line-height: 1; }
.nav a .ico { font-size: 19px; width: 26px; text-align: center; color: inherit; }

.topbar {
  height: 60px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 17px; font-weight: 650; }
.topbar .user { display: flex; align-items: center; gap: 20px; font-size: 13px; }
.topbar .user .sep { width: 1px; height: 26px; background: var(--border); }
.topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--petrol); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.topbar .user small { color: var(--text-muted); display: block; }

/* Botón para abatir (visible en escritorio) */
.collapse-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 8px; cursor: pointer;
  font-size: 16px; color: var(--text-muted);
}
.collapse-btn:hover { background: var(--bg); color: var(--text); }

.content { padding: 26px; }
.page-head { margin-bottom: 20px; display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.page-head h3 { font-size: 20px; }
.page-head p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- KPI CARDS ---------- */
.kpi-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--petrol);
}
.kpi.amber::before { background: var(--amber); }
.kpi.success::before { background: var(--success); }
.kpi.danger::before { background: var(--danger); }
.kpi .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 28px; font-weight: 750; margin-top: 6px; letter-spacing: -.5px; }
.kpi .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- CARDS / PANELS ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h4 { font-size: 15px; }
.card-body { padding: 20px; }
.card-grid { display: grid; gap: 20px; grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data thead th {
  text-align: left; padding: 11px 14px; background: #f6f8f9;
  color: var(--text-muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid #eef2f3; vertical-align: middle; }
table.data tbody tr:hover { background: #fafcfc; }
table.data .emp { display: flex; align-items: center; gap: 10px; }
table.data .emp .av {
  width: 32px; height: 32px; border-radius: 50%; background: var(--petrol-tint);
  color: var(--petrol); display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.text-right { text-align: right; }
/* Los encabezados de columnas numéricas se alinean IGUAL que sus valores:
   esta regla gana en especificidad a los estilos generales de th, para que
   el título quede exactamente encima de los montos en todo el sistema. */
table th.text-right, .data th.text-right, .data thead th.text-right { text-align: right !important; }
.text-muted { color: var(--text-muted); }

/* ---------- BADGES ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 1.4;
}
.badge--ok     { background: #e3f3ea; color: #1e6b41; }
.badge--warn   { background: #fcf0d9; color: #9a6410; }
.badge--danger { background: #fbe4e0; color: #a02c1c; }
.badge--info   { background: #e2eef5; color: #225d7d; }
.badge--muted  { background: #eceff0; color: #5e6f73; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background .12s, box-shadow .12s; text-decoration: none;
}
.btn-primary { background: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-dark); text-decoration: none; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:hover { background: var(--amber-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f4f7f7; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a02c1c; text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- FORMS ---------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--petrol);
  box-shadow: 0 0 0 3px rgba(13,92,99,.12);
}
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- ALERTS ---------- */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 13.5px; border: 1px solid transparent; display: flex; gap: 9px; align-items: flex-start;
}
.alert-success { background: #e3f3ea; color: #1e6b41; border-color: #bfe3cd; }
.alert-error   { background: #fbe4e0; color: #a02c1c; border-color: #f1c4bc; }
.alert-info    { background: #e2eef5; color: #225d7d; border-color: #c2dded; }

/* ---------- MISC ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; width: 100%;
}
.empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty .big { font-size: 38px; margin-bottom: 8px; }

.chart-box { position: relative; height: 280px; }

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }

/* Botón de filtro activo (vacaciones y otros listados) */
.btn.btn-active{ background:var(--brand); color:#fff; border-color:var(--brand); }

/* ============ MODO OSCURO ============ */
html.oscuro {
  --bg:            #101b1d;
  --surface:       #182a2d;
  --border:        #274246;
  --text:          #e4edee;
  --text-muted:    #93a8ab;
  --petrol-tint:   #12363b;
  --shadow:        0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.5);
}
html.oscuro body { background: var(--bg); color: var(--text); }
html.oscuro .card, html.oscuro .kpi { background: var(--surface); }
html.oscuro input, html.oscuro select, html.oscuro textarea {
  background: #122225; color: var(--text); border-color: var(--border);
}
html.oscuro table.data tbody tr:nth-child(even) { background: rgba(255,255,255,.03); }
html.oscuro table.data tbody tr:hover { background: rgba(255,255,255,.06); }
html.oscuro .btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
html.oscuro .alert-info { background: #12363b; color: #b7d9dc; }
html.oscuro .alert-success { background: #143526; color: #a9dcbd; }
html.oscuro .alert-danger { background: #3b1f1b; color: #efb4ab; }
html.oscuro .empty { color: var(--text-muted); }
html.oscuro .badge--muted { background: #274246; color: #b9cdd0; }
.btn-tema { background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 11px; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text); }

/* ==== MODO OSCURO: cobertura ampliada ==== */
html.oscuro .topbar{ background:var(--surface); border-color:var(--border); }
html.oscuro .page-head h3, html.oscuro h1, html.oscuro h2, html.oscuro h3, html.oscuro h4{ color:var(--text); }
html.oscuro .page-head p{ color:var(--text-muted); }
html.oscuro .card-head{ border-color:var(--border); }
html.oscuro .toolbar{ background:transparent; }
html.oscuro .toolbar input, html.oscuro .toolbar select{ background:#122225; color:var(--text); }
html.oscuro table.data th{ background:#13262a; color:#b9cdd0; border-color:var(--border); }
html.oscuro table.data td{ border-color:var(--border); }
html.oscuro .empty{ background:transparent; }
html.oscuro code{ background:#0d1c1f; color:#9fd3d8; padding:2px 6px; border-radius:5px; }
html.oscuro .hint{ color:var(--text-muted); }
html.oscuro .btn-primary{ box-shadow:none; }
html.oscuro .kpi .num{ color:var(--text); }

/* ═══ LEGIBILIDAD EN MODO OSCURO ═══
   Textos y fondos que en claro usan grises fijos, en oscuro pasan a las
   variables del tema para que siempre se lean bien. Los documentos de
   impresión (volantes, certificados, carnet) quedan en blanco a propósito. */
.fila-sel { background:#fafcfc; }                                /* fila seleccionada (claro) */
html.oscuro .fila-sel { background:rgba(53,208,165,.10); }       /* fila seleccionada (oscuro) */
html.oscuro .text-muted { color:var(--text-muted); }
html.oscuro .vh .sub,
html.oscuro .cab .sub,
html.oscuro .sub { color:var(--text-muted); }                    /* subtítulos grises fijos */
html.oscuro .doc-toolbar button { background:#122225; color:var(--text); border-color:var(--border); }
html.oscuro .doc-editor { background:var(--surface); color:var(--text); }
html.oscuro small, html.oscuro .small { color:var(--text-muted); }
html.oscuro a { color:#7fd4c6; }
html.oscuro a.btn, html.oscuro .acc-item, html.oscuro .acc-btn { color:inherit; }
html.oscuro a.btn-primary, html.oscuro button.btn-primary { color:#fff; }
html.oscuro .breadcrumbs, html.oscuro .breadcrumbs a { color:var(--text-muted); }
html.oscuro .modal, html.oscuro .modal-box { background:var(--surface); color:var(--text); }
html.oscuro th { color:#b9cdd0; }
html.oscuro .alert-warning, html.oscuro .alert-warn{ background:#3a2f14; color:#e8cf96; }
html.oscuro .badge--info{ background:#12363b; color:#9fd3d8; }
html.oscuro .badge--ok{ background:#143526; color:#a9dcbd; }
html.oscuro .badge--warn{ background:#3a2f14; color:#e8cf96; }
html.oscuro .badge--danger{ background:#3b1f1b; color:#efb4ab; }
html.oscuro .avatar{ background:var(--petrol); color:#fff; }
html.oscuro input[readonly]{ background:#0d1c1f !important; color:var(--text-muted); }
html.oscuro select option{ background:#122225; color:var(--text); }
html.oscuro .doc-editor{ background:#122225; color:var(--text); border-color:var(--border); }
html.oscuro a{ color:#7fc4ca; }
html.oscuro .btn{ color:var(--text); }
html.oscuro .btn-primary{ color:#fff; }
html.oscuro .btn-danger{ color:#fff; }

/* ============ VENTANAS FLOTANTES (modales) ============ */
.modal-fondo{ position:fixed; inset:0; background:rgba(9,30,33,.55); z-index:200; display:none;
  align-items:flex-start; justify-content:center; padding:4vh 16px; overflow:auto; backdrop-filter:blur(2px); }
.modal-fondo.abierto{ display:flex; }
.modal-caja{ background:var(--surface); border-radius:14px; box-shadow:var(--shadow-lg); width:100%;
  max-width:640px; animation:modalIn .18s ease; }
.modal-caja.ancha{ max-width:860px; }
@keyframes modalIn{ from{ transform:translateY(14px); opacity:0; } to{ transform:none; opacity:1; } }
.modal-cab{ display:flex; justify-content:space-between; align-items:center; padding:16px 20px;
  border-bottom:1px solid var(--border); }
.modal-cab h4{ margin:0; font-size:15.5px; }
.modal-cerrar{ background:none; border:none; font-size:20px; cursor:pointer; color:var(--text-muted);
  line-height:1; padding:4px 8px; border-radius:6px; }
.modal-cerrar:hover{ background:var(--petrol-tint); }
.modal-cuerpo{ padding:18px 20px; max-height:72vh; overflow:auto; }
html.oscuro .modal-fondo{ background:rgba(0,0,0,.65); }
html.oscuro .alert-error { background: #3b1f1b; color: #efb4ab; border-color: #5a2d26; }

/* ============ AYUDA FLOTANTE (?) ============ */
.ayuda{ position:relative; display:inline-flex; }
.ayuda > button{ width:22px; height:22px; border-radius:50%; border:1.5px solid var(--petrol);
  background:var(--petrol-tint); color:var(--petrol); font-weight:800; font-size:12.5px; cursor:pointer;
  line-height:1; display:inline-flex; align-items:center; justify-content:center; }
.ayuda > button:hover{ background:var(--petrol); color:#fff; }
.ayuda-panel{ display:none; position:absolute; top:28px; left:50%; transform:translateX(-50%);
  z-index:120; width:min(420px, 82vw); background:var(--surface); border:1px solid var(--border);
  border-radius:11px; box-shadow:var(--shadow-lg); padding:13px 15px; font-size:12.6px; line-height:1.7;
  color:var(--text-muted); font-weight:400; text-align:left; letter-spacing:normal; text-transform:none; }
.ayuda-panel strong{ color:var(--text); font-weight:600; }
.ayuda.abierta .ayuda-panel, .ayuda:hover .ayuda-panel{ display:block; }
.ayuda-panel code{ background:var(--petrol-tint); padding:1px 6px; border-radius:5px; font-size:11.5px; word-break:break-all; }
.page-head .ayuda{ margin-left:8px; vertical-align:middle; }
html.oscuro .ayuda > button{ background:#12363b; }
html.oscuro .ayuda-panel code{ background:#0d1c1f; color:#9fd3d8; }

/* ═══════════ MENÚ LATERAL EN ACORDEÓN ═══════════
   Botones grandes tipo tarjeta en el VERDE del panel · solo un módulo abierto a la vez */
.nav-acordeon { display:flex; flex-direction:column; gap:10px; padding:6px 10px; }
.acc-grupo { border-radius: 12px; }
.acc-btn {
  width: 100%; min-height: 54px; display: flex; align-items: center; gap: 12px;
  padding: 0 14px; border: 1px solid rgba(255,255,255,.07); border-radius: 12px;
  background: #0f4d54;                    /* verde petróleo del panel */
  color: #d9ecec; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left; text-decoration: none;
  transition: background .22s ease, border-color .22s ease;
}
.acc-btn:hover { background: #14606a; }   /* verde ligeramente más claro */
.acc-btn.activo {
  background: #17727d;                    /* activo: verde resaltado */
  border-left: 4px solid #35d0a5;         /* acento verde */
  padding-left: 10px;
  color: #fff;
}
.acc-btn .ico { width: 26px; display:flex; align-items:center; justify-content:center; flex:none; }
.acc-btn .txt { flex: 1; line-height: 1.25; }
.acc-btn .flecha { font-size: 12px; opacity: .75; transition: transform .25s ease; }
.acc-grupo.abierto .acc-btn .flecha { transform: rotate(90deg); }
.acc-directo { margin-bottom: 2px; }

/* Submenús: más pequeños, indentados, con despliegue suave y texto completo */
.acc-sub {
  display: grid; grid-template-rows: 0fr; overflow: hidden;
  transition: grid-template-rows .28s ease;
}
.acc-grupo.abierto .acc-sub { grid-template-rows: 1fr; }
.acc-sub-inner { min-height: 0; overflow: hidden; display:flex; flex-direction:column; padding-top: 6px; }
.acc-item {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 4px 2px 16px; padding: 9px 12px;
  border-radius: 9px; font-size: 13px; color: #bcd6d6; text-decoration: none;
  transition: background .18s ease, color .18s ease;
}
.acc-item:hover { background: rgba(53,208,165,.14); color: #fff; }
.acc-item.active { background: rgba(53,208,165,.22); color: #fff; font-weight: 600; }
.acc-item .ico { width: 22px; display:flex; align-items:center; justify-content:center; flex:none; }
.acc-item .txt { flex:1; line-height:1.25; white-space: normal; }  /* el texto completo, sin cortar */
