/* Plataforma RRHH IMA — sistema de diseño. Sin dependencias externas (tipografía del sistema, iconos SVG en línea). */
:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #f8faf8;
  --ink: #15211b;
  --ink-2: #3a4a41;
  --muted: #66766d;
  --line: #e1e7e3;
  --line-strong: #cfd8d2;
  --brand: #15803d;
  --brand-strong: #166534;
  --brand-soft: #e7f4ec;
  --brand-ink: #ffffff;
  --side: #0d2418;
  --side-2: #12301f;
  --side-ink: #bdd2c5;
  --side-ink-strong: #ffffff;
  --accent: #4ade80;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a5b00;
  --warn-soft: #fff4de;
  --ok: #15803d;
  --ok-soft: #e7f4ec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(13, 36, 24, .05), 0 6px 20px rgba(13, 36, 24, .05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b130f;
    --surface: #121c16;
    --surface-2: #16221b;
    --ink: #e8f0ea;
    --ink-2: #c3d2c8;
    --muted: #8fa398;
    --line: #213128;
    --line-strong: #2d4235;
    --brand: #34c26a;
    --brand-strong: #4ade80;
    --brand-soft: #14301f;
    --brand-ink: #062412;
    --danger: #ff8a7d;
    --danger-soft: #3a1815;
    --warn: #f4b556;
    --warn-soft: #36270d;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura de la aplicación ---------- */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: var(--side-ink);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 20px; color: var(--side-ink-strong); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #22c55e, #15803d); display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(34, 197, 94, .25);
}
.brand-mark svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-text strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand-text span { font-size: 12px; color: var(--side-ink); }

.nav-group { margin-top: 14px; }
.nav-title { padding: 0 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #7f9a8a; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 1px 0;
  border-radius: 9px; color: var(--side-ink); font-weight: 500; position: relative;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: var(--side-ink-strong); text-decoration: none; }
.nav-link.is-active { background: rgba(74, 222, 128, .12); color: var(--side-ink-strong); }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.ico { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; padding: 18px 12px 4px; font-size: 12px; color: #6f8a7a; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 12px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.crumb { font-weight: 600; color: var(--ink-2); }
.crumb small { font-weight: 500; color: var(--muted); margin-right: 8px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.userchip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--brand-ink); background: var(--brand); }
.userchip b { display: block; font-size: 13px; line-height: 1.2; }
.userchip small { display: block; font-size: 11px; color: var(--muted); line-height: 1.2; }
.top-actions form { margin: 0; display: block; }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.menu-toggle, #nav-toggle { display: none; }

main { padding: 28px 32px 56px; width: 100%; max-width: 1360px; }
main > h1:first-child, main > .page-head h1 { margin-top: 0; }

/* ---------- Tipografía de contenido ---------- */
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 19px; letter-spacing: -.01em; margin: 32px 0 12px; }
h3 { font-size: 15px; margin: 22px 0 10px; color: var(--ink-2); }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 15px; margin-bottom: 22px; }
ul, ol { padding-left: 1.3em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; }
small { color: var(--muted); }

/* Menú secundario que generan las pantallas ("Inicio | Nuevo | ...") */
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.subnav a {
  padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 13px; font-weight: 500; transition: border-color .15s, background .15s;
}
.subnav a:hover { text-decoration: none; border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }

/* ---------- Tablas ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin: 0 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th {
  position: sticky; top: 0; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td, .table tr:hover > td { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }
.table td form { display: inline-flex; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }

/* ---------- Formularios ---------- */
main > form, .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin: 0 0 22px;
}
form { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin: 0 0 14px; }
form br { display: none; }
form > p, form > h2, form > h3, form > table, form > .table-wrap, form > div, form > fieldset, form > hr, form > ul, form > ol { flex: 1 1 100%; margin-top: 0; margin-bottom: 0; }
label { display: inline-flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label:has(> input[type=checkbox]), label:has(> input[type=radio]) { flex-direction: row; align-items: center; gap: 9px; font-weight: 500; font-size: 14px; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px; min-width: 12rem; max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-width: min(100%, 28rem); min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=checkbox], input[type=radio] { min-width: 0; width: 17px; height: 17px; accent-color: var(--brand); padding: 0; }
input[type=file] { padding: 7px 10px; background: var(--surface-2); }
input[type=hidden] { display: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; font-size: 13px; color: var(--ink-2); }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 14px; }
summary { cursor: pointer; font-weight: 600; }

button, .btn, input[type=submit] {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: 1px solid var(--brand-strong); background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 1px 2px rgba(13, 36, 24, .12); transition: background .15s, transform .05s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--brand-strong); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
.table button, td button { padding: 5px 12px; font-size: 13px; }
button[data-confirm], form[data-confirm] button { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line-strong)); box-shadow: none; }
button[data-confirm]:hover, form[data-confirm] button:hover { background: var(--danger-soft); }

