/* ============================================================
   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, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}
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; }

.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; }

/* ---------------- 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: 220px; 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: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; }
.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; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.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; }

.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: center; gap: 12px; padding: 14px 18px; background: #ecfeff; border: 1px solid #a5f3fc; color: #155e75; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }

.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-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; }

/* Popup: se mantiene abierto al tocar dentro (enlaces Maps usables) */
.mapx-popup .leaflet-popup-content-wrapper {
    border-radius: 16px; padding: 0; overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 24px 60px -18px rgba(15,23,42,.55);
}
.mapx-popup .leaflet-popup-content { margin: 0 !important; width: 280px !important; max-width: min(300px, calc(100vw - 40px)); }
.mapx-popup .leaflet-popup-tip { 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: 6px !important; right: 6px !important;
    z-index: 3; touch-action: manipulation;
}
.mapx-popup .leaflet-popup-close-button:hover { opacity: 1; background: rgba(255,255,255,.15); border-radius: 8px; }
.mapx-popup a.mpp-btn { -webkit-tap-highlight-color: transparent; }

.mpp { font-family: var(--font); }
.mpp-head {
    display: flex; align-items: center; gap: 12px; padding: 16px 40px 16px 16px;
    background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff;
}
.mpp-av {
    width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
    background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.28);
    display: grid; place-items: center; font-weight: 700; font-size: .98rem;
}
.mpp-name { min-width: 0; }
.mpp-name strong { display: block; font-size: 1rem; line-height: 1.25; font-weight: 700; }
.mpp-ci {
    display: inline-block; margin-top: 5px; font-size: .72rem; font-weight: 600;
    padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.2); letter-spacing: .02em;
}
.mpp-body { padding: 8px 16px 4px; display: flex; flex-direction: column; }
.mpp-item { display: flex; align-items: flex-start; gap: 11px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.mpp-item:last-child { border-bottom: 0; }
.mpp-ic {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: rgba(79,70,229,.1); color: var(--brand); display: grid; place-items: center;
}
.mpp-txt { min-width: 0; padding-top: 1px; }
.mpp-txt span { display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.mpp-txt b { display: block; font-size: .87rem; color: var(--text); font-weight: 600; line-height: 1.35; word-break: break-word; margin-top: 1px; }
.mpp-txt a { color: var(--text); }
.mpp-txt a:hover { color: var(--brand); }
.mpp-actions { display: flex; gap: 9px; padding: 12px 16px 16px; }
.mpp-btn {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px; min-height: 44px; border-radius: 11px; font-size: .84rem; font-weight: 600;
    border: 1px solid var(--border); color: var(--text-soft); transition: var(--tr);
    text-decoration: none; touch-action: manipulation;
}
.mpp-btn:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand); }
.mpp-btn.primary {
    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; }

@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;
    }
    .mpp-actions { flex-wrap: wrap; }
    .leaflet-touch .leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; }
}
@media (max-width: 420px) {
    .mpp-actions { flex-direction: column; }
}

/* ---------------- Sessions ---------------- */
.session-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.session-card { display: flex; align-items: center; gap: 14px; padding: 18px; }
.session-card.current { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.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-info { flex: 1; min-width: 0; }
.session-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------- 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: 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(1180px, 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;
}
#accessModal .acc-scroll {
    min-height: 0;
    height: 100%;
    border: 0;
    border-radius: 0;
    border-top: 1px solid var(--border);
}
#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;
    gap: 12px;
    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; }
.acc-scroll {
    flex: 1 1 auto;
    min-height: 200px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}
