/* Palma · sistema visual (fase 0). Se carga después de legacy.css y lo sobrescribe. */

:root {
    --p-ground: #F4F3EE;
    --p-surface: #FFFFFF;
    --p-surface-2: #F0F1EA;
    --p-ink: #16231B;
    --p-ink-soft: #4B5A50;
    --p-ink-faint: #5C6A60;
    --p-line: #DCDDD3;
    --p-line-strong: #C9CCBF;
    --p-primary: #1F5135;
    --p-primary-hover: #173F29;
    --p-primary-soft: #E3EEE6;
    --p-nav: #2A7F50;
    --p-nav-2: rgba(255, 255, 255, .12);
    --p-nav-active: rgba(255, 255, 255, .22);
    --p-nav-ink: #F1F8F3;
    --p-nav-muted: #D3EBDB;
    --p-warn: #7A4E0E;
    --p-warn-soft: #F5EBDB;
    --p-danger: #9B2C24;
    --p-danger-soft: #F7E4E1;
    --p-info: #2F5F8F;
    --p-info-soft: #E6ECF3;
    --p-radius: 12px;
    --p-radius-sm: 8px;
    --p-font: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    --p-font-display: 'IBM Plex Serif', Georgia, serif;
    --p-sidebar: 256px;

    /* Bootstrap */
    --bs-body-font-family: var(--p-font);
    --bs-body-color: var(--p-ink);
    --bs-body-bg: var(--p-ground);
    --bs-border-color: var(--p-line);
    --bs-primary: #1F5135;
    --bs-primary-rgb: 31, 81, 53;
    --bs-link-color: #1F5135;
    --bs-link-color-rgb: 31, 81, 53;
    --bs-link-hover-color: #123321;
    --bs-secondary-color: var(--p-ink-soft);
    --bs-border-radius: var(--p-radius-sm);
    --bs-border-radius-lg: var(--p-radius);
}

html { -webkit-text-size-adjust: 100%; }
body.p-app, body.p-auth {
    margin: 0;
    font-family: var(--p-font);
    color: var(--p-ink);
    background: var(--p-ground);
    -webkit-font-smoothing: antialiased;
}
.text-secondary { color: var(--p-ink-soft) !important; }

/* ---------- Estructura ---------- */
.p-shell { min-height: 100vh; display: flex; }
.p-sidebar {
    width: var(--p-sidebar);
    flex: 0 0 var(--p-sidebar);
    background: var(--p-nav);
    color: var(--p-nav-ink);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.p-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.p-content { padding: 28px; width: 100%; max-width: 1400px; margin: 0 auto; box-sizing: border-box; }

.p-brand { display: flex; align-items: center; gap: 10px; color: #FFFFFF; text-decoration: none; padding: 4px 8px; }
.p-brand:hover { color: #FFFFFF; }
.p-brand-mark {
    width: 32px; height: 32px; border-radius: 8px; background: rgba(255, 255, 255, .2);
    display: grid; place-items: center; flex: none;
}
.p-brand-mark svg { width: 18px; height: 18px; }
.p-brand-name { font-weight: 700; letter-spacing: .08em; font-size: 14px; }

.p-nav { display: flex; flex-direction: column; gap: 2px; }
.p-nav + .p-nav { border-top: 1px solid rgba(255, 255, 255, .22); padding-top: 14px; }
.p-nav-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--p-nav-muted); padding: 0 10px 6px; }
.p-nav a {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px;
    border-radius: var(--p-radius-sm); color: var(--p-nav-ink); font-size: 15px; text-decoration: none;
}
.p-nav a i { width: 18px; text-align: center; font-size: 14px; opacity: .85; }
.p-nav a:hover { background: var(--p-nav-2); color: #FFFFFF; }
.p-nav a.is-active { background: var(--p-nav-active); color: #FFFFFF; font-weight: 600; box-shadow: inset 3px 0 0 #FFFFFF; }
.p-nav a:focus-visible, .p-btn-icon:focus-visible, .p-user:focus-visible { outline: 2px solid #E0A23A; outline-offset: 2px; }

.p-topbar {
    position: sticky; top: 0; z-index: 1020;
    background: var(--p-surface); border-bottom: 1px solid var(--p-line);
    padding: 10px 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.p-topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--p-ink-faint); min-width: 0; }
.p-breadcrumb a { color: var(--p-primary); text-decoration: none; }
.p-breadcrumb strong { color: var(--p-ink); font-weight: 600; }
.p-topbar-right { display: flex; align-items: center; gap: 8px; }

.p-btn-icon {
    width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--p-line);
    background: var(--p-surface); color: var(--p-ink); display: inline-grid; place-items: center; cursor: pointer;
}
.p-btn-icon:hover { background: var(--p-surface-2); }
.p-user {
    height: 44px; border-radius: 10px; border: 1px solid var(--p-line); background: var(--p-surface);
    display: inline-flex; align-items: center; gap: 8px; padding: 0 12px 0 6px; color: var(--p-ink); font-size: 14px;
}
.p-user::after { margin-left: 2px; }
.p-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--p-primary-soft); color: var(--p-primary);
    display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none;
}
.p-user-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.p-user-text small { color: var(--p-ink-faint); font-size: 12px; }

.p-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.p-page-title { margin: 0; font-family: var(--p-font-display); font-weight: 600; font-size: 30px; line-height: 1.15; letter-spacing: -.005em; }
.p-page-kicker { font-size: 13px; color: var(--p-ink-faint); margin-bottom: 2px; }

/* ---------- Componentes ---------- */
.p-card { background: var(--p-surface); border: 1px solid var(--p-line); border-radius: var(--p-radius); }
.p-card-pad { padding: 20px 22px; }
.p-section-title { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--p-ink-soft); margin: 0 0 12px; }

