/* ============================================================
   PKU Medical - Sistema de diseño
   ============================================================ */
:root {
    --brand:        #4f46e5;
    --brand-dark:   #4338ca;
    --brand-600:    #4f46e5;
    --accent:       #6366f1;
    --bg:           #eef1f6;
    --surface:      #ffffff;
    --surface-2:    #f5f7fb;
    --text:         #0f172a;
    --text-soft:    #475569;
    --muted:        #8b95a7;
    --border:       #e2e6ee;
    --danger:       #ef4444;
    --danger-dark:  #dc2626;
    --success:      #16a34a;
    --warning:      #f59e0b;
    --info:         #3b82f6;
    --radius:       14px;
    --radius-sm:    10px;
    --shadow:       0 1px 3px rgba(15,23,42,.08), 0 8px 24px -12px rgba(15,23,42,.18);
    --shadow-lg:    0 20px 60px -20px rgba(15,23,42,.35);
    --sidebar-w:    264px;
    --tr:           .22s cubic-bezier(.4,0,.2,1);
    --font:         'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --hc-ink:       #3730a3;
}

* { box-sizing: border-box; }
html {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}
body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}
@supports (overflow-x: clip) {
    html, body { overflow-x: clip; }
}
img, video, canvas, iframe { max-width: 100%; }
a { color: var(--brand-dark); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.ta-right { text-align: right; }

/* ---------------- App shell ---------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform var(--tr);
}
.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-logo {
    width: 42px; height: 42px; border-radius: 12px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    color: #fff; font-weight: 800; font-size: .95rem;
    display: grid; place-items: center;
    box-shadow: 0 6px 18px -6px var(--brand);
    letter-spacing: .5px;
}
.brand-logo.big { width: 64px; height: 64px; font-size: 1.3rem; border-radius: 18px; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { color: #fff; font-size: 1.02rem; }
.brand-text span { font-size: .74rem; color: #94a3b8; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: #cbd5e1; font-weight: 500; font-size: .92rem;
    transition: var(--tr); position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(79,70,229,.25), rgba(99,102,241,.12)); color: #fff; }
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; border-radius: 3px; background: var(--brand);
}
.nav-ic { display: grid; place-items: center; opacity: .9; }
.nav-item.danger:hover { background: rgba(239,68,68,.15); color: #fecaca; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }

.main {
    flex: 1; margin-left: var(--sidebar-w);
    display: flex; flex-direction: column; min-width: 0;
    transition: margin var(--tr);
}
.topbar {
    height: 66px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
    position: sticky; top: 0; z-index: 30;
    backdrop-filter: saturate(1.4);
    min-width: 0;
}
.page-title { min-width: 0; flex: 1; }
.page-title h1 { font-size: 1.22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; position: relative; z-index: 40; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 999px; transition: var(--tr); }
.user-chip:hover { background: var(--surface-2); }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff; font-weight: 700; display: grid; place-items: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: .88rem; }
.user-meta span { font-size: .74rem; color: var(--muted); }

.content {
    padding: 26px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
    overflow-x: hidden;
}
.content:not(.content-map) { touch-action: pan-y; }

/* ---------------- Cards & grids ---------------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 1.02rem; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 24px; margin-bottom: 24px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); }
.dash-grid { grid-template-columns: 1.3fr 1fr; }
.link { font-size: .84rem; font-weight: 600; }

.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-ic { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.ic-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.ic-green { background: linear-gradient(135deg, #10b981, #059669); }
.ic-purple { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.ic-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--muted); font-size: .84rem; margin-top: 4px; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 12px; }
.bar-label { font-size: .84rem; color: var(--text-soft); }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--accent)); animation: growW .8s ease; }
.bar-val { font-weight: 700; font-size: .85rem; text-align: right; }
@keyframes growW { from { width: 0 !important; } }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.timeline li { display: flex; gap: 12px; align-items: flex-start; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 6px; box-shadow: 0 0 0 4px rgba(79,70,229,.15); }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
    transition: var(--tr); white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; box-shadow: 0 8px 18px -8px var(--brand); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 10px 22px -8px var(--brand); }
.btn-ghost { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { background: #eef2f7; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-outline-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.loading { opacity: .72; pointer-events: none; }
.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--text-soft); padding: 8px; border-radius: 10px; display: grid; place-items: center; transition: var(--tr); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-toggle { display: none; }

/* ---------------- Forms ---------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.field input, .field select, .field textarea {
    font-family: inherit; font-size: .92rem; color: var(--text);
    padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); transition: var(--tr); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-title { font-weight: 700; font-size: .9rem; color: var(--text); margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--border); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1.05rem; padding: 6px; opacity: .6; }
.pw-toggle:hover { opacity: 1; }

/* ---------------- Tables ---------------- */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: min(220px, 100%); display: flex; align-items: center; }
.search svg { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-family: inherit; font-size: .9rem; transition: var(--tr); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.table-wrap {
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}
.table { width: 100%; max-width: 100%; border-collapse: collapse; table-layout: auto; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; overflow-wrap: anywhere; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; overflow-wrap: anywhere; word-break: break-word; }
.table tbody tr { transition: background var(--tr); }
.table tbody tr:hover { background: var(--surface-2); }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #f1f5f9; color: #475569; }
.dot-status { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.on { background: var(--success); } .off { background: var(--muted); }

/* Selector de filtro en toolbars */
.filter-select {
    padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); font-family: inherit; font-size: .88rem; color: var(--text);
    cursor: pointer; transition: var(--tr); min-width: 170px;
}
.filter-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

/* ---------------- Usuarios ---------------- */
.users-table td { vertical-align: middle; }
.u-cell { display: flex; align-items: center; gap: 12px; }
.u-av {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: .84rem; box-shadow: 0 4px 10px -4px rgba(15,23,42,.4);
}
.u-av-0 { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.u-av-1 { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.u-av-2 { background: linear-gradient(135deg, #10b981, #059669); }
.u-av-3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.u-av-4 { background: linear-gradient(135deg, #ec4899, #db2777); }
.u-av-5 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.u-name { display: flex; flex-direction: column; min-width: 0; }
.u-name strong { color: var(--text); line-height: 1.2; }
.u-name small { color: var(--muted); font-size: .78rem; }
.u-self-tag { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); background: rgba(79,70,229,.12); padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.us-role-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}
.us-role-cell .u-custom-tag { margin-left: 0; }
.us-status-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    line-height: 1.3;
}
.us-status-flag { white-space: nowrap; font-weight: 600; font-size: .78rem; color: var(--text-soft); }
.us-status-login {
    display: block;
    font-variant-numeric: tabular-nums;
    font-size: .84rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.us-email-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    line-height: 1.3;
}
.us-email-addr {
    display: block;
    word-break: break-word;
    color: var(--text);
}
.us-email-verified {
    display: block;
    font-variant-numeric: tabular-nums;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-soft);
    white-space: nowrap;
}

.tact {
    width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
    color: var(--text-soft); cursor: pointer; display: grid; place-items: center; transition: var(--tr);
}
.tact:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand); }
.tact.warn:hover { border-color: var(--warning); color: var(--warning); }
.tact.danger:hover { border-color: var(--danger); color: var(--danger); }
.tact.ok:hover { border-color: var(--success); color: var(--success); }
.tact.info:hover { border-color: #0ea5e9; color: #0ea5e9; }
.tact:disabled { opacity: .55; cursor: not-allowed; }
.tact.loading { position: relative; color: transparent !important; pointer-events: none; }
.tact.loading::after {
    content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--brand); animation: tact-spin .6s linear infinite;
}
@keyframes tact-spin { to { transform: rotate(360deg); } }

/* Marca de agua / crédito de autoría (pie global) */
.app-credit {
    margin-top: auto; padding: 18px 28px 22px; text-align: center;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.app-credit-ver {
    font-size: 11px; font-weight: 700; letter-spacing: .4px; color: var(--muted);
    user-select: none;
}
.app-credit-mark {
    font-size: 11.5px; letter-spacing: .3px; color: var(--text-soft); opacity: .75;
    user-select: none;
}
.main .content { flex: 1 0 auto; }

.info-banner.subtle { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------------- Passkeys ---------------- */
.pk-list { display: flex; flex-direction: column; gap: 10px; }
.pk-empty { color: var(--muted); text-align: center; padding: 26px 10px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.pk-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); transition: var(--tr); }
.pk-item:hover { border-color: var(--brand); }
.pk-ic { width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent)); }
.pk-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pk-info strong { color: var(--text); }
.pk-info small { color: var(--muted); font-size: .8rem; }
.pk-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------------- Flash & toast ---------------- */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .9rem; border: 1px solid transparent; animation: slideDown .35s ease; }
.flash-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.flash-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.info-banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; background: #ecfeff; border: 1px solid #a5f3fc; color: #155e75; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }
.info-banner svg { flex-shrink: 0; margin-top: 2px; }
.info-banner p { margin: 0; min-width: 0; flex: 1; line-height: 1.5; overflow-wrap: break-word; }