.acc-table { border-collapse: separate; border-spacing: 0; margin: 0; min-width: 720px; }
.acc-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);
    text-align: center;
    padding: 8px 6px;
    font-size: .68rem;
    letter-spacing: .02em;
    white-space: nowrap;
}
.acc-table thead th.acc-hc { background: #312e81; }
.acc-table .acc-user-col {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 5;
    min-width: 200px;
    background: #1e293b;
    color: #e2e8f0;
}
.acc-table tbody .acc-user-col {
    background: var(--surface);
    color: var(--text);
    z-index: 3;
    box-shadow: 4px 0 8px -6px rgba(15, 23, 42, .35);
}
.acc-table tbody tr:hover .acc-user-col,
.acc-table tbody tr:hover { background: var(--surface-2); }
.acc-table .acc-all-col { width: 52px; }
.acc-table tbody td { text-align: center; padding: 8px 6px; }
.acc-table tbody .acc-user-col { text-align: left; padding: 8px 12px; }
.acc-table tbody .acc-user-col strong { display: block; font-size: .88rem; }
.acc-table tbody .acc-user-col small { display: block; color: var(--muted); font-size: .74rem; }
.acc-col {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 2px;
    max-width: 88px;
    white-space: normal;
    line-height: 1.2;
}
.acc-col:hover { text-decoration: underline; }
.acc-col:disabled { cursor: default; text-decoration: none; }
.acc-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.acc-table tr.acc-admin td { opacity: .72; }
.acc-table tr.acc-inactive .acc-user-col strong { 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: 720px) {
    .acc-modal-card {
        width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
        margin: 0; border-radius: 0;
    }
    .acc-table .acc-user-col { min-width: 148px; }
    .acc-table input[type=checkbox] { width: 22px; height: 22px; }
    .acc-modal-card .modal-foot .btn { min-height: 44px; }
}
.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-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; }
    .menu-toggle { display: grid; }
    .content { padding: 18px 14px; }
    .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)); }
    .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%; }
}
@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; }
.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 { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.pt-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.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 a pantalla completa (web app) ---- */
body.pt-app,
body.us-app,
body.hrs-team-app {
    height: 100dvh;
    overflow: hidden;
}
body.pt-app .app-shell,
body.us-app .app-shell,
body.hrs-team-app .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
}
body.pt-app .main,
body.us-app .main,
body.hrs-team-app .main {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}
body.pt-app .app-credit,
body.us-app .app-credit,
body.hrs-team-app .app-credit { display: none; }
.main .content.content-pt,
.main .content.content-us { flex: 1 1 auto; }
.content.content-pt,
.content.content-us {
    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: hidden;
}
.content.content-pt .flash-stack,
.content.content-us .flash-stack { flex-shrink: 0; }
.pt-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    height: 100%;
}
.pt-kpis {
    flex-shrink: 0;
    margin-bottom: 0;
    gap: 10px;
    width: 100%;
}
body.pt-app .pt-kpis.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pt-toolbar {
    flex-shrink: 0;
    margin-bottom: 0;
    width: 100%;
    align-items: stretch;
}
.pt-toolbar .search { min-width: 0; }
.pt-toolbar .search input { min-height: 44px; }
.pt-toolbar-actions {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex: 0 1 auto;
    min-width: 0;
}
.pt-toolbar-actions select {
    min-height: 44px;
    min-width: 0;
    flex: 1 1 180px;
}
.pt-toolbar-actions .btn { min-height: 44px; flex: 0 0 auto; }
.pt-hint { flex-shrink: 0; margin: 0; }
.pt-list-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}
.pt-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.pt-page .table { min-width: 0; }
.pt-page .table th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2);
}
.pt-page .table tbody tr.clickable { min-height: 52px; }
.pt-page .table td, .pt-page .table th { vertical-align: middle; }