.p-alert { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--p-radius); padding: 14px 16px; margin-bottom: 20px; border: 1px solid transparent; }
.p-alert i { margin-top: 3px; }
.p-alert-success { background: var(--p-primary-soft); border-color: #BFD6C6; color: #123321; }
.p-alert-error { background: var(--p-danger-soft); border-color: #E6BDB7; color: #6E1E18; }
.p-alert-info { background: var(--p-info-soft); border-color: #C3D2E2; color: #1E3D5C; }
.p-email-pending { padding: 10px 14px; font-size: 14px; }
.p-email-pending .p-link-button { color: inherit; font-weight: 600; }
.p-email-pending a { color: inherit; font-weight: 600; }
.p-alert-warn { background: var(--p-warn-soft); border-color: #E5CFA5; color: #5E3B08; }

.p-badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.p-badge-warn { background: var(--p-warn-soft); color: var(--p-warn); }
.p-badge-ok { background: var(--p-primary-soft); color: var(--p-primary); }
.p-badge-danger { background: var(--p-danger-soft); color: var(--p-danger); }

/* Portada (Inicio) */
.p-modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); gap: 16px; }
.p-module {
    display: flex; flex-direction: column; gap: 14px; min-height: 150px; padding: 22px;
    background: var(--p-surface); border: 1px solid var(--p-line); border-radius: 14px;
    color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.p-module:hover { border-color: var(--p-line-strong); box-shadow: 0 6px 20px rgba(22, 35, 27, .07); color: inherit; }
.p-module-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; }
.p-tone-green { background: var(--p-primary-soft); color: var(--p-primary); }
.p-tone-blue { background: var(--p-info-soft); color: var(--p-info); }
.p-tone-amber { background: var(--p-warn-soft); color: #8A5A12; }
.p-tone-slate { background: #E8EAE6; color: #34433A; }
.p-module-name { font-size: 18px; font-weight: 600; }
.p-module-desc { font-size: 14px; color: var(--p-ink-soft); line-height: 1.45; }

/* ---------- Autenticación ---------- */
.p-auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 20px; box-sizing: border-box; }
.p-auth-card { width: 100%; max-width: 380px; background: var(--p-surface); border: 1px solid var(--p-line); border-radius: 16px; padding: 32px 28px; box-sizing: border-box; }
.p-auth-card h1 { font-size: 22px; font-weight: 600; margin: 18px 0 20px; }
.p-auth-card .p-brand { color: var(--p-ink); padding: 0; }
.p-auth-card .p-brand-mark { background: var(--p-primary); }
.p-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.p-field label { font-size: 14px; font-weight: 600; }
.p-field .p-hint { font-size: 13px; color: var(--p-ink-faint); }
.p-input {
    height: 48px; border: 1px solid var(--p-line-strong); border-radius: 10px; padding: 0 14px;
    font: inherit; font-size: 16px; background: var(--p-surface); color: var(--p-ink); width: 100%; box-sizing: border-box;
}
.p-input:focus { outline: none; border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(31, 81, 53, .18); }
.p-btn-primary {
    height: 50px; width: 100%; border: 0; border-radius: 10px; background: var(--p-primary); color: #FFFFFF;
    font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
}
.p-btn-primary:hover { background: var(--p-primary-hover); }
.p-btn-primary:focus-visible { outline: 3px solid rgba(31, 81, 53, .35); outline-offset: 2px; }
.p-btn-secondary {
    display: flex; align-items: center; justify-content: center; height: 50px; width: 100%; box-sizing: border-box;
    border: 1px solid var(--p-line-strong); border-radius: 10px; background: var(--p-surface); color: var(--p-ink);
    font: inherit; font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none;
}
.p-btn-secondary:hover { border-color: var(--p-primary); color: var(--p-primary); }
.p-auth-actions { display: grid; gap: 10px; }
.p-auth-actions a.p-btn-primary { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.p-auth-text { margin: -8px 0 20px; font-size: 15px; line-height: 1.5; color: var(--p-ink-soft); }
.p-link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--p-primary); font-weight: 500; text-decoration: underline; cursor: pointer; }
.p-auth-links { display: flex; justify-content: center; margin-top: 18px; font-size: 14px; }
.p-auth-links a { color: var(--p-primary); font-weight: 500; }
.p-auth-card .p-alert { margin-bottom: 18px; font-size: 14px; }

/* ---------- Bootstrap en las páginas existentes ---------- */
.p-app .btn { border-radius: var(--p-radius-sm); font-weight: 600; }
.p-app .btn-primary { --bs-btn-bg: #1F5135; --bs-btn-border-color: #1F5135; --bs-btn-hover-bg: #173F29; --bs-btn-hover-border-color: #173F29; --bs-btn-active-bg: #123321; --bs-btn-active-border-color: #123321; --bs-btn-disabled-bg: #1F5135; --bs-btn-disabled-border-color: #1F5135; }
.p-app .btn-outline-primary { --bs-btn-color: #1F5135; --bs-btn-border-color: #1F5135; --bs-btn-hover-bg: #1F5135; --bs-btn-hover-border-color: #1F5135; --bs-btn-active-bg: #173F29; }
.p-app .form-control, .p-app .form-select { border-color: var(--p-line-strong); border-radius: var(--p-radius-sm); }
.p-app .form-control:focus, .p-app .form-select:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(31, 81, 53, .15); }
.p-app .table { --bs-table-bg: transparent; }
.p-app .table > thead th { background: var(--p-surface-2); color: var(--p-ink-soft); font-weight: 600; font-size: 13px; }
.p-app .dropdown-menu { border: 1px solid var(--p-line); border-radius: var(--p-radius); box-shadow: 0 10px 30px rgba(22, 35, 27, .12); }

/* ---------- Celular ---------- */
.p-menu-toggle { display: none; }
@media (max-width: 991.98px) {
    .p-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 1045; height: 100%;
        transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .25);
    }
    .p-shell.is-nav-open .p-sidebar { transform: translateX(0); }
    .p-scrim { position: fixed; inset: 0; background: rgba(10, 20, 14, .45); z-index: 1040; display: none; }
    .p-shell.is-nav-open .p-scrim { display: block; }
    .p-menu-toggle { display: inline-grid; }
    .p-topbar { padding: 8px 12px; }
    .p-content { padding: 16px; }
    .p-page-title { font-size: 24px; }
    .p-user-text, .p-breadcrumb-trail { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .p-sidebar { transition: none; }
}
@media print {
    .p-sidebar, .p-topbar, .p-scrim { display: none !important; }
    .p-content { padding: 0; max-width: none; }
}

/* =====================================================================
   Estilo de sistema: denso, plano y ordenado (se impone al diseño anterior).
   Escala: letra base 14px · controles 36px · filas de tabla compactas · radios 6–10px.
   ===================================================================== */
:root { --p-sidebar: 232px; }
body.p-app, body.p-app.module-campos, body.p-app.module-campamento {
    background: var(--p-ground) !important;
    font-size: 14px;
    line-height: 1.45;
}
.p-app h1, .p-app h2, .p-app h3, .p-app h4, .p-app h5, .p-app h6 { letter-spacing: 0; font-weight: 600; color: var(--p-ink); }
.p-app .h3, .p-app h3 { font-size: 18px; }
.p-app .h4, .p-app h4 { font-size: 16px; }
.p-app .h5, .p-app h5 { font-size: 15px; }
.p-app .h6, .p-app h6 { font-size: 14px; }
.p-app .small, .p-app small { font-size: 12.5px; }
.p-app .text-secondary, .p-app .small, .p-app .form-text { color: var(--p-ink-soft) !important; }

/* Estructura */
.p-sidebar { padding: 14px 10px; gap: 16px; }
.p-nav a { min-height: 36px; font-size: 14px; padding: 0 10px; }
.p-nav-title { font-size: 11px; padding-bottom: 4px; }
.p-topbar { padding: 8px 24px; min-height: 56px; }
.p-btn-icon { width: 38px; height: 38px; border-radius: 8px; }
.p-user { height: 38px; border-radius: 8px; }
.p-content { max-width: none; padding: 20px 24px 32px; }
.p-page-head { margin-bottom: 16px; align-items: center; }
.p-page-title { font-family: var(--p-font); font-size: 22px; font-weight: 600; letter-spacing: -.005em; }
.p-page-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* Paneles: planos, borde fino */
.p-app .panel, .p-app .card-soft {
    background: var(--p-surface) !important;
    border: 1px solid var(--p-line) !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}
.p-app .p-4 { padding: 16px 18px !important; }
.p-app .p-3 { padding: 12px 14px !important; }
.p-app .mb-4 { margin-bottom: 16px !important; }
.p-app .mt-4 { margin-top: 16px !important; }
.p-app .g-4 { --bs-gutter-x: 16px; --bs-gutter-y: 16px; }
.p-app .g-3 { --bs-gutter-x: 12px; --bs-gutter-y: 12px; }
.p-app .section-title, .p-app.module-campos .section-title { font-size: 15px !important; font-weight: 600 !important; margin-bottom: 2px; }
.p-app .section-title i { font-size: 13px; }

/* Formularios y botones */
.p-app .form-label { font-size: 12.5px; font-weight: 600; color: var(--p-ink-soft); margin-bottom: 4px; }
.p-app .form-control, .p-app .form-select, .p-app .input-group-text {
    min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: 6px; border-color: var(--p-line-strong);
}
.p-app .form-select { padding-right: 32px; }
.p-app textarea.form-control { min-height: 64px; }
.p-app .form-control-lg, .p-app .form-select-lg { min-height: 40px; font-size: 15px; }
.p-app .btn { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 6px; font-weight: 600; }
.p-app .btn-sm { min-height: 30px; padding: 3px 10px; font-size: 13px; border-radius: 6px; }
.p-app .btn-lg { min-height: 40px; padding: 8px 18px; font-size: 15px; }
.p-app .btn i { margin-right: 6px; }
.p-app .btn i:only-child { margin-right: 0; }
.p-app .form-check-input { width: 16px; height: 16px; margin-top: .2em; }

/* Tablas: compactas, con cabecera fija dentro del contenedor */
.p-app .table { --bs-table-border-color: var(--p-line); font-size: 13.5px; }
.p-app .table > :not(caption) > * > * { padding: 8px 10px; }
.p-app .table thead th {
    font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--p-ink-soft);
    background: var(--p-surface-2); border-bottom: 1px solid var(--p-line); white-space: nowrap;
}
.p-app .table td { padding-top: 8px; }
.p-app .table tbody tr:hover > td { background: #F7F8F3; }
.p-app .table-responsive { border: 1px solid var(--p-line); border-radius: 8px; }
.p-app .panel .table-responsive { border-radius: 8px; }

/* Insignias */
.p-app .badge { font-size: 12px; font-weight: 600; }
.p-app .badge.py-2 { padding-top: .32em !important; padding-bottom: .32em !important; }
.p-app .badge.px-3 { padding-left: .65em !important; padding-right: .65em !important; }

/* Indicadores (KPI) */
.p-app .kpi-card { transition: border-color .15s; }
.p-app .kpi-card:hover { transform: none; box-shadow: none; border-color: var(--p-line-strong) !important; }
.p-app .kpi-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--p-primary-soft); color: var(--p-primary); font-size: 15px; }
.p-app .campos-kpi-value { font-size: 24px !important; line-height: 1.2; letter-spacing: -.01em; }
.p-app .campos-kpi-label { font-size: 11.5px !important; }