/* Avisos (las pantallas marcan errores y confirmaciones con estilos en línea de color) */
[style*="color:#a00"], [style*="color:red"] { color: var(--danger) !important; }
p[style*="color:#a00"], p[style*="color:red"], ul[style*="color:#a00"], ul[style*="color:red"], div[style*="color:#a00"] {
  background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--radius-sm); padding: 10px 14px;
}
ul[style*="color:#a00"], ul[style*="color:red"] { padding-left: 2em; }
[style*="color:#070"] { color: var(--ok) !important; }
p[style*="color:#070"], div[style*="color:#070"] { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); border-radius: var(--radius-sm); padding: 10px 14px; }
[style*="color:#964"] { color: var(--warn) !important; }
p[style*="color:#964"] { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: var(--radius-sm); padding: 10px 14px; }
div[style*="border:1px solid #ccc"] { border: 1px solid var(--line) !important; border-radius: var(--radius); background: var(--surface); padding: 16px 18px !important; box-shadow: var(--shadow); }
.alert { padding: 11px 15px; border-radius: var(--radius-sm); margin: 0 0 16px; font-size: 14px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.alert-info { background: var(--brand-soft); color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 28%, transparent); }

/* ---------- Panel de inicio ---------- */
.hero {
  background: radial-gradient(1200px 400px at 90% -30%, rgba(74, 222, 128, .28), transparent 60%), linear-gradient(135deg, #0d2418, #14532d);
  color: #fff; border-radius: 18px; padding: 28px 32px; margin: 0 0 26px; box-shadow: var(--shadow);
}
.hero h1 { color: #fff; font-size: 30px; }
.hero p { color: #cfe6d7; margin: 4px 0 0; }
.hero .tag { display: inline-block; margin-top: 14px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.tile {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; box-shadow: 0 10px 28px rgba(13, 36, 24, .1); }
.tile .ico-box { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); flex: none; }
.tile .ico-box .ico { width: 22px; height: 22px; }
.tile b { display: block; font-size: 15px; margin-bottom: 2px; }
.tile span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.section-label { margin: 28px 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Acceso y errores (sin sesión) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px 64px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(900px 500px at 10% 110%, rgba(74, 222, 128, .28), transparent 60%), linear-gradient(150deg, #0a1f14 0%, #14532d 100%);
}
.auth-hero::after {
  content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 0 0 60px rgba(255, 255, 255, .03), 0 0 0 130px rgba(255, 255, 255, .02);
}
.auth-hero .brand { padding: 0; }
.auth-hero h2 { font-size: 38px; line-height: 1.12; letter-spacing: -.025em; margin: 0 0 16px; max-width: 18ch; }
.auth-hero p { color: #cfe6d7; max-width: 44ch; font-size: 16px; }
.auth-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: #dcefe3; font-size: 14px; }
.auth-hero li::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 12px; }
.auth-hero small { color: #8fb09d; position: relative; z-index: 1; }
.auth-hero > * { position: relative; z-index: 1; }
.auth-pane { display: grid; place-items: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 28px; }
.auth-card form { background: none; border: 0; box-shadow: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.auth-card form label { display: grid; }
.auth-card input { width: 100%; padding: 11px 14px; font-size: 15px; }
.auth-card button { width: 100%; padding: 12px; font-size: 15px; }
.auth-card .btn-ghost { background: transparent; color: var(--ink-2); }
.auth-mobile-brand { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 288px; max-width: 86vw; transform: translateX(-102%); transition: transform .22s ease; }
  #nav-toggle:checked ~ .app .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .scrim { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(5, 12, 8, .55); }
  #nav-toggle:checked ~ .scrim { display: block; }
  .menu-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
  .menu-toggle .ico { width: 20px; height: 20px; }
  .topbar { padding: 10px 16px; }
  main { padding: 20px 16px 48px; }
  .userchip div { display: none; }
  .userchip { padding: 4px; }
  .hero { padding: 22px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .auth-mobile-brand { display: flex; margin-bottom: 26px; color: var(--ink); }
  .auth-mobile-brand .brand-text span { color: var(--muted); }
}
@media (max-width: 560px) {
  input, select, textarea { min-width: 0; width: 100%; }
  label { width: 100%; }
  main > form, .card { padding: 16px; }
}
@media print {
  .side, .topbar, .subnav { display: none; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .table-wrap { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Etiquetas de estado */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: color-mix(in srgb, #2563eb 12%, transparent); color: #2563eb; }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { .badge-info { color: #8ab4ff; } }

/* Listas de enlaces (índices de módulos y reportes) como tarjetas */
main > ul:has(> li > a) { list-style: none; padding: 0; margin: 0 0 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
main > ul:has(> li > a) > li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
main > ul:has(> li > a) > li:hover { border-color: var(--brand); transform: translateY(-1px); }
main > ul:has(> li > a) > li > a { display: block; font-weight: 600; color: var(--ink); }
main > ul:has(> li > a) > li > a:hover { color: var(--brand-strong); text-decoration: none; }
main > ul:has(> li > a) > li > small, main > ul:has(> li > a) > li > br + small { display: block; margin-top: 3px; line-height: 1.4; }
main > ul:has(> li > a) > li > br { display: none; }
.table td.empty { text-align: center; color: var(--muted); padding: 30px 16px; }

/* Acciones en celdas de tabla: separadas y alineadas, sin importar cuántos enlaces o formularios haya */
.row-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.row-actions form { flex-wrap: nowrap; gap: 8px; align-items: center; }
.row-actions { flex-direction: column; align-items: flex-start; gap: 10px; }
.row-actions form { width: 100%; }
.row-actions input { width: auto; flex: 1 1 130px; min-width: 0; }
.row-actions button { flex: 0 0 auto; }
.table td > a + a, .table td > a + form, .table td > form + a, .table td > form + form { margin-left: 12px; }