/* ---- 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-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: hidden;
    width: 100%;
}
.us-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.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; }
body.us-app .perm-modal-card.us-sheet-lg {
    width: min(1080px, calc(100vw - 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-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; }
    .acc-table { min-width: 640px; }
    .acc-table .acc-user-col { min-width: 132px; }
    .acc-table input[type=checkbox] { width: 22px; height: 22px; }
}

@media (max-width: 1100px) {
    body.pt-app .pt-kpis.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .pt-page .stat-card { padding: 12px 14px; gap: 10px; }
    .pt-page .stat-ic { width: 40px; height: 40px; border-radius: 12px; }
    .pt-page .stat-ic svg { width: 20px; height: 20px; }
    .pt-page .stat-num { font-size: 1.35rem; }
}
@media (max-width: 860px) {
    .pt-toolbar { flex-wrap: wrap; }
    .pt-toolbar .search { flex: 1 1 100%; }
    .pt-toolbar-actions { flex: 1 1 100%; }
    .pt-toolbar-actions .btn { flex: 0 0 auto; }
    body.pt-app .pt-kpis.stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .content.content-flush.content-pt {
        padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }
    .pt-page .stat-ic { display: none; }
    .pt-page .stat-card { padding: 10px 12px; }
    .pt-page .stat-num { font-size: 1.2rem; }
    .pt-page .stat-label { font-size: .72rem; }
    .pt-btn-full { display: none; }
    .pt-btn-short { display: inline; }
    .pt-hint { display: none; }
    .pt-page .table thead { display: none; }
    .pt-page .table tbody tr.clickable {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
        min-height: 64px;
    }
    .pt-page .table tbody tr.clickable td {
        border: 0; padding: 0;
    }
    .pt-page .table .pt-td-age,
    .pt-page .table .pt-td-place,
    .pt-page .table .pt-td-phone,
    .pt-page .table .pt-td-geo { display: none; }
    .pt-page .table .pt-td-main { min-width: 0; }
    .pt-page .table .pt-td-go { display: grid; place-items: center; }
    .pt-meta {
        display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
        margin-top: 4px; color: var(--text-soft); font-size: .78rem; line-height: 1.35;
    }
    .pt-meta .badge { margin-left: 2px; }
    .pt-page .table tbody tr:not(.clickable) td {
        display: block; padding: 28px 12px;
    }
    .pt-av { width: 44px; height: 44px; border-radius: 12px; }
    .pt-toolbar-actions select,
    .pt-toolbar .search input,
    .pt-toolbar-actions .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 (rediseño) — tarjeta única, limpia y profesional.
   Ligero y fluido (solo transform/opacity en GPU), 60/120 Hz.
   ============================================================ */
.login {
    min-height: 100vh; min-height: 100dvh; margin: 0;
    display: grid; place-items: center;
    padding: clamp(14px, 3.5vw, 40px);
    padding-top: max(clamp(14px, 3.5vw, 40px), env(safe-area-inset-top));
    padding-bottom: max(clamp(14px, 3.5vw, 40px), env(safe-area-inset-bottom));
    font-family: var(--font); color: #e8eaf3; position: relative; 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; 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 --- */
.lg-split {
    position: relative; z-index: 2;
    width: min(1000px, 100%);
    display: grid; grid-template-columns: 1.05fr .95fr;
    background: rgba(15,20,38,.92);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: clamp(18px, 2.4vw, 28px);
    overflow: hidden;
    box-shadow: 0 40px 90px -34px rgba(0,0,0,.8);
    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; }

/* Lado del formulario (derecha) */
.lg-form-side { display: flex; align-items: center; justify-content: center; padding: clamp(28px, 4vw, 48px); }
.lg-form-card { width: min(380px, 100%); text-align: left; }
.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; }
    .lg-split { grid-template-columns: 1fr; width: min(430px, 100%); background: rgba(15,20,38,.94); }
    .lg-mini-brand { display: flex; }
    .lg-form-side { padding: clamp(28px, 7vw, 40px); }
}
@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: 260px; 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; }
}

@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: hidden;
}
.hrs-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}
.hrs-tabs {
    display: flex; flex-wrap: nowrap; gap: 6px;
    padding: 6px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; width: 100%; max-width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    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: hidden;
}
.hrs-workspace {
    display: flex; flex-direction: column; gap: 12px;
    flex: 1 1 auto; min-height: 0; overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.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: auto; }

.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: 180px; flex: 1 1 180px; }
.hrs-staff-wrap { overflow: auto; min-height: 0; }
.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: 160px; overflow: auto; }
.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-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: 120px; 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: 160px !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: 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(180px, 1.4fr) minmax(120px, .9fr) minmax(88px, .6fr) minmax(120px, .8fr) minmax(110px, .6fr) 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); }