/* Celular */
@media (max-width: 767.98px) {
    .p-content { padding: 12px 12px 24px; }
    .p-app .p-4 { padding: 12px !important; }
    /* Las tablas se desplazan de lado en vez de aplastarse. */
    .p-app .table-responsive { -webkit-overflow-scrolling: touch; }
    .p-app .table-responsive > .table:not(.p-stack) { min-width: 640px; }
    .p-app .table-responsive::after { content: ''; display: block; }
    .p-page-title { font-size: 19px; }
    .p-app .row > [class*="col-"] { min-width: 0; }
}

/* Barra superior y filtros en el celular */
.p-topbar-brand { display: none; font-weight: 700; letter-spacing: .08em; font-size: 14px; color: var(--p-primary); text-decoration: none; }
.p-filter-toggle { display: none; }
@media (max-width: 991.98px) {
    .p-breadcrumb { display: none; }
    .p-topbar-brand { display: inline; }
    .p-topbar { min-height: 52px; }
}
@media (max-width: 767.98px) {
    .p-filter-toggle { display: inline-flex; align-items: center; width: 100%; justify-content: center; margin-bottom: 12px; }
    .p-filter-box:not(.is-open) { display: none !important; }
    .p-filter-form.row > [class*="col-"], .p-filter-form .row > [class*="col-"] { flex: 0 0 50%; max-width: 50%; }
    .p-filter-form.row > [class*="col-"]:has(input[type="search"]), .p-filter-form .row > [class*="col-"]:has(input[type="search"]),
    .p-filter-form.row > [class*="col-"]:has(input[name="q"]), .p-filter-form .row > [class*="col-"]:has(input[name="q"]),
    .p-filter-form.row > [class*="col-"]:has(button), .p-filter-form .row > [class*="col-"]:has(button),
    .p-filter-form.row > [class*="col-"]:has(textarea), .p-filter-form .row > [class*="col-"]:has(textarea) { flex-basis: 100%; max-width: 100%; }
    .p-app .p-filter-form .form-label { font-size: 12px; }
}

/* Tablas como tarjetas en el celular */
@media (max-width: 767.98px) {
    .p-app .table-responsive:has(> table.p-stack) { border: 0; overflow: visible; }
    .p-app table.p-stack, .p-app table.p-stack tbody { display: block; width: 100%; }
    .p-app table.p-stack thead { display: none; }
    .p-app table.p-stack tbody tr {
        display: block; background: var(--p-surface); border: 1px solid var(--p-line); border-radius: 10px;
        padding: 6px 12px; margin-bottom: 10px;
    }
    .p-app table.p-stack tbody tr:hover > td { background: transparent; }
    .p-app table.p-stack tbody tr > td {
        display: block; position: relative; border: 0; border-bottom: 1px solid var(--p-line);
        padding: 7px 0 7px 40% !important; text-align: right; min-width: 0; overflow-wrap: anywhere;
    }
    .p-app table.p-stack tbody tr > td:last-child { border-bottom: 0; }
    .p-app table.p-stack tbody tr > td::before {
        content: attr(data-label); position: absolute; left: 0; top: 8px; width: 37%; text-align: left;
        font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--p-ink-faint);
    }
    .p-app table.p-stack tbody tr > td[data-label=""], .p-app table.p-stack tbody tr > td:not([data-label]) { padding-left: 0 !important; }
    .p-app table.p-stack tbody tr > td[data-label=""]::before, .p-app table.p-stack tbody tr > td:not([data-label])::before { content: none; }
    /* La primera celda con contenido es el título de la tarjeta; la casilla de selección va arriba a la derecha. */
    .p-app table.p-stack tbody tr { position: relative; }
    .p-app table.p-stack tbody tr > td.p-stack-title { padding: 8px 36px 8px 0 !important; text-align: left; font-size: 15px; }
    .p-app table.p-stack tbody tr > td.p-stack-title::before { content: none; }
    .p-app table.p-stack tbody tr > td.p-stack-check { position: absolute; top: 10px; right: 12px; padding: 0 !important; border: 0; }
    .p-app table.p-stack tbody tr > td.p-stack-check::before { content: none; }
    .p-app table.p-stack tbody tr > td .d-flex { justify-content: flex-end; flex-wrap: wrap; }
    .p-app table.p-stack tbody tr > td.p-stack-title .d-flex { justify-content: flex-start; flex-wrap: nowrap; }
    .p-app table.p-stack tbody tr.p-stack-full { padding: 0; border: 0; background: transparent; }
    .p-app table.p-stack tbody tr.p-stack-full > td { display: block; text-align: left; }
    .p-app table.p-stack tbody tr.p-stack-full > td::before { content: none; }
    .p-app table.p-stack tbody tr.collapse:not(.show) { display: none; }
}

.p-page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.p-history > li { padding: 10px 0 10px 14px; border-left: 2px solid var(--p-line-strong); margin-left: 4px; }
.p-history > li + li { margin-top: 2px; }
.p-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 6px 16px; }
.p-check-grid .form-check { padding: 6px 8px 6px 32px; border-radius: 6px; margin: 0; }
.p-check-grid .form-check:hover { background: var(--p-surface-2); }
.p-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.p-dl dt { color: var(--p-ink-soft); font-weight: 500; font-size: 13px; }
.p-dl dd { margin: 0; }
@media (max-width: 767.98px) { .p-dl { grid-template-columns: 1fr; gap: 2px; } .p-dl dd { margin-bottom: 8px; } .p-page-actions { width: 100%; } .p-page-actions .btn { flex: 1 1 auto; } }

/* =====================================================================
   Terreno: celular del jefe de cuadrilla. Botones grandes (≥48px), pocos pasos.
   ===================================================================== */
