:root {
    --brand: #2f855a; --brand-d: #1f5c3e; --brand-dd: #14492f; --brand-l: #d6f2e1;
    --ink: #17201b; --muted: #55635a; --faint: #8a978f; --line: #e1e8e3; --bg: #f4f7f5; --card: #fff; --soft: #edf2ee;
    --ok: #2f855a; --warn: #b7791f; --bad: #c53030; --neutral: #718096;
    --r: 14px; --shadow: 0 1px 2px rgba(20,40,30,.06), 0 6px 20px rgba(20,40,30,.06);
}
@media (prefers-color-scheme: dark) {
    :root { --ink: #e2e8e4; --muted: #afbdb4; --faint: #7d8a82; --line: #2e3832; --bg: #0f1411; --card: #171d19; --soft: #202823; --brand-l: #1f3d2c; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100%; }
.side { background: linear-gradient(180deg, var(--brand-dd), var(--brand-d)); color: #fff; padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 18px; }
.logo img { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.14); }
.logo small { display: block; font-weight: 400; font-size: 12px; opacity: .75; }
.nav a { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.85); text-decoration: none; padding: 10px 12px; border-radius: 11px; margin: 2px 0; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav .count { margin-left: auto; background: #f6c26b; color: #3b2600; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 0 8px; }
.side-foot { margin-top: auto; font-size: 13px; opacity: .85; padding: 8px; }
.side-foot b { display: block; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.2px; }
.menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1200px; }

.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.langs button { border: 0; background: transparent; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.langs button.on { background: var(--brand); color: #fff; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
    .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
    .menu-btn { display: inline-flex; }
    .topbar { padding: 12px 16px; }
    .content { padding: 18px 14px 60px; }
}

/* ---------- Piezas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .card + .grid, .grid + .card, .section { margin-top: 18px; }
.card h2, .section-title { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.section-title { margin: 26px 0 10px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kpi { cursor: pointer; display: flex; align-items: center; gap: 14px; transition: transform .1s; text-decoration: none; color: inherit; }
.kpi:hover { transform: translateY(-1px); }
.kpi .n { font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .i { margin-left: auto; width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; background: var(--soft); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.alert { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: #fff4dd; color: #6b4400; }
.alert.bad { background: #fde2e1; color: #7a1515; }
.alert.ok { background: var(--brand-l); color: #0c3b23; }
@media (prefers-color-scheme: dark) { .alert.warn { background: #3b2c10; color: #ffe3ad; } .alert.bad { background: #4a1818; color: #ffd5d5; } .alert.ok { color: #c6f6d5; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 9px 16px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: var(--bad); }
.btn.ghost.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 8px 10px; }
.btn.big { padding: 13px 22px; font-size: 16px; }

.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.pending { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip.approved, .chip.signed { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.chip.rejected { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.chip.cancelled, .chip.inactive { color: var(--neutral); background: color-mix(in srgb, var(--neutral) 14%, transparent); }
.chip.admin { color: var(--brand); background: var(--brand-l); }
.chip.unsigned { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

.tabs { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; border-radius: 9px; padding: 7px 14px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 11px; min-width: 0; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13.5px; }
.form .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.form .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px !important; font-weight: 500 !important; }

table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tr.click { cursor: pointer; }
.list tr.click:hover td { background: var(--soft); }
.list .actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
@media (max-width: 700px) {
    .list.stack thead { display: none; }
    .list.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
    .list.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 4px; }
    .list.stack td::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; }
    .list.stack .actions { justify-content: flex-end; }
    .list.stack .actions::before { content: none; }
}
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-l); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.who { display: flex; align-items: center; gap: 10px; }
.who b { display: block; }

/* Solicitudes en tarjetas */
.req { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.req:last-child { border-bottom: 0; }
.req .body { flex: 1; min-width: 200px; }
.req .when { font-weight: 700; }
.req .comment { margin-top: 6px; background: var(--soft); border-radius: 9px; padding: 6px 10px; font-size: 13px; }

/* Subida por lotes */
.drop { border: 2px dashed color-mix(in srgb, var(--brand) 45%, transparent); border-radius: 16px; padding: 34px 20px; text-align: center; background: color-mix(in srgb, var(--brand) 5%, transparent); cursor: pointer; transition: background .15s; }
.drop.over { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.drop .big { font-size: 34px; }
.drop b { display: block; font-size: 16px; margin: 6px 0 2px; }
.files .file { display: grid; grid-template-columns: 1fr minmax(180px, 260px) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.files .file:last-child { border-bottom: 0; }
.files .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .state { min-width: 120px; text-align: right; font-size: 13px; }
.files .state.ok { color: var(--ok); font-weight: 600; }
.files .state.err { color: var(--bad); }
.files .file.contract { grid-template-columns: 1fr minmax(160px, 220px) minmax(140px, 200px) auto; }
@media (max-width: 700px) { .files .file, .files .file.contract { grid-template-columns: 1fr; } .files .state { text-align: left; } }

/* Calendario */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .h { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal .d { min-height: 96px; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 6px; font-size: 12px; overflow: hidden; }
.cal .d.out { background: transparent; border-color: transparent; }
.cal .d.we { background: var(--soft); }
.cal .d.hol { background: color-mix(in srgb, var(--warn) 10%, var(--card)); }
.cal .d.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal .num { font-weight: 700; font-size: 13px; }
.cal .ev { display: block; border-radius: 6px; padding: 1px 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cal .ev.approved { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.cal .ev.pending { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.cal .ev.sat { background: color-mix(in srgb, #3b6ea8 16%, transparent); color: #3b6ea8; }
.cal .ev.hol { color: var(--warn); background: transparent; padding: 0; }
@media (max-width: 700px) { .cal .d { min-height: 64px; font-size: 10.5px; padding: 4px; } .cal .ev { padding: 0 3px; } }

/* Modal y avisos */
.modal-bg { position: fixed; inset: 0; background: rgba(10,20,15,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1000px, 100%); height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 17px; flex: 1; }
.modal .mb { padding: 18px 20px; }
.modal.wide .mb { flex: 1; padding: 0; display: flex; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.viewer { width: 100%; height: 100%; border: 0; background: #525659; }
.viewer-img { max-width: 100%; margin: auto; display: block; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d2a22; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 60; max-width: min(560px, calc(100% - 32px)); }
.toast.err { background: #8f1d1d; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; font-weight: 600; word-break: break-word; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* Acceso */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand-dd), var(--brand) 55%, var(--bg) 55%); }
.login .card { width: min(420px, 100%); padding: 28px; }
.login .head { text-align: center; color: #fff; margin-bottom: 18px; }
.login .head img { width: 72px; height: 72px; border-radius: 20px; background: rgba(255,255,255,.15); }
.login .head h1 { margin: 10px 0 0; font-size: 24px; }
.login .head p { margin: 2px 0 0; opacity: .85; }
.login .langs { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); }
.login .langs button { color: #fff; }
.login .langs button.on { background: #fff; color: var(--brand-d); }
.login .foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }
