/* 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-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); }

/* 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-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 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); }