body.t-body { margin: 0; font-family: var(--p-font); color: var(--p-ink); background: var(--p-ground); font-size: 16px; padding-bottom: calc(76px + env(safe-area-inset-bottom)); -webkit-font-smoothing: antialiased; }
.t-header { background: var(--p-nav); color: #FFFFFF; padding: 14px 16px 16px; padding-top: calc(14px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 10; }
.t-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 640px; margin: 0 auto; }
.t-header-kicker { font-size: 13px; color: #D3EBDB; }
.t-header-title { font-size: 20px; font-weight: 600; line-height: 1.2; }
.t-icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 0; background: rgba(255,255,255,.18); color: #FFFFFF; display: grid; place-items: center; font-size: 17px; cursor: pointer; }
.t-main { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; display: flex; flex-direction: column; gap: 14px; }
.t-card { background: var(--p-surface); border: 1px solid var(--p-line); border-radius: 14px; padding: 14px; }
.t-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.t-hint { font-size: 13px; color: var(--p-ink-faint); }
.t-input, .t-select {
    width: 100%; box-sizing: border-box; height: 52px; border: 1px solid var(--p-line-strong); border-radius: 12px; padding: 0 14px;
    font: inherit; font-size: 16px; background: var(--p-surface); color: var(--p-ink);
}
.t-input:focus, .t-select:focus { outline: none; border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(31,81,53,.18); }
.t-row { display: flex; gap: 10px; }
.t-row > * { flex: 1; min-width: 0; }
.t-field { margin-bottom: 14px; }
.t-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.t-chip { position: relative; }
.t-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.t-chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--p-line-strong); background: var(--p-surface); font-size: 15px; }
.t-chip input:checked + span { background: var(--p-primary); border-color: var(--p-primary); color: #FFFFFF; font-weight: 600; }
.t-chip input:focus-visible + span { outline: 3px solid rgba(31,81,53,.35); outline-offset: 2px; }
.t-stepper { display: flex; height: 52px; border: 1px solid var(--p-line-strong); border-radius: 12px; overflow: hidden; background: var(--p-surface); }
.t-stepper button { width: 52px; border: 0; background: var(--p-surface-2); font-size: 22px; color: var(--p-ink); cursor: pointer; }
.t-stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font: inherit; font-size: 18px; font-weight: 600; color: var(--p-ink); background: transparent; }
.t-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; border: 0; border-radius: 12px; background: var(--p-primary); color: #FFFFFF; font: inherit; font-weight: 600; font-size: 17px; cursor: pointer; text-decoration: none; }
.t-btn:active { background: var(--p-primary-hover); }
.t-btn-light { background: var(--p-surface); color: var(--p-ink); border: 1px solid var(--p-line-strong); }
.t-btn-danger { background: var(--p-danger); }
.t-btn-sm { min-height: 44px; font-size: 15px; width: auto; padding: 0 16px; }
.t-list { display: flex; flex-direction: column; gap: 10px; }
.t-item { background: var(--p-surface); border: 1px solid var(--p-line); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.t-item-main { min-width: 0; }
.t-item-title { font-weight: 600; overflow-wrap: anywhere; }
.t-item-sub { font-size: 14px; color: var(--p-ink-soft); }
.t-pending { color: var(--p-warn); font-weight: 600; }
.t-section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 2px 0; }
.t-section-head h2 { font-size: 16px; margin: 0; }
.t-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.t-result { text-align: left; min-height: 48px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--p-line); background: var(--p-surface); font: inherit; color: var(--p-ink); cursor: pointer; }
.t-result small { display: block; color: var(--p-ink-faint); }
.t-picked { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--p-primary-soft); border: 1px solid #BFD6C6; font-weight: 600; }
.t-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--p-surface); border-top: 1px solid var(--p-line); padding-bottom: env(safe-area-inset-bottom); }
.t-tabs a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 64px; font-size: 13px; color: var(--p-ink-soft); text-decoration: none; }
.t-tabs a i { font-size: 19px; }
.t-tabs a.is-active { color: var(--p-primary); font-weight: 600; }
.t-dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #E0A23A; color: #2B1B04; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.t-empty { text-align: center; color: var(--p-ink-faint); padding: 18px 8px; }
.t-body .p-alert { margin-bottom: 0; }
.t-history li { padding: 6px 0; border-bottom: 1px solid var(--p-line); font-size: 14px; }
@media (min-width: 900px) { body.t-body { padding-bottom: 90px; } }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.p-qr-box { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; padding: 12px; border: 1px solid var(--p-line); border-radius: 10px; background: var(--p-surface-2); }
.p-qr { width: 200px; height: 200px; background: #FFFFFF; border-radius: 8px; padding: 6px; flex: none; }
.p-qr svg { width: 100%; height: 100%; display: block; }
.p-qr-box > .d-grid { flex: 1 1 260px; }

/* El atributo hidden siempre oculta, aunque el componente tenga display propio. */
[hidden] { display: none !important; }

/* Cifras resumen (franja de KPIs compactos sobre una tabla) */
.p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 10px; margin-bottom: 12px; }
.p-stat { background: var(--p-surface); border: 1px solid var(--p-line); border-radius: var(--p-radius-sm); padding: 10px 14px; min-width: 0; }
.p-stat-label { display: block; color: var(--p-ink-soft); font-size: 12px; font-weight: 500; }
.p-stat-value { display: block; font-size: 19px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.p-stat-note { display: block; color: var(--p-ink-faint); font-size: 12px; }
.p-stat-warn { border-color: var(--p-warn); background: var(--p-warn-soft); }
.p-num-neg { color: var(--p-danger); }
.p-row-deleted td { color: var(--p-ink-faint); text-decoration: line-through; }
.p-row-deleted td:last-child { text-decoration: none; }
@media (max-width: 575.98px) { .p-stats { grid-template-columns: 1fr 1fr; } .p-stat-value { font-size: 16px; } }

/* Lista con búsqueda (select[data-searchable] → palma-select.js) */
.p-combo { position: relative; }
.p-combo-list { position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 2px); max-height: min(320px, 50vh); overflow-y: auto; box-shadow: 0 8px 24px rgba(22, 35, 27, .14); border-radius: var(--p-radius-sm); }
.p-combo-list .list-group-item { font-size: 14px; padding: 8px 12px; }
.p-combo-list .list-group-item.active { background: var(--p-primary-soft); color: var(--p-ink); border-color: var(--p-line); }
@media (max-width: 767.98px) { .p-combo-list { position: static; margin-top: 4px; max-height: 45vh; box-shadow: none; border: 1px solid var(--p-line); } }
.p-app .panel:has(.p-combo) { overflow: visible; }
@media (min-width: 768px) { .p-combo-list { min-width: min(520px, 70vw); } }

/* Panel de gestión: tarjetas de indicadores */
.p-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 12px; }
.p-kpi { display: flex; flex-direction: column; background: var(--p-surface); border: 1px solid var(--p-line); border-radius: var(--p-radius-sm); padding: 14px 16px; min-width: 0; }
.p-kpi-warn { border-color: var(--p-warn); box-shadow: inset 3px 0 0 var(--p-warn); }
.p-kpi-label { font-size: 12.5px; font-weight: 600; color: var(--p-ink-soft); margin: 0 0 4px; letter-spacing: .01em; }
.p-kpi-value { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.p-kpi-compare { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12.5px; margin-top: 4px; }
.p-kpi-note { font-size: 12.5px; color: var(--p-ink-faint); margin: 8px 0 0; flex: 1; }
.p-kpi-link { font-size: 13px; font-weight: 600; margin-top: 10px; text-decoration: none; }
.p-kpi-link:hover { text-decoration: underline; }
.p-delta { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font-weight: 600; font-size: 12px; background: var(--p-surface-2); color: var(--p-ink-soft); }
.p-delta-good { background: var(--p-primary-soft); color: var(--p-primary); }
.p-delta-bad { background: var(--p-danger-soft); color: var(--p-danger); }
.p-chart { position: relative; height: 260px; }
@media (max-width: 575.98px) { .p-kpis { grid-template-columns: 1fr 1fr; gap: 8px; } .p-kpi { padding: 10px 12px; } .p-kpi-value { font-size: 17px; } .p-kpi-note { display: none; } .p-chart { height: 220px; } }
@media (min-width: 1280px) { .p-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } .p-kpi-value { font-size: 22px; } }