@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: auto; }
    body.hrs-team-app .content.content-hours { overflow: hidden; }
    .hrs-page, .hrs-panel-fill.active { overflow: visible; height: auto; }
    body.hrs-team-app .hrs-page,
    body.hrs-team-app .hrs-panel-fill.active { overflow: hidden; height: auto; }
    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 4; }
    .hrs-fee-mod, .hrs-fee-hrs, .hrs-fee-amt, .hrs-fee-st { grid-column: 1; }
    .hrs-fee-mod::before, .hrs-fee-hrs::before, .hrs-fee-amt::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 0 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 4; }
    .hrs-fee-mod, .hrs-fee-hrs, .hrs-fee-amt {
        grid-column: 1;
        font-size: .8rem;
    }
    .hrs-fee-mod::before, .hrs-fee-hrs::before, .hrs-fee-amt::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 {
    height: 100dvh;
    overflow: hidden;
}
body.hc-app .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
}
body.hc-app .main {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}
body.hc-app .content.content-hc {
    flex: 1 1 auto;
    min-height: 0;
    overflow: 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: auto;
    overflow-y: hidden;
}
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; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.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); }
.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: nowrap; align-items: center; gap: 6px;
    padding: 6px; width: 100%; min-height: 52px; flex-shrink: 0;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    position: sticky; top: 66px; z-index: 25;
    scroll-snap-type: x proximity;
    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: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 8px 16px 18px;
    box-sizing: border-box;
}
.hc-page .table {
    width: max-content;
    min-width: 100%;
}
.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-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: 360px;
    min-height: 240px;
    max-height: 70vh;
}
.hc-chart-wrap.is-empty { height: 0; min-height: 0; overflow: hidden; }
.hc-chart-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
}
.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-layout { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 24px; align-items: start; min-width: 0; }
.keto-versions .card-body { max-height: 70vh; overflow: auto; }
.keto-ver {
    display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
    padding: 12px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); cursor: pointer; font: inherit; color: inherit; transition: var(--tr);
}
.keto-ver-wrap { display: grid; gap: 6px; margin-bottom: 8px; }
.keto-ver-wrap.is-active .keto-ver { border-color: var(--brand); background: rgba(79,70,229,.08); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.keto-ver-edit { justify-self: start; }
.keto-ver:hover { border-color: var(--brand); }
.keto-ver.active { border-color: var(--brand); background: rgba(79,70,229,.08); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.keto-ver strong { font-size: .9rem; }
.keto-ver span { font-size: .75rem; color: var(--muted); }
.keto-sheet { padding: 0 0 18px; overflow: hidden; min-width: 0; }
.keto-sheet-head {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap;
    padding: 18px 18px 12px; border-bottom: 1px solid var(--border);
}
.keto-sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.keto-title-input {
    width: min(100%, 420px); 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-params {
    display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 10px;
    padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.keto-params-day { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.keto-goals {
    display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 8px;
    padding: 12px 18px;
}
.keto-kpi, .keto-total {
    background: var(--surface); 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: 4px 18px 12px; }
.keto-day-hint { margin: 0; padding: 0 18px 10px; font-size: .82rem; color: var(--muted); }
.keto-row-actions { padding: 0 18px 10px; }
.keto-del-row { white-space: nowrap; }
.keto-table .keto-g { min-width: 88px; }
.keto-meal-tabs { display: flex; gap: 6px; padding: 0 18px 10px; overflow-x: auto; }
.keto-meal-tab {
    border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
    font: inherit; font-weight: 600; font-size: .82rem; padding: 8px 12px; border-radius: 999px; cursor: pointer;
}
.keto-meal-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.keto-table-wrap { padding: 0 10px; }
.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: 180px; }
.keto-rest-ok { color: #166534; font-size: .78rem; }
.keto-rest-bad { color: #b91c1c; font-size: .78rem; font-weight: 600; }
.keto-notes { padding: 0 18px; }
.keto-add-food { margin: 8px 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; }

.table small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-top: 2px; }

@media (max-width: 1100px) {
    .keto-layout { grid-template-columns: 1fr; }
    .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-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: 2; margin-left: 0; justify-self: end; }
    .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; }
    .keto-title-input, .keto-table select, .keto-table input { font-size: 16px; }
    .hc-chart-wrap { height: 280px; min-height: 220px; }
}

/* 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 {
    min-height: 0;
    overflow: hidden;
    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;
    height: calc(100dvh - 66px);
    max-height: calc(100dvh - 66px);
    overflow: hidden;
}
.main .content.content-map { flex: 1 1 auto; }
body:has(.content-map) { overflow: hidden; }
body:has(.content-map) .main { min-height: 100dvh; overflow: hidden; }
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; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -20px; padding: 0 20px 12px;
    scrollbar-width: none;
}
.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-ver.active { background: rgba(99,102,241,.16); }
    .keto-kpi.hi { background: rgba(99,102,241,.16); }
    .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, calc(100vw - 24px));
    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; }

.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: 180px; }
.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; }
}
