:root {
    --verde: #2e7d32; --azul: #1565c0; --rojo: #c62828; --amarillo: #f9a825;
    --bg: #f4f6f8; --panel: #fff; --line: #e2e6ea; --text: #233; --muted: #6b7780;
    --brand: #16a085;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ---- Login ---- */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-card { background: var(--panel); padding: 2.5rem; border-radius: 12px; width: 340px;
    box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.auth-brand { margin: 0; color: var(--brand); font-size: 1.6rem; }
.auth-sub { margin: .2rem 0 1.5rem; color: var(--muted); font-size: .9rem; }
.auth-form label { display: block; margin-bottom: 1rem; font-size: .85rem; color: var(--muted); }
.auth-form input { width: 100%; padding: .6rem; margin-top: .3rem; border: 1px solid var(--line);
    border-radius: 6px; font-size: 1rem; }

/* Honeypot: fuera de pantalla, no display:none (algunos bots lo respetan). */
.hp { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Captcha adaptativo */
.captcha-img { display: block; margin: .3rem 0; border: 1px solid var(--line); border-radius: 6px; }
.captcha-q { display: inline-block; margin: .3rem 0; font-weight: 600; color: var(--text); }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1f2a32; color: #cfd8dc; padding: 1rem 0; }
.sidebar-brand { font-weight: 700; color: #fff; padding: .5rem 1.2rem 1.2rem; font-size: 1.15rem; }
.sidebar nav a { display: block; padding: .65rem 1.2rem; color: #cfd8dc; text-decoration: none; }
.sidebar nav a:hover { background: #2b3942; color: #fff; }
.main { flex: 1; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center;
    background: var(--panel); padding: .8rem 1.4rem; border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 600; }
.topbar-user { font-size: .85rem; color: var(--muted); }
.btn-logout { margin-left: 1rem; color: var(--rojo); text-decoration: none; }
.bell { position: relative; text-decoration: none; margin-right: 1rem; font-size: 1.1rem; }
.bell-badge { position: absolute; top: -8px; right: -10px; background: var(--rojo); color: #fff;
    font-size: .65rem; padding: 1px 5px; border-radius: 10px; }
.content { padding: 1.4rem; }

/* ---- Cards / paneles ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.card-label { display: block; font-size: .78rem; color: var(--muted); }
.card-value { display: block; font-size: 1.5rem; font-weight: 700; margin-top: .3rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem; margin-top: 1rem; }
.panel h2 { margin: 0 0 .8rem; font-size: 1rem; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; }
.tbl .num { text-align: right; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .5rem; vertical-align: middle; }

/* ---- Badges estado de pago ---- */
.badges { list-style: none; padding: 0; margin: 0; }
.badges li { margin-bottom: .5rem; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 20px; color: #fff; font-size: .75rem; min-width: 90px; text-align: center; }
.badge-pagado { background: var(--verde); }
.badge-proceso { background: var(--azul); }
.badge-debe { background: var(--rojo); }

/* ---- Alertas ---- */
.alert { padding: .7rem 1.4rem; font-size: .9rem; }
.alert-ok { background: #e8f5e9; color: var(--verde); }
.alert-err { background: #fdecea; color: var(--rojo); }
.btn-primary { width: 100%; padding: .7rem; background: var(--brand); color: #fff; border: 0;
    border-radius: 6px; font-size: 1rem; cursor: pointer; }
.btn-primary:hover { filter: brightness(.95); }

/* ---- Botones genéricos ---- */
.btn { display: inline-block; padding: .45rem .9rem; background: #eef1f3; color: var(--text);
    border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-size: .9rem; cursor: pointer; }
.btn:hover { background: #e3e8eb; }
.btn-primary-sm { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-danger { background: var(--rojo); color: #fff; border-color: var(--rojo); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* ---- Toolbar / búsqueda ---- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search { display: flex; gap: .5rem; flex: 1; max-width: 520px; }
.search input { flex: 1; padding: .5rem; border: 1px solid var(--line); border-radius: 6px; }
.pager { margin-top: 1rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.pager a { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--text); }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- Formularios ---- */
.form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1.2rem; background: var(--panel); }
.form legend { font-weight: 600; padding: 0 .4rem; }
.form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; }
.form label { display: block; font-size: .82rem; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form input, .form select, .form textarea { width: 100%; padding: .5rem; margin-top: .25rem;
    border: 1px solid var(--line); border-radius: 6px; font-size: .95rem; color: var(--text); }
.form .field-err { color: var(--rojo); font-size: .75rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; }
.form-actions .btn-primary { width: auto; padding: .6rem 1.6rem; }
fieldset.sensible { border-color: #e0b4b4; background: #fcf5f5; }

/* ---- Ficha ---- */
.ficha-titulo { margin: 0 0 .2rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .82rem; }
.dl dd { margin: 0; }
.lock { font-size: .7rem; background: #fce9e9; color: var(--rojo); padding: .1rem .5rem; border-radius: 10px; vertical-align: middle; }
.reveal { background: #fff7e6; padding: .15rem .5rem; border: 1px solid #f0d090; border-radius: 4px; }

/* ---- Formularios en línea / apilados ---- */
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.inline-form select, .inline-form input { padding: .45rem; border: 1px solid var(--line); border-radius: 6px; }
.stack-form { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.stack-form input, .stack-form textarea { padding: .5rem; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
.form label.check { display: flex; align-items: center; gap: .5rem; }
.form label.check input { width: auto; margin: 0; }

/* ---- Línea de tiempo de seguimiento ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .6rem 0 .6rem .9rem; border-left: 2px solid var(--line); margin-left: .3rem; }
.timeline li strong { display: block; }

/* ---- Barra de progreso (presupuestos) ---- */
.bar { background: #e9edf0; border-radius: 6px; height: 8px; width: 90px; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar-fill { height: 100%; border-radius: 6px; }

/* ---- Gráficos SVG ---- */
.chart-row { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.chart-legend { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.chart-legend li { margin: .25rem 0; }
.chart-legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .5rem; vertical-align: middle; }
.chart-full { width: 100%; overflow-x: auto; }

/* ---- Foto de empleado ---- */
.emp-foto { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

/* ---- Modal de bienvenida ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start;
    justify-content: center; padding: 4vh 1rem; z-index: 1000; }
.modal-card { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; padding: 1.4rem 1.6rem;
    box-shadow: 0 12px 40px rgba(0,0,0,.25); max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; color: var(--brand); font-size: 1.25rem; }
.modal-card h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
.modal-x { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-list { list-style: none; margin: 0; padding: 0; }
.modal-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; }

/* ---- Editor de permisos por rol ---- */
.perm-modulo { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .3rem .8rem; margin-top: .3rem; }

/* ---- Reportes: rejilla de accesos ---- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.report-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: 1.2rem; text-decoration: none; color: var(--text); }
.report-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.report-card h3 { margin: 0 0 .4rem; }
.report-card p { margin: 0; color: var(--muted); font-size: .85rem; }

/* ---- Impresión (Guardar como PDF) ---- */
@media print {
    .sidebar, .topbar, .toolbar, form, .btn, .pager, .alert { display: none !important; }
    .layout, .main, .content { display: block; margin: 0; padding: 0; }
    .panel { border: none; box-shadow: none; padding: 0; }
    body { background: #fff; }
    .tbl th, .tbl td { font-size: 11px; }
}