/* Salud del servidor */
.p-health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.p-health-card { background: var(--p-surface); border: 1px solid var(--p-line); border-radius: var(--p-radius-sm); padding: 14px 16px; min-width: 0; }
.p-health-card.is-warn { border-color: var(--p-warn); box-shadow: inset 3px 0 0 var(--p-warn); }
.p-health-card.is-bad { border-color: var(--p-danger); box-shadow: inset 3px 0 0 var(--p-danger); }
.p-health-unit { font-size: 13px; font-weight: 500; color: var(--p-ink-soft); }
.p-meter { height: 8px; border-radius: 999px; background: var(--p-surface-2); overflow: hidden; margin-top: 8px; }
.p-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--p-nav); transition: width .4s ease; }
.is-warn .p-meter > span { background: #C08A2E; }
.is-bad .p-meter > span { background: var(--p-danger); }
.p-health-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--p-surface-2); color: var(--p-ink-soft); }
.p-health-badge.is-ok { background: var(--p-primary-soft); color: var(--p-primary); }
.p-health-badge.is-warn { background: var(--p-warn-soft); color: var(--p-warn); }
.p-health-badge.is-bad { background: var(--p-danger-soft); color: var(--p-danger); }
@media (max-width: 575.98px) { .p-health-grid { grid-template-columns: 1fr 1fr; gap: 8px; } .p-health-card { padding: 10px 12px; } }
.p-app .p-health-card h3.p-kpi-label { font-size: 13px; font-weight: 600; margin: 0; }
@media (max-width: 575.98px) { .p-health-card .p-kpi-note { display: block; font-size: 12px; } .p-health-card .p-kpi-value { font-size: 18px; } }

/* Reparto de producción por cuadrilla (partials/batch_form.php + palma-reparto.js) */
.pb-fieldset { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.pb-summary { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--p-surface); border: 1px solid var(--p-line-strong); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; box-shadow: 0 4px 14px rgba(22, 35, 27, .08); }
.pb-summary-main { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 15px; font-variant-numeric: tabular-nums; }
.pb-summary-left { font-weight: 700; }
.pb-meter { height: 8px; border-radius: 999px; background: var(--p-surface-2); overflow: hidden; margin: 8px 0 6px; }
.pb-meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--p-nav); transition: width .2s ease; }
.pb-summary-msg { font-size: 13px; color: var(--p-ink-soft); }
.pb-summary.is-ok { border-color: var(--p-nav); }
.pb-summary.is-ok .pb-summary-left { color: var(--p-primary); }
.pb-summary.is-warn .pb-summary-left { color: var(--p-warn); }
.pb-summary.is-over { border-color: var(--p-danger); background: var(--p-danger-soft); }
.pb-summary.is-over .pb-summary-left, .pb-summary.is-over .pb-summary-msg { color: var(--p-danger); font-weight: 600; }
.pb-summary.is-over .pb-meter > span { background: var(--p-danger); }
.pb-rows { display: flex; flex-direction: column; gap: 8px; }
.pb-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--p-line); border-radius: 12px; background: var(--p-surface); }
.pb-row-name { min-width: 0; display: flex; flex-direction: column; }
.pb-row-name span { font-weight: 600; overflow-wrap: anywhere; }
.pb-row-left { font-size: 13px; color: var(--p-ink-faint); font-variant-numeric: tabular-nums; }
.pb-row-qty { display: flex; align-items: center; gap: 6px; }
.pb-row-qty .t-input { width: 96px; text-align: center; font-variant-numeric: tabular-nums; }
.pb-fill { padding: 0 12px; }
.pb-row.is-done { border-color: color-mix(in srgb, var(--p-nav) 45%, var(--p-line)); }
.pb-row.is-done .pb-row-left { color: var(--p-primary); }
.pb-row.is-over { border-color: var(--p-danger); background: var(--p-danger-soft); }
.pb-row.is-over .pb-row-left { color: var(--p-danger); font-weight: 600; }
.t-btn:disabled { opacity: .5; cursor: not-allowed; }
.pb-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--p-warn-soft); color: var(--p-warn); }
.pb-badge.is-ok { background: var(--p-primary-soft); color: var(--p-primary); }
@media (max-width: 380px) { .pb-row { grid-template-columns: 1fr; } .pb-row-qty .t-input { flex: 1; width: auto; } }
.pb-summary-base { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--p-primary); font-variant-numeric: tabular-nums; }
.pb-summary-base.is-bad { color: var(--p-danger); }

/* ---------- Campana de avisos (barra superior, oficina y terreno) ---------- */
.p-bell { position: relative; }
.p-bell > summary { list-style: none; position: relative; }
.p-bell > summary::-webkit-details-marker { display: none; }
.p-bell-count {
    position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    background: #B3261E; color: #FFFFFF; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; box-sizing: border-box;
}
.p-bell-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 1050; width: min(360px, calc(100vw - 32px));
    background: var(--p-surface); color: var(--p-ink); border: 1px solid var(--p-line); border-radius: var(--p-radius);
    box-shadow: 0 12px 32px rgba(22, 35, 27, .16); padding: 6px; max-height: 70vh; overflow-y: auto;
}
.p-bell-terreno .p-bell-panel { position: fixed; right: 16px; left: 16px; top: 64px; width: auto; }
.p-bell-head { font-weight: 600; font-size: 13px; color: var(--p-ink-soft); padding: 8px 10px 4px; }
.p-bell-empty { padding: 10px; color: var(--p-ink-faint); font-size: 14px; }
.p-bell-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: var(--p-radius-sm); color: inherit; text-decoration: none; }
.p-bell-item:hover, .p-bell-item:focus-visible { background: var(--p-surface-2); }
.p-bell-item > i { margin-top: 3px; width: 18px; text-align: center; color: var(--p-ink-faint); }
.p-bell-item.is-warn > i { color: var(--p-warn); }
.p-bell-item.is-error > i { color: var(--p-danger); }
.p-bell-item span { display: grid; gap: 2px; min-width: 0; }
.p-bell-item strong { font-size: 14px; }
.p-bell-item small { font-size: 13px; color: var(--p-ink-soft); }