.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 4000; }
.toast { padding: 13px 18px; border-radius: var(--radius-sm); color: #fff; font-size: .88rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn .3s ease; min-width: 240px; }
.toast.success { background: linear-gradient(135deg, #16a34a, #15803d); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.toast.hide { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ---------------- Modal ---------------- */
.modal { position: fixed; inset: 0; z-index: 90; display: none; }
.modal.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(3px); animation: fadeIn .25s ease; }
.modal-card {
    position: relative; margin: 5vh auto; max-width: 640px; width: calc(100% - 32px);
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 90vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px; overflow-x: hidden; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; margin-top: 6px; }

/* ---------------- Maps (mini, en fichas) ---------------- */
.mini-map { height: 320px; border-radius: var(--radius-sm); overflow: hidden; z-index: 1; }
.mini-map.small { height: 200px; margin-top: 6px; }
.pin { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; background: var(--brand); transform: rotate(-45deg); display: inline-block; }

/* ============================================================
   Mapa interactivo (map.php)
   ============================================================ */
.mapx {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "head map" "list map";
    gap: 0;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: var(--surface);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    position: relative;
}
.mapx-head { grid-area: head; padding: 16px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mapx-search { position: relative; display: flex; align-items: center; }
.mapx-search svg { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.mapx-search input {
    width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--border);
    border-radius: 999px; background: var(--surface-2); font-family: inherit; font-size: .9rem;
    color: var(--text); transition: var(--tr);
}
.mapx-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); background: var(--surface); }
.mapx-select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); font-family: inherit; font-size: .88rem; color: var(--text); cursor: pointer; transition: var(--tr);
}
.mapx-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.mapx-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mapx-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 6px; text-align: center; }
.mapx-stat b { display: block; font-size: 1.25rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.mapx-stat span { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.mapx-list { grid-area: list; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; min-height: 0; overscroll-behavior: contain; border-right: 1px solid var(--border); }
.mapx-item {
    display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
    padding: 10px; border: 1px solid transparent; border-radius: var(--radius-sm);
    background: transparent; cursor: pointer; font-family: inherit; transition: var(--tr);
    touch-action: manipulation;
}
.mapx-item:hover { background: var(--surface-2); border-color: var(--border); }
.mapx-item-av {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 11px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 700; font-size: .82rem;
}
.mapx-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mapx-item-info strong { font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapx-item-info small { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapx-item-go { color: var(--muted); flex-shrink: 0; transition: var(--tr); }
.mapx-item:hover .mapx-item-go { color: var(--brand); transform: translateX(2px); }

.mapx-empty { text-align: center; color: var(--muted); padding: 40px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mapx-empty svg { color: var(--border); }
.mapx-empty p { margin: 6px 0 0; font-weight: 600; color: var(--text-soft); }
.mapx-empty span { font-size: .82rem; max-width: 240px; }
.mapx-skeleton { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.mapx-skeleton span { height: 56px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.mapx-map-wrap { grid-area: map; position: relative; min-height: 0; min-width: 0; height: 100%; }
.mapx-map { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.mapx-panel-toggle { display: none; }

.mapx-fit {
    width: 34px; height: 34px; border: none; border-radius: 8px; background: var(--surface);
    color: var(--text-soft); cursor: pointer; box-shadow: 0 1px 5px rgba(0,0,0,.3);
    display: grid; place-items: center; margin-bottom: 8px;
}
.mapx-fit:hover { color: var(--brand); background: var(--surface-2); }

.mapx-pin-wrap { background: none; border: none; }
.mapx-pin {
    width: 22px; height: 22px; background: var(--brand); border: 3px solid #fff;
    border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    box-shadow: 0 3px 8px rgba(0,0,0,.4); transition: transform .15s ease;
}
.mapx-pin-wrap:hover .mapx-pin { transform: rotate(-45deg) scale(1.12); }
.mapx-cluster-wrap { background: none; }
.mapx-cluster {
    width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
    background: radial-gradient(circle at 30% 30%, var(--accent), var(--brand));
    color: #fff; font-weight: 700; border: 3px solid rgba(255,255,255,.85);
    box-shadow: 0 4px 12px -2px rgba(79,70,229,.55);
}
.mapx-cluster span { font-size: .82rem; }

/* Tarjeta del pin: usa los colores del tema (claro / oscuro) y se mantiene abierta al tocar dentro */
.mapx-popup .leaflet-popup-content-wrapper {
    border-radius: 18px; padding: 0; overflow: hidden;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 24px 60px -18px rgba(15,23,42,.6);
}
.mapx-popup .leaflet-popup-content { margin: 0 !important; width: auto !important; min-width: 0; line-height: 1.4; }
.mapx-popup .leaflet-popup-tip { background: var(--surface); box-shadow: 0 8px 20px -8px rgba(15,23,42,.4); }
.mapx-popup .leaflet-popup-close-button {
    color: #fff !important; opacity: .9; font-size: 22px; font-weight: 400;
    width: 36px !important; height: 36px !important; line-height: 36px !important;
    padding: 0 !important; top: 8px !important; right: 8px !important;
    z-index: 3; touch-action: manipulation; border-radius: 10px;
}
.mapx-popup .leaflet-popup-close-button:hover { opacity: 1; background: rgba(255,255,255,.18); }
.mapx-popup .mpp-btn { -webkit-tap-highlight-color: transparent; }
/* Leaflet pinta los enlaces en celeste: los botones usan los colores del tema. */
.mapx-popup a.mpp-btn { color: var(--text); }
.mapx-popup a.mpp-btn:hover { color: var(--brand); }
.mapx-popup a.mpp-btn.primary, .mapx-popup a.mpp-btn.primary:hover { color: #fff; }

.mpp { font-family: var(--font); width: min(320px, calc(100vw - 56px)); }
.mpp-head {
    display: flex; align-items: center; gap: 12px; padding: 16px 48px 16px 16px;
    background: linear-gradient(135deg, #4338ca, #6366f1); color: #fff;
}
.mpp-av {
    width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
    background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3);
    display: grid; place-items: center; font-weight: 800; font-size: 1rem; letter-spacing: .02em;
}
.mpp-name { min-width: 0; display: grid; gap: 6px; }
.mpp-name strong { font-size: 1.02rem; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.mpp-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.mpp-tag { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.2); white-space: nowrap; }
.mpp-zone {
    display: flex; align-items: center; gap: 8px; padding: 10px 16px;
    background: rgba(245,158,11,.12); color: var(--text); font-size: .84rem; font-weight: 700;
    border-bottom: 1px solid var(--border);
}
.mpp-zone svg { color: #d97706; flex-shrink: 0; }
.mpp-body { padding: 6px 16px 2px; display: grid; }
.mpp-row { display: flex; align-items: flex-start; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.mpp-row:last-of-type { border-bottom: 0; }
.mpp-ic {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: rgba(79,70,229,.12); color: var(--brand); display: grid; place-items: center;
}
.mpp-row > div { min-width: 0; display: grid; gap: 1px; }
.mpp-k { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.mpp-v { font-size: .88rem; color: var(--text); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.mpp-v a { color: var(--brand); text-decoration: none; }
.mpp-coords { padding: 4px 0 8px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mpp-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 16px; }
.mpp-actions .mpp-btn { flex: 1 1 0; }
.mpp-actions .mpp-btn:not(.primary) { flex-direction: column; gap: 3px; padding: 8px 4px; font-size: .72rem; }
.mpp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 0;
    padding: 10px 8px; min-height: 44px; border-radius: 12px; font: inherit; font-size: .82rem; font-weight: 700;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer;
    text-decoration: none; touch-action: manipulation; transition: var(--tr);
}
.mpp-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mpp-btn:hover { border-color: var(--brand); color: var(--brand); }
.mpp-btn.primary {
    flex-basis: 100% !important; background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff;
    border-color: transparent; box-shadow: 0 10px 22px -10px var(--brand);
}
.mpp-btn.primary:hover { filter: brightness(1.08); color: #fff; }
.mpp-btn.is-on { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.6); color: #b45309; }

/* Pines: los seleccionados se destacan */
.mapx-pin.is-selected { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.35), 0 3px 8px rgba(0,0,0,.4); }

/* Botón «Solo seleccionados» */
.mapx-sel-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 14px;
    border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; transition: var(--tr);
}
.mapx-sel-toggle b { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: rgba(245,158,11,.2); color: #b45309; font-size: .76rem; }
.mapx-sel-toggle:hover:not(:disabled) { border-color: #f59e0b; }
.mapx-sel-toggle.is-on { background: #f59e0b; border-color: #f59e0b; color: #1f1300; }
.mapx-sel-toggle.is-on b { background: rgba(0,0,0,.15); color: #1f1300; }
.mapx-sel-toggle:disabled { opacity: .5; cursor: default; }

/* Selector de pacientes */
.mapx-pick { position: relative; display: grid; gap: 8px; padding: 6px 4px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.mapx-pick-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mapx-pick-field { position: relative; display: flex; align-items: center; }
.mapx-pick-field svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.mapx-pick-field input {
    width: 100%; min-height: 42px; padding: 9px 12px 9px 36px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font: inherit; font-size: .9rem;
}
.mapx-pick-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); background: var(--surface); }
.mapx-pick-suggest {
    position: absolute; top: calc(100% - 6px); left: 4px; right: 4px; z-index: 20; max-height: 300px; overflow-y: auto;
    padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
    box-shadow: 0 18px 40px -16px rgba(15,23,42,.5);
}
.mapx-sug {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px;
    background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.mapx-sug > svg { color: var(--brand); flex-shrink: 0; }
.mapx-sug:hover, .mapx-sug.is-active { background: var(--surface-2); }
.mapx-sug-empty { margin: 0; padding: 10px; font-size: .84rem; color: var(--muted); }
.mapx-pick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mapx-chip {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 4px 3px 10px; border-radius: 999px;
    background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.45); font-size: .78rem; font-weight: 700; color: var(--text);
}
.mapx-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapx-chip button {
    display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%;
    background: transparent; color: var(--text-soft); cursor: pointer; flex-shrink: 0;
}
.mapx-chip button:hover { background: rgba(0,0,0,.08); color: var(--danger); }
.mapx-chip-clear { border: 0; background: none; color: var(--muted); font: inherit; font-size: .76rem; font-weight: 700; cursor: pointer; padding: 3px 6px; }
.mapx-chip-clear:hover { color: var(--danger); }
.mapx-pick-hint { margin: 0; font-size: .78rem; color: var(--muted); line-height: 1.4; }

/* Lista: fila con botón de selección rápida */
.mapx-items { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mapx-row { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); }
.mapx-row .mapx-item { flex: 1; min-width: 0; }
.mapx-row.is-selected { background: rgba(245,158,11,.08); }
.mapx-row-sel {
    display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface); color: var(--brand); cursor: pointer; transition: var(--tr);
}
.mapx-row-sel:hover { border-color: var(--brand); }
.mapx-row.is-selected .mapx-row-sel { background: #f59e0b; border-color: #f59e0b; color: #1f1300; }
.mapx-items-title { margin: 4px 4px 2px; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* Tarjeta de paciente seleccionado con la zona en un mini mapa */
.mapx-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; margin-bottom: 6px; }
.mapx-card-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 8px 12px; }
.mapx-card-x {
    display: grid; place-items: center; width: 32px; height: 32px; margin-left: auto; flex-shrink: 0; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft); cursor: pointer;
}
.mapx-card-x:hover { color: var(--danger); border-color: var(--danger); }
.mapx-mini { height: 150px; background: var(--surface-2); cursor: pointer; z-index: 0; }
.mapx-card-zone { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px 4px; font-size: .82rem; line-height: 1.4; color: var(--text-soft); }
.mapx-card-zone svg { color: #d97706; flex-shrink: 0; margin-top: 1px; }
.mapx-card-zone b { color: var(--text); }
.mapx-card-go {
    display: flex; align-items: center; justify-content: center; gap: 6px; width: calc(100% - 24px); margin: 6px 12px 12px;
    min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--brand);
    font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer;
}
.mapx-card-go:hover { border-color: var(--brand); }
@media (prefers-color-scheme: dark) {
    .mpp-btn.is-on, .mapx-sel-toggle b { color: #fcd34d; }
}

@media (max-width: 900px) {
    .mapx {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas: "head" "map";
        height: 100%;
        min-height: 0;
    }
    .mapx-head {
        border-right: 0;
        padding: 10px 12px;
        gap: 8px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
    }
    .mapx-list { border-right: 0; }
    .mapx-search { flex: 1 1 160px; min-width: 0; }
    .mapx-select { flex: 1 1 140px; min-width: 0; }
    .mapx-stats { flex: 1 1 100%; gap: 6px; }
    .mapx-stat { padding: 8px 4px; }
    .mapx-stat b { font-size: 1.05rem; }
    .mapx-stats { grid-template-columns: repeat(3, 1fr); }
    .mapx-search input, .mapx-select { font-size: 16px; }
    .mapx-list {
        grid-area: unset;
        position: absolute; left: 0; right: 0; bottom: 0;
        height: min(62dvh, 560px);
        max-height: calc(100% - 8px);
        background: var(--surface);
        border-top: 1px solid var(--border);
        border-radius: 18px 18px 0 0; box-shadow: 0 -12px 30px -12px rgba(15,23,42,.4);
        transform: translateY(calc(100% + 24px)); transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index: 500; padding: 18px 10px calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .mapx-list::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 4px; background: var(--border); }
    .mapx.panel-open .mapx-list { transform: translateY(0); }
    .mapx-item { min-height: 52px; padding: 12px 10px; }
    .mapx-map-wrap { min-height: 0; height: 100%; }
    .mapx-panel-toggle {
        display: inline-flex; align-items: center; gap: 6px; position: absolute; left: 12px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 450;
        padding: 10px 16px; min-height: 44px; border: none; border-radius: 999px; background: var(--brand); color: #fff;
        font-family: inherit; font-weight: 600; font-size: .84rem; cursor: pointer; box-shadow: 0 6px 16px -4px var(--brand);
        touch-action: manipulation;
    }
    .mapx-sel-toggle { flex: 1 1 100%; }
    .leaflet-touch .leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; }
}

/* ---------------- Sessions ---------------- */
.session-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.session-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px 18px 16px;
    min-width: 0;
}
.session-card.current { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.session-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.session-ic { width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); color: var(--brand); display: grid; place-items: center; flex-shrink: 0; }
.session-title { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.session-title strong { font-size: .98rem; line-height: 1.3; overflow-wrap: anywhere; }
.session-meta { margin: 0; display: grid; gap: 8px; }
.session-meta > div { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); gap: 10px; align-items: start; }
.session-meta dt { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.session-meta dd { margin: 0; font-size: .86rem; font-weight: 600; color: var(--text); line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }
.session-place {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--border); min-width: 0;
}
.session-place-ic { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(79,70,229,.12); color: var(--brand); }
.session-place-body { display: grid; gap: 3px; min-width: 0; }
.session-place-k { font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.session-place-v { font-size: .9rem; line-height: 1.4; overflow-wrap: anywhere; }
.session-place-v.is-muted { color: var(--muted); font-weight: 600; }
.session-place small { font-size: .76rem; color: var(--text-soft); }
.session-place a { color: var(--brand); font-weight: 600; }
.session-geo-btn { justify-self: start; margin-top: 6px; }
.session-approx { font-size: .72rem; font-weight: 600; color: var(--muted); }
.session-action { display: flex; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--border); }
.session-action .btn { white-space: nowrap; flex-shrink: 0; width: max-content; }
@media (max-width: 520px) {
    .session-meta > div { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------------- Roles ---------------- */
.roles-hero {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    margin-bottom: 20px; padding: 22px 24px; border-radius: 16px; color: #fff;
    background: linear-gradient(135deg, #4338ca, #6366f1);
    box-shadow: 0 18px 40px -22px rgba(79,70,229,.65);
}
.roles-eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; opacity: .85; }
.roles-hero h2 { margin: 6px 0 8px; font-size: 1.45rem; }
.roles-hero p { margin: 0; max-width: 62ch; opacity: .92; font-size: .92rem; line-height: 1.45; }
.roles-hero a { color: #fff; font-weight: 700; text-decoration: underline; }
.roles-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; margin-bottom: 20px; }
.roles-side-body { padding: 12px !important; }
.role-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.role-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border-radius: 12px; border: 1px solid var(--border); cursor: pointer; transition: var(--tr);
}
.role-item:hover { border-color: var(--brand); background: var(--surface-2); }
.role-item.active { border-color: var(--brand); background: linear-gradient(90deg, rgba(79,70,229,.12), transparent); }
.role-item-ic {
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
    background: rgba(79,70,229,.12); color: var(--brand);
}
.role-item-text { min-width: 0; }
.role-item strong { display: block; font-size: .95rem; }
.role-item small { color: var(--muted); font-size: .78rem; }
.roles-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.roles-empty svg { opacity: .4; margin-bottom: 8px; }
.roles-empty p { margin: 6px 0 4px; font-weight: 600; color: var(--text-soft); }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.perm-check { display: inline-grid; place-items: center; padding: 6px; }
.perm-modal-card { width: min(920px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.perm-modal-card .modal-body {
    display: flex; flex-direction: column; gap: 12px;
    overflow: hidden; min-height: 0; flex: 1 1 auto;
}
.perm-head-actions { display: flex; align-items: center; gap: 4px; }
#permUserWrap {
    display: flex; flex-direction: column; gap: 12px;
    min-height: 0; flex: 1 1 auto;
}
.perm-help { margin: 0; flex-shrink: 0; }
.perm-scroll {
    flex: 1 1 auto;
    min-height: 180px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}
.perm-table { border-collapse: separate; border-spacing: 0; margin: 0; }
.perm-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #1e293b;
    color: #e2e8f0;
    border-bottom: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .22);
    letter-spacing: .06em;
}
.perm-table tbody tr:hover { background: var(--surface-2); }
.perm-modal-card .modal-foot {
    padding: 12px 22px 16px;
    border-top: 1px solid var(--border);
    margin: 0;
    flex-shrink: 0;
}
.perm-group td {
    text-align: left !important;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    padding: 10px 12px;
}
.perm-row-hc td:first-child { padding-left: 22px; }
.perm-row-hc .perm-view-name { display: block; }

.acc-modal-card {
    width: min(1280px, 98vw);
    max-height: 94dvh;
    display: flex;
    flex-direction: column;
}
#accessModal.us-overlay.open {
    display: flex;
    flex-direction: column;
}
#accessModal .us-sheet {
    position: relative;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
    flex: 1 1 auto;
    min-height: 0;
}
.us-sheet-head {
    align-items: flex-start;
    gap: 12px 16px;
    flex-wrap: wrap;
    padding: 14px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
}
.us-sheet-titles { min-width: 0; flex: 1 1 240px; }
.us-sheet-titles h2 { font-size: 1.15rem; }
.us-sheet-tools {
    flex: 1 1 280px;
    min-width: 0;
    margin: 0;
}
.us-sheet-head .icon-btn { flex-shrink: 0; }
#accessModal .acc-modal-body {
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
}
#accessModal .modal-foot {
    padding: 12px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.acc-modal-card .modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
}
.acc-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.acc-toolbar .search { flex: 1 1 220px; min-width: 0; }
.acc-hint {
    margin: 0;
    font-size: .8rem;
    font-weight: 650;
    color: var(--muted);
}
.acc-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
}
.acc-leg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    font-weight: 650;
    color: var(--text-soft);
}
.acc-leg em {
    font-style: normal;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    display: inline-grid;
    place-items: center;
    font-size: .72rem;
    font-weight: 800;
    color: #fff;
}
.acc-leg-v em { background: #0f766e; }
.acc-leg-c em { background: #1d4ed8; }
.acc-leg-e em { background: #b45309; }
.acc-leg-d em { background: #b91c1c; }
.acc-leg-note {
    margin-left: auto;
    font-size: .76rem;
    color: var(--muted);
}
.acc-workspace {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.acc-layout {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    height: 100%;
    min-height: 0;
}
.acc-rail-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--surface-2);
}
.acc-rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.acc-rail-head strong {
    font-size: .72rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}
.acc-dirty-badge {
    font-size: .72rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(79, 70, 229, .14);
    color: var(--brand);
}
.acc-rail {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.acc-user {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    padding: 10px;
    cursor: pointer;
    position: relative;
}
.acc-user:hover { background: var(--surface); }
.acc-user.is-active {
    background: var(--surface);
    border-color: rgba(79, 70, 229, .28);
    box-shadow: 0 0 0 1px rgba(79, 70, 229, .08);
}
.acc-user.is-inactive { opacity: .72; }
.acc-user.is-dirty .acc-user-av {
    box-shadow: 0 0 0 2px rgba(79, 70, 229, .35);
}
.acc-user-av,
.acc-detail-av {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.acc-user.is-admin .acc-user-av {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
}
.acc-user-text { min-width: 0; flex: 1; }
.acc-user-text strong {
    display: block;
    font-size: .88rem;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.acc-user-meta {
    display: block;
    margin-top: 2px;
    font-size: .74rem;
    color: var(--muted);
}
.acc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    flex-shrink: 0;
}
.acc-detail {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.acc-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.acc-detail-who {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.acc-detail-who h3 { margin: 0; font-size: 1.05rem; }
.acc-detail-who p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.acc-detail-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    color: var(--text-soft);
}
.acc-detail-stats strong {
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.acc-admin-pill,
.acc-ro-pill {
    font-style: normal;
    font-size: .72rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
}
.acc-admin-pill { background: rgba(15, 118, 110, .12); color: #0f766e; }
.acc-ro-pill { background: var(--surface-2); color: var(--muted); }
.acc-detail-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 14px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface-2);
}
.acc-detail-tools .acc-group-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    border: 0;
    flex: 1 1 auto;
    overflow: auto;
}
.acc-view-search {
    flex: 0 1 220px;
    min-width: 0;
    margin: 0;
}
.acc-gtab {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-weight: 650;
    font-size: .8rem;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}
.acc-gtab.active {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    border-color: transparent;
    color: #fff;
}
.acc-admin-banner { margin: 12px 16px 0; }
.acc-detail-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 12px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.acc-empty-detail {
    margin: auto;
    padding: 32px 20px;
    text-align: center;
    max-width: 36ch;
}
.acc-empty-detail strong { display: block; margin-bottom: 6px; font-size: 1rem; }
.acc-empty-detail p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.acc-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.acc-block-head h3 {
    margin: 0;
    font-size: .72rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}
.acc-block-head span {
    font-size: .74rem;
    font-weight: 800;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.acc-mod-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.acc-mod {
    display: grid;
    grid-template-columns: minmax(140px, 1.1fr) auto minmax(160px, .9fr);
    gap: 10px 14px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}
.acc-mod.has-access {
    border-color: rgba(15, 118, 110, .28);
    background: linear-gradient(180deg, rgba(20, 184, 166, .06), var(--surface));
}
.acc-mod-name {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
    min-width: 0;
}
.acc-mod-name:disabled { cursor: default; }
.acc-mod-name strong {
    display: block;
    font-size: .92rem;
    line-height: 1.25;
}
.acc-mod-name span {
    display: block;
    margin-top: 2px;
    font-size: .72rem;
    color: var(--muted);
}
.acc-mod-name:not(:disabled):hover strong { color: var(--brand); text-decoration: underline; }
.acc-mod-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.acc-flag {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
}
.acc-flag:disabled { cursor: default; opacity: .7; }
.acc-flag-na {
    opacity: .35;
    cursor: default;
}
.acc-flag.is-on { color: #fff; border-color: transparent; }
.acc-flag-v.is-on { background: #0f766e; }
.acc-flag-c.is-on { background: #1d4ed8; }
.acc-flag-e.is-on { background: #b45309; }
.acc-flag-d.is-on { background: #b91c1c; }
.acc-mod-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
}
.acc-sum {
    font-size: .68rem;
    font-weight: 750;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: .02em;
}
.acc-sum.on { background: rgba(15, 118, 110, .12); color: #0f766e; }
.acc-sum.off { background: var(--surface-2); color: var(--muted); }
.acc-modal-card .modal-foot {
    padding: 12px 22px 16px;
    border-top: 1px solid var(--border);
    margin: 0;
    flex-shrink: 0;
}
@media (max-width: 900px) {
    .acc-layout { grid-template-columns: 1fr; grid-template-rows: minmax(160px, 34%) minmax(0, 1fr); }
    .acc-rail-wrap { border-right: 0; border-bottom: 1px solid var(--border); }
    .acc-leg-note { margin-left: 0; width: 100%; }
    .acc-mod {
        grid-template-columns: 1fr;
        align-items: start;
    }
    .acc-mod-summary { justify-content: flex-start; }
}
@media (max-width: 720px) {
    .acc-modal-card {
        width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
        margin: 0; border-radius: 0;
    }
    .acc-modal-card .modal-foot .btn { min-height: 44px; }
    .acc-flag { width: 40px; height: 40px; }
}
.perm-na { color: var(--muted); font-size: .85rem; }
.perm-modal-card .modal-body { overflow: auto; }
.perm-modal-sub { margin: 4px 0 0; font-size: .84rem; color: var(--muted); font-weight: 500; }
.perm-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: .8rem; color: var(--text-soft); }
.perm-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.perm-legend .dot.inherit { background: var(--muted); }
.perm-legend .dot.custom { background: var(--brand); }
.perm-src {
    display: inline-block; font-size: .7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
    white-space: nowrap;
}
.perm-src.inherit { background: var(--surface-2); color: var(--muted); }
.perm-src.custom { background: rgba(79,70,229,.12); color: var(--brand); }
.u-custom-tag {
    display: inline-block; margin-left: 6px; font-size: .68rem; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; background: rgba(79,70,229,.12); color: var(--brand);
    vertical-align: middle;
}
.u-custom-tag.muted {
    background: var(--surface-2); color: var(--muted); font-weight: 600;
}
#permModalFoot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.u-hist-modal { width: min(760px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.u-hist-modal .modal-body { min-height: 0; }
.u-hist-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--surface);
    margin-bottom: 12px;
}
.u-hist-item:last-child { margin-bottom: 0; }
.u-hist-item header {
    display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
    margin-bottom: 10px;
}
.u-hist-item header p { margin: 2px 0 0; font-size: .8rem; color: var(--muted); }
.u-hist-auth {
    display: inline-block;
    font-size: .72rem; font-weight: 800; letter-spacing: .04em;
    text-transform: uppercase;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(79,70,229,.12); color: var(--brand-dark);
    white-space: nowrap;
}
.u-hist-change {
    border-top: 1px dashed var(--border);
    padding: 8px 0 2px;
}
.u-hist-kind {
    display: inline-block;
    font-size: .68rem; font-weight: 800; letter-spacing: .05em;
    text-transform: uppercase;
    margin-right: 8px; color: var(--brand-dark);
}
.u-hist-added .u-hist-kind { color: #166534; }
.u-hist-removed .u-hist-kind { color: #991b1b; }
.u-hist-change ul { margin: 6px 0 0; padding-left: 18px; font-size: .86rem; color: var(--text-soft); }
.u-hist-sum { margin: 0; font-size: .86rem; color: var(--text-soft); white-space: pre-wrap; }

/* ---------------- Profile ---------------- */
.profile-layout { grid-template-columns: 1fr 1.2fr; }
.profile-avatar { width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-size: 1.8rem; font-weight: 800; display: grid; place-items: center; margin-bottom: 18px; }
.profile-dl { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.profile-dl > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--border); padding-bottom: 10px; }
.profile-dl dt { color: var(--muted); font-size: .84rem; margin: 0; }
.profile-dl dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.page-btn { padding: 8px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; font-size: .85rem; transition: var(--tr); }
.page-btn:hover { border-color: var(--brand); }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------------- Auth screens ---------------- */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); }
.auth-body.single { grid-template-columns: 1fr; place-items: center; }
.auth-hero { background: linear-gradient(150deg, #1e1b4b 0%, #4338ca 100%); color: #fff; display: flex; align-items: center; justify-content: center; padding: 40px; position: relative; overflow: hidden; }
.auth-hero::before { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(99,102,241,.35), transparent 70%); top: -120px; right: -120px; }
.auth-hero::after { content: ''; position: absolute; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(79,70,229,.35), transparent 70%); bottom: -120px; left: -100px; }
.auth-hero-inner { position: relative; max-width: 400px; animation: fadeUp .6s ease; }
.auth-hero-inner h2 { font-size: 1.9rem; margin: 18px 0 12px; }
.auth-hero-inner p { color: #cbd5e1; line-height: 1.7; }
.hero-points { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 12px; }
.hero-points li { display: flex; align-items: center; gap: 10px; color: #e2e8f0; font-size: .92rem; }
.hero-points li::before { content: '✓'; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: .8rem; flex-shrink: 0; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-panel.wide { min-height: 100vh; width: 100%; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); padding: 36px; border-radius: 20px; box-shadow: var(--shadow-lg); }
.auth-card.security-card { max-width: 520px; }
.sec-steps {
    list-style: none;
    display: flex;
    gap: 8px;
    padding: 0;
    margin: 14px 0 4px;
}
.sec-steps li {
    flex: 1;
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    padding: 6px 4px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    border: 1px solid var(--border);
}
.sec-steps li.is-now { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }
.sec-steps li.is-done { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.sec-remain { margin: 0 0 12px; font-size: .8rem; }
.sec-mail-now { font-size: .9rem; margin: 0 0 12px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-logo { margin: 0 auto 14px; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-links { text-align: center; margin-top: 18px; font-size: .88rem; }
.install-log { font-size: .88rem; color: var(--text-soft); }
.install-creds { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin: 16px 0; font-size: .9rem; }
.install-creds code { background: #0f172a; color: #7dd3fc; padding: 2px 8px; border-radius: 6px; }

/* ---------------- Animations ---------------- */
.animate-in { animation: fadeUp .5s ease both; }
.animate-in[style*="--i:1"] { animation-delay: .06s; }
.animate-in[style*="--i:2"] { animation-delay: .12s; }
.animate-in[style*="--i:3"] { animation-delay: .18s; }
.animate-pop { animation: pop .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-grid, .roles-layout, .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .auth-body { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; max-width: 100%; overflow-x: hidden; }
    .menu-toggle { display: grid; }
    .content { padding: 18px 14px; max-width: 100%; overflow-x: hidden; }
    .content.content-map { padding: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .user-meta { display: none; }
    .stat-grid { grid-template-columns: 1fr; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 39; }
    .topbar { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); min-width: 0; }
    .page-title h1 { font-size: 1.02rem; }
    .field input, .field select, .field textarea { font-size: 16px; }
    .toast-wrap { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
    .toast { min-width: 0; width: 100%; }
    .search, .field.compact, .hrs-search-field, .hrs-fee-search { min-width: 0 !important; }
    .toolbar, .hrs-filters, .hrs-fee-bar-tools, .hrs-head-wrap { max-width: 100%; }
    .bar-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 40px; }
    .notify-panel { width: min(380px, calc(100vw - 16px)); right: -8px; }
}
@media (max-width: 480px) {
    .stat-card { padding: 16px; }
    .stat-num { font-size: 1.5rem; }
}

/* ---------------- Modo oscuro automático (según el sistema) ---------------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:        #0b1020;
        --surface:   #151b30;
        --surface-2: #1b2340;
        --text:      #e6e9f2;
        --text-soft: #b6c0d4;
        --muted:     #8792a8;
        --border:    #29314e;
        --shadow:    0 1px 3px rgba(0,0,0,.45), 0 8px 24px -12px rgba(0,0,0,.6);
        --shadow-lg: 0 20px 60px -20px rgba(0,0,0,.75);
        --hc-ink:    #c7d2fe;
    }
    .topbar { backdrop-filter: none; }
    .btn-ghost:hover { background: #232c48; }
    .table th { background: #12182b; }
    .search input,
    .field input, .field select, .field textarea { background: #12182b; color: var(--text); }
    .field input::placeholder, .search input::placeholder { color: #6b7592; }
    .info-banner { background: rgba(79,70,229,.14); border-color: rgba(79,70,229,.4); color: #c7d2fe; }
    .role-item:hover, .user-chip:hover { background: #1b2340; }
    .page-btn { background: var(--surface); }
    .install-creds { background: #12182b; }
    .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
    .leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
    /* Controles Leaflet en modo oscuro */
    .leaflet-bar a, .leaflet-control-layers { background: var(--surface); color: var(--text); border-color: var(--border); }
    .leaflet-bar a { border-bottom-color: var(--border); }
    .leaflet-bar a:hover { background: var(--surface-2); }
    .leaflet-control-layers-toggle { filter: invert(.9) hue-rotate(180deg); }
    .leaflet-control-attribution { background: rgba(21,27,48,.8) !important; color: var(--muted) !important; }
    .leaflet-control-attribution a { color: var(--text-soft) !important; }
    .mapx-search input, .mapx-select, .filter-select { background: #12182b; }
    .info-banner.subtle { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.4); color: #fcd34d; }
    .hc-delete-policy {
        background: rgba(79,70,229,.18);
        border-color: rgba(165,180,252,.35);
        color: #c7d2fe;
    }
    .hc-page .card,
    .hc-sheet,
    .hc-phe-kpi,
    .hc-lab-card,
    .hc-visit-card,
    .hc-ficha-modal,
    .hc-lab-view-modal,
    .hc-edit-block {
        background: var(--surface);
        color: var(--text);
    }
    /* Chips de estado (flash/badges) mantienen fondo claro y texto oscuro: siguen legibles */
}

/* ============================================================
   Historial / trazabilidad del paciente
   ============================================================ */
.trace-meta { display: grid; gap: 8px; margin-bottom: 4px; }
.trace-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; font-size: .9rem; }
.trace-k { color: var(--muted); font-weight: 600; }
.trace-v { color: var(--text); text-align: right; }

.timeline { list-style: none; margin: 10px 0 0; padding: 0 0 0 6px; }
.timeline .empty { color: var(--muted); padding: 14px 0; }
.tl-item { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--border); }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 2px; }
.tl-item::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--surface); }
.tl-item.tl-create::before { background: #16a34a; }
.tl-item.tl-update::before { background: #4f46e5; }
.tl-item.tl-delete::before { background: #dc2626; }
.tl-item.tl-view::before { background: #0ea5e9; }
.tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-tag { font-weight: 700; font-size: .82rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.tl-when { font-size: .8rem; color: var(--muted); }
.tl-user { font-size: .86rem; color: var(--text-soft); margin-top: 3px; font-weight: 600; }
.tl-detail { font-size: .86rem; color: var(--text-soft); margin-top: 4px; line-height: 1.5; word-break: break-word; }

/* Campo de solo lectura (edad automática) */
.field input[readonly] { background: var(--surface-2); color: var(--text-soft); cursor: default; }

/* ============================================================
   Pacientes — tabla profesional + ficha
   ============================================================ */
.toolbar select {
    padding: 11px 16px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); font-family: inherit; font-size: .9rem; color: var(--text); cursor: pointer;
}
.toolbar select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

.pt-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pt-id { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.pt-av { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 700; font-size: .85rem; display: grid; place-items: center; flex-shrink: 0; }
.pt-name { display: block; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.pt-sub { display: block; color: var(--muted); font-size: .78rem; margin-top: 0; }
.pt-meta { display: none; }
.pt-btn-short { display: none; }
.table tbody tr.clickable { cursor: pointer; }
.pt-chevron { color: var(--muted); display: inline-grid; }
.table tbody tr.clickable:hover .pt-chevron { color: var(--brand); transform: translateX(2px); transition: var(--tr); }

/* ---- Pacientes / Usuarios / Horas / Catálogo: el documento se desplaza en vertical ---- */
body.pt-app,
body.us-app,
body.hrs-app,
body.hrs-team-app,
body.food-app {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}
body.pt-app .app-shell,
body.us-app .app-shell,
body.hrs-app .app-shell,
body.hrs-team-app .app-shell,
body.food-app .app-shell {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}
body.pt-app .main,
body.us-app .main,
body.hrs-app .main,
body.hrs-team-app .main,
body.food-app .main {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}
body.pt-app .app-credit,
body.us-app .app-credit,
body.hrs-app .app-credit,
body.hrs-team-app .app-credit,
body.food-app .app-credit { display: none; }
.main .content.content-pt,
.main .content.content-us,
.main .content.content-food { flex: 0 0 auto; }
.content.content-pt,
.content.content-us,
.content.content-food {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 12px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
}
.content.content-pt .flash-stack,
.content.content-us .flash-stack,
.content.content-food .flash-stack { flex-shrink: 0; }
body.pt-app .content.content-pt,
body.food-app .content.content-food {
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.pt-page {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}
.pt-bar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.pt-bar-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
    width: 100%;
}
.pt-bar-title h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; }
.pt-bar-title p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; font-weight: 600; }
.pt-bar-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    flex: 1 1 420px;
    min-width: 0;
}
.pt-bar-tools .field.compact { min-width: 120px; flex: 0 1 160px; }
.pt-search { flex: 1 1 220px !important; min-width: 0 !important; }
.pt-bar-tools .btn { min-height: 40px; white-space: nowrap; flex-shrink: 0; width: max-content; }
.pt-export-last,
.pt-bar .ficha-export-last {
    width: 100%;
    max-width: 100%;
    margin: 0;
    color: var(--muted);
    text-align: left;
    font-size: .72rem;
    line-height: 1.4;
    font-weight: 600;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.pt-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    margin: 0;
}
.pt-kpi {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    padding: 8px 12px;
    min-width: 0;
    text-align: left;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.pt-kpi[aria-hidden="true"] { cursor: default; }
.pt-kpi span {
    display: block; font-size: .68rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.pt-kpi strong {
    display: block; margin-top: 2px; font-size: clamp(.95rem, 1.6vw, 1.2rem);
    letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.pt-kpi.active {
    border-color: var(--brand);
    background: rgba(79,70,229,.08);
}
.pt-kpi.active span, .pt-kpi.active strong { color: var(--brand); }
.pt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-chip {
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-soft); font: inherit; font-weight: 600; font-size: .8rem;
    min-height: 34px; padding: 0 12px; border-radius: 999px; cursor: pointer;
}
.pt-chip.active {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    border-color: transparent; color: #fff;
}
.pt-board {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
}
.pt-sheet {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}
.pt-sheet-head,
.pt-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, .55fr) minmax(0, 1.05fr) minmax(0, .7fr) minmax(0, 1.15fr) 36px;
    gap: 8px 14px;
    align-items: center;
    width: 100%;
}
.pt-sheet-head {
    flex-shrink: 0;
    position: sticky; top: 0; z-index: 2;
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted);
}
.pt-sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
.pt-row {
    padding: 11px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    min-height: 68px;
}
.pt-row:hover, .pt-row:focus-visible { background: var(--surface-2); outline: none; }
.pt-td-who { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.pt-td-who .pt-av { margin-top: 2px; }
.pt-td-age, .pt-td-place, .pt-td-phone, .pt-td-mod { min-width: 0; }
.pt-td-age strong, .pt-td-place strong { display: block; font-size: .9rem; }
.pt-td-age span, .pt-td-place span { display: block; font-size: .75rem; color: var(--muted); margin-top: 1px; }
.pt-td-mod {
    font-variant-numeric: tabular-nums;
    font-size: .84rem;
    color: var(--text-soft);
    line-height: 1.3;
}
.pt-td-mod time { display: block; white-space: nowrap; }
.pt-td-mod-who {
    display: block;
    margin-top: 3px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}
.pt-td-mod-view {
    display: inline-flex;
    margin-top: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    color: var(--brand);
    background: rgba(79,70,229,.08);
}
.pt-phone { color: inherit; font-weight: 600; text-decoration: none; }
.pt-phone:hover { color: var(--brand); text-decoration: underline; }
.pt-mute { color: var(--muted); }
.pt-pill {
    display: inline-flex; align-items: center; gap: 3px;
    margin-top: 4px; min-height: 20px; padding: 0 7px;
    border-radius: 999px; font-size: .68rem; font-weight: 700; font-style: normal;
    background: var(--surface-2); color: var(--text-soft);
}
.pt-pill.ok { background: rgba(16,185,129,.12); color: #047857; }
.pt-pill.warn { background: rgba(245,158,11,.14); color: #b45309; }
.pt-pill.mute { background: var(--surface-2); color: var(--muted); }
.pt-td-go { display: grid; place-items: center; color: var(--muted); }
.pt-row:hover .pt-td-go { color: var(--brand); transform: translateX(2px); }
.pt-empty {
    display: grid; place-items: center; text-align: center;
    min-height: 180px; padding: 32px 16px; color: var(--text-soft);
}
.pt-empty p { margin: 0; font-weight: 700; color: var(--text); }
.pt-empty span { display: block; margin-top: 6px; font-size: .86rem; }

/* ---- Usuarios a pantalla completa (web app) ---- */
.us-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    height: 100%;
}
.us-lead {
    flex-shrink: 0;
    margin: 0;
    font-size: .88rem;
    color: var(--text-soft);
    line-height: 1.45;
}
.us-pw-lead {
    flex-shrink: 0;
    margin: 0;
    font-size: .82rem;
    color: var(--text-soft);
    line-height: 1.4;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}
.us-kpis {
    flex-shrink: 0;
    margin-bottom: 0;
    gap: 10px;
    width: 100%;
}
body.us-app .us-kpis.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.us-toolbar {
    flex-shrink: 0;
    margin-bottom: 0;
    width: 100%;
    align-items: stretch;
}
.us-toolbar .search { min-width: 0; }
.us-toolbar .search input { min-height: 44px; }
.us-toolbar-actions {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: wrap;
}
.us-toolbar-actions .filter-select {
    min-height: 44px;
    min-width: 0;
    flex: 1 1 140px;
}
.us-toolbar-actions .btn {
    min-height: 44px;
    flex: 0 0 auto;
    gap: 8px;
}
.us-btn-short { display: none; }
.us-meta { display: none; }
.us-list-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
}
.us-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
.us-page .table { min-width: 0; }
.us-page .table th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2);
}
.us-page .table td, .us-page .table th { vertical-align: middle; }
.us-page .row-actions { flex-wrap: wrap; }
.us-page .tact { width: 40px; height: 40px; }
.us-pro-id {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.us-pro-id h3 { font-size: .95rem; }
.us-pro-id-sub { margin: 0; font-size: .84rem; color: var(--text-soft); overflow-wrap: anywhere; }
body.us-app #userModal .modal-card {
    max-width: 680px;
    max-height: 92dvh;
}
body.us-app .perm-modal-card.us-sheet-lg {
    width: min(1080px, calc(100% - 24px));
    max-height: 96dvh;
    margin: 2dvh auto;
}
body.us-app #userModal.open,
body.us-app #roleModal.open,
body.us-app #permModal.open,
body.us-app #userHistModal.open {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

@media (max-width: 1100px) {
    body.us-app .us-kpis.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .us-page .stat-card { padding: 12px 14px; gap: 10px; }
    .us-page .stat-ic { width: 40px; height: 40px; border-radius: 12px; }
    .us-page .stat-ic svg { width: 20px; height: 20px; }
    .us-page .stat-num { font-size: 1.35rem; }
}
@media (max-width: 860px) {
    .us-toolbar { flex-wrap: wrap; }
    .us-toolbar .search { flex: 1 1 100%; }
    .us-toolbar-actions { flex: 1 1 100%; }
    body.us-app .us-kpis.stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .us-sheet-head { flex-wrap: wrap; }
    .us-sheet-tools { flex: 1 1 100%; }
}
@media (max-width: 720px) {
    .content.content-flush.content-us {
        padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }
    .us-lead { display: none; }
    .us-page .stat-ic { display: none; }
    .us-page .stat-card { padding: 10px 12px; }
    .us-page .stat-num { font-size: 1.2rem; }
    .us-page .stat-label { font-size: .72rem; }
    .us-btn-full { display: none; }
    .us-btn-short { display: inline; }
    .us-page .table thead { display: none; }
    .us-page .table tbody tr.us-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px 14px;
        border-bottom: 1px solid var(--border);
    }
    .us-page .table tbody tr.us-row td { border: 0; padding: 0; }
    .us-td-email, .us-td-role, .us-td-status, .us-td-date { display: none; }
    .us-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 10px;
        margin-top: 6px;
        font-size: .78rem;
        color: var(--text-soft);
        line-height: 1.35;
    }
    .us-meta .badge, .us-meta .u-custom-tag { margin-left: 0; }
    .us-meta .us-role-cell, .us-meta .us-status-cell, .us-meta .us-email-cell { gap: 3px; }
    .us-meta .us-status-login, .us-meta .us-email-verified { white-space: normal; }
    .us-td-acts .row-actions { justify-content: flex-start; }
    .us-page .tact { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .us-page .u-av { width: 44px; height: 44px; border-radius: 12px; }
    .us-toolbar-actions .filter-select,
    .us-toolbar .search input,
    .us-toolbar-actions .btn,
    body.us-app .modal input,
    body.us-app .modal select {
        font-size: 16px;
    }
    body.us-app .perm-modal-card.us-sheet-lg,
    body.us-app #userModal .modal-card,
    body.us-app #roleModal .modal-card,
    body.us-app .u-hist-modal {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
    }
    body.us-app .modal-foot .btn,
    #accessModal .modal-foot .btn { min-height: 44px; }
    .us-sheet-titles h2 { font-size: 1.02rem; }
    .us-sheet-head .perm-modal-sub { display: none; }
    body.us-app .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1180px) {
    .pt-sheet-head, .pt-row {
        grid-template-columns: minmax(0, 1.4fr) minmax(0, .5fr) minmax(0, 1fr) minmax(0, .9fr) 36px;
    }
    .pt-td-phone, .pt-sheet-head span:nth-child(4) { display: none; }
}
@media (max-width: 1100px) {
    .pt-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
    .pt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pt-sheet-head { display: none; }
    .pt-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "who go"
            "age go"
            "place go"
            "phone go"
            "mod go";
        align-items: start;
        gap: 6px 10px;
        padding: 12px 14px;
        min-height: 0;
    }
    .pt-td-who { grid-area: who; }
    .pt-td-age { grid-area: age; }
    .pt-td-place { grid-area: place; }
    .pt-td-phone { grid-area: phone; display: grid; }
    .pt-td-mod { grid-area: mod; }
    .pt-td-go { grid-area: go; align-self: center; }
    .pt-td-age, .pt-td-place, .pt-td-phone, .pt-td-mod {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 2px 10px;
        align-items: start;
    }
    .pt-td-age > *, .pt-td-place > *, .pt-td-phone > *, .pt-td-mod > * { grid-column: 2; }
    .pt-td-age::before, .pt-td-place::before, .pt-td-phone::before, .pt-td-mod::before {
        content: attr(data-col);
        grid-column: 1;
        grid-row: 1 / span 6;
        align-self: center;
        font-size: .68rem;
        font-weight: 700;
        letter-spacing: .03em;
        text-transform: uppercase;
        color: var(--muted);
    }
}
@media (max-width: 720px) {
    body.pt-app .content.content-flush.content-pt {
        padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    }
    .pt-bar { padding: 10px 12px; border-radius: 14px; }
    .pt-sheet { border-radius: 14px; }
    .pt-btn-full { display: none; }
    .pt-btn-short { display: inline; }
    .pt-chips { display: none; }
    .pt-av { width: 44px; height: 44px; border-radius: 12px; }
    .pt-bar-tools .field.compact,
    .pt-search,
    .pt-bar-tools .btn,
    #fichaModal input, #fichaModal select, #fichaModal textarea {
        font-size: 16px;
    }
    .ficha-card {
        width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
        margin: 0; border-radius: 0; overflow: auto;
    }
    .ficha-hero {
        padding: 16px 48px 16px max(16px, env(safe-area-inset-left));
        align-items: flex-start;
    }
    .ficha-hero-main h2 { font-size: 1.12rem; overflow-wrap: anywhere; }
    .ficha-body {
        grid-template-columns: 1fr;
        padding: 16px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        gap: 18px;
    }
    .ficha-edit-head { padding: 18px 48px 0 max(16px, env(safe-area-inset-left)); }
    #fichaEdit { padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
    #fichaEdit .modal-foot {
        position: sticky; bottom: 0; z-index: 2;
        background: var(--surface);
        padding: 12px 0 max(12px, env(safe-area-inset-bottom));
        margin: 0; border-top: 1px solid var(--border);
    }
    #fichaEdit .modal-foot .btn { flex: 1; min-height: 44px; }
    .ficha-dl > div { flex-direction: column; align-items: flex-start; gap: 2px; }
    .ficha-dl dd { text-align: left; }
    .ficha-map, #editMap { height: 200px; }
}

/* ---- Ficha ---- */
.ficha-card { max-width: 900px; display: block; overflow-y: auto; max-height: 92vh; }
.ficha-close { position: absolute; top: 16px; right: 16px; z-index: 4; background: var(--surface-2); }

.ficha-hero {
    display: flex; align-items: center; gap: 18px; padding: 26px 56px 26px 30px;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 3;
    background: var(--surface);
}
.ficha-hero::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(135deg, rgba(79,70,229,.10), transparent 55%);
}
.ficha-avatar { position: relative; width: 66px; height: 66px; border-radius: 18px; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 800; font-size: 1.5rem; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 12px 26px -12px var(--brand); }
.ficha-hero-main { flex: 1; min-width: 0; position: relative; }
.ficha-hero-main h2 { font-size: 1.35rem; letter-spacing: -.01em; }
.ficha-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }
.chip svg { opacity: .8; }
.chip-geo-yes { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.chip-geo-no { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.ficha-hero-actions { display: flex; gap: 8px; flex-shrink: 0; position: relative; }

.ficha-body { padding: 24px 30px 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px 28px; }
.ficha-section h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.ficha-section--full { grid-column: 1 / -1; }
.ficha-dl { display: flex; flex-direction: column; margin: 0; }
.ficha-dl > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.ficha-dl > div:last-child { border-bottom: none; }
.ficha-dl dt { color: var(--muted); font-size: .85rem; }
.ficha-dl dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }
.ficha-dl dd a { color: var(--brand); font-weight: 600; }
.ficha-map { margin-top: 14px; height: 190px; }

.ficha-edit-head { padding: 24px 56px 0 30px; position: relative; }
.ficha-edit-head h2 { font-size: 1.25rem; }
.ficha-edit-head .ficha-close { top: 20px; }
#fichaEdit { padding: 0 30px 26px; gap: 14px; }
#fichaEdit .section-title:first-of-type { margin-top: 10px; }

@media (max-width: 720px) {
    .ficha-body { grid-template-columns: 1fr; }
    .ficha-hero { flex-wrap: wrap; }
    .ficha-hero-actions { width: 100%; }
    .ficha-hero-actions .btn { flex: 1; }
}

/* ============================================================
   LOGIN — pantalla completa del viewport (ancho y alto), sin scroll
   horizontal. El split llena el recuadro; si el contenido no entra
   (teclado iOS, pantalla baja) se desplaza solo en vertical.
   Compat: 100vh primero, luego 100dvh. overflow-x en body, no en html
   global, para no afectar el resto del sistema.
   ============================================================ */
.login {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    font-family: var(--font);
    color: #e8eaf3;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    background: radial-gradient(140% 120% at 50% 0%, #131a30 0%, #0a0e1a 55%, #070a14 100%);
}

/* Aurora: resplandores suaves (radial-gradient ya difuminado, SIN filter).
   Se mueven solo con translate3d -> compositan en GPU, sin repaint. */
.aurora { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora .glow {
    position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%;
    opacity: .45; will-change: transform; transform: translateZ(0);
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.aurora .g1 { top: -24vmax; left: -18vmax; background: radial-gradient(circle at center, rgba(99,102,241,.85), rgba(99,102,241,0) 60%); animation: drift1 26s ease-in-out infinite; }
.aurora .g2 { bottom: -26vmax; right: -16vmax; background: radial-gradient(circle at center, rgba(56,189,248,.6), rgba(56,189,248,0) 60%); animation: drift2 32s ease-in-out infinite; }
.aurora .g3 { top: 28%; left: 42%; width: 48vmax; height: 48vmax; opacity: .34; background: radial-gradient(circle at center, rgba(168,85,247,.55), rgba(168,85,247,0) 62%); animation: drift3 38s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(6vmax,4vmax,0); } }
@keyframes drift2 { 0%,100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(-5vmax,-4vmax,0); } }
@keyframes drift3 { 0%,100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(-4vmax,5vmax,0); } }

/* --- Tarjeta central --- */
.au-card {
    position: relative; z-index: 2; width: min(420px, 96vw);
    background: rgba(15,20,38,.92); border: 1px solid rgba(255,255,255,.09);
    border-radius: 22px; padding: 40px 34px 30px; text-align: center;
    box-shadow: 0 30px 80px -30px rgba(0,0,0,.75);
    animation: lgIn .45s ease both;
}
@keyframes lgIn { from { opacity: 0; transform: translateY(14px); } }
.au-card form { text-align: left; }

.au-logo { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; background: linear-gradient(135deg, #818cf8, #6366f1); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; letter-spacing: .5px; box-shadow: 0 12px 28px -8px #6366f1; }
.au-title { font-size: 1.5rem; margin: 20px 0 8px; letter-spacing: -.02em; }
.au-sub { color: #98a1c4; font-size: .94rem; margin: 0 0 28px; min-height: 1.3em; line-height: 1.45; transition: color .2s ease; }
.au-sub.greet { color: #c7d2fe; }
.au-sub.greet strong { color: #fff; font-weight: 700; }

.au-links { margin-top: 22px; text-align: center; }
.au-links a { color: #a5b4fc; font-size: .9rem; font-weight: 500; transition: color .18s; }
.au-links a:hover { color: #c7d2fe; }
.au-foot { margin-top: 22px; font-size: .76rem; color: #7d86a8; }
.au-watermark { margin-top: 8px; font-size: .68rem; letter-spacing: .3px; color: #7d86a8; opacity: .7; }

.au-flash { padding: 13px 16px; border-radius: 12px; font-size: .9rem; margin-bottom: 20px; border: 1px solid; text-align: left; line-height: 1.4; }
.au-flash.err { background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.42); color: #fecaca; }
.au-flash.ok { background: rgba(16,185,129,.14); border-color: rgba(16,185,129,.42); color: #bbf7d0; margin: 16px 0 0; }

.au-or { display: flex; align-items: center; gap: 14px; margin: 22px 0 14px; color: rgba(226,232,240,.5); font-size: .82rem; }
.au-or::before, .au-or::after { content: ''; flex: 1; height: 1px; background: rgba(226,232,240,.16); }

/* Campos flotantes: más altos y con aire entre etiqueta y valor */
.ifield { position: relative; margin-bottom: 18px; }
.ifield:last-of-type { margin-bottom: 6px; }
.ifield .ic { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #8b93ba; transition: color .18s; display: grid; }
.ifield input {
    width: 100%; height: 62px; padding: 26px 48px 10px 48px;
    border-radius: 14px; border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.05); color: #fff; font-family: inherit; font-size: 1rem;
    line-height: 1.25; transition: border-color .18s, box-shadow .18s;
}
.ifield input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 4px rgba(99,102,241,.22); }
.ifield input:focus ~ .ic { color: #a5b4fc; }
.ifield label {
    position: absolute; left: 48px; top: 50%; transform: translateY(-50%);
    color: #98a1c4; font-size: 1rem; pointer-events: none;
    transition: top .16s ease, font-size .16s ease, color .16s ease, transform .16s ease;
    transform-origin: left center; line-height: 1;
}
.ifield input:focus + label,
.ifield input:not(:placeholder-shown) + label {
    top: 11px; transform: none; font-size: .72rem; letter-spacing: .03em;
    color: #a5b4fc; font-weight: 600;
}
.ifield .pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: #8b93ba; padding: 8px; border-radius: 8px; }
.ifield .pw-toggle:hover { color: #c7d2fe; background: rgba(255,255,255,.06); }

.lg-remember {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 8px 0 16px;
    min-height: 44px;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.35;
}
.lg-remember input {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #6366f1;
}
.lg-remember small {
    display: block;
    font-weight: 500;
    color: rgba(226,232,240,.55);
    font-size: 0.75rem;
}

.lg-btn {
    width: 100%; height: 54px; margin-top: 14px; border: none; border-radius: 13px; cursor: pointer;
    font-family: inherit; font-weight: 700; font-size: 1rem; color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 12px 28px -10px #4f46e5;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: transform .12s ease, box-shadow .18s ease; position: relative; overflow: hidden;
}
.lg-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 34px -12px #4f46e5; }
.lg-btn:active { transform: translateY(0); }
.lg-btn .arw { transition: transform .18s ease; display: grid; }
.lg-btn:hover .arw { transform: translateX(3px); }
.lg-btn.loading { pointer-events: none; color: transparent; }
.lg-btn.loading .arw { opacity: 0; }
.lg-btn.loading::after {
    content: ''; position: absolute; width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Botón secundario (passkey) */
.lg-btn.ghost {
    background: rgba(255,255,255,.06); color: #e2e8f0; border: 1px solid rgba(226,232,240,.22);
    box-shadow: none; margin-top: 0;
}
.lg-btn.ghost:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); box-shadow: 0 10px 24px -14px #000; }
.lg-btn.ghost.loading::after { border-color: rgba(226,232,240,.35); border-top-color: #e2e8f0; }

/* --- Layout partido (split) adaptable: ocupa todo el alto/ancho del login --- */
.lg-split {
    position: relative; z-index: 2;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    background: rgba(15,20,38,.92);
    border: 0;
    border-radius: 0;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: none;
    animation: lgIn .45s ease both;
}

/* Panel institucional (izquierda) */
.lg-brand {
    position: relative; overflow: hidden; color: #fff;
    display: flex; flex-direction: column; justify-content: space-between;
    gap: clamp(20px, 3vw, 34px);
    padding: clamp(28px, 3.6vw, 48px);
    background: linear-gradient(150deg, #4338ca 0%, #4f46e5 52%, #6366f1 100%);
}
.lg-brand-orb {
    position: absolute; width: 60%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
    top: -18%; right: -20%;
    background: radial-gradient(circle at center, rgba(255,255,255,.28), transparent 62%);
}
.lg-brand-top { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; }
.lg-brand-top .au-logo,
.lg-mini-brand .au-logo { margin: 0; flex-shrink: 0; }
.lg-brand-name { display: flex; flex-direction: column; line-height: 1.2; }
.lg-brand-name strong { font-size: 1.06rem; letter-spacing: -.01em; }
.lg-brand-name span { font-size: .78rem; color: rgba(255,255,255,.78); }
.lg-brand-mid { position: relative; z-index: 1; }
.lg-brand-mid h2 { font-size: clamp(1.35rem, 2.2vw, 1.9rem); line-height: 1.2; margin: 0 0 clamp(18px, 2.4vw, 26px); letter-spacing: -.02em; }
.lg-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.lg-features li { display: flex; align-items: flex-start; gap: 13px; }
.lg-feat-ic {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
    background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.18);
}
.lg-features strong { display: block; font-size: .92rem; }
.lg-features span { font-size: .8rem; color: rgba(255,255,255,.8); }
.lg-brand-foot { position: relative; z-index: 1; font-size: .68rem; letter-spacing: .3px; color: rgba(255,255,255,.6); display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.lg-form-card .au-watermark { display: none; text-align: center; overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }

/* Lado del formulario (derecha) */
.lg-form-side { display: flex; align-items: center; justify-content: center; padding: clamp(28px, 4vw, 48px); min-width: 0; overflow-x: hidden; }
.lg-form-card { width: min(380px, 100%); max-width: 100%; text-align: left; min-width: 0; }
.lg-form-card .au-title { font-size: clamp(1.4rem, 2.4vw, 1.65rem); margin: 0 0 8px; }
.lg-form-card .au-sub { margin: 0 0 26px; }
.lg-form-card .au-links,
.lg-form-card .au-foot { text-align: center; }

/* Marca compacta (solo visible al colapsar) */
.lg-mini-brand { display: none; align-items: center; gap: 12px; margin-bottom: 26px; }

@media (max-width: 860px) {
    .lg-brand { display: none; }
    /* Columna única a pantalla completa: sin caja angosta que deje franjas a los lados. */
    .lg-split { grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 100%; background: rgba(15,20,38,.94); }
    .lg-mini-brand { display: flex; min-width: 0; }
    .lg-form-side { padding: clamp(28px, 7vw, 40px); width: 100%; min-width: 0; }
    .lg-form-card { width: min(430px, 100%); }
    .lg-form-card .au-watermark { display: block; }
}
@media (max-width: 380px) {
    .lg-form-side { padding: 26px 20px; }
    .lg-mini-brand .lg-brand-name span { display: none; }
}

/* Pantallas muy bajas (móvil apaisado): compacta verticalmente */
@media (max-height: 640px) and (min-width: 861px) {
    .lg-features { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .aurora .glow, .lg-split { animation: none !important; }
}

/* ============================================================
   Dashboard institucional (/dashboard.php)
   ============================================================ */
.dsh-hero {
    position: relative; overflow: hidden;
    border-radius: 18px; margin-bottom: 20px;
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 45%, #6366f1 100%);
    color: #fff; box-shadow: 0 20px 50px -24px rgba(79,70,229,.7);
}
.dsh-hero-bg {
    position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background:
        radial-gradient(520px 300px at 88% -20%, rgba(255,255,255,.28), transparent 60%),
        radial-gradient(420px 320px at 10% 130%, rgba(255,255,255,.16), transparent 60%);
}
.dsh-hero-inner {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    gap: 28px; padding: 30px 32px; flex-wrap: wrap;
}
.dsh-hero-main { min-width: 0; flex: 1; }
.dsh-hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .76rem; font-weight: 600; letter-spacing: .3px;
    padding: 6px 12px; border-radius: 999px;
    background: rgba(255,255,255,.16); color: #eef2ff;
}
.dsh-hero-title { font-size: 2rem; margin: 14px 0 6px; letter-spacing: -.02em; }
.dsh-hero-sub { margin: 0; color: rgba(255,255,255,.9); font-size: .96rem; max-width: 56ch; }
.dsh-hero-sub strong { color: #fff; }
.dsh-hero-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.dsh-chip {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: .8rem; font-weight: 600; padding: 7px 13px; border-radius: 999px;
    background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.2);
}
.dsh-hero-actions {
    display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 10px;
    width: min(340px, 100%);
}
.dsh-qa {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: 12px; color: #fff;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
    font-weight: 600; font-size: .9rem; transition: var(--tr);
}
.dsh-qa:hover { background: rgba(255,255,255,.22); transform: translateY(-2px); }
.dsh-qa-ic { display: grid; place-items: center; opacity: .95; }
.dsh-qa-go { margin-left: auto; opacity: .8; }

/* KPIs */
.dsh-kpis {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px;
}
.dsh-kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow); padding: 20px;
    position: relative; overflow: hidden; transition: var(--tr);
}
.dsh-kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.dsh-kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dsh-kpi-ic { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; color: #fff; }
.dsh-kpi-trend {
    font-size: .74rem; font-weight: 700; padding: 4px 9px; border-radius: 999px;
    background: var(--surface-2); color: var(--text-soft);
}
.dsh-kpi-trend.up { background: rgba(22,163,74,.12); color: #15803d; }
.dsh-kpi-num { font-size: 2.1rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.dsh-kpi-label { color: var(--muted); font-size: .86rem; margin-top: 6px; }
.dsh-kpi-bar { height: 6px; border-radius: 999px; background: var(--surface-2); margin-top: 14px; overflow: hidden; }
.dsh-kpi-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #10b981, #059669); animation: growW .9s ease; }

/* Grid de paneles */
.dsh-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; margin-bottom: 20px; }
.dsh-panel { display: flex; flex-direction: column; }
.dsh-panel .card-head { align-items: flex-start; }
.dsh-panel-sub { display: block; color: var(--muted); font-size: .78rem; margin-top: 3px; font-weight: 500; }

/* Estado vacío */
.dsh-empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.dsh-empty svg { opacity: .4; margin-bottom: 8px; }
.dsh-empty p { margin: 6px 0 2px; font-weight: 600; color: var(--text-soft); }
.dsh-empty span { font-size: .85rem; }

/* Timeline de actividad */
.dsh-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dsh-tl-item {
    display: flex; align-items: center; gap: 13px;
    padding: 11px 0; border-bottom: 1px dashed var(--border);
}
.dsh-tl-item:last-child { border-bottom: 0; padding-bottom: 0; }
.dsh-tl-item:first-child { padding-top: 0; }
.dsh-tl-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.dsh-tl-ic.brand  { background: rgba(79,70,229,.12);  color: var(--brand); }
.dsh-tl-ic.ok     { background: rgba(22,163,74,.12);  color: #15803d; }
.dsh-tl-ic.warn   { background: rgba(245,158,11,.14); color: #b45309; }
.dsh-tl-ic.danger { background: rgba(239,68,68,.12);  color: #dc2626; }
.dsh-tl-ic.muted  { background: var(--surface-2);     color: var(--muted); }
.dsh-tl-body { min-width: 0; flex: 1; }
.dsh-tl-body strong { display: block; font-size: .9rem; }
.dsh-tl-meta { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dsh-tl-time { font-size: .74rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

/* Mapa */
.dsh-map-card { margin-bottom: 20px; }
.dsh-map { height: 360px; border-radius: var(--radius-sm); overflow: hidden; z-index: 1; }
.dsh-pin-wrap { background: none; border: 0; }
.dsh-pin {
    display: block; width: 16px; height: 16px; margin: 3px;
    background: var(--brand); border: 3px solid #fff; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg); box-shadow: 0 2px 8px rgba(15,23,42,.45);
}

/* Responsive dashboard */
@media (max-width: 1100px) {
    .dsh-kpis { grid-template-columns: repeat(2, 1fr); }
    .dsh-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .dsh-hero-inner { padding: 24px 22px; }
    .dsh-hero-title { font-size: 1.6rem; }
    .dsh-hero-actions { width: 100%; grid-template-columns: repeat(2, 1fr); }
    .dsh-map { height: 300px; }
}
@media (max-width: 460px) {
    .dsh-kpis { grid-template-columns: 1fr; }
    .dsh-hero-actions { grid-template-columns: 1fr; }
    .dsh-kpi-num { font-size: 1.8rem; }
}

.sec-ok-modal .modal-card { max-width: 520px; }
.sec-ok-modal .modal-head h2 { margin: 0; color: var(--success); font-size: 1.35rem; }
.sec-ok-lead { margin: 0 0 16px; color: var(--text); line-height: 1.55; font-size: .95rem; }
.sec-ok-dates {
    margin: 0 0 8px;
    padding: 12px 14px;
    list-style: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.sec-ok-dates li {
    font-size: .88rem;
    color: var(--text-soft);
    line-height: 1.45;
    padding: 6px 0;
}
.sec-ok-dates li + li { border-top: 1px solid var(--border); }
.sec-ok-modal .modal-foot { justify-content: center; margin-top: 12px; }
.sec-ok-modal .modal-foot .btn { min-width: 120px; }

@media (prefers-color-scheme: dark) {
    .dsh-kpi, .dsh-map-card, .dsh-panel { background: var(--surface); }
    .dsh-kpi-trend.up { background: rgba(34,197,94,.18); color: #4ade80; }
    .dsh-tl-ic.ok { color: #4ade80; }
    .dsh-tl-ic.warn { color: #fbbf24; }
    .dsh-tl-ic.danger { color: #f87171; }
}

/* ============================================================
   Horas trabajadas y equipo (pantalla completa)
   ============================================================ */
body:has(.content-hours) .app-credit { display: none; }
.main .content.content-hours { flex: 1 1 auto; }
.content.content-hours {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
}
.hrs-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow-x: hidden;
}
.hrs-tabs {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 6px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; width: 100%; max-width: 100%;
    overflow: hidden;
    flex-shrink: 0;
}
.hrs-tab {
    border: 0; background: transparent; color: var(--text-soft); font: inherit;
    font-weight: 600; font-size: .9rem; padding: 10px 16px; border-radius: 10px;
    cursor: pointer; transition: var(--tr); white-space: nowrap; flex: 1 1 auto;
    min-height: 44px;
}
.hrs-tab:hover { background: var(--surface-2); color: var(--text); }
.hrs-tab.active { background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; box-shadow: 0 8px 20px -10px var(--brand); }
.hrs-panel[hidden] { display: none !important; }
.hrs-panel { min-width: 0; }
.hrs-panel-fill.active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
}
.hrs-workspace {
    display: flex; flex-direction: column; gap: 12px;
    flex: 1 1 auto; min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
}
.hrs-fill-card {
    flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
}
.hrs-fill-card .card-body,
.hrs-team-body {
    flex: 1 1 auto; min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.hrs-day-hero, .hrs-liq-hero {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; padding: 18px 20px; flex-shrink: 0;
    border-radius: 16px; color: #fff;
    background: linear-gradient(135deg, #4338ca, #6366f1);
    box-shadow: 0 18px 40px -22px rgba(79,70,229,.65);
}
.hrs-liq-hero { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.hrs-team-hero {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; padding: 18px 20px; flex-shrink: 0;
    border-radius: 16px; color: #fff;
    background: linear-gradient(135deg, #0b3d4a, #1a6a7c);
    box-shadow: 0 18px 40px -22px rgba(11, 61, 74, .7);
}
.hrs-fee-hero {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; padding: 18px 20px; flex-shrink: 0;
    border-radius: 16px; color: #fff;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    box-shadow: 0 18px 40px -22px rgba(15, 118, 110, .65);
}
.hrs-team-hero .hrs-day-title, .hrs-fee-hero .hrs-day-title { margin: 8px 0 6px; }
.hrs-team-hero .hrs-day-sub, .hrs-fee-hero .hrs-day-sub { margin: 0; opacity: .92; max-width: 62ch; }
.hrs-team-hero-side {
    text-align: right; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
    border-radius: 14px; padding: 14px 16px; min-width: 220px;
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.hrs-team-hero-side strong { font-size: 1.15rem; letter-spacing: -.02em; }
.hrs-team-hero-side .btn { width: 100%; justify-content: center; }
.hrs-search-field { min-width: 0; flex: 1 1 180px; }
.hrs-staff-wrap {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    max-width: 100%;
}
.hrs-staff { width: 100%; border-collapse: collapse; }
.hrs-staff th {
    text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.hrs-staff td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.hrs-staff-row:hover td { background: var(--surface-2); }
.hrs-staff-row.open td { background: rgba(11, 61, 74, .06); }
.hrs-staff-row.is-zero td { color: var(--muted); }
.hrs-staff-row td strong { display: block; font-size: .95rem; color: var(--text); }
.hrs-staff-meta { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; }
.hrs-staff .hrs-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hrs-staff-exp { width: 48px; padding-right: 0 !important; }
.hrs-staff-act { width: 72px; text-align: right; }
.hrs-staff-detail td {
    padding: 4px 14px 16px 58px; background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.hrs-staff-detail h3 { font-size: .95rem; margin: 10px 0 4px; }
.hrs-staff-detail[hidden] { display: none !important; }
.hrs-eyebrow { display: inline-block; font-size: .75rem; font-weight: 600; opacity: .85; letter-spacing: .4px; text-transform: uppercase; }
.hrs-day-title { margin: 8px 0 6px; font-size: clamp(1.25rem, 2.4vw, 1.75rem); }
.hrs-day-date { opacity: .9; font-weight: 600; }
.hrs-day-sub { margin: 0; opacity: .9; font-size: .92rem; max-width: 62ch; }
.hrs-day-total { text-align: right; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); border-radius: 14px; padding: 14px 18px; min-width: 140px; }
.hrs-day-total-label { display: block; font-size: .75rem; opacity: .85; margin-bottom: 4px; }
.hrs-day-total strong { font-size: 1.55rem; letter-spacing: -.02em; }

.hrs-timer {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    flex-shrink: 0;
}
.hrs-timer[data-running="1"] {
    border-color: rgba(16, 185, 129, .35);
    background: linear-gradient(180deg, rgba(16,185,129,.08), var(--surface));
}
.hrs-timer-main {
    display: grid;
    grid-template-columns: minmax(160px, auto) 1fr auto;
    gap: 12px 16px;
    align-items: center;
}
.hrs-timer-live { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.hrs-timer-clock {
    font-variant-numeric: tabular-nums;
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    letter-spacing: .02em;
    line-height: 1.1;
    font-weight: 800;
}
.hrs-timer[data-running="1"] .hrs-timer-clock { color: #059669; }
.hrs-timer-meta { font-size: .78rem; color: var(--muted); font-weight: 500; }
.hrs-timer-dot {
    display: none; width: 8px; height: 8px; border-radius: 50%;
    background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.5);
    margin-bottom: 4px;
}
.hrs-timer[data-running="1"] .hrs-timer-dot {
    display: inline-block;
    animation: hrs-pulse 1.4s ease-out infinite;
}
@keyframes hrs-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,.45); }
    70% { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.hrs-timer-desc {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
}
.hrs-timer-desc:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.hrs-timer-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.hrs-timer-start, .hrs-timer-stop { display: inline-flex; align-items: center; gap: 8px; }

.hrs-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; }
.hrs-grid-fill { flex: 1 1 auto; min-height: 0; }
.hrs-grid-fill > .card { min-height: 0; display: flex; flex-direction: column; }
.hrs-list-card .hrs-scroll, .hrs-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.hrs-self-page .hrs-list-card { min-height: 0; overflow-x: hidden; overflow-y: visible; }
.hrs-self-page .hrs-entry,
.hrs-self-page .hrs-entry-desc,
.hrs-self-page .hrs-day-block { max-width: 100%; overflow-wrap: anywhere; }
.hrs-panel-sub { display: block; color: var(--muted); font-size: .78rem; margin-top: 3px; font-weight: 500; }
.hrs-time-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; margin-bottom: 14px; }
.hrs-page input.hrs-time-24 {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: .06em;
    font-size: 1.05rem;
}
.hrs-calc {
    min-width: 110px; height: 46px; display: grid; place-items: center;
    border-radius: 11px; background: rgba(79,70,229,.1); color: var(--brand);
    font-weight: 700; font-size: .95rem; border: 1px solid rgba(79,70,229,.18);
}
.hrs-calc.bad { background: rgba(239,68,68,.1); color: var(--danger); border-color: rgba(239,68,68,.25); }
.hrs-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.field em { font-style: normal; color: var(--muted); font-weight: 500; }

.hrs-empty { text-align: center; padding: 28px 14px; color: var(--muted); }
.hrs-empty p { margin: 0 0 4px; font-weight: 600; color: var(--text-soft); }

.hrs-entry {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: start;
    padding: 14px 0; border-bottom: 1px dashed var(--border);
}
.hrs-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.hrs-entry:first-child { padding-top: 0; }
.hrs-entry-time { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; grid-column: 1; }
.hrs-entry-time strong { font-size: .98rem; }
.hrs-badge {
    display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 10px;
    border-radius: 999px; background: rgba(79,70,229,.12); color: var(--brand);
}
.hrs-entry-desc { grid-column: 1 / -1; margin: 2px 0 0; font-size: .88rem; color: var(--text-soft); line-height: 1.4; }
.hrs-entry-desc.muted { color: var(--muted); }
.hrs-entry-actions { display: flex; gap: 6px; grid-column: 2; grid-row: 1; }

.hrs-head-wrap { flex-wrap: wrap; gap: 14px; }
.hrs-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.hrs-liq-filters .field.compact input,
.hrs-liq-filters .field.compact select { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.28); }
.hrs-liq-filters .field.compact span { color: rgba(255,255,255,.8); }
.field.compact { margin: 0; min-width: 0; flex: 1 1 120px; }
.field.compact span { font-size: .75rem; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 600; }
.field.compact input, .field.compact select {
    height: 40px; border: 1px solid var(--border); border-radius: 10px;
    padding: 0 10px; background: var(--surface); color: var(--text); font: inherit;
    width: 100%; min-width: 0;
}
.hrs-hist-summary { margin-bottom: 16px; color: var(--text-soft); font-size: .92rem; }
.hrs-day-block {
    border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
    margin-bottom: 12px; background: var(--surface-2);
}
.hrs-day-block-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.hrs-day-block-head .muted { display: block; font-size: .8rem; font-weight: 500; }
.hrs-day-block-body { background: var(--surface); border-radius: 12px; padding: 4px 14px; }

.hrs-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; flex-shrink: 0; }
.hrs-kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 14px 16px; box-shadow: var(--shadow);
}
.hrs-kpi-label { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.hrs-kpi-num { font-size: clamp(1.15rem, 2vw, 1.45rem); font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }

.hrs-person, .hrs-fee {
    border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
    margin-bottom: 10px; overflow: hidden;
}
.hrs-person.open { border-color: rgba(79,70,229,.35); box-shadow: var(--shadow); }
.hrs-person-head, .hrs-fee {
    display: grid; gap: 12px 16px; align-items: center;
    padding: 12px 14px;
}
.hrs-person-head {
    grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1fr) auto;
}
.hrs-expand {
    min-width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text-soft); display: inline-flex; align-items: center; justify-content: center;
    gap: 4px; padding: 0 8px;
    cursor: pointer; transition: var(--tr);
}
.hrs-expand-lbl { font-size: .72rem; font-weight: 700; }
.hrs-person.open .hrs-expand { background: rgba(79,70,229,.1); color: var(--brand); }
.hrs-person.open .hrs-expand svg { transform: rotate(90deg); }
.hrs-person-who { min-width: 0; }
.hrs-person-who strong, .hrs-fee-who strong { display: block; font-size: .98rem; }
.hrs-person-who span, .hrs-fee-who span { font-size: .78rem; color: var(--muted); }
.hrs-person-stats { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.hrs-person-stats span { font-size: .88rem; }
.hrs-person-stats em { display: block; font-style: normal; font-size: .68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.hrs-person-detail { padding: 0 14px 14px 66px; border-top: 1px dashed var(--border); }
.hrs-person-detail h3 { font-size: .95rem; margin: 12px 0 4px; }
.hrs-cal { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hrs-cal-day {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px;
    padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
}
.hrs-cal-day.miss { color: var(--muted); }
.hrs-cal-when { font-weight: 600; font-size: .86rem; }
.hrs-cal-status { font-size: .78rem; font-weight: 700; }
.hrs-cal-ents { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; font-size: .82rem; color: var(--text-soft); }
.hrs-cal-ents em { font-style: normal; font-weight: 700; color: var(--brand); }
.hrs-cal-month { margin-top: 12px; }
.hrs-cal-month > strong { font-size: .82rem; color: var(--brand); }

.hrs-fee { grid-template-columns: minmax(160px, .85fr) minmax(0, 1.5fr) minmax(180px, .85fr) auto; align-items: start; }
.hrs-fee-input { width: 100%; min-height: 44px; }
.hrs-fee[data-kind="salary"] .hrs-fee-hourly { display: none; }
.hrs-fee[data-kind="hourly"] .hrs-fee-salary { display: none; }
.hrs-seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.hrs-seg-opt {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); cursor: pointer; font-size: .84rem; font-weight: 600;
}
.hrs-seg-opt:has(input:checked) {
    border-color: var(--brand); background: rgba(79,70,229,.08); color: var(--brand);
}
.hrs-fee-hours { margin: 0 0 8px; font-size: .88rem; color: var(--text-soft); }
.hrs-fee-extra {
    margin: 0 0 12px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.hrs-fee-extra-label { margin: 0 0 8px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.hrs-fee-extra-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hrs-fee-extra-grid input { min-height: 40px; }
.hrs-fee-extra-note { margin: 8px 0 0; font-size: .84rem; color: var(--text-soft); }
.hrs-fee-extra-note em { font-style: normal; color: var(--muted); }
.hrs-fee-time-dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 0; }
.hrs-fee-time-dl dt { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.hrs-fee-time-dl dd { margin: 2px 0 0; font-weight: 700; }
.hrs-fee-calc, .hrs-liq-break { margin: 8px 0 0; font-weight: 800; color: var(--brand); font-size: .92rem; }
.hrs-fee-paid-amt { margin: 8px 0 0; font-weight: 800; font-size: 1.05rem; }
.hrs-liq-break { margin: 6px 0 10px; }

/* ---- Honorarios web app ---- */
body.hrs-team-app .content.content-hours {
    overflow: hidden;
    padding: 10px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.hrs-fee-app.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.hrs-fee-work {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}
.hrs-fee-bar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    width: 100%;
}
.hrs-fee-bar-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
}
.hrs-fee-bar-title h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.hrs-fee-bar-title p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; font-weight: 600; }
.hrs-fee-bar-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    flex: 1 1 420px;
    min-width: 0;
}
.hrs-fee-bar-tools .field.compact { min-width: 92px; flex: 0 1 120px; }
.hrs-fee-search { flex: 1 1 180px !important; min-width: 0 !important; }
.hrs-fee-bar-tools .btn { min-height: 40px; }
.hrs-fee-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}
.hrs-fee-kpi {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    padding: 8px 12px;
    min-width: 0;
}
.hrs-fee-kpi span {
    display: block; font-size: .68rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.hrs-fee-kpi strong {
    display: block; margin-top: 2px; font-size: clamp(.95rem, 1.6vw, 1.15rem);
    letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.hrs-fee-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.hrs-fee-views, .hrs-fee-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.hrs-fee-view, .hrs-fee-chip {
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-soft); font: inherit; font-weight: 600; font-size: .8rem;
    min-height: 36px; padding: 0 12px; border-radius: 999px; cursor: pointer;
}
.hrs-fee-view.active, .hrs-fee-chip.active {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    border-color: transparent; color: #fff;
}
.hrs-fee-board {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
    width: 100%;
}
.hrs-fee-sheet-card {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}
.hrs-fee-sheet-card > #feeList {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.hrs-fee-sheet { min-width: 0; }
.hrs-fee-sheet-head,
.hrs-fee-main {
    display: grid;
    grid-template-columns: minmax(160px, 1.3fr) minmax(110px, .85fr) minmax(80px, .55fr) minmax(110px, .75fr) minmax(90px, .55fr) minmax(108px, .7fr) 40px;
    gap: 8px 12px;
    align-items: center;
}
.hrs-fee-sheet-head {
    position: sticky; top: 0; z-index: 2;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted);
}
.hrs-fee-row { border-bottom: 1px solid var(--border); }
.hrs-fee-row.open { background: rgba(15, 118, 110, .04); }
.hrs-fee-row.is-empty .hrs-fee-amt { color: var(--muted); }
.hrs-fee-main {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    padding: 12px 14px;
    cursor: pointer;
    min-height: 56px;
}
.hrs-fee-main:hover { background: var(--surface-2); }
.hrs-fee-who strong { display: block; font-size: .95rem; }
.hrs-fee-who span { display: block; font-size: .75rem; color: var(--muted); }
.hrs-fee-amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.hrs-fee-hrs, .hrs-fee-mod { font-size: .86rem; color: var(--text-soft); }
.hrs-fee-chev { display: grid; place-items: center; color: var(--muted); }
.hrs-fee-row.open .hrs-fee-chev svg { transform: rotate(90deg); }
.hrs-pill {
    display: inline-flex; align-items: center; min-height: 24px;
    padding: 0 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
    background: var(--surface-2); color: var(--text-soft);
}
.hrs-pill.ok { background: rgba(16,185,129,.12); color: #047857; }
.hrs-pill.warn { background: rgba(245,158,11,.14); color: #b45309; }
.hrs-pill.mute { background: var(--surface-2); color: var(--muted); }
.hrs-fee-editor {
    padding: 0 14px 14px;
    border-top: 1px dashed var(--border);
}
.hrs-fee-editor-grid {
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(0, 1.1fr);
    gap: 14px;
    padding-top: 12px;
}
.hrs-fee-form-actions {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.hrs-fee-form-actions .btn { min-height: 44px; }
.hrs-btn-short { display: none; }
.hrs-fee-log-wrap h3 {
    margin: 0 0 8px; font-size: .82rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted);
}
.hrs-fee-log, .hrs-fee-ledger-list { list-style: none; margin: 0; padding: 0; }
.hrs-fee-log-item, .hrs-fee-ledger-row {
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-2);
    margin-bottom: 6px;
}
.hrs-fee-log-item p, .hrs-fee-log-empty { margin: 4px 0 0; font-size: .8rem; color: var(--text-soft); }
.hrs-fee-log-stamp { color: var(--muted) !important; }
.hrs-fee-log-main { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.hrs-fee-log-main strong { font-size: .84rem; }
.hrs-fee-ledger-head,
.hrs-fee-ledger-row {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(120px, .8fr) minmax(110px, .6fr) minmax(160px, .9fr);
    gap: 8px 12px;
    align-items: start;
}
.hrs-fee-ledger-head {
    position: sticky; top: 0; z-index: 2;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted);
}
.hrs-fee-ledger-row {
    margin: 0;
    padding: 12px 14px;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.hrs-fee-ledger-move strong { display: block; font-size: .88rem; margin-top: 4px; }
.hrs-fee-ledger-move time { display: block; font-size: .74rem; color: var(--muted); margin-top: 2px; }
.hrs-fee-ledger-amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.hrs-fee-ledger-who, .hrs-fee-ledger-actor { font-size: .84rem; color: var(--text-soft); }
.hrs-fee-row[data-kind="salary"] .hrs-fee-hourly { display: none; }
.hrs-fee-row[data-kind="hourly"] .hrs-fee-salary { display: none; }

.hrs-stamp {
    margin: 8px 0 0; padding: 8px 10px; border-radius: 10px;
    background: var(--surface-2); color: var(--text-soft); font-size: .8rem; line-height: 1.35;
}
.hrs-stamp.ok { background: rgba(16,185,129,.1); color: #047857; }
.hrs-liq-amount { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.hrs-liq-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.hrs-liq-meta dt { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.hrs-liq-meta dd { margin: 2px 0 0; font-weight: 600; }
.hrs-liq-row {
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
    margin-bottom: 10px; background: var(--surface-2);
}
.hrs-liq-row > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.hrs-liq-row p { margin: 2px 0; font-size: .84rem; color: var(--text-soft); }
.hrs-inv {
    margin-top: 14px;
    padding: 14px;
    border: 1px dashed rgba(15,118,110,.35);
    border-radius: 12px;
    background: rgba(15,118,110,.05);
}
.hrs-inv-title { margin: 0 0 6px; font-weight: 800; font-size: .92rem; }
.hrs-inv-file { margin: 0 0 8px; }
.hrs-inv-file a, .hrs-inv-link { font-weight: 700; color: var(--brand); text-decoration: none; }
.hrs-inv-file a:hover, .hrs-inv-link:hover { text-decoration: underline; }
.hrs-inv-file span, .hrs-inv-empty { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.hrs-inv-empty { margin: 0 0 8px; }
.hrs-inv-pick { margin-top: 4px; cursor: pointer; }
.hrs-inv-muted { font-size: .8rem; color: var(--muted); font-weight: 600; }
.hrs-fee-inv { font-size: .82rem; min-width: 0; }
.hrs-inv-count { margin: 0 0 8px; font-size: .78rem; color: var(--muted); font-weight: 700; }
.hrs-inv-list { list-style: none; margin: 0 0 10px; padding: 0; }
.hrs-inv-list li {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
    padding: 6px 0; border-bottom: 1px solid var(--border);
}
.hrs-inv-list li:last-child { border-bottom: 0; }
.hrs-inv-list span { font-size: .75rem; color: var(--muted); }
.hrs-inv-del { min-height: 32px; padding: 2px 10px; font-size: .76rem; }
.hrs-inv-links { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.hrs-inv-links .hrs-inv-link { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
    .hrs-person-head { grid-template-columns: auto 1fr auto; }
    .hrs-person-stats { grid-column: 2; }
    .hrs-export-one { grid-column: 1 / -1; width: 100%; }
    .hrs-fee { grid-template-columns: 1fr 1fr; }
    .hrs-fee-actions, .hrs-fee-pay { grid-column: 1 / -1; }
    .hrs-staff-detail td { padding-left: 14px; }
    .hrs-fee-editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
    .content.content-hours { overflow-x: hidden; overflow-y: visible; }
    body.hrs-team-app .content.content-hours { overflow-x: hidden; overflow-y: visible; }
    .hrs-page, .hrs-panel-fill.active { height: auto; min-height: 0; }
    body.hrs-team-app .hrs-page,
    body.hrs-team-app .hrs-panel-fill.active { overflow-x: hidden; overflow-y: visible; height: auto; }
    body.hrs-app .hrs-day-sub { display: none; }
    body.hrs-app .hrs-grid-fill > .card:not(.hrs-list-card) { min-height: auto; }
    body.hrs-app .hrs-grid-fill {
        grid-template-rows: none;
        overflow: visible;
    }
    body.hrs-team-app #tab-fees.hrs-panel-fill.active { min-height: 0; flex: 1 1 auto; }
    .hrs-grid, .hrs-grid-fill { grid-template-columns: 1fr; }
    .hrs-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hrs-timer-main { grid-template-columns: 1fr; }
    .hrs-timer-actions { justify-content: stretch; }
    .hrs-timer-actions .btn { flex: 1; justify-content: center; min-height: 44px; }
    .hrs-person-detail { padding-left: 14px; }
    .hrs-list-card .hrs-scroll { min-height: 0; }
    .hrs-fee-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hrs-fee-sheet-head, .hrs-fee-ledger-head { display: none; }
    .hrs-fee-main {
        grid-template-columns: 1fr auto;
        gap: 4px 10px;
        min-height: 64px;
    }
    .hrs-fee-who { grid-column: 1; }
    .hrs-fee-chev { grid-column: 2; grid-row: 1 / span 6; }
    .hrs-fee-mod, .hrs-fee-hrs, .hrs-fee-amt, .hrs-fee-st, .hrs-fee-inv { grid-column: 1; }
    .hrs-fee-mod::before, .hrs-fee-hrs::before, .hrs-fee-amt::before, .hrs-fee-inv::before {
        content: attr(data-col) ': ';
        font-weight: 700;
        color: var(--muted);
        text-transform: uppercase;
        font-size: .68rem;
        letter-spacing: .03em;
    }
    .hrs-fee-row {
        margin: 8px;
        border: 1px solid var(--border);
        border-radius: 14px;
        overflow: hidden;
        border-bottom: 0;
    }
    .hrs-fee-ledger-row { grid-template-columns: 1fr; }
    .hrs-fee-form-actions .btn { flex: 1 1 auto; min-height: 44px; }
}
@media (max-width: 640px) {
    .hrs-time-row { grid-template-columns: 1fr 1fr; }
    .hrs-calc { grid-column: 1 / -1; }
    .hrs-kpis { grid-template-columns: 1fr 1fr; }
    .hrs-day-total, .hrs-team-hero-side { text-align: left; width: 100%; }
    .hrs-team-hero-side { align-items: stretch; }
    .hrs-tab { flex: 1 1 auto; text-align: center; padding: 10px 12px; font-size: .84rem; }
    .hrs-person-head { grid-template-columns: auto 1fr; }
    .hrs-person-stats { grid-column: 1 / -1; }
    .hrs-fee { grid-template-columns: 1fr; }
    .hrs-liq-meta { grid-template-columns: 1fr; }
    .hrs-head-wrap { align-items: stretch; }
    .hrs-filters { width: 100%; }
    .hrs-filters .btn { flex: 1 1 auto; min-height: 44px; }
    .hrs-form-actions .btn { min-height: 44px; }
    .hrs-timer-desc, .hrs-fee-input, .hrs-time-row input, .hrs-page textarea { font-size: 16px; }
    .hrs-expand-lbl { display: none; }
    .hrs-page .tact { min-width: 44px; min-height: 44px; }
    .hrs-fee-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hrs-fee-bar-tools .btn { flex: 1 1 auto; min-height: 44px; }
    .hrs-fee-search { flex: 1 1 100% !important; }
    .hrs-fee-sheet-head, .hrs-fee-ledger-head { display: none; }
    .hrs-fee-main {
        grid-template-columns: 1fr auto;
        gap: 4px 10px;
        min-height: 64px;
        padding: 12px 14px;
    }
    .hrs-fee-who { grid-column: 1; }
    .hrs-fee-chev { grid-column: 2; grid-row: 1 / span 6; }
    .hrs-fee-mod, .hrs-fee-hrs, .hrs-fee-amt, .hrs-fee-inv {
        grid-column: 1;
        font-size: .8rem;
    }
    .hrs-fee-mod::before, .hrs-fee-hrs::before, .hrs-fee-amt::before, .hrs-fee-inv::before {
        content: attr(data-col) ': ';
        font-weight: 700;
        color: var(--muted);
        text-transform: uppercase;
        font-size: .68rem;
        letter-spacing: .03em;
    }
    .hrs-fee-st { grid-column: 1; }
    .hrs-fee-editor-grid,
    .hrs-fee-ledger-head,
    .hrs-fee-ledger-row { grid-template-columns: 1fr; }
    .hrs-fee-row { border: 0; margin: 8px; border-radius: 14px; border: 1px solid var(--border); overflow: hidden; }
    .hrs-fee-row + .hrs-fee-row { margin-top: 8px; }
    .hrs-btn-full { display: none; }
    .hrs-btn-short { display: inline; }
    .hrs-fee-view, .hrs-fee-chip { min-height: 40px; flex: 1 1 auto; justify-content: center; }
    .hrs-fee-form-actions .btn { flex: 1 1 auto; }
}

/* ============================================================
   Historia clínica profesional (/historia.php)
   ============================================================ */
.content:has(.hc-page) {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 16px max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    min-height: calc(100dvh - 110px);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}
body.hc-app {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}
body.hc-app .app-shell {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}
body.hc-app .main {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}
body.hc-app .content.content-hc {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-width: none;
    width: 100%;
    padding: 0;
}
body.hc-app .hc-page {
    padding: 12px max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
body.hc-app .hc-tabs {
    top: 0;
    flex-shrink: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    flex-wrap: wrap;
}
body.hc-app .app-credit { display: none; }
.hc-page {
    display: flex; flex-direction: column; gap: 18px;
    width: 100%; flex: 1 1 auto; min-width: 0; min-height: 100%;
    color: var(--text);
}
.hc-ficha-modal {
    max-width: min(1080px, calc(100% - 16px));
    width: calc(100% - 16px);
    max-height: 94dvh;
    margin: 3vh auto;
}
.hc-ficha-modal #hcFichaEdit {
    display: flex; flex-direction: column; gap: 0;
    max-height: 92dvh; min-height: 0;
}
.hc-ficha-modal .modal-head { flex-shrink: 0; align-items: flex-start; gap: 12px; }
.hc-ficha-modal .modal-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.hc-ficha-modal .modal-foot {
    flex-shrink: 0; margin: 0; padding: 14px 22px 18px;
    border-top: 1px solid var(--border);
}
.hc-top {
    display: flex; flex-direction: column; align-items: stretch; gap: 12px;
    padding: 18px 20px; border-radius: 16px; color: #fff;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 55%, #6366f1 100%);
    box-shadow: 0 18px 40px -22px rgba(79,70,229,.65);
    min-width: 0;
}
.hc-top-main {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0;
}
.hc-back { background: rgba(255,255,255,.12) !important; color: #fff !important; border-color: rgba(255,255,255,.18) !important; }
.hc-back:hover { background: rgba(255,255,255,.2) !important; }
.hc-identity { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.hc-id-text { min-width: 0; flex: 1; }
.hc-avatar {
    width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 800; font-size: 1.15rem;
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22);
}
.hc-kicker { margin: 0; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; font-weight: 600; }
.hc-id-text h2 {
    margin: 2px 0 8px; font-size: clamp(1.05rem, 2.4vw, 1.55rem);
    overflow-wrap: anywhere; word-break: break-word;
}
.hc-id-text .chip { background: rgba(255,255,255,.12); color: #eef2ff; border-color: rgba(255,255,255,.18); }
.hc-top-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-left: auto;
    min-width: 0;
    max-width: min(100%, 28rem);
}
.hc-top-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
.hc-top-actions .btn,
.hc-top-btns .btn,
.ficha-export-box .btn {
    white-space: nowrap;
    flex-shrink: 0;
    width: max-content;
    max-width: 100%;
}
.hc-top-actions .btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.18); }
.hc-top-actions .btn-ghost:hover { background: rgba(255,255,255,.22); }
.ficha-export-box { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; max-width: min(100%, 28rem); }
.ficha-export-last {
    margin: 0;
    width: 100%;
    max-width: 100%;
    font-size: .72rem;
    line-height: 1.4;
    font-weight: 600;
    color: rgba(224, 231, 255, .92);
    text-align: right;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.ficha-export-last:empty, .ficha-export-last[hidden] { display: none; }
.pt-export-box { align-items: flex-start; }
.pt-export-box .ficha-export-last,
.pt-bar .ficha-export-last { color: var(--muted); text-align: left; }
.ficha-fmt-card { max-width: 520px; }
.ficha-fmt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ficha-fmt-opt {
    display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
    padding: 14px 12px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.ficha-fmt-opt:hover { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.ficha-fmt-opt strong { font-size: .95rem; }
.ficha-fmt-opt span { font-size: .78rem; color: var(--muted); font-weight: 600; }

/* Historia clínica en PDF: todas las vistas o una selección */
.hc-pdf-card { max-width: 640px; }
.hc-pdf-mode { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hc-pdf-mode-opt, .hc-pdf-view { position: relative; display: flex; cursor: pointer; min-width: 0; }
.hc-pdf-mode-opt input, .hc-pdf-view input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.hc-pdf-mode-opt span, .hc-pdf-view span {
    display: grid; gap: 2px; width: 100%; padding: 12px 14px; border-radius: 12px;
    border: 1.5px solid var(--border); background: var(--surface-2); transition: border-color var(--tr), background var(--tr);
}
.hc-pdf-mode-opt strong, .hc-pdf-view strong { font-size: .92rem; }
.hc-pdf-mode-opt em, .hc-pdf-view em { font-style: normal; font-size: .76rem; color: var(--muted); }
.hc-pdf-mode-opt input:checked + span, .hc-pdf-view input:checked + span { border-color: var(--brand); background: rgba(79,70,229,.1); box-shadow: 0 0 0 1px var(--brand) inset; }
.hc-pdf-mode-opt input:focus-visible + span, .hc-pdf-view input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.hc-pdf-views {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px;
    margin: 14px 0 0; padding: 0; border: 0; min-width: 0;
}
.hc-pdf-views legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hc-pdf-views:disabled { opacity: .5; }
.hc-pdf-views:disabled .hc-pdf-view { cursor: default; }
.hc-pdf-err { margin: 10px 0 0; color: var(--danger); font-size: .84rem; font-weight: 600; }
.hc-pdf-foot { justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 520px) {
    .hc-pdf-mode { grid-template-columns: 1fr; }
    .hc-pdf-foot .btn { flex: 1 1 100%; }
}
@media (max-width: 720px) {
    .ficha-fmt-grid { grid-template-columns: 1fr; }
    .ficha-export-box, .pt-export-box, .hc-top-actions { align-items: stretch; max-width: 100%; }
    .ficha-export-last, .pt-export-box .ficha-export-last { text-align: left; }
}
.hc-presence {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    width: 100%; max-width: none;
    font-size: .78rem; font-weight: 600; color: #e0e7ff;
    background: rgba(15,23,42,.28); border: 1px solid rgba(255,255,255,.16);
    padding: 8px 10px; border-radius: 12px;
}
.hc-presence[hidden] { display: none !important; }
.hc-presence-label {
    font-size: .68rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; opacity: .78; white-space: nowrap;
}
.hc-presence-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; flex: 1; }
.hc-presence-chip {
    display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
    padding: 3px 10px 3px 3px; border-radius: 999px;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.14);
}
.hc-presence-av {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-size: .62rem; font-weight: 800;
    background: rgba(255,255,255,.22); color: #fff;
}
.hc-presence-name {
    font-size: .78rem; font-weight: 600; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: min(280px, 58vw);
}
.hc-cloud { font-size: .72rem; opacity: .88; white-space: nowrap; }
.hc-draft {
    grid-column: 1 / -1; margin: 0 0 8px; padding: 10px 12px; border-radius: 10px;
    background: #eef2ff; color: #3730a3; font-size: .86rem;
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
}
.hc-draft[hidden] { display: none !important; margin: 0; padding: 0; }
.hc-draft-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.hc-stamp { margin: 0 0 12px; color: var(--muted); font-size: .86rem; }
.hc-legal { margin: 16px 4px 0; font-size: .78rem; color: var(--muted); line-height: 1.55; }
.stepup-disc { font-size: .82rem; color: var(--text-soft); line-height: 1.55; margin: 0 0 16px; }
.stepup-err { color: #fecaca; font-size: .86rem; margin: 12px 0 0; }
#stepupModal .is-off,
#stepupModal [hidden] { display: none !important; }
.stepup-pin-wrap { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.stepup-pin-label { font-size: .84rem; font-weight: 700; color: var(--text); }
.stepup-pin-input {
    display: block; width: 100%; height: 56px; box-sizing: border-box;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.65rem; font-weight: 700; letter-spacing: .45em;
    text-align: center; color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--brand);
    border-radius: 12px;
    padding: 8px 12px 8px 22px;
    outline: none;
    caret-color: var(--brand);
    -webkit-text-security: disc;
    text-security: disc;
}
.stepup-pin-input::-ms-reveal,
.stepup-pin-input::-ms-clear,
.stepup-pin-input::-webkit-credentials-auto-fill-button,
.stepup-pin-input::-webkit-clear-button {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
    width: 0; height: 0;
}
.stepup-pin-input:focus { box-shadow: 0 0 0 4px rgba(79,70,229,.28); }
.stepup-pin-input::placeholder { color: var(--muted); letter-spacing: .45em; }
#stepupModal .modal-foot { padding: 14px 22px 18px; border-top: 1px solid var(--border); margin: 0; flex-wrap: wrap; }

.hc-top,
.hc-delete-policy { flex-shrink: 0; }
.hc-tabs {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 6px; width: 100%; max-width: 100%; min-height: 52px; flex-shrink: 0;
    overflow-x: hidden; overflow-y: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    position: sticky; top: 66px; z-index: 25;
    color: var(--text);
}
.hc-tabs::-webkit-scrollbar { height: 6px; }
.hc-tabs::-webkit-scrollbar:vertical { display: none; width: 0; }
.hc-tab {
    border: 0; background: transparent; color: var(--text-soft); font: inherit; font-weight: 600;
    font-size: .86rem; padding: 10px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
    transition: var(--tr); scroll-snap-align: start; flex: 0 0 auto;
    min-height: 40px; display: inline-flex; align-items: center;
}
.hc-tab:hover { background: var(--surface-2); color: var(--text); }
.hc-tab.active { background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; box-shadow: 0 8px 20px -10px var(--brand); }
.hc-panel { display: none; min-width: 0; max-width: 100%; }
.hc-panel.active {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: hcIn .28s ease;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    flex: 1 1 auto;
}
.hc-page .card { min-width: 0; max-width: 100%; color: var(--text); background: var(--surface); }
.hc-page .card:has(.table-wrap) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.hc-page .table-wrap {
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 8px 16px 18px;
    box-sizing: border-box;
}
.hc-page .table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.hc-page .table th,
.hc-page .table td { vertical-align: middle; }
.hc-page .table td.row-actions,
.hc-page .table th:last-child {
    white-space: nowrap;
    padding-right: 16px;
}
.hc-page .table td .pt-sub { white-space: normal; overflow-wrap: anywhere; }
.hc-page .row-actions { flex-wrap: nowrap; justify-content: flex-end; }
@keyframes hcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hc-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.hc-grid-2 > * { min-width: 0; }
.hc-sheet-wrap { width: 100%; min-width: 0; }
.hc-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}
.hc-subtab {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 38px;
}
.hc-subtab:hover { background: var(--surface-2); color: var(--text); }
.hc-subtab.active {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    border-color: transparent;
}
.hc-protein-hist { width: 100%; min-width: 0; }
.hc-sheet-block-wide {
    grid-column: 1 / -1;
    border-left: 0 !important;
}
.hc-sheet-block-wide + .hc-sheet-grid { border-top: 1px solid var(--border); }
.hc-protein-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-top: 10px;
}
.hc-protein-form .field { flex: 1 1 220px; margin: 0; }
.hc-protein-form .btn { min-height: 40px; }
.hc-protein-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.hc-protein-value[data-protein-new] {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    min-width: 2ch;
}
.hc-protein-pencil {
    appearance: none;
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--hc-ink);
    cursor: pointer;
    flex-shrink: 0;
}
.hc-protein-pencil:hover { background: #eef2ff; border-color: var(--brand); }
.hc-protein-hint {
    display: block;
    margin-top: 6px;
    font-size: .72rem;
    line-height: 1.4;
    color: var(--muted);
    font-weight: 500;
}
.hc-protein-form .hc-protein-hint {
    flex: 1 1 100%;
    margin-top: 0;
}
.hc-protein-acts { margin-top: 8px; }
.hc-sheet {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 100%;
}
.hc-sheet-head {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(220px, .9fr);
    gap: 20px 28px;
    padding: 22px 24px 18px;
    color: var(--text);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.hc-sheet-kicker {
    margin: 0 0 6px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--hc-ink);
}
.hc-sheet-head h2 {
    margin: 0 0 8px;
    font-size: clamp(1.2rem, 2.2vw, 1.7rem);
    letter-spacing: -.02em;
    color: var(--text);
}
.hc-sheet-head-copy p {
    margin: 0;
    color: var(--text-soft);
    font-size: .9rem;
    max-width: 62ch;
}
.hc-sheet-meta {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
}
.hc-sheet-meta dt {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}
.hc-sheet-meta dd {
    margin: 2px 0 0;
    font-weight: 700;
    font-size: .92rem;
    color: var(--text);
    overflow-wrap: anywhere;
}
.hc-sheet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    background: var(--surface);
    color: var(--text);
}
.hc-sheet-block {
    padding: 18px 22px 20px;
    min-width: 0;
    color: var(--text);
}
.hc-sheet-block + .hc-sheet-block { border-left: 1px solid var(--border); }
.hc-sheet-block h3 {
    margin: 0 0 12px;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--hc-ink);
}
.hc-sheet-field {
    padding: 10px 0 12px;
    border-bottom: 1px solid var(--border);
}
.hc-sheet-field:last-child { border-bottom: 0; }
.hc-sheet-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}
.hc-sheet-value {
    font-weight: 600;
    font-size: .98rem;
    color: var(--text);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.hc-sheet-value a { font-weight: 700; color: var(--brand); }
.hc-field-stamp {
    display: block;
    margin-top: 6px;
    font-size: .72rem;
    line-height: 1.45;
    color: var(--muted);
    font-weight: 500;
}
.hc-field-stamp.is-empty { display: none; }
.hc-sheet-map {
    padding: 0 22px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
.hc-sheet-map h3 {
    margin: 16px 0 10px;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--hc-ink);
}
.hc-sheet-map .ficha-map {
    height: min(42vh, 340px);
    min-height: 220px;
    border-radius: 14px;
    border: 1px solid var(--border);
    width: 100%;
}
.hc-ficha-edit-body { display: flex; flex-direction: column; gap: 18px; padding: 16px 22px 8px; }
.hc-edit-block {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px 16px;
}
.hc-edit-block-head { margin-bottom: 12px; }
.hc-edit-block-head h3 { font-size: .95rem; margin: 0 0 2px; }
.hc-edit-block-head p { margin: 0; color: var(--muted); font-size: .8rem; }
.hc-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.hc-edit-field { min-width: 0; }
.hc-edit-span { grid-column: 1 / -1; }
.hc-edit-field .field { margin: 0; }
.hc-edit-map {
    margin-top: 12px;
    height: 240px;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.hc-anam-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.hc-anam-field textarea { min-height: 110px; resize: vertical; }
.hc-anam-stamp {
    display: block; margin-top: 6px; white-space: pre-line;
    font-size: .75rem; color: var(--muted); line-height: 1.45; font-weight: 500;
}
.hc-visit-card {
    border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
    background: var(--surface); margin-bottom: 14px;
}
.hc-visit-card:last-child { margin-bottom: 0; }
.hc-visit-head {
    display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
    margin-bottom: 12px; flex-wrap: wrap;
}
.hc-visit-head strong { display: block; font-size: .95rem; }
.hc-visit-head span { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.hc-visit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hc-visit-field h4 { margin: 0 0 4px; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.hc-visit-field p { margin: 0; white-space: pre-wrap; font-size: .92rem; }
.hc-lab-grid { grid-template-columns: repeat(4, 1fr); }
.hc-lab-panels { display: grid; gap: 12px; }
.hc-lab-panel {
    margin: 0; min-width: 0;
    border: 1px solid var(--border); border-radius: 12px;
    padding: 8px 12px 12px; background: var(--surface-2);
}
.hc-lab-panel legend {
    font-size: .8rem; font-weight: 800; padding: 0 6px; color: var(--text);
}
.hc-lab-panel .hc-hint { margin: 8px 0 0; }
.hc-lab-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hc-lab-values { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.hc-lab-sum-block { font-size: .82rem; color: var(--text-soft); line-height: 1.4; }
.hc-lab-sum-block strong { color: var(--text); margin-right: 6px; }
.hc-phe-kpis {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.hc-phe-kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 12px 14px; box-shadow: var(--shadow); min-width: 0;
}
.hc-phe-kpi span { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hc-phe-kpi strong { display: block; margin-top: 4px; font-size: 1.18rem; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.hc-phe-kpi em { display: block; margin-top: 2px; font-style: normal; font-size: .75rem; color: var(--text-soft); }
.hc-hint { margin: 12px 0 0; font-size: .82rem; color: var(--muted); }
.hc-delete-policy {
    margin: 0 0 14px;
    padding: 11px 14px;
    font-size: .82rem;
    line-height: 1.45;
    color: #312e81;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
}
.hc-del-locked {
    display: inline-block;
    font-size: .75rem;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}
.hc-del-until {
    display: block;
    font-size: .72rem;
    color: var(--muted);
    margin-top: 3px;
}
.hc-eye-btn {
    padding: 6px 8px;
    line-height: 0;
}
.hc-eye-btn svg { display: block; }
.hc-lab-view-modal {
    max-width: min(760px, calc(100% - 24px));
    width: calc(100% - 24px);
    max-height: 92dvh;
    margin: 4vh auto;
}
.hc-lab-view-modal .modal-body { overflow-y: auto; min-height: 0; }
.hc-lab-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.hc-lab-view-panel {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}
.hc-lab-view-panel h3 {
    margin: 0 0 10px;
    font-size: .8rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.hc-lab-view-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    padding: 5px 0;
    border-top: 1px dashed var(--border);
    font-size: .92rem;
}
.hc-lab-view-row:first-of-type { border-top: 0; }
.hc-lab-view-row span { color: var(--text-soft); }
.hc-lab-view-row strong { font-variant-numeric: tabular-nums; text-align: right; }
.hc-lab-view-row small { font-weight: 600; color: var(--muted); margin-left: 4px; }
.hc-lab-view-notes {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: .88rem;
}
.hc-lab-view-stamp {
    margin: 16px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    color: #155e75;
    font-weight: 700;
    font-size: .92rem;
    line-height: 1.45;
}
.hc-lab-view-reviews { margin-top: 16px; }
.hc-lab-view-reviews h3 {
    margin: 0 0 8px;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.hc-lab-view-reviews ul { margin: 0; padding-left: 18px; color: var(--text-soft); font-size: .84rem; }
.hc-lab-view-reviews li { margin: 4px 0; }
.hc-anam-view-wrap { display: block; }
.hc-anam-view-dl { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.hc-anam-view-item {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}
.hc-anam-view-item dt {
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 6px;
}
.hc-anam-view-item dd {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
    line-height: 1.5;
    font-size: .92rem;
}
.hc-notes { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.hc-note-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 16px 18px 0; flex-wrap: wrap; }
.hc-panel .card-head { gap: 12px; flex-wrap: wrap; }
.hc-note-body { margin: 0; padding: 8px 18px 18px; color: var(--text-soft); line-height: 1.55; white-space: pre-wrap; }
.hc-chart-wrap {
    position: relative;
    width: 100%;
    height: clamp(300px, 58vh, 620px);
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}
.hc-chart-wrap.is-empty { height: 0; min-height: 0; overflow: hidden; }
/* Absoluto: el ancho del canvas genera scroll interno sin ensanchar la tarjeta ni la página. */
.hc-chart-wrap canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    touch-action: pan-x pan-y;
}
.hc-chart-hint { margin: 6px 0 0; font-size: .74rem; color: var(--muted); }
.hc-chart-tip {
    position: absolute;
    z-index: 3;
    min-width: 160px;
    max-width: 260px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #0f172a;
    color: #fff;
    font-size: .78rem;
    line-height: 1.35;
    box-shadow: 0 10px 24px rgba(15,23,42,.28);
    pointer-events: none;
}
.hc-chart-tip strong { display: block; margin-bottom: 4px; }
.hc-chart-tip span { display: block; color: #cbd5e1; }
.hc-chart-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-bottom: 12px; font-size: .8rem; font-weight: 600; color: var(--text-soft); }
.hc-lg { display: inline-flex; align-items: center; gap: 7px; }
.hc-lg::before { content: ''; width: 16px; height: 3px; border-radius: 2px; background: currentColor; }
.lg-phe { color: #4f46e5; }
.lg-phef { color: #7c3aed; }
.lg-phef::before { border-top: 2px dashed currentColor; height: 0; background: none; }
.lg-tyr { color: #0ea5e9; }
.lg-ref { color: #16a34a; }
.lg-ref::before { border-top: 2px dashed #dc2626; height: 0; background: none; width: 16px; }

.keto-app { display: flex; flex-direction: column; gap: 14px; min-width: 0; width: 100%; }
.keto-hero {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    padding: 16px 18px; border: 1px solid var(--border); border-radius: 16px;
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.keto-hero h2 { margin: 2px 0 4px; font-size: 1.25rem; letter-spacing: -.02em; }
.keto-hero p { margin: 0; max-width: 52rem; color: var(--text-soft); font-size: .88rem; line-height: 1.45; }
.keto-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 14px; align-items: start; min-width: 0; }
.keto-rail {
    border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.keto-rail-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.keto-rail-head h3 { margin: 0; font-size: .95rem; }
.keto-rail-head p { margin: 4px 0 0; font-size: .78rem; color: var(--muted); line-height: 1.35; }
.keto-rail-list { padding: 10px; max-height: min(72vh, 820px); overflow: auto; -webkit-overflow-scrolling: touch; }
.keto-empty { text-align: center; padding: 28px 12px; color: var(--text-soft); }
.keto-empty p { margin: 0; font-weight: 700; color: var(--text); }
.keto-empty span { display: block; margin-top: 6px; font-size: .82rem; }
.keto-card {
    display: grid; gap: 6px; margin-bottom: 8px; padding: 4px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2);
}
.keto-card.is-active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); background: #fff; }
.keto-card-main {
    display: grid; gap: 3px; width: 100%; text-align: left; border: 0; background: transparent;
    color: inherit; font: inherit; cursor: pointer; padding: 8px 8px 4px; border-radius: 10px;
}
.keto-card-main:hover { background: rgba(79,70,229,.05); }
.keto-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.keto-card-top strong { font-size: .9rem; line-height: 1.25; }
.keto-card-meta { display: block; font-size: .74rem; color: var(--muted); }
.keto-card-edit { justify-self: start; margin: 0 8px 8px; }
.keto-badge {
    display: inline-flex; align-items: center; min-height: 20px; padding: 0 7px; border-radius: 999px;
    font-size: .66rem; font-weight: 700; font-style: normal; white-space: nowrap;
    background: var(--surface); color: var(--text-soft); border: 1px solid var(--border);
}
.keto-badge.mine { background: rgba(16,185,129,.12); color: #047857; border-color: transparent; }
.keto-badge.mute { background: rgba(148,163,184,.18); color: #64748b; border-color: transparent; }
.keto-sheet {
    border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
    padding: 0 0 18px; overflow-x: hidden; overflow-y: visible; min-width: 0;
}
.keto-sheet.is-editing { box-shadow: inset 3px 0 0 var(--brand); }
.keto-mode {
    margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border);
    background: var(--surface-2); font-size: .86rem; line-height: 1.4; color: var(--text-soft);
}
.keto-mode strong { display: block; color: var(--text); margin-bottom: 2px; font-size: .9rem; }
.keto-mode em { font-style: normal; font-weight: 700; color: var(--brand); }
.keto-mode.edit { background: rgba(79,70,229,.08); border-bottom-color: rgba(79,70,229,.2); }
.keto-mode.warn { background: rgba(245,158,11,.12); border-bottom-color: rgba(245,158,11,.28); }
.keto-mode.warn em { color: #b45309; }
.keto-mode.mute { background: var(--surface-2); }
.keto-sheet-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap;
    padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
}
.keto-sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.keto-stamp { margin: 6px 0 0; font-size: .8rem; color: var(--muted); font-weight: 600; }
.keto-title-input {
    width: min(100%, 460px); font: inherit; font-size: 1.15rem; font-weight: 700;
    border: 0; border-bottom: 2px solid var(--border); background: transparent; color: var(--text);
    padding: 4px 0; margin-top: 4px;
}
.keto-title-input:focus { outline: none; border-bottom-color: var(--brand); }
.keto-sheet-titles h2 { margin: 4px 0 0; font-size: 1.15rem; letter-spacing: -.02em; }
.keto-block { padding: 14px 18px 6px; }
.keto-block-title {
    margin: 0 0 10px; font-size: .72rem; font-weight: 800; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted);
}
.keto-block-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin-bottom: 8px;
}
.keto-block-head .keto-block-title { margin-bottom: 4px; }
.keto-params {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px;
    padding: 0; background: transparent; border: 0;
}
.keto-params-day { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.keto-goals {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 0;
}
.keto-kpi, .keto-total {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.keto-kpi span, .keto-total span { display: block; font-size: .7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.keto-kpi strong, .keto-total strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.keto-kpi em, .keto-total em { display: block; font-style: normal; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.keto-kpi.hi, .keto-total.hi { background: rgba(79,70,229,.08); border-color: rgba(79,70,229,.22); }
.keto-totals { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 12px 0 4px; }
.keto-day-hint { margin: 0; padding: 0; font-size: .82rem; color: var(--muted); line-height: 1.4; max-width: 54rem; }
.keto-row-actions { padding: 0 18px 10px; }
.keto-del-row { white-space: nowrap; }
.keto-act-mute { color: var(--muted); font-size: .8rem; }
.keto-table .keto-g { min-width: 88px; }
.keto-table-wrap {
    padding: 0; border: 1px solid var(--border); border-radius: 12px;
    overflow-x: hidden; overflow-y: visible;
    max-width: 100%; min-width: 0;
    background: var(--surface);
}
.keto-catalog-empty {
    margin: 10px 0 0; padding: 10px 12px; border-radius: 10px;
    background: rgba(245,158,11,.12); color: #92400e; font-size: .86rem; font-weight: 600;
}
.keto-table { margin: 0; }
.keto-table thead th {
    position: sticky; top: 0; z-index: 1; background: var(--surface-2);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .03em;
}
.keto-table select, .keto-table input {
    width: 100%; min-width: 0; font: inherit; font-size: .84rem; padding: 7px 8px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
.keto-table td { vertical-align: middle; font-variant-numeric: tabular-nums; font-size: .84rem; }
.keto-food { min-width: 0; }
.keto-sheet.is-readonly .keto-table select,
.keto-sheet.is-readonly .keto-table input {
    background: var(--surface-2); color: var(--text-soft); cursor: default;
}
.keto-add-food { margin: 12px 18px 0; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 12px; }
.keto-add-food summary { cursor: pointer; font-weight: 600; color: var(--text-soft); }
.keto-custom-foods { margin-top: 14px; }
.keto-custom-head { margin: 0 0 8px; font-size: .82rem; font-weight: 700; color: var(--text-soft); }
.keto-custom-foods ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.keto-custom-foods li { font-size: .82rem; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.keto-custom-foods li span { display: block; color: var(--muted); font-size: .75rem; margin-top: 2px; }

.keto-catalog-link {
    margin: 8px 18px 16px; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2);
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.keto-catalog-link .keto-block-title { margin: 0 0 4px; }
.keto-catalog-link .keto-day-hint { margin: 0; max-width: 52ch; }
.keto-catalog-link .btn { flex: 0 0 auto; }
.table small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-top: 2px; }

/* ---- Catálogo de alimentos ---- */
.food-page {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 0 0 auto;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}
.food-bar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.food-bar-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
    width: 100%;
}
.food-bar-title h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; }
.food-bar-title p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; font-weight: 600; }
.food-bar-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    flex: 1 1 420px;
    min-width: 0;
}
.food-bar-tools .field.compact { min-width: 120px; flex: 0 1 160px; }
.food-search { flex: 1 1 220px !important; min-width: 0 !important; }
.food-bar-tools .btn { min-height: 40px; }
.food-btn-short { display: none; }
.food-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    margin: 0;
}
.food-kpi {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    color: inherit;
    font: inherit;
}
.food-kpi[aria-hidden="true"] { cursor: default; }
.food-kpi span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.food-kpi strong { font-size: 1.25rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.food-kpi.active {
    border-color: rgba(79, 70, 229, .35);
    background: linear-gradient(180deg, rgba(79, 70, 229, .08), var(--surface));
}
.food-kpi.active span, .food-kpi.active strong { color: var(--brand); }
.food-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 76px;
    overflow: auto;
}
.food-latest {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(15, 118, 110, .28);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(20, 184, 166, .10), rgba(79, 70, 229, .06));
}
.food-latest[hidden] { display: none !important; }
.food-latest-mark {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #0f766e;
}
.food-latest-name {
    font-size: 1.05rem;
    letter-spacing: -.01em;
    line-height: 1.25;
}
.food-latest-meta {
    margin: 0;
    font-size: .86rem;
    color: var(--text-soft);
    line-height: 1.4;
}
.food-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-weight: 600;
    font-size: .8rem;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.food-chip em {
    font-style: normal;
    font-size: .72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.food-chip.active {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    border-color: transparent;
    color: #fff;
}
.food-chip.active em { color: rgba(255, 255, 255, .85); }
.food-bar-note {
    margin: 0;
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.4;
}
.food-board {
    flex: 0 0 auto;
    min-height: 220px;
    display: flex;
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
}
.food-sheet {
    flex: 0 0 auto;
    min-height: 220px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}
.food-sheet-head,
.food-row {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) repeat(5, minmax(0, .55fr)) minmax(0, 1fr) minmax(0, .9fr);
    gap: 8px 12px;
    align-items: center;
    width: 100%;
}
.food-sheet--ro .food-sheet-head,
.food-sheet--ro .food-row {
    grid-template-columns: minmax(0, 1.6fr) repeat(5, minmax(0, .55fr)) minmax(0, 1.1fr);
}
.food-sheet-head {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.food-sheet-body {
    flex: 0 0 auto;
    min-height: 220px;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
.food-row {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    min-height: 72px;
}
.food-row[role="button"] { cursor: pointer; }
.food-row:hover,
.food-row:focus-visible {
    background: var(--surface-2);
    outline: none;
}
.food-row.is-custom {
    box-shadow: inset 3px 0 0 rgba(79, 70, 229, .45);
}
.food-td-name {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.food-av {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #fff;
    font-weight: 700;
    font-size: .82rem;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.food-row.is-custom .food-av {
    background: linear-gradient(135deg, var(--brand), var(--accent));
}
.food-id { min-width: 0; }
.food-name {
    display: block;
    font-weight: 650;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.food-sub {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    margin-top: 2px;
}
.food-td-num {
    font-variant-numeric: tabular-nums;
    min-width: 0;
}
.food-td-num strong { font-size: .92rem; font-weight: 650; }
.food-td-origin {
    font-size: .8rem;
    color: var(--text-soft);
    line-height: 1.35;
    min-width: 0;
}
.food-td-origin span {
    display: block;
    color: var(--muted);
    font-size: .72rem;
    margin-top: 2px;
}
.food-td-acts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.food-td-acts .btn { min-height: 34px; }
.food-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--muted);
}
.food-empty p {
    margin: 0 0 6px;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
}
.food-empty span { font-size: .86rem; }

.food-modal-card {
    width: min(720px, calc(100% - 24px));
    max-height: min(92dvh, 900px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.food-modal-card .form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}
.food-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.food-modal-head h2 { margin: 2px 0 4px; font-size: 1.2rem; }
.food-modal-sub { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; max-width: 46ch; }
.food-modal-body {
    padding: 14px 18px;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.food-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.food-span-2 { grid-column: 1 / -1; }
.food-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px max(14px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface-2);
}

@media (max-width: 1100px) {
    .food-sheet-head,
    .food-row {
        grid-template-columns: minmax(0, 1.4fr) repeat(5, minmax(0, .5fr)) minmax(0, .9fr) minmax(0, .85fr);
    }
    .food-sheet--ro .food-sheet-head,
    .food-sheet--ro .food-row {
        grid-template-columns: minmax(0, 1.4fr) repeat(5, minmax(0, .5fr)) minmax(0, 1fr);
    }
}
@media (max-width: 900px) {
    .food-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .food-sheet-head { display: none; }
    .food-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px 12px;
        padding: 14px;
        align-items: start;
    }
    .food-td-name { grid-column: 1 / -1; }
    .food-td-num::before {
        content: attr(data-label);
        display: block;
        font-size: .68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--muted);
        margin-bottom: 2px;
    }
    .food-td-origin { grid-column: 1 / -1; }
    .food-td-acts { grid-column: 1 / -1; justify-content: stretch; }
    .food-td-acts .btn { flex: 1; min-height: 40px; }
}
@media (max-width: 720px) {
    .food-btn-full { display: none; }
    .food-btn-short { display: inline; }
    .food-bar-tools .field.compact { flex: 1 1 100%; }
    .food-search { min-width: 0 !important; }
    .food-form-grid { grid-template-columns: 1fr; }
    .food-modal-card {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }
    .keto-catalog-link { margin: 8px 12px 14px; }
}

@media (max-width: 1100px) {
    .keto-layout { grid-template-columns: 1fr; }
    .keto-rail-list { max-height: 280px; }
    .keto-params, .keto-params-day { grid-template-columns: repeat(2, 1fr); }
    .keto-goals { grid-template-columns: repeat(3, 1fr); }
    .keto-totals { grid-template-columns: repeat(3, 1fr); }
    .hc-lab-grid { grid-template-columns: 1fr 1fr; }
    .hc-phe-kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
    .hc-grid-2, .hc-anam-grid, .hc-sheet-grid, .hc-edit-grid, .hc-sheet-head { grid-template-columns: 1fr; }
    .hc-sheet-block + .hc-sheet-block { border-left: 0; border-top: 1px solid var(--border); }
    .hc-sheet-block-wide { border-top: 1px solid var(--border); }
    .hc-tabs { width: 100%; }
    .hc-top-main {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 10px 12px;
    }
    .hc-back { grid-column: 1; justify-self: start; }
    .hc-top-actions { grid-column: 1 / -1; margin-left: 0; justify-self: stretch; align-items: stretch; max-width: 100%; }
    .hc-top-btns { justify-content: flex-end; }
    .hc-page .ficha-export-last { text-align: left; }
    .hc-identity { grid-column: 1 / -1; }
    .hc-page .card-head { align-items: flex-start; }
    .hc-page .ficha-map, .hc-sheet-map .ficha-map { height: 220px; }
}
@media (max-width: 640px) {
    .hc-ficha-modal, .hc-lab-view-modal {
        width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
        margin: 0; border-radius: 0;
    }
    .hc-ficha-modal #hcFichaEdit { max-height: 100dvh; }
    .hc-ficha-modal .modal-foot, .hc-lab-view-modal .modal-foot { padding: 12px 16px max(16px, env(safe-area-inset-bottom)); }
    .hc-ficha-edit-body { padding: 12px 14px 8px; }
    .hc-page input, .hc-page select, .hc-page textarea,
    .hc-ficha-modal input, .hc-ficha-modal select, .hc-ficha-modal textarea {
        font-size: 16px;
    }
}
@media (max-width: 560px) {
    .content:has(.hc-page) {
        padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }
    .hc-top { padding: 14px; border-radius: 14px; }
    .hc-avatar { width: 48px; height: 48px; border-radius: 14px; font-size: 1rem; }
    .hc-lab-grid, .keto-params { grid-template-columns: 1fr 1fr; }
    .hc-phe-kpis { grid-template-columns: 1fr 1fr; }
    .keto-goals { grid-template-columns: 1fr 1fr; }
    .hc-tab { padding: 11px 13px; font-size: .82rem; min-height: 44px; }
    .hc-presence-label { width: 100%; }
    .hc-presence-name { max-width: min(240px, 72vw); }
    .hc-page .ficha-dl > div { flex-direction: column; align-items: flex-start; gap: 2px; }
    .hc-page .ficha-dl dd { text-align: left; }
    .hc-page .card-head .btn { width: 100%; }
    .hc-top-actions .btn { min-height: 40px; }
    .hc-sheet-head, .hc-sheet-block, .hc-sheet-map { padding-left: 14px; padding-right: 14px; }
    .hc-visit-actions .btn, .hc-lab-card-head .btn, .row-actions .btn { min-height: 40px; }
    .keto-sheet-actions { width: 100%; }
    .keto-sheet-actions .btn { flex: 1; min-height: 44px; }
    .keto-hero { padding: 14px; }
    .keto-title-input, .keto-table select, .keto-table input { font-size: 16px; }
    .keto-goals, .keto-totals { grid-template-columns: 1fr 1fr; }
    .keto-params-day { grid-template-columns: 1fr; }
    .hc-chart-wrap { height: clamp(300px, 62vh, 520px); }
}

/* Perfil a pantalla completa */
.content.content-flush {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 16px 20px 24px;
    min-height: calc(100dvh - 110px);
    display: flex;
    flex-direction: column;
}
.content.content-flush.content-pt,
.content.content-flush.content-us,
.content.content-flush.content-food {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
    padding: 12px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.content.content-map {
    padding: 0;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.main .content.content-map { flex: 1 1 auto; min-height: 0; }
body:has(.content-map) .app-credit { display: none; }
.content:has(.pf-page) {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 16px max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    min-height: calc(100dvh - 110px);
    display: flex;
    flex-direction: column;
    overflow-x: clip;
}
.pf-page {
    display: flex; flex-direction: column; gap: 20px;
    width: 100%; flex: 1 1 auto; min-width: 0;
}
.pf-top {
    display: flex; flex-direction: column; gap: 14px;
    padding: 18px 20px 0; border-radius: 18px; color: #fff;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 55%, #6366f1 100%);
    box-shadow: 0 18px 40px -22px rgba(79,70,229,.65);
    min-width: 0; width: 100%;
}
.pf-top-main {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; min-width: 0; padding-bottom: 4px;
}
.pf-identity { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 280px; }
.pf-id-text { min-width: 0; flex: 1; }
.pf-kicker { margin: 0; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; opacity: .8; font-weight: 700; }
.pf-id-text h2, .pf-hero h2 {
    margin: 2px 0 0; font-size: clamp(1.12rem, 2.2vw, 1.55rem);
    overflow-wrap: anywhere; word-break: break-word;
}
.pf-hero-meta { margin: 6px 0 0; color: #c7d2fe; font-size: .88rem; overflow-wrap: anywhere; word-break: break-word; }
.pf-avatar {
    width: 58px; height: 58px; border-radius: 16px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1.25rem; font-weight: 800;
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22);
}
.pf-top-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: 100%; }
.pf-chip {
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
    color: #e0e7ff; font-size: .74rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
    max-width: 100%; overflow-wrap: anywhere;
}
.pf-chip.on { background: rgba(255,255,255,.22); color: #fff; }
.pf-tabs {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin: 0; padding: 0 0 12px;
    overflow: hidden;
    max-width: 100%;
}
.pf-tabs::-webkit-scrollbar { display: none; }
.pf-tab {
    flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
    color: #c7d2fe; font-size: .82rem; font-weight: 600; text-decoration: none;
    white-space: nowrap; border: 1px solid transparent;
}
.pf-tab:hover { background: rgba(255,255,255,.1); color: #fff; }
.pf-tab.is-on { background: #fff; color: #312e81; }
.pf-stage {
    flex: 1 1 auto; min-width: 0; min-height: 0;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; width: 100%;
}
.pf-stage-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; flex-shrink: 0;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.pf-stage-title { min-width: 0; flex: 1 1 220px; }
.pf-stage-title h2 { font-size: 1.12rem; overflow-wrap: anywhere; }
.pf-stage-title p { margin: 5px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; max-width: 72ch; overflow-wrap: anywhere; }
.pf-stage-body { flex: 1 1 auto; padding: 22px; min-width: 0; width: 100%; }
.pf-split {
    display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 24px; align-items: start;
}
.pf-rail { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.pf-rail-kicker {
    margin: 0; font-size: .7rem; font-weight: 800; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted);
}
.pf-stamp {
    display: flex; flex-direction: column; gap: 4px;
    padding: 16px; border-radius: 14px;
    background: var(--surface-2); border: 1px dashed var(--border);
}
.pf-stamp strong { font-size: 1rem; }
.pf-stamp span { font-size: .86rem; color: var(--text-soft); overflow-wrap: anywhere; }
.pf-work { min-width: 0; max-width: 640px; }
.pf-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px; align-content: start; width: 100%;
}
.pf-card {
    display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
    padding: 18px; border-radius: 16px; text-decoration: none; color: inherit;
    background: var(--surface-2); border: 1px solid var(--border);
    min-width: 0; min-height: 168px; transition: var(--tr);
}
.pf-card:hover { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.pf-card-ic {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto;
}
.pf-card strong { font-size: .98rem; color: var(--text); overflow-wrap: anywhere; }
.pf-card em { font-style: normal; font-size: .82rem; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; flex: 1; }
.pf-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin-top: 6px; }
.pf-card-go { font-size: .78rem; font-weight: 700; color: var(--brand); }
.pf-tile-st {
    font-size: .72rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap;
    background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.pf-tile-st.on { background: rgba(22,163,74,.12); color: #15803d; border-color: transparent; }
.pf-submit { align-self: flex-start; }
.pf-status { margin: 0; font-size: .88rem; color: var(--text-soft); line-height: 1.45; overflow-wrap: anywhere; }
.pf-legal { margin: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.pf-legal summary { cursor: pointer; padding: 10px 14px; font-size: .84rem; font-weight: 700; color: var(--text-soft); }
.pf-legal p { margin: 0; padding: 0 14px 14px; font-size: .82rem; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.pf-account-dl { margin: 0; }
.pf-account-dl dd { overflow-wrap: anywhere; word-break: break-word; }
.pf-section-label {
    margin: 4px 0 0; font-size: .72rem; font-weight: 800; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted);
}
.pf-reg { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 0; min-width: 0; background: var(--surface-2); }
.pf-reg legend { padding: 0 6px; font-size: .82rem; font-weight: 700; color: var(--text-soft); }
.pf-radio, .pf-check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-size: .9rem; min-width: 0; }
.pf-radio span, .pf-check span { min-width: 0; overflow-wrap: anywhere; }
.pf-radio input, .pf-check input { margin-top: 3px; flex-shrink: 0; }
.pf-constancia { margin: 8px 0 0; font-size: .86rem; color: var(--text-soft); overflow-wrap: anywhere; }
.pf-label { margin: 0 0 8px; font-size: .82rem; font-weight: 700; color: var(--text-soft); }
.pf-sign-layout {
    display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.2fr); gap: 22px;
    width: 100%; min-width: 0;
}
.pf-sign-preview, .pf-sign-tools { min-width: 0; }
.pf-sign-tools { display: flex; flex-direction: column; gap: 12px; }
.pf-sign-tools input[type=file] { max-width: 100%; }
.pf-sign-frame {
    min-height: 220px; border: 1px dashed var(--border); border-radius: 14px;
    background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 12px, var(--surface) 12px, var(--surface) 24px);
    display: grid; place-items: center; padding: 16px; overflow: hidden; width: 100%;
}
.pf-sign-frame img { max-width: 100%; max-height: 200px; width: auto; height: auto; object-fit: contain; }
.pf-sign-pad-wrap { width: 100%; min-width: 0; overflow: hidden; border-radius: 12px; }
.pf-sign-pad {
    display: block; width: 100%; max-width: 100%; height: 220px;
    touch-action: none; cursor: crosshair;
    border: 1px solid var(--border); border-radius: 12px; background: #fff;
    box-sizing: border-box;
}
.pf-sign-actions { justify-content: flex-start; }
.pf-sign-msg { margin: 0; font-size: .86rem; color: var(--danger); overflow-wrap: anywhere; }
.pf-sign-msg.ok { color: var(--success); }
.pf-page .pk-item { min-width: 0; flex-wrap: wrap; }
.pf-page .pk-info small { overflow-wrap: anywhere; }
.pf-pin-form { min-width: 0; }
.pf-pin-digits { width: 100%; }
.pf-pin-form .stepup-pin-input { max-width: 100%; }
.pf-pin-hint {
    margin: 0; padding: 12px 14px; border-radius: 12px;
    background: rgba(79,70,229,.08); color: var(--text); font-size: .86rem; line-height: 1.45;
}
.pf-auth-ways { display: grid; grid-template-columns: 1fr; gap: 12px; width: 100%; min-width: 0; }
.pf-auth-ways.has-pk { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pf-auth-way {
    display: flex; flex-direction: column; gap: 10px;
    border: 1px solid var(--border); border-radius: 14px;
    padding: 16px; background: var(--surface-2); min-width: 0;
}
.pf-auth-pk { border-color: rgba(79,70,229,.28); background: rgba(79,70,229,.05); }
.pf-auth-way h3 { font-size: .95rem; }
.pf-auth-way > p { margin: 0; font-size: .84rem; color: var(--muted); overflow-wrap: anywhere; }
.pf-auth-way .pf-submit,
.pf-auth-way .btn { align-self: stretch; width: 100%; white-space: normal; margin-top: auto; }
.pf-auth-pk .btn { min-height: 44px; }

/* Historial clínico */
.hist-board {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; width: 100%;
}
.hist-board-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
    padding: 18px 20px; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.hist-board-head h2 { font-size: 1.08rem; }
.hist-board-sub { margin: 6px 0 0; color: var(--muted); font-size: .84rem; max-width: 72ch; }
.hist-board-head .hc-stamp { margin: 10px 0 0; }
.hist-board-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.hist-card {
    display: grid; grid-template-columns: minmax(150px, 200px) 1fr; gap: 16px;
    border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
    background: var(--surface);
}
.hist-card-rail { display: flex; flex-direction: column; gap: 6px; padding-right: 8px; border-right: 1px solid var(--border); }
.hist-badge {
    display: inline-flex; width: fit-content; font-weight: 700; font-size: .75rem;
    padding: 3px 10px; border-radius: 999px; background: #312e81; color: #fff;
}
.hist-card-rail time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-card-rail em { font-style: normal; font-size: .75rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.hist-card-main h3 { font-size: .98rem; }
.hist-id { margin: 2px 0 0; font-size: .82rem; color: var(--text-soft); }
.hist-sum { margin: 8px 0 0; font-size: .88rem; color: var(--text); line-height: 1.45; }
.hist-fields { margin: 10px 0 0; display: grid; gap: 6px; }
.hist-kv { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px; padding-top: 6px; border-top: 1px dashed var(--border); }
.hist-kv dt { margin: 0; font-size: .75rem; font-weight: 700; color: var(--muted); }
.hist-kv dd { margin: 0; font-size: .86rem; white-space: pre-wrap; word-break: break-word; }
.hist-more { margin: 6px 0 0; font-size: .78rem; color: var(--muted); }
.hist-card-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.hist-card.hist-create { box-shadow: inset 3px 0 0 #16a34a; }
.hist-card.hist-update { box-shadow: inset 3px 0 0 #4f46e5; }
.hist-card.hist-del { box-shadow: inset 3px 0 0 #dc2626; }
.hist-card.hist-export { box-shadow: inset 3px 0 0 #7c3aed; }
.hist-card.hist-export .hist-badge { background: #6d28d9; }

/* Auditoría por tipos */
.adt-page { display: flex; flex-direction: column; gap: 22px; width: 100%; flex: 1; }
.adt-hero {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap;
    padding: 22px 24px; border-radius: var(--radius); color: #fff;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%);
    box-shadow: var(--shadow);
}
.adt-kicker { margin: 0 0 4px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; opacity: .75; font-weight: 700; }
.adt-hero h2 { font-size: 1.45rem; }
.adt-hero-sub { margin: 8px 0 0; color: #c7d2fe; font-size: .92rem; max-width: 62ch; }
.adt-hero-stat { text-align: right; }
.adt-hero-stat strong { display: block; font-size: 2rem; font-weight: 800; line-height: 1; }
.adt-hero-stat span { font-size: .78rem; color: #a5b4fc; }
.adt-types {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.adt-type {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    color: inherit; transition: var(--tr);
}
.adt-type:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.adt-type.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.16); }
.adt-type-ic {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
}
.adt-type-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.adt-type-body strong { font-size: .88rem; color: var(--text); }
.adt-type-body em { font-style: normal; font-size: .74rem; color: var(--muted); }
.tone-indigo { background: rgba(79,70,229,.14); color: #4338ca; }
.tone-teal { background: rgba(13,148,136,.14); color: #0f766e; }
.tone-blue { background: rgba(37,99,235,.14); color: #1d4ed8; }
.tone-violet { background: rgba(124,58,237,.14); color: #6d28d9; }
.tone-amber { background: rgba(245,158,11,.16); color: #b45309; }
.tone-slate { background: var(--surface-2); color: var(--text-soft); }
.adt-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adt-toolbar .search { flex: 1; min-width: min(100%, 260px); }
.adt-count { margin-left: auto; font-size: .82rem; color: var(--muted); font-weight: 600; }
.adt-boards, .adt-ledger { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.adt-ledger { grid-template-columns: 1fr; }
.adt-board {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; min-width: 0;
}
.adt-board-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.adt-board-title { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.adt-board-title h3 { font-size: 1rem; }
.adt-board-title p { margin: 3px 0 0; font-size: .8rem; color: var(--muted); }
.adt-feed { list-style: none; margin: 0; padding: 8px 12px 12px; display: flex; flex-direction: column; }
.adt-event {
    display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: start;
    padding: 12px 6px; border-bottom: 1px dashed var(--border);
}
.adt-event:last-child { border-bottom: 0; }
.adt-av {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 700;
}
.adt-event-main strong { display: block; font-size: .9rem; }
.adt-event-meta { display: block; margin-top: 2px; font-size: .78rem; color: var(--muted); }
.adt-event-detail { margin: 6px 0 0; font-size: .84rem; color: var(--text-soft); line-height: 1.45; word-break: break-word; }
.adt-event time { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 4px; }

@media (max-width: 1100px) {
    .pf-sign-layout,
    .pf-split { grid-template-columns: 1fr; }
    .pf-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pf-work { max-width: none; }
    .hist-card { grid-template-columns: 1fr; }
    .hist-card-rail { border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 10px; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .adt-boards { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .content.content-flush { padding: 14px 12px 20px; }
    .content.content-flush.content-hours { padding: 10px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); }
    body.hrs-team-app .content.content-flush.content-hours {
        padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        overflow: hidden;
    }
    .content.content-flush.content-pt,
    .content.content-flush.content-us { padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
    .content.content-flush.content-map { padding: 0; }
    .content:has(.hc-page),
    .content:has(.pf-page) {
        padding: 12px max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }
    .pf-top { padding: 16px 14px 0; border-radius: 16px; }
    .pf-tabs { margin: 0 -14px; padding: 0 14px 12px; }
    .pf-top-chips { justify-content: flex-start; }
    .pf-avatar { width: 48px; height: 48px; font-size: 1.15rem; border-radius: 14px; }
    .pf-cards { grid-template-columns: 1fr; }
    .pf-card { min-height: 0; }
    .pf-stage-head { padding: 16px; }
    .pf-stage-body { padding: 16px; }
    .pf-stage-head .btn,
    .pf-submit,
    .pf-sign-actions .btn,
    .pf-pin-form .btn {
        width: 100%;
        white-space: normal;
        min-height: 44px;
    }
    .pf-pin-form .stepup-pin-input {
        font-size: 1.25rem;
        letter-spacing: .28em;
        padding: 8px 10px;
        height: 52px;
    }
    .pf-sign-pad { height: 180px; }
    .pf-auth-ways.has-pk { grid-template-columns: 1fr; }
    .pf-pin-digits { grid-template-columns: 1fr; }
    .hist-kv { grid-template-columns: 1fr; }
    .adt-event { grid-template-columns: 40px 1fr; }
    .adt-event time { grid-column: 2; padding-top: 0; }
    .adt-count { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
    .pf-check { font-size: .84rem; }
}

@media (prefers-color-scheme: dark) {
    .hc-top { box-shadow: none; }
    .keto-card.is-active { background: rgba(99,102,241,.12); }
    .keto-kpi.hi, .keto-total.hi { background: rgba(99,102,241,.16); }
    .keto-mode.edit { background: rgba(99,102,241,.14); }
    .keto-title-input, .keto-table select, .keto-table input { color: var(--text); }
    .tone-indigo { background: rgba(129,140,248,.18); color: #c7d2fe; }
    .tone-teal { background: rgba(45,212,191,.16); color: #99f6e4; }
    .tone-blue { background: rgba(96,165,250,.16); color: #bfdbfe; }
    .tone-violet { background: rgba(167,139,250,.18); color: #ddd6fe; }
    .tone-amber { background: rgba(251,191,36,.16); color: #fde68a; }
    .hc-lab-view-stamp { background: rgba(8,145,178,.16); border-color: rgba(34,211,238,.28); color: #a5f3fc; }
    .notify-item.is-unread { background: rgba(99,102,241,.16); border-color: rgba(165,180,252,.35); }
    .pf-top { box-shadow: none; }
    .pf-tab.is-on { background: #eef2ff; color: #312e81; }
    .pf-sign-pad { background: #fff; }
    .pf-pin-hint { background: rgba(129,140,248,.16); }
}

.notify-wrap { position: relative; }
.notify-bell { position: relative; }
.notify-badge {
    position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: #dc2626; color: #fff; font-size: .65rem; font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.notify-panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 92vw);
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 18px 40px -18px rgba(15,23,42,.45); z-index: 50; overflow: hidden;
}
.notify-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.notify-head strong { display: block; }
.notify-head p { margin: 4px 0 0; font-size: .78rem; color: var(--muted); }
.notify-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.notify-item {
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 12px 10px; background: var(--surface);
}
.notify-item.is-unread { border-color: #a5b4fc; background: #eef2ff; }
.notify-item strong { display: block; font-size: .9rem; }
.notify-item p { margin: 6px 0 0; font-size: .82rem; color: var(--text-soft); line-height: 1.4; }
.notify-item time { display: block; margin-top: 8px; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.notify-acts { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.notify-item.is-login { border-left: 4px solid var(--brand); }
.notify-details { margin-top: 8px; }
.notify-details summary { cursor: pointer; font-size: .78rem; font-weight: 700; color: var(--brand); }
.notify-details dl { margin: 8px 0 0; display: grid; gap: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.notify-details dl > div { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 8px; padding: 6px 9px; border-top: 1px solid var(--border); }
.notify-details dl > div:first-child { border-top: 0; }
.notify-details dt { font-size: .7rem; color: var(--muted); font-weight: 600; }
.notify-details dd { margin: 0; font-size: .76rem; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.notify-details a { color: var(--brand); }

.hc-lab-history { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hc-lab-card {
    border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px 16px;
    background: var(--surface); min-width: 0;
}
.hc-lab-card-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    margin-bottom: 12px;
}
.hc-lab-card-head h3 { font-size: 1rem; margin: 0; }
.hc-lab-card-notes { margin: 12px 0 0; font-size: .86rem; color: var(--text); }
.hc-lab-card .hc-lab-view-grid { margin-top: 4px; }

.hist-export-list { gap: 10px; }
.hist-export-row {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--surface);
}
.hist-export-row time { display: block; margin-top: 4px; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-export-row em { display: inline-block; margin-left: 8px; font-style: normal; font-size: .75rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; }
.hist-export-row .hist-sum { margin-top: 6px; font-size: .82rem; color: var(--text-soft); }
.hist-export-row .row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.hist-board-audit-head {
    padding: 16px 20px 0; border-top: 1px solid var(--border);
}
.hist-board-audit-head h3 { font-size: .98rem; margin: 0; }
.hist-board-audit-head p { margin: 4px 0 0; font-size: .82rem; color: var(--muted); }

/* Historia · Auditoría clasificada */
.hc-audit { display: flex; flex-direction: column; gap: 16px; }
.hc-audit-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px 22px;
}
.hc-audit-hero h2 { margin: 4px 0 6px; font-size: 1.28rem; }
.hc-audit-hero p { margin: 0; color: var(--muted); max-width: 72ch; }
.hc-audit-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.hc-audit-kpi {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 16px;
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}
.hc-audit-kpi span { display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hc-audit-kpi strong { display: block; margin-top: 4px; font-size: 1.35rem; }
.hc-audit-kpi.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.hc-audit-kpi.kind-auth strong { color: #7c3aed; }
.hc-audit-kpi.kind-create strong { color: #16a34a; }
.hc-audit-kpi.kind-update strong { color: #4f46e5; }
.hc-audit-kpi.kind-delete strong { color: #dc2626; }
.hc-audit-kpi.kind-view strong { color: #0284c7; }
.hc-audit-kpi.kind-export strong { color: #b45309; }
.hc-audit-toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.hc-audit-search { flex: 1 1 220px; min-width: 0; }
.hc-audit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hc-audit-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-soft);
}
.hc-audit-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.hc-audit-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
}
.hc-audit-group-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.hc-audit-group-head h3 { margin: 0; font-size: 1rem; }
.hc-audit-group-head span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.hc-audit-list { list-style: none; margin: 0; padding: 6px 0; }
.hc-audit-item {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}
.hc-audit-item:last-child { border-bottom: 0; }
.hc-audit-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; background: var(--brand); }
.hc-audit-item.kind-auth .hc-audit-dot { background: #7c3aed; }
.hc-audit-item.kind-create .hc-audit-dot { background: #16a34a; }
.hc-audit-item.kind-update .hc-audit-dot { background: #4f46e5; }
.hc-audit-item.kind-delete .hc-audit-dot { background: #dc2626; }
.hc-audit-item.kind-view .hc-audit-dot { background: #0284c7; }
.hc-audit-item.kind-export .hc-audit-dot { background: #b45309; }
.hc-audit-item-main { min-width: 0; }
.hc-audit-item-main strong { display: block; font-size: .95rem; }
.hc-audit-item-main p { margin: 4px 0 0; color: var(--text-soft); font-size: .86rem; }
.hc-audit-meta { text-align: right; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hc-audit-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hc-audit-tag {
    font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
    padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft);
}
.hc-audit-tag.official { background: rgba(124,58,237,.12); color: #6d28d9; }
@media (max-width: 720px) {
    .hc-audit-item { grid-template-columns: 12px 1fr; }
    .hc-audit-meta { grid-column: 2; text-align: left; margin-top: 4px; white-space: normal; }
}

/* ============================================================
   Scroll del sistema: el documento se desplaza SOLO en vertical
   en todas las vistas (PC y móvil). Nunca horizontal.
   ============================================================ */
html, body {
    height: auto !important;
    max-height: none !important;
    max-width: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
}
html:has(body.pt-app),
html:has(body.us-app),
html:has(body.hc-app),
html:has(body.food-app),
html:has(body.hrs-app),
html:has(body.hrs-team-app),
html:has(body.hrs-insight-app),
html:has(body.att-portal) {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}
body.pt-app,
body.us-app,
body.hc-app,
body.food-app,
body.hrs-app,
body.hrs-team-app,
body.hrs-insight-app,
body.att-portal,
body:has(.content-map) {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}
.app-shell,
.main,
.content:not(.content-map),
.content.content-pt,
.content.content-us,
.content.content-food,
.content.content-hc,
.content.content-hours,
.content.content-flush,
.pt-page, .pt-board, .pt-sheet, .pt-sheet-body,
.us-page, .us-list-card, .us-table-wrap,
.food-page, .food-board, .food-sheet, .food-sheet-body,
.hc-page, .hc-panel.active, .keto-app, .keto-layout, .keto-sheet, .keto-table-wrap, .pf-page,
.hrs-page, .hrs-workspace, .hrs-panel, .hrs-panel-fill.active,
.hrs-grid, .hrs-grid-fill, .hrs-fill-card, .hrs-list-card,
.hrs-fee-work, .hrs-scroll, .hrs-fill-card .card-body {
    max-width: 100%;
    min-width: 0;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
}

/* Listas largas: que crezcan con el documento. Si el recuadro se
   encoge (flex:1) y overflow-y queda en visible, las filas se recortan. */
body.food-app .content.content-food,
body.food-app .content.content-flush,
body.pt-app .content.content-pt,
body.us-app .content.content-us,
body.food-app .food-page,
body.food-app .food-board,
body.food-app .food-sheet,
body.food-app .food-sheet-body,
body.pt-app .pt-page,
body.pt-app .pt-board,
body.pt-app .pt-sheet,
body.pt-app .pt-sheet-body,
body.us-app .us-page,
body.us-app .us-list-card,
body.us-app .us-table-wrap {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
}
body.food-app .food-sheet-body,
body.pt-app .pt-sheet-body,
body.us-app .us-table-wrap {
    min-height: 220px !important;
}
.content.content-map {
    overflow: hidden;
    min-height: 0;
}

/* Mapa: ocupa el alto de la ventana. Sin esto .mapx queda en 0 px. */
html:has(body:has(.content-map)),
body:has(.content-map) {
    height: 100% !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}
body:has(.content-map) .app-shell,
body:has(.content-map) .main {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
}
body:has(.content-map) .topbar {
    flex: 0 0 auto;
    position: relative;
    top: auto;
}
body:has(.content-map) .content.content-map {
    flex: 1 1 auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: hidden !important;
}
body:has(.content-map) .mapx {
    flex: 1 1 auto;
    height: auto !important;
    min-height: 0;
    max-height: none;
}
body:has(.content-map) .mapx-map-wrap {
    min-height: 0;
    height: 100%;
    align-self: stretch;
}
.leaflet-container,
.leaflet-container img,
.leaflet-container canvas,
.leaflet-tile,
.leaflet-marker-icon {
    max-width: none !important;
}
.table th, .table td,
.hrs-entry, .hrs-entry-desc, .hrs-person-who, .hrs-fee-who,
.pt-name, .dsh-hero-title, .dsh-hero-sub {
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 860px) {
    html, body {
        overflow-x: hidden;
        max-width: 100%;
    }
    .app-shell, .main, .content, .hrs-page, .hc-page, .pt-page, .us-page, .pf-page {
        overflow-x: hidden;
        max-width: 100%;
    }
    .table-wrap, .us-table-wrap, .keto-table-wrap, .hc-page .table-wrap,
    .pt-sheet-body, .food-sheet-body, .hrs-scroll {
        overflow-x: hidden !important;
        overflow-y: visible !important;
        max-width: 100%;
    }
    .hc-page .table,
    .us-page .table,
    .hrs-page .table {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
    }
    .hc-page .table thead { display: none; }
    .hc-page .table, .hc-page .table tbody, .hc-page .table tr {
        display: block;
        width: 100%;
    }
    .hc-page .table tr {
        padding: 10px 8px;
        margin-bottom: 10px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
    }
    .hc-page .table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border-bottom: 0;
        padding: 6px 4px;
        white-space: normal;
    }
    .hc-page .table td.row-actions,
    .hc-page .table th:last-child,
    .hc-page .row-actions {
        flex-wrap: wrap;
        white-space: normal;
        justify-content: flex-start;
    }
    .hc-tabs, .pf-tabs, .hrs-tabs {
        flex-wrap: wrap;
        overflow-x: hidden;
    }
    .hc-tab, .hrs-tab, .pf-tab { flex: 1 1 auto; min-width: 0; }
    .field.compact, .search { min-width: 0; }
    .hrs-fee { grid-template-columns: 1fr; }
    .hrs-time-row { grid-template-columns: 1fr 1fr; }
    .hrs-calc { grid-column: 1 / -1; min-width: 0; width: 100%; }
    .keto-params, .keto-params-day, .keto-goals, .keto-totals {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .keto-table thead,
    .hc-page .keto-table thead { display: none; }
    .keto-table, .keto-table tbody, .keto-table tr,
    .hc-page .keto-table, .hc-page .keto-table tbody, .hc-page .keto-table tr {
        display: block; width: 100%;
    }
    .keto-table tr, .hc-page .keto-table tr {
        padding: 10px;
        margin-bottom: 10px;
        border: 1px solid var(--border);
        border-radius: 12px;
    }
    .keto-table td, .hc-page .keto-table td {
        display: block;
        width: 100%;
        padding: 6px 0;
        white-space: normal;
        justify-content: stretch;
    }
    .keto-table td[data-label]::before,
    .hc-page .keto-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: .68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--muted);
        margin-bottom: 4px;
    }
    .keto-del-row, .keto-food { white-space: normal; min-width: 0; }
    .modal-card, .food-modal-card {
        max-width: 100%;
        width: min(100%, calc(100% - 16px));
    }
    .dsh-hero-actions { width: 100%; }
    .dsh-hero-title { font-size: 1.45rem; overflow-wrap: anywhere; }
}

/* El documento se desplaza en vertical en PC y móvil. Sin scroll horizontal. */
.content:not(.content-map) {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    touch-action: pan-y;
}

/* ---------- Evaluación social PKU (historia.php · pestaña social) ---------- */
.sv-app { display: grid; gap: 14px; min-width: 0; }
.sv-app [hidden] { display: none !important; }
.sv-layout { display: grid; grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); gap: 14px; align-items: start; min-width: 0; }
/* Mientras se completa una evaluación, el formulario ocupa todo el ancho. */
.sv-app.is-editing .sv-layout { grid-template-columns: minmax(0, 1fr); }
.sv-app.is-editing .sv-rail { display: none; }
.sv-rail-item {
    display: grid; gap: 5px; width: 100%; text-align: left; margin-bottom: 8px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
    color: inherit; font: inherit; cursor: pointer; transition: border-color var(--tr), box-shadow var(--tr);
}
.sv-rail-item:hover { border-color: var(--brand); }
.sv-rail-item.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.14); background: var(--surface); }
.sv-rail-item strong { font-size: .88rem; }
.sv-rail-item small { font-size: .74rem; color: var(--muted); }
.sv-rail-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.sv-status {
    display: inline-flex; align-items: center; min-height: 20px; padding: 0 8px; border-radius: 999px;
    font-size: .68rem; font-weight: 700; white-space: nowrap;
}
.sv-status.is-ok { background: rgba(22,163,74,.13); color: #15803d; }
.sv-status.is-warn { background: rgba(245,158,11,.16); color: #b45309; }
.sv-status.is-bad { background: rgba(239,68,68,.14); color: #b91c1c; }
.sv-status.is-off { background: rgba(148,163,184,.2); color: #64748b; }
.sv-mini-bar { display: block; height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.sv-mini-bar i { display: block; height: 100%; background: var(--warning); }

.sv-sheet {
    border: 1px solid var(--border); border-radius: 16px; background: var(--surface); min-width: 0; overflow: clip;
    container: svsheet / inline-size;
}
.sv-empty { padding: 28px 16px; text-align: center; }
.sv-toolbar { padding: 16px 18px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.sv-toolbar-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sv-toolbar-title { min-width: 0; flex: 1 1 260px; }
.sv-toolbar h2 { margin: 2px 0 0; font-size: 1.15rem; }
.sv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sv-progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.sv-progress-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.sv-progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width var(--tr); }
.sv-progress span { font-size: .78rem; color: var(--text-soft); }

.sv-alerts { display: grid; gap: 8px; padding: 12px 18px 0; }
.sv-alerts:empty { display: none; }
.sv-alert { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: .86rem; line-height: 1.4; }
.sv-alert.is-bad { background: rgba(239,68,68,.12); color: #b91c1c; font-weight: 600; }
.sv-alert.is-warn { background: rgba(245,158,11,.14); color: #92400e; }
.sv-alert.is-info { background: #eef2ff; color: #3730a3; }
.sv-indicators { padding: 12px 18px 0; }
.sv-indicators:empty { display: none; }
.sv-ind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 8px; }
.sv-ind { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); border-left-width: 4px; min-width: 0; }
.sv-ind span { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.sv-ind strong { display: block; margin-top: 3px; font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.sv-ind em { display: block; font-style: normal; font-size: .74rem; color: var(--text-soft); line-height: 1.3; overflow-wrap: anywhere; }
.sv-ind.is-ok { border-left-color: var(--success); }
.sv-ind.is-warn { border-left-color: var(--warning); }
.sv-ind.is-bad { border-left-color: var(--danger); }
.sv-ind-box { margin: 4px 0 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.sv-ind-box summary { cursor: pointer; padding: 10px 14px; font-size: .84rem; font-weight: 700; color: var(--text-soft); }
.sv-ind-box .sv-indicators { padding: 0 14px 14px; }
.sv-ind-box .keto-block-title { display: none; }

/* Navegación por secciones en la vista de lectura */
.sv-nav { display: flex; gap: 6px; padding: 12px 18px 0; overflow-x: auto; scrollbar-width: thin; }
.sv-nav-chip {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 4px 9px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft); font: inherit; font-size: .74rem; cursor: pointer;
}
.sv-nav-chip b { color: var(--text); }
.sv-nav-chip.is-done { border-color: rgba(22,163,74,.45); background: rgba(22,163,74,.1); }
.sv-nav-chip.is-off { opacity: .5; }

/* ---- Asistente: pasos + sección actual ---- */
.sv-wiz { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.sv-steps {
    display: flex; gap: 6px; padding: 12px 14px; overflow-x: auto; scrollbar-width: thin;
    border-bottom: 1px solid var(--border); background: var(--surface-2); scroll-snap-type: x proximity;
}
.sv-step {
    display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 40px; padding: 6px 12px 6px 6px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-soft);
    font: inherit; font-size: .8rem; text-align: left; cursor: pointer; scroll-snap-align: center;
    transition: border-color var(--tr), background var(--tr), color var(--tr);
}
.sv-step b {
    display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .78rem; font-variant-numeric: tabular-nums;
}
.sv-step-title { display: none; }
.sv-step em { font-style: normal; font-size: .72rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.sv-step:hover { border-color: var(--brand); }
.sv-step.is-done b { background: var(--success); border-color: var(--success); color: #fff; }
.sv-step.is-current { border-color: var(--brand); background: rgba(79,70,229,.1); color: var(--text); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.sv-step.is-current b { background: var(--brand); border-color: var(--brand); color: #fff; }
.sv-step.is-current .sv-step-title { display: inline; font-weight: 700; }
.sv-step.is-off { opacity: .45; cursor: not-allowed; }
.sv-wiz-main { min-width: 0; padding: 0 18px 0; }
.sv-wiz .sv-sec { display: none; border-bottom: 0; padding-top: 18px; }
.sv-wiz .sv-sec.is-current { display: block; }

@container svsheet (min-width: 860px) {
    .sv-wiz { grid-template-columns: 250px minmax(0, 1fr); }
    .sv-steps {
        flex-direction: column; gap: 4px; padding: 14px 10px; overflow: visible;
        border-bottom: 0; border-right: 1px solid var(--border);
    }
    .sv-step { width: 100%; border-radius: 12px; border-color: transparent; background: transparent; padding: 6px 10px 6px 6px; }
    .sv-step:hover { background: var(--surface); }
    .sv-step.is-current { background: var(--surface); }
    .sv-step-title, .sv-step.is-current .sv-step-title { display: block; flex: 1; min-width: 0; font-size: .8rem; line-height: 1.25; }
    .sv-wiz-main { padding: 0 24px; }
}

/* ---- Sección y preguntas ---- */
.sv-sec { padding: 16px 0 6px; scroll-margin-top: 140px; }
.sv-sec-head { display: flex; align-items: center; gap: 12px; }
.sv-sec-head h3 { margin: 0; font-size: 1.08rem; letter-spacing: -.01em; }
.sv-sec-head p { margin: 2px 0 0; font-size: .76rem; color: var(--muted); }
.sv-sec-n {
    display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 800; font-size: .95rem;
}
.sv-sec-prog {
    margin-left: auto; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
    font-size: .74rem; color: var(--text-soft); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.sv-sec-intro { margin: 12px 0 4px; font-size: .86rem; color: var(--text-soft); line-height: 1.5; }
.sv-script {
    margin: 10px 0; padding: 12px 16px; border-left: 4px solid var(--brand); border-radius: 0 12px 12px 0;
    background: var(--surface-2); font-style: italic; font-size: .9rem; line-height: 1.6; color: var(--text);
}
.sv-q {
    padding: 14px 16px; margin: 12px 0; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
    transition: border-color var(--tr), box-shadow var(--tr);
}
.sv-q:focus-within { border-color: rgba(79,70,229,.55); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.sv-q.is-missing { border-color: rgba(239,68,68,.6); background: rgba(239,68,68,.04); }
.sv-q-control { background: var(--surface-2); }
.sv-q-head { display: flex; align-items: flex-start; gap: 10px; }
.sv-q-id {
    flex: 0 0 auto; min-width: 2.6em; padding: 2px 6px; border-radius: 7px; background: rgba(79,70,229,.1);
    font-weight: 800; font-size: .76rem; color: var(--brand); text-align: center; font-variant-numeric: tabular-nums;
}
.sv-q-id:empty { display: none; }
.sv-q-text { margin: 0; flex: 1 1 auto; min-width: 0; font-size: .96rem; font-weight: 600; line-height: 1.4; }
.sv-req { color: var(--danger); display: none; }
.sv-q.is-req .sv-req { display: inline; }
.sv-sug {
    flex: 0 0 auto; font-size: .66rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
    background: rgba(59,130,246,.13); color: #1d4ed8; white-space: nowrap;
}
.sv-q-body { margin-top: 12px; display: grid; gap: 10px; min-width: 0; }
.sv-note, .sv-hint { margin: 8px 0 0; font-size: .78rem; color: var(--muted); line-height: 1.4; }
.sv-q-body .sv-note, .sv-q-body .sv-hint { margin: 0; }
.sv-logic { margin: 8px 0 0; font-size: .78rem; color: #b45309; font-style: italic; }
.sv-warn { margin: 8px 0 0; font-size: .8rem; color: #b45309; font-weight: 600; }

/* Opciones: tarjetas táctiles con marca visible (radio redondo, casilla cuadrada) */
.sv-opts { display: grid; gap: 8px; }
.sv-opts.is-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.sv-opts.is-inline { display: flex; flex-wrap: wrap; }
.sv-opt { position: relative; display: flex; cursor: pointer; min-width: 0; }
.sv-opts.is-inline .sv-opt { flex: 0 1 auto; min-width: 110px; }
.sv-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sv-opt span {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 10px 14px;
    border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: .9rem; line-height: 1.3; transition: background var(--tr), border-color var(--tr), box-shadow var(--tr);
}
.sv-opt em { font-style: normal; min-width: 0; overflow-wrap: anywhere; }
.sv-mark {
    position: relative; flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--muted); background: var(--surface); transition: border-color var(--tr), background var(--tr);
}
.sv-opt input[type="checkbox"] + span .sv-mark { border-radius: 6px; }
.sv-opt:hover span { border-color: var(--brand); }
.sv-opt input:checked + span { background: rgba(79,70,229,.1); border-color: var(--brand); font-weight: 600; box-shadow: 0 0 0 1px var(--brand) inset; }
.sv-opt input:checked + span .sv-mark { border-color: var(--brand); background: var(--brand); }
.sv-opt input[type="radio"]:checked + span .sv-mark::after {
    content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff;
}
.sv-opt input[type="checkbox"]:checked + span .sv-mark::after {
    content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.sv-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.sv-opt input:disabled + span { cursor: default; }
.sv-count { margin: 0; font-size: .76rem; color: var(--muted); font-weight: 600; }

.sv-select, .sv-text, .sv-num {
    width: 100%; max-width: 560px; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
}
.sv-num { max-width: 160px; font-variant-numeric: tabular-nums; }
textarea.sv-text { max-width: none; resize: vertical; min-height: 96px; }
.sv-select:focus, .sv-text:focus, .sv-num:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.sv-pair { display: flex; gap: 12px; flex-wrap: wrap; }
.sv-pair .field { width: 160px; }
.sv-pair input { min-height: 46px; font-size: 1rem; }

/* Grillas (FIES, frases de acuerdo): cada fila es una tarjeta con botones segmentados */
.sv-grid { display: grid; gap: 8px; }
.sv-grid-row {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.sv-grid-label { display: flex; gap: 8px; font-size: .9rem; line-height: 1.4; }
.sv-grid-label b { flex: 0 0 auto; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; padding-top: 1px; }
.sv-seg { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 6px; }
.sv-seg.is-long { grid-template-columns: minmax(0, 1fr); }
.sv-seg .sv-opt span { justify-content: center; text-align: center; min-height: 42px; padding: 8px 10px; font-size: .84rem; background: var(--surface); }
.sv-seg .sv-mark { display: none; }
.sv-seg .sv-opt input:checked + span { background: var(--brand); color: #fff; box-shadow: none; }
@container svsheet (min-width: 860px) {
    .sv-grid-row { grid-template-columns: minmax(220px, 1fr) minmax(0, 1.4fr); align-items: center; }
    .sv-seg, .sv-seg.is-long { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
}
.sv-scale { display: grid; gap: 6px; max-width: 560px; }
.sv-scale .sv-seg { grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); }
.sv-scale .sv-seg .sv-opt span { font-size: 1rem; font-weight: 700; }
.sv-scale-ends { display: flex; justify-content: space-between; gap: 10px; }
.sv-scale-ends small { font-size: .74rem; color: var(--muted); }
.sv-scale-ends small:last-child { text-align: right; }
.sv-inline-btn { justify-self: start; }

/* Barra Anterior / Siguiente: queda pegada abajo mientras se completa la sección */
.sv-pager {
    position: sticky; bottom: 0; z-index: 4;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin: 16px -18px 0; padding: 12px 18px max(12px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -8px 18px rgba(15,23,42,.06);
}
.sv-pager .btn { min-height: 44px; }
.sv-pager-pos { flex: 1; text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.sv-next-lbl { display: inline-flex; gap: 6px; min-width: 0; }
.sv-next-title { display: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; opacity: .85; }
.sv-next-title::before { content: "· "; }
@container svsheet (min-width: 860px) {
    .sv-pager { margin: 16px -24px 0; padding-left: 24px; padding-right: 24px; }
    .sv-next-title { display: inline-block; }
}
@container svsheet (max-width: 520px) {
    .sv-pager-pos { order: -1; flex-basis: 100%; }
    .sv-pager .btn { flex: 1 1 0; justify-content: center; }
    .sv-pager [data-sv-save] { flex-basis: 100%; }
}

/* ---- Vista de lectura: pregunta → respuesta ---- */
.sv-summary { padding: 4px 18px 18px; }
.sv-sum { border-bottom: 1px solid var(--border); padding: 18px 0 10px; }
.sv-sum:last-child { border-bottom: 0; }
.sv-dl { margin: 10px 0 0; display: grid; }
.sv-dl-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px 0; border-top: 1px dashed var(--border); }
.sv-dl-row:first-child { border-top: 0; }
.sv-dl-row dt { display: flex; gap: 8px; align-items: flex-start; font-size: .84rem; color: var(--text-soft); line-height: 1.4; }
.sv-dl-row dd { margin: 0; font-size: .92rem; line-height: 1.45; overflow-wrap: anywhere; }
.sv-dl-row.is-empty dd { font-size: .84rem; }
.sv-dl-muted { color: var(--muted); font-size: .82rem; }
.sv-dl-other { color: var(--text-soft); }
.sv-dl-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.sv-dl-tags span { padding: 3px 9px; border-radius: 999px; background: rgba(79,70,229,.1); color: var(--text); font-size: .82rem; font-weight: 600; }
.sv-dl-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sv-dl-grid li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); font-size: .84rem; }
.sv-dl-grid b { flex: 0 0 auto; text-align: right; }
@container svsheet (min-width: 760px) {
    .sv-dl-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
    .sv-dl-row dd { padding-top: 1px; }
}

@media (max-width: 1100px) {
    .sv-layout { grid-template-columns: 1fr; }
    .sv-rail .keto-rail-list { max-height: 260px; }
}
@media (max-width: 720px) {
    .sv-toolbar { padding: 14px 14px 10px; }
    .sv-actions { width: 100%; }
    .sv-actions .btn { flex: 1 1 auto; min-height: 42px; justify-content: center; }
    .sv-wiz-main, .sv-summary { padding-left: 12px; padding-right: 12px; }
    .sv-pager { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
    .sv-q { padding: 12px; }
    .sv-alerts, .sv-indicators, .sv-nav { padding-left: 12px; padding-right: 12px; }
    .sv-select, .sv-text, .sv-num { font-size: 16px; }
}
@media (prefers-color-scheme: dark) {
    .sv-status.is-ok { color: #86efac; }
    .sv-status.is-warn { color: #fcd34d; }
    .sv-status.is-bad { color: #fca5a5; }
    .sv-status.is-off { color: #cbd5e1; }
    .sv-alert.is-bad { color: #fecaca; }
    .sv-alert.is-warn { color: #fde68a; }
    .sv-alert.is-info { background: rgba(99,102,241,.18); color: #c7d2fe; }
    .sv-sug { color: #bfdbfe; }
    .sv-logic, .sv-warn { color: #fcd34d; }
    .sv-q-id { color: #a5b4fc; background: rgba(129,140,248,.16); }
    .sv-opt input:checked + span, .sv-step.is-current { background: rgba(129,140,248,.18); }
    .sv-pager { box-shadow: 0 -8px 18px rgba(0,0,0,.3); }
}

/* ---------- Ubicación obligatoria (bloquea el sistema hasta compartir el GPS) ---------- */
body.geo-locked { overflow: hidden; }
.geo-gate {
    position: fixed; inset: 0; z-index: 4000; display: flex; overflow-y: auto; overscroll-behavior: contain;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: rgba(15,23,42,.72); backdrop-filter: blur(6px);
}
.geo-gate[hidden] { display: none; }
.geo-gate-card {
    width: min(100%, 520px); margin: auto; padding: 26px 24px 22px; border-radius: 20px; text-align: left;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.55);
}
.geo-gate-ic {
    width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 14px;
    background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; box-shadow: 0 12px 26px -12px var(--brand);
}
.geo-gate-card h2 { margin: 0 0 8px; font-size: 1.3rem; }
.geo-gate-why { margin: 0 0 12px; font-size: .92rem; line-height: 1.55; color: var(--text-soft); }
.geo-gate-points { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 4px; font-size: .86rem; color: var(--text); }
.geo-gate-msg { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; font-size: .86rem; font-weight: 600; }
.geo-gate-msg.is-bad { background: rgba(239,68,68,.12); color: #b91c1c; }
.geo-gate-msg.is-ok { background: rgba(22,163,74,.12); color: #15803d; }
.geo-gate-help { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: .84rem; line-height: 1.5; }
.geo-gate-help ol { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.geo-gate-acts { display: flex; flex-wrap: wrap; gap: 10px; }
.geo-gate-acts .btn { min-height: 46px; justify-content: center; }
.geo-gate-acts [data-geo-allow] { flex: 1 1 100%; }
.geo-gate-acts [data-geo-reload] { flex: 1 1 160px; color: var(--text); border-color: var(--brand); }
.geo-gate-msg:not(.is-bad):not(.is-ok) { background: var(--surface-2); color: var(--text-soft); font-weight: 500; }
.geo-gate-hint { margin: 12px 0 0; font-size: .8rem; color: var(--text-soft); text-align: center; }
@media (prefers-color-scheme: dark) {
    .geo-gate-msg.is-bad { color: #fecaca; }
    .geo-gate-msg.is-ok { color: #86efac; }
}
.lg-geo-note {
    display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; padding: 10px 12px; border-radius: 12px;
    background: rgba(79,70,229,.08); border: 1px solid rgba(79,70,229,.22); font-size: .78rem; line-height: 1.45; color: var(--text-soft);
}
.lg-geo-note svg { flex-shrink: 0; margin-top: 1px; color: var(--brand); }

/* ============ Reuniones del equipo (meetings.php) ============ */
.mx { --mx-r: 18px; --mx-ok: #16a34a; --mx-star: #f59e0b; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Encabezado */
.mx-hero {
    position: relative; overflow: hidden; border-radius: 22px; padding: 22px 24px 18px; color: #fff;
    background:
        radial-gradient(600px 220px at 100% 0%, rgba(255,255,255,.18), transparent 60%),
        radial-gradient(420px 260px at 0% 120%, rgba(56,189,248,.35), transparent 60%),
        linear-gradient(135deg, #4338ca 0%, #6d28d9 55%, #7c3aed 100%);
    box-shadow: 0 18px 40px -22px rgba(76,29,149,.75);
}
.mx-hero-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px 20px; }
.mx-eyebrow { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.mx-hero h2 { margin: 2px 0 4px; font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.01em; color: #fff; }
.mx-hero p { margin: 0; opacity: .88; font-size: .92rem; }
.mx-hero-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.mx-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.mx-stat { position: relative; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(6px); min-width: 0; }
.mx-stat b { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mx-stat span { font-size: .78rem; opacity: .88; }
.mx-stat .mx-prog { margin-top: 8px; background: rgba(255,255,255,.22); }
.mx-stat .mx-prog > i { background: #86efac; }

/* Botones */
.mx-btn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; transition: transform var(--tr), background var(--tr), box-shadow var(--tr); white-space: nowrap; }
.mx-btn:focus-visible { outline: 3px solid rgba(255,255,255,.6); outline-offset: 2px; }
.mx-btn:active { transform: translateY(1px); }
.mx-btn[disabled] { opacity: .6; cursor: progress; }
.mx-btn-light { background: #fff; color: #4338ca; box-shadow: 0 6px 18px -8px rgba(0,0,0,.45); }
.mx-btn-light:hover { background: #eef2ff; }
.mx-btn-glass { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.mx-btn-glass:hover { background: rgba(255,255,255,.24); }
.mx-btn-primary { background: var(--brand); color: #fff; }
.mx-btn-primary:hover { background: var(--brand-dark); }
.mx-btn-soft { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.mx-btn-soft:hover { border-color: var(--brand); color: var(--brand); }
.mx-btn-soft:focus-visible, .mx-btn-primary:focus-visible { outline-color: rgba(79,70,229,.45); }
.mx-link { all: unset; cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--brand); white-space: nowrap; }
.mx-link:hover { text-decoration: underline; }
.mx-more { display: block; margin-top: 10px; }

/* Pestañas + buscador */
.mx-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; position: sticky; top: 64px; z-index: 5;
    padding: 6px; margin: 0 -6px; border-radius: 16px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.mx-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.mx-tabs::-webkit-scrollbar { display: none; }
.mx-tab { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px;
    font-weight: 600; font-size: .9rem; color: var(--text-soft); white-space: nowrap; transition: background var(--tr), color var(--tr); }
.mx-tab:hover { color: var(--text); background: var(--surface-2); }
.mx-tab.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px rgba(79,70,229,.8); }
.mx-tab:focus-visible { outline: 3px solid rgba(79,70,229,.4); }
.mx-tab-n { font-size: .72rem; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: rgba(245,158,11,.18); color: #b45309; text-align: center; }
.mx-tab.active .mx-tab-n { background: rgba(255,255,255,.25); color: #fff; }
.mx-tab-n:empty { display: none; }
.mx-search { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; max-width: 420px; height: 46px; padding: 0 14px;
    border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); box-shadow: var(--shadow); }
.mx-search input { all: unset; flex: 1; min-width: 0; font-size: 16px; color: var(--text); }
.mx-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79,70,229,.14); }

.mx-view[hidden] { display: none !important; }
.mx-view { animation: mx-in .22s ease; }
@keyframes mx-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Tarjetas */
.mx-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--mx-r); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.mx-card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.mx-card-h h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.mx-card-h p { margin: 3px 0 0; font-size: .8rem; color: var(--muted); }
.mx-kicker { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.mx-star-ic { color: var(--mx-star); }
.mx-empty { padding: 22px 12px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .9rem; }
.mx-empty strong { color: var(--text); }
.mx-empty-big { padding: 48px 16px; }
.mx-empty-ic { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--surface-2); color: var(--brand); }
.mx-empty-ok .mx-empty-ic { background: rgba(22,163,74,.12); color: var(--mx-ok); }

/* Panel */
.mx-panel-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
#mxTMeeting { max-width: 340px; }
#mxTPerson { max-width: 260px; }
@media (min-width: 1000px) { .mx-panel-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.mx-last h3 { font-size: 1.15rem; line-height: 1.3; margin-top: 4px; }
.mx-last-topics { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mx-last-topics li { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: .88rem; line-height: 1.45; }
.mx-last-topics span { color: var(--text-soft); }
.mx-last-nums { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 14px; font-size: .85rem; color: var(--text-soft); }
.mx-last-nums b { color: var(--text); font-size: 1.05rem; }
.mx-last-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.mx-key { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow: auto; }
.mx-key-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 6px; padding: 10px 12px 10px 6px; border-radius: 12px;
    background: linear-gradient(90deg, rgba(245,158,11,.12), rgba(245,158,11,.04)); font-size: .87rem; line-height: 1.45; }
.mx-key-item > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.mx-key-item span:not(.mx-key-meta) { color: var(--text-soft); }
.mx-key-meta { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #b45309; }
.mx-team { display: flex; flex-direction: column; gap: 4px; }
.mx-team-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(70px, 120px) 44px; align-items: center; gap: 10px;
    padding: 8px; border-radius: 12px; }
.mx-team-row:hover, .mx-team-row:focus-visible { background: var(--surface-2); }
.mx-team-name { display: flex; flex-direction: column; font-weight: 600; font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mx-team-name small { font-weight: 500; color: var(--muted); font-size: .76rem; }
.mx-team-bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.mx-team-bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22c55e, #16a34a); }
.mx-team-row b { text-align: right; font-size: .85rem; font-variant-numeric: tabular-nums; }

.mx-prog { display: block; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.mx-prog > i { display: block; height: 100%; border-radius: inherit; background: var(--mx-ok); }

/* Avatares */
.mx-av { --h: 240; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: .74rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, hsl(var(--h) 70% 55%), hsl(calc(var(--h) + 30) 70% 45%)); }

/* Tareas */
.mx-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mx-task { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid transparent; transition: background var(--tr), opacity var(--tr); }
.mx-task:hover { border-color: var(--border); }
.mx-task.is-done { opacity: .7; }
.mx-task.is-done .mx-task-text strong, .mx-task.is-done .mx-task-text > span:not(.mx-task-meta) { text-decoration: line-through; text-decoration-color: rgba(100,116,139,.6); }
.mx-task-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.mx-task-text > span:not(.mx-task-meta) { color: var(--text-soft); }
.mx-task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; font-size: .75rem; }
.mx-done-info { color: var(--mx-ok); font-weight: 600; }
.mx-cb { all: unset; box-sizing: border-box; width: 24px; height: 24px; margin-top: 1px; border-radius: 8px; border: 2px solid var(--muted);
    display: inline-flex; align-items: center; justify-content: center; color: transparent; cursor: pointer; transition: all var(--tr); background: var(--surface); }
.mx-cb:hover { border-color: var(--mx-ok); }
.mx-cb:focus-visible { outline: 3px solid rgba(22,163,74,.35); outline-offset: 1px; }
.mx-cb.on { background: var(--mx-ok); border-color: var(--mx-ok); color: #fff; }
.mx-cb[disabled] { cursor: not-allowed; opacity: .45; }
.mx-pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600;
    background: rgba(79,70,229,.1); color: var(--brand); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mx-mlink { all: unset; cursor: pointer; font-size: .75rem; font-weight: 600; color: var(--muted); }
.mx-mlink:hover, .mx-mlink:focus-visible { color: var(--brand); text-decoration: underline; }
.mx-you { font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--brand); color: #fff; }

.mx-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.mx-toolbar-end { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.mx-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.mx-seg button { all: unset; cursor: pointer; padding: 8px 14px; border-radius: 9px; font-size: .85rem; font-weight: 600; color: var(--text-soft); white-space: nowrap; }
.mx-seg button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.mx-seg button:focus-visible { outline: 3px solid rgba(79,70,229,.35); }
.mx-select { height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; max-width: 100%; }
.mx-check { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.mx-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.mx-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.mx-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--mx-r); box-shadow: var(--shadow); padding: 12px; min-width: 0; }
.mx-col-h { display: flex; align-items: center; gap: 10px; padding: 2px 2px 10px; }
.mx-col-h strong { font-size: .95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-col-h small { margin-left: auto; font-weight: 700; font-size: .78rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); }

/* Reuniones: lista + lector */
.mx-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 900px) {
    .mx-split { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
    .mx-list { position: sticky; top: 132px; max-height: calc(100vh - 150px); overflow: auto; }
    .mx-back { display: none !important; }
}
@media (max-width: 899px) {
    .mx-split.has-sel .mx-list { display: none; }
    .mx-split:not(.has-sel) .mx-reader { display: none; }
}
.mx-list { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--mx-r); box-shadow: var(--shadow); min-width: 0; }
.mx-month { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 8px 4px; font-weight: 700; font-size: .82rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.mx-month:first-child { padding-top: 2px; }
.mx-month small { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.mx-li { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 10px; border-radius: 14px; border: 1px solid transparent; transition: background var(--tr), border-color var(--tr); }
.mx-li:hover { background: var(--surface-2); }
.mx-li:focus-visible { outline: 3px solid rgba(79,70,229,.35); }
.mx-li.active { background: rgba(79,70,229,.08); border-color: rgba(79,70,229,.35); }
.mx-li.is-empty { opacity: .65; }
.mx-li-date { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 48px; height: 52px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--border); line-height: 1; color: var(--text); flex: 0 0 48px; }
.mx-li.active .mx-li-date { background: var(--brand); border-color: var(--brand); color: #fff; }
.mx-li-date b { font-size: 1.25rem; font-weight: 800; }
.mx-li-date span { font-size: .66rem; font-weight: 700; text-transform: uppercase; margin-top: 3px; opacity: .8; }
.mx-li-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mx-li-main strong { font-size: .9rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mx-li-sub { font-size: .75rem; color: var(--muted); }
.mx-li-nums { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--text-soft); font-weight: 600; }
.mx-li-prog { flex: 1; max-width: 80px; height: 5px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.mx-li-prog > i { display: block; height: 100%; background: var(--mx-ok); }

.mx-reader { background: var(--surface); border: 1px solid var(--border); border-radius: var(--mx-r); box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.mx-rd-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(79,70,229,.07), transparent); }
.mx-back { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-weight: 600; font-size: .88rem; color: var(--brand); }
.mx-rd-date { font-size: .8rem; font-weight: 600; color: var(--brand); }
.mx-rd-head h3 { margin: 4px 0 2px; font-size: clamp(1.15rem, 2.2vw, 1.4rem); line-height: 1.3; }
.mx-rd-sub { margin: 0; color: var(--text-soft); font-size: .86rem; }
.mx-rd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 10px; font-size: .8rem; color: var(--text-soft); }
.mx-rd-prog { display: inline-flex; align-items: center; gap: 8px; }
.mx-rd-prog .mx-prog { width: 90px; }
.mx-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.mx-tool { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px;
    font-size: .82rem; font-weight: 600; color: var(--text-soft); background: var(--surface); border: 1px solid var(--border); text-decoration: none; }
.mx-tool:hover, .mx-tool:focus-visible { color: var(--brand); border-color: var(--brand); }
.mx-tool.danger:hover { color: var(--danger); border-color: var(--danger); }
.mx-rd-body { padding: 18px 22px 8px; }
.mx-rd-foot { padding: 10px 22px 16px; font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.mx-note { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-soft); font-size: .9rem; margin-bottom: 14px; }

.mx-sec { margin: 0 0 22px; }
.mx-sec > h4, .mx-fold > summary { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-soft); }
.mx-sec > h4::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.mx-sec-n { order: 2; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--mx-ok); }
.mx-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.mx-topic { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px; padding: 12px 12px 12px 6px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.mx-topic strong { font-size: .92rem; }
.mx-topic p { margin: 4px 0 0; font-size: .85rem; line-height: 1.45; color: var(--text-soft); }
.mx-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mx-point { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 4px; padding: 10px 12px 10px 6px; border-radius: 14px; background: var(--surface-2); }
.mx-point.is-key { background: linear-gradient(90deg, rgba(245,158,11,.14), rgba(245,158,11,.04)); box-shadow: inset 3px 0 0 var(--mx-star); }
.mx-point-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.mx-point-text > span:not(.mx-status) { color: var(--text-soft); }
.mx-status { align-self: flex-start; font-size: .7rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.mx-status.ok { background: rgba(22,163,74,.13); color: #15803d; }
.mx-status.warn { background: rgba(245,158,11,.17); color: #b45309; }
.mx-star { all: unset; box-sizing: border-box; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; color: var(--muted); opacity: .5; }
button.mx-star { cursor: pointer; }
button.mx-star:hover, button.mx-star:focus-visible { opacity: 1; color: var(--mx-star); background: rgba(245,158,11,.14); }
.mx-star.on { color: var(--mx-star); opacity: 1; }
.mx-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mx-person { border: 1px solid var(--border); border-radius: 16px; padding: 10px; min-width: 0; }
.mx-person-h { display: flex; align-items: center; gap: 10px; padding: 2px 2px 10px; }
.mx-person-h strong { font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-person-h small { margin-left: auto; font-weight: 700; color: var(--mx-ok); font-size: .78rem; }
.mx-fold { border-top: 1px solid var(--border); padding-top: 12px; }
.mx-fold > summary { cursor: pointer; list-style: none; margin: 0; }
.mx-fold > summary::-webkit-details-marker { display: none; }
.mx-fold > summary::before { content: '▸'; font-size: .9rem; transition: transform var(--tr); }
.mx-fold[open] > summary::before { transform: rotate(90deg); }
.mx-fold > summary span { font-weight: 600; color: var(--muted); }
.mx-fold[open] > summary { margin-bottom: 12px; }
.mx-attendees { margin: 0; font-size: .88rem; color: var(--text-soft); overflow-wrap: anywhere; }
.mx-trans-tools { margin-bottom: 8px; }
.mx-trans-find { width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; box-sizing: border-box; }
.mx-trans-body { max-height: 460px; overflow: auto; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: .86rem; line-height: 1.55; }
.mx-trans-body p { margin: 0 0 4px; border-radius: 6px; padding: 1px 4px; }
.mx-trans-body p.hit { background: rgba(245,158,11,.25); }
.mx-ts { margin: 12px 0 4px; font-size: .72rem; font-weight: 700; color: var(--brand); }

/* Decisiones */
.mx-dec { display: flex; flex-direction: column; gap: 14px; }
.mx-dec-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--mx-r); box-shadow: var(--shadow); padding: 14px; }
.mx-dec-when { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.mx-dec-when .mx-mlink { font-size: .95rem; font-weight: 700; color: var(--text); }

/* Soltar archivos */
.mx-drop { position: fixed; inset: 14px; z-index: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    border: 3px dashed #a5b4fc; border-radius: 26px; background: rgba(67,56,202,.82); color: #fff; font-size: 1.15rem; pointer-events: none; backdrop-filter: blur(3px); }
.mx-drop[hidden] { display: none; }
.mx-drop span { font-size: .92rem; opacity: .85; }

/* Formulario */
.mt-modal-card { width: min(760px, calc(100vw - 24px)); }
.mt-form-hint { margin: 2px 0 8px; font-size: .8rem; color: var(--muted); }
.mt-form-hint code { font-size: .78rem; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
#mtForm textarea { font-size: 15px; line-height: 1.45; }

@media (max-width: 760px) {
    .mx-hero { padding: 18px 16px 14px; border-radius: 18px; }
    .mx-hero-acts { width: 100%; }
    .mx-hero-acts .mx-btn { flex: 1 1 0; }
    .mx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mx-stat b { font-size: 1.35rem; }
    .mx-bar { top: 56px; }
    .mx-tabs { width: 100%; }
    .mx-tab { flex: 1 1 auto; justify-content: center; padding: 9px 10px; }
    .mx-search { max-width: none; flex-basis: 100%; }
    .mx-card { padding: 14px; }
    .mx-toolbar > * { flex: 1 1 auto; }
    .mx-toolbar-end { margin-left: 0; width: 100%; }
    .mx-toolbar-end .mx-btn { flex: 1 1 0; }
    .mx-seg { width: 100%; }
    .mx-seg button { flex: 1; text-align: center; }
    .mx-board { grid-template-columns: minmax(0, 1fr); }
    .mx-rd-head { padding: 16px; }
    .mx-rd-body { padding: 14px 14px 4px; }
    .mx-tool span { display: none; }
    .mx-tool { width: 42px; height: 42px; padding: 0; justify-content: center; }
    .mx-team-row { grid-template-columns: auto minmax(0, 1fr) 40px; }
    .mx-team-bar { display: none; }
}
@media (prefers-color-scheme: dark) {
    .mx-status.ok { color: #86efac; }
    .mx-status.warn, .mx-key-meta { color: #fcd34d; }
    .mx-tab-n { color: #fcd34d; }
    .mx-pill { background: rgba(129,140,248,.18); color: #c7d2fe; }
}