/* Aviso destacado al entrar (terreno) */
.t-alert-banner { display: flex; gap: 10px; align-items: flex-start; background: var(--p-warn-soft); color: var(--p-warn); border: 1px solid #E5CFA5; border-radius: 14px; padding: 12px 14px; text-decoration: none; }
.t-alert-banner i { margin-top: 3px; }
.t-alert-banner strong { display: block; color: #5E3B08; }
.t-alert-banner span { font-size: 14px; }

/* Revisión antes de enviar (terreno) */
.rv-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.rv-table th, .rv-table td { padding: 8px 4px; border-bottom: 1px solid var(--p-line); text-align: left; vertical-align: top; }
.rv-table th { font-size: 12px; color: var(--p-ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.rv-table .num { text-align: right; white-space: nowrap; }
.rv-table tfoot td { font-weight: 700; border-top: 2px solid var(--p-ink); border-bottom: 0; }
.rv-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 15px; }
.rv-facts dt { color: var(--p-ink-soft); font-weight: 500; }
.rv-facts dd { margin: 0; font-weight: 600; }
.rv-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 10px 12px; border-radius: 10px; }
.rv-check.is-ok { background: var(--p-primary-soft); color: var(--p-primary); }
.rv-check.is-warn { background: var(--p-warn-soft); color: var(--p-warn); }
.rv-check i { margin-top: 3px; }

/* Lo ganado a la fecha (al registrar anticipos) */
.p-earned { border: 1px solid var(--p-line); border-radius: var(--p-radius-sm); background: var(--p-surface-2); padding: 10px 12px; display: grid; gap: 4px; font-size: 14px; }
.p-earned > div { display: flex; justify-content: space-between; gap: 12px; }
.p-earned > div span { color: var(--p-ink-soft); }
.p-earned > div.is-total { border-top: 1px solid var(--p-line-strong); padding-top: 6px; margin-top: 2px; }
.p-earned p { margin: 4px 0 0; color: var(--p-warn); font-weight: 600; }
.p-earned.is-over { border-color: #E5CFA5; background: var(--p-warn-soft); }
.p-earned-cell { font-size: 13px; line-height: 1.35; }
.p-earned-cell.is-over { color: var(--p-warn); font-weight: 600; }

/* Libro de remuneraciones: detalle por día y fila de totales */
.p-book-days summary { cursor: pointer; color: var(--p-primary); margin-top: 2px; }
.p-book-days table td { font-size: 13px; border-color: var(--p-line); }
.p-app .table tfoot .p-book-total > * { font-weight: 700; border-top: 2px solid var(--p-ink); background: var(--p-surface-2); }

/* ===== Ayuda: botón «¿Cómo se hace?», asistente y manual ===== */
.h-widget { position: fixed; right: 20px; bottom: 20px; z-index: 1040; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; font-family: var(--p-font); }
.h-fab { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--p-primary); color: #fff; font-weight: 600; font-size: 15px; box-shadow: 0 6px 20px rgba(22, 35, 27, .25); cursor: pointer; }
.h-fab:hover { background: var(--p-primary-hover); }
.h-fab:focus-visible, .h-icon:focus-visible, .h-send:focus-visible, .h-suggest button:focus-visible { outline: 3px solid #E0A23A; outline-offset: 2px; }
.h-fab i { font-size: 19px; }
.h-widget.is-open .h-fab { display: none; }
.h-panel { width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 110px)); display: flex; flex-direction: column; background: var(--p-surface); border: 1px solid var(--p-line); border-radius: var(--p-radius); box-shadow: 0 16px 40px rgba(22, 35, 27, .22); overflow: hidden; }
.h-panel[hidden] { display: none; }
.h-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; background: var(--p-primary); color: #fff; }
.h-panel-head strong { display: block; font-size: 15px; }
.h-panel-head small { display: block; font-size: 12.5px; opacity: .85; }
.h-panel-actions { display: flex; gap: 4px; }
.h-icon { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 16px; cursor: pointer; }
.h-icon:hover { background: rgba(255, 255, 255, .16); }
.h-log { position: relative; flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--p-ground); }
.h-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.45; color: var(--p-ink); overflow-wrap: anywhere; }
.h-msg p { margin: 0 0 6px; } .h-msg p:last-child { margin-bottom: 0; }
.h-msg ol, .h-msg ul { margin: 4px 0 6px; padding-left: 20px; } .h-msg li { margin-bottom: 3px; }
.h-msg-bot { align-self: flex-start; background: var(--p-surface); border: 1px solid var(--p-line); }
.h-msg-user { align-self: flex-end; background: var(--p-primary-soft); white-space: pre-wrap; }
.h-msg-error { align-self: flex-start; background: var(--p-danger-soft); color: var(--p-danger); }
.h-msg-wait { color: var(--p-ink-soft); font-style: italic; }
.h-warn { padding: 6px 8px; border-radius: 6px; background: var(--p-warn-soft); color: var(--p-warn); }
.h-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.h-suggest button { text-align: left; padding: 7px 11px; border: 1px solid var(--p-line-strong); border-radius: 999px; background: var(--p-surface); color: var(--p-primary); font-size: 13.5px; cursor: pointer; }
.h-suggest button:hover { background: var(--p-primary-soft); }
.h-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--p-line); background: var(--p-surface); }
.h-form textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 10px 12px; border: 1px solid var(--p-line-strong); border-radius: 10px; font: inherit; font-size: 16px; color: var(--p-ink); background: var(--p-surface); }
.h-form textarea:focus { outline: 2px solid var(--p-primary); outline-offset: 0; border-color: var(--p-primary); }
.h-send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 10px; background: var(--p-primary); color: #fff; cursor: pointer; }
.h-panel-foot { padding: 8px 14px 10px; background: var(--p-surface); font-size: 13.5px; }
.h-panel-foot a { color: var(--p-primary); text-decoration: none; font-weight: 600; }
/* Terreno: sobre la barra de pestañas inferior; en el celular, solo el ícono. */
.t-body .h-widget { bottom: calc(76px + env(safe-area-inset-bottom)); right: 12px; }
@media (max-width: 575px) {
    .h-widget { right: 12px; bottom: 12px; }
    .h-fab { width: 52px; height: 52px; padding: 0; justify-content: center; }
    .h-fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    .h-fab i { font-size: 24px; }
    .h-widget.is-open { left: 8px; right: 8px; bottom: 8px; }
    .h-panel { width: 100%; height: calc(100vh - 16px); height: calc(100dvh - 16px); }
}
.p-content { padding-bottom: 88px; }
.h-manual { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.h-manual-toc { position: sticky; top: 16px; }
.h-manual-toc nav a { display: block; padding: 6px 0; color: var(--p-primary); text-decoration: none; font-weight: 500; }
.h-task { scroll-margin-top: 16px; }
.h-task-body { max-width: 78ch; }
.h-task-body ul { padding-left: 22px; }
.h-task-body li { margin-bottom: 6px; }
.h-ui { font-weight: 600; color: var(--p-ink); }
.h-where, .h-perm, .h-callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.h-where { background: var(--p-surface-2); }
.h-perm { background: transparent; border: 1px solid var(--p-line); font-size: .92em; }
.h-where i, .h-perm i, .h-callout i { margin-top: 3px; }
.h-keywords { display: none; }
.h-steps { list-style: none; padding-left: 0; margin: 14px 0; counter-reset: none; }
.h-steps > li { position: relative; padding-left: 40px; margin-bottom: 12px; min-height: 28px; }
.h-step-n { position: absolute; left: 0; top: -1px; width: 28px; height: 28px; border-radius: 50%; background: var(--p-primary); color: #fff; font-weight: 700; font-size: .9em; display: inline-flex; align-items: center; justify-content: center; }
.h-sub { position: relative; padding: 2px 0 2px 16px; margin-top: 4px; }
.h-sub::before { content: '–'; position: absolute; left: 2px; color: var(--p-ink-soft); }
.h-callout-ok { background: var(--p-primary-soft, #E3F1E8); }
.h-callout-warn { background: var(--p-warn-soft); }
.h-callout-info { background: var(--p-info-soft); }
.h-toc-list { padding-left: 20px; font-size: .92em; }
.h-toc-list li { margin-bottom: 6px; }
.h-toc-list a, .h-results a { text-decoration: none; }
.h-results { list-style: none; padding-left: 0; }
.h-results li { padding: 6px 0; border-top: 1px solid var(--p-line); }
.h-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.h-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.h-card:hover { border-color: var(--p-primary); }
.h-card-title { font-weight: 700; font-size: 1.05em; color: var(--p-primary); }
.h-manual-toc { max-height: calc(100vh - 32px); overflow: auto; }
@media (max-width: 899px) { .h-manual { grid-template-columns: 1fr; } .h-manual-toc { position: static; } }
@media print { .h-widget { display: none; } }
.p-personal { border-top: 1px solid var(--p-line); }
.p-personal > summary { cursor: pointer; list-style: none; }
.p-personal > summary::-webkit-details-marker { display: none; }
.p-personal > summary::before { content: '▸'; margin-right: 8px; color: var(--p-ink-soft); }
.p-personal[open] > summary::before { content: '▾'; }
.p-personal > summary > span:first-child { flex: 1; }
/* Rentabilidad: cada monto abre su composición */
.p-drill { display: inline; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: inherit; cursor: pointer; text-decoration: underline dotted 1px; text-underline-offset: 3px; text-decoration-color: var(--p-line-strong); }
.p-drill:hover { color: var(--p-primary); text-decoration-color: currentColor; }
.p-drill:focus-visible { outline: 3px solid #E0A23A; outline-offset: 2px; border-radius: 3px; }
.p-drill-name { text-decoration: none; }
.p-profit tr.is-open > td { background: var(--p-primary-soft); }
.p-detail-row > td { background: var(--p-ground); padding: 14px !important; }
.p-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.p-detail-box { background: var(--p-surface); border: 1px solid var(--p-line); border-radius: var(--p-radius-sm); padding: 12px 14px; scroll-margin: 90px; }
.p-detail-box h3 { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.p-detail-cat { padding: 6px 0; border-top: 1px solid var(--p-line); scroll-margin: 90px; }
.p-detail-box h3 + .p-detail-cat { border-top: 0; }
.p-detail-list { list-style: none; margin: 4px 0; padding: 0; font-size: 13px; }
.p-detail-list li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.p-detail-list a { color: var(--p-ink); text-decoration: none; min-width: 0; }
.p-detail-list a:hover { color: var(--p-primary); text-decoration: underline; }
.p-calc { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0; font-size: 13.5px; }
.p-calc dd { margin: 0; text-align: right; white-space: nowrap; }
.is-focus { animation: p-focus 1.6s ease-out; }
@keyframes p-focus { 0% { box-shadow: 0 0 0 3px #E0A23A; } 100% { box-shadow: 0 0 0 3px transparent; } }
.p-stat-link { color: inherit; text-decoration: none; transition: border-color .15s; }
.p-stat-link:hover { border-color: var(--p-primary); }
.p-stat-link:hover .p-stat-note { color: var(--p-primary); }
#personal, #generales { scroll-margin-top: 90px; }

/* ===== Menú lateral en árbol: módulo → páginas, con la ubicación actual siempre visible ===== */
.p-tree { display: flex; flex-direction: column; gap: 2px; }
.p-tree-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--p-nav-muted); padding: 14px 10px 6px; margin-top: 8px; border-top: 1px solid rgba(255, 255, 255, .22); }
.p-tree-home, .p-tree-module > summary {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--p-radius-sm);
    color: var(--p-nav-ink); font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.p-tree-home i, .p-tree-module > summary > i:first-child { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
.p-tree-home:hover, .p-tree-module > summary:hover { background: var(--p-nav-2); color: #FFFFFF; }
.p-tree-home.is-active { background: var(--p-nav-active); color: #FFFFFF; font-weight: 600; }
.p-tree-module > summary { list-style: none; user-select: none; }
.p-tree-module > summary::-webkit-details-marker { display: none; }
.p-tree-module > summary > span { flex: 1; }
.p-tree-caret { font-size: 11px; opacity: .7; transition: transform .15s; }
.p-tree-module:not([open]) .p-tree-caret { transform: rotate(-90deg); }
/* Módulo actual: encabezado destacado y bloque con fondo propio. */
.p-tree-module.is-current { background: rgba(0, 0, 0, .14); border-radius: var(--p-radius-sm); padding-bottom: 6px; margin: 2px 0; }
.p-tree-module.is-current > summary { color: #FFFFFF; font-weight: 700; }
.p-tree-module ul { list-style: none; margin: 2px 0 4px 19px; padding: 0 0 0 12px; border-left: 2px solid rgba(255, 255, 255, .28); display: flex; flex-direction: column; gap: 1px; }
.p-tree-module ul a {
    position: relative; display: flex; align-items: center; min-height: 34px; padding: 0 10px; border-radius: var(--p-radius-sm);
    color: var(--p-nav-muted); font-size: 14px; text-decoration: none;
}
.p-tree-module ul a:hover { background: var(--p-nav-2); color: #FFFFFF; }
/* Página actual: fondo blanco, texto verde, y su marca sobre la línea guía. */
.p-tree-module ul a.is-active { background: #FFFFFF; color: var(--p-primary); font-weight: 700; }
.p-tree-module ul a.is-active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: #FFFFFF; }
.p-tree a:focus-visible, .p-tree summary:focus-visible { outline: 2px solid #E0A23A; outline-offset: 2px; }
.p-sidebar { overflow-y: auto; }
/* Reparto: quitar a alguien (solo del reporte o de la cuadrilla) sin salir de la pantalla */
.pb-remove { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 1px solid var(--p-line-strong); border-radius: 10px; background: var(--p-surface); color: var(--p-ink-soft); font-size: 18px; cursor: pointer; }
.pb-remove:hover { color: var(--p-danger); border-color: var(--p-danger); }
.pb-remove:focus-visible { outline: 3px solid #E0A23A; outline-offset: 2px; }
.pb-row.is-asking { border-color: var(--p-danger); }
.pb-ask { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--p-line-strong); }
.pb-ask p { flex: 1 1 100%; margin: 0; font-weight: 600; }
@media (max-width: 420px) { .pb-row-qty .t-input { width: 76px; } .pb-row-qty .pb-fill { padding: 0 10px; } }
.t-logout { width: auto; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.t-logout i { font-size: 17px; }
@media (max-width: 479px) { .t-logout { width: 44px; padding: 0; justify-content: center; } .t-logout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); } }

/* Archivos generados en segundo plano: avisos sobre el botón «¿Cómo se hace?» */
.j-stack { position: fixed; right: 20px; bottom: 80px; z-index: 1045; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; width: min(380px, calc(100vw - 32px)); font-family: var(--p-font); pointer-events: none; }
.j-card { pointer-events: auto; position: relative; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; width: 100%; padding: 14px 40px 14px 16px; background: var(--p-surface); color: var(--p-ink); border: 1px solid var(--p-line); border-left: 4px solid var(--p-primary); border-radius: var(--p-radius); box-shadow: 0 12px 32px rgba(22, 35, 27, .22); }
.j-card > i { font-size: 20px; margin-top: 2px; color: var(--p-primary); }
.j-failed { border-left-color: var(--p-danger); }
.j-failed > i { color: var(--p-danger); }
.j-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; }
.j-text strong { font-size: 15px; }
.j-text span { overflow-wrap: anywhere; }
.j-note { color: var(--p-ink-soft); font-size: 13px; }
.j-err { color: var(--p-danger); font-size: 13px; }
.j-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.j-btn { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--p-line); border-radius: 999px; color: var(--p-ink); background: var(--p-surface); font-weight: 600; font-size: 14px; text-decoration: none; }
.j-btn:hover { border-color: var(--p-primary); color: var(--p-primary); }
.j-primary { background: var(--p-primary); border-color: var(--p-primary); color: #fff; }
.j-primary:hover { background: var(--p-primary-hover); color: #fff; }
.j-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 999px; background: transparent; color: var(--p-ink-soft); cursor: pointer; }
.j-close:hover { background: var(--p-line); }
.j-btn:focus-visible, .j-close:focus-visible { outline: 3px solid #E0A23A; outline-offset: 2px; }
@media (max-width: 575.98px) { .j-stack { right: 16px; bottom: 76px; } }
.p-bell-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--p-line); color: var(--p-primary); font-weight: 600; font-size: 14px; text-decoration: none; }
.p-bell-foot:hover { background: var(--p-primary-soft, #EEF3EF); }

/* Sueldos: calendario de días (nómina operacional) */
.s-calendar th, .s-calendar td { white-space: nowrap; }
.s-calendar .s-name { position: sticky; left: 0; z-index: 1; background: var(--p-surface); min-width: 190px; }
.s-calendar thead th { font-size: 12px; font-weight: 600; }
.s-calendar .s-weekend { background: #F4F5EF; }
.s-cell { display: inline-grid; place-items: center; width: 30px; height: 30px; margin: 3px; border: 1px solid var(--p-line); border-radius: 8px; background: var(--p-surface); color: var(--p-ink); font-size: 13px; cursor: pointer; }
.s-cell:hover:not(:disabled) { border-color: var(--p-primary); }
.s-cell:focus-visible { outline: 3px solid #E0A23A; outline-offset: 1px; }
.s-worked { background: var(--p-primary); border-color: var(--p-primary); color: #fff; }
.s-absent { background: var(--p-danger-soft); border-color: #E6BDB7; color: var(--p-danger); }
.s-lock, .s-cell:disabled { cursor: not-allowed; opacity: .7; }
.s-out { background: repeating-linear-gradient(45deg, #EEE, #EEE 3px, #F7F7F7 3px, #F7F7F7 6px); border-style: dashed; cursor: default; }
.s-legend { width: 22px; height: 22px; margin: 0 4px 0 0; vertical-align: middle; cursor: default; font-size: 11px; }

/* Aviso de ambiente de pruebas (APP_INSTANCE_LABEL; producción no lo tiene) */
.p-env-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #F2C14E; color: #3D2A00; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; vertical-align: middle; }
.p-env-badge-side { margin: 2px 8px 8px 46px; }
.p-env-badge-top { margin-left: 6px; }
@media (min-width: 900px) { .p-env-badge-top { display: none; } }
.p-env-note { margin: 12px 0 0; font-size: 13px; color: var(--p-ink-soft); }

/* Contador rojo en el menú (p. ej. «Inconsistencias»: problemas por corregir). */
.p-nav-count { display: inline-block; min-width: 1.4em; padding: 0 .45em; margin-left: .35em; border-radius: 999px; background: #dc3545; color: #fff; font-size: 11px; font-weight: 700; line-height: 1.6; text-align: center; vertical-align: 1px; }
.p-book .p-book-open { white-space: nowrap; }
.p-remembered { color: var(--p-muted, #5c6a60); }
.p-remembered a { font-weight: 600; }
/* Lista de verificación antes de cerrar un libro. */
.p-checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; font-size: 13px; }
.p-checklist li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .45rem; align-items: start; line-height: 1.4; }
.p-checklist li i { margin-top: .15rem; }
.p-check-block i { color: #dc3545; } .p-check-block span { color: #842029; font-weight: 600; }
.p-check-warn i { color: #d48806; }
.p-check-ok i { color: #198754; } .p-check-ok span { color: var(--p-muted, #5c6a60); }
.p-check-info i { color: #3b82f6; } .p-check-info span { color: var(--p-muted, #5c6a60); }
/* Gastos → Nuevo gasto: tipo de gasto y, debajo, de dónde sale el combustible. */
.p-expense-tabs { display: grid; gap: .6rem; }
.p-expense-tabs-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.p-expense-tabs-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--p-muted, #5c6a60); min-width: 13rem; }
.p-expense-subtabs { gap: .35rem; }
.p-expense-subtabs .nav-link { padding: .3rem .8rem; font-size: 13px; border: 1px solid var(--p-line, #d6ddd6); border-radius: 999px; color: inherit; }
.p-expense-subtabs .nav-link.active { background: var(--p-primary, #2f6b45); border-color: var(--p-primary, #2f6b45); color: #fff; }
@media (max-width: 575px) { .p-expense-tabs-label { min-width: 100%; } }
/* Calendario de sueldos: el mes completo cabe (las columnas de días se reparten el ancho); botones rápidos bajo el
   nombre (24-11-2026). En pantallas angostas la tabla se desplaza hacia el lado. */
.s-calendar { width: 100%; table-layout: fixed; min-width: 760px; }
.s-calendar .s-name { width: 175px; min-width: 0; white-space: normal; word-break: break-word; }
.s-calendar th, .s-calendar td { padding-left: 1px; padding-right: 1px; }
.s-calendar thead th { font-size: 11px; text-align: center; }
.s-calendar thead th.s-name { text-align: left; }
.s-calendar .s-cell { width: 100%; max-width: 28px; height: 26px; margin: 2px 0; border-radius: 6px; font-size: 12px; }
.s-row-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin-top: .35rem; font-weight: 400; }
.btn-xs { padding: .05rem .45rem; font-size: 12px; border-radius: 6px; }
.s-all-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.s-row-tools .btn { white-space: nowrap; padding: .05rem .45rem; font-size: 12px; line-height: 1.5; border-radius: 6px; }

/* ===================================================================================================
   Nuevo aspecto, fase 1 (24-11-2026; muestra aprobada por Jaime): secciones que se distinguen, más
   contenido a la vista. Solo estilo: no cambia funciones. Va al final para ganarle a lo anterior.
   =================================================================================================== */
:root {
    --p-ground: #E9E8E0;
    --p-sidebar: 224px;
    --p-card-line: #DFE0D6;
    --p-card-head: #F7F7F2;
    --p-card-head-line: #E4E5DB;
    --p-card-shadow: 0 1px 2px rgba(22, 35, 27, .06), 0 4px 12px rgba(22, 35, 27, .04);
    --p-zebra: #FBFBF8;
    --bs-body-bg: var(--p-ground);
}
body.p-app { background: var(--p-ground); }

/* Estructura: menú más angosto, barra superior y márgenes más ajustados. */
.p-sidebar { padding: 16px 12px; gap: 14px; }
.p-content { padding: 20px 24px 28px; }
.p-topbar { padding: 8px 24px; }
.p-page-head { margin-bottom: 16px; }
.p-page-title { font-size: 26px; }

/* Tarjetas: se despegan del fondo con una sombra suave. */
.p-app .panel, .p-app .card-soft, .p-card {
    border-color: var(--p-card-line) !important;
    border-radius: 12px !important;
    box-shadow: var(--p-card-shadow) !important;
}
.p-app .panel { --p-pad-y: 16px; --p-pad-x: 18px; }
.p-app .panel.p-3 { --p-pad-y: 12px; --p-pad-x: 14px; }

/* Encabezado de cada tarjeta: el primer título (o la fila de título + acciones) se vuelve una franja
   con fondo propio y una línea debajo, así se ve dónde empieza y termina cada sección. */
.p-app .panel:is(.p-4, .p-3):not(.d-flex, .row, .d-grid) > :is(h2, h3):first-child,
.p-app .panel:is(.p-4, .p-3):not(.d-flex, .row, .d-grid) > :is(.d-flex, .campos-data-header):first-child:has(> :is(h2, h3), > div > :is(h2, h3), > div > .section-title) {
    margin: calc(-1 * var(--p-pad-y)) calc(-1 * var(--p-pad-x)) 14px !important;
    padding: 10px var(--p-pad-x) !important;
    background: var(--p-card-head);
    border-bottom: 1px solid var(--p-card-head-line);
    border-radius: 11px 11px 0 0;
}
.p-app .panel:is(.p-4, .p-3):not(.d-flex, .row, .d-grid) > :is(h2, h3):first-child { font-size: 15px; font-weight: 600; line-height: 1.35; }
.p-app .panel:is(.p-4, .p-3) > :is(.d-flex, .campos-data-header):first-child :is(h2, h3) { margin-bottom: 0 !important; font-size: 15px; }

/* Tablas más densas, con filas alternadas para seguir la línea con la vista. */
.p-app .table { font-size: 13px; }
.p-app .table > :not(caption) > * > * { padding: 7px 10px; }
.p-app .table thead th { font-size: 11px; letter-spacing: .05em; background: #FAFAF7; border-bottom-color: var(--p-card-head-line); }
.p-app .table > tbody > tr:nth-child(even) > * { background-color: var(--p-zebra); }
.p-app .table > tbody > tr:hover > * { background-color: #F2F4EE; }
.p-app .table-responsive { border-color: var(--p-card-head-line); }

/* Indicadores: más compactos. */
.p-stat { border-color: var(--p-card-line); box-shadow: var(--p-card-shadow); }

@media (max-width: 991.98px) {
    .p-content { padding: 16px; }
    .p-topbar { padding: 8px 12px; }
}

/* El calendario de días conserva su grilla en celular: se desplaza hacia el lado con celdas tocables. */
.p-app .table-responsive > table.s-calendar { min-width: 900px !important; }
