/* Estilo heredado del Analizador v10 para que la herramienta resulte familiar. */
:root {
  --bg: #f3f6fb; --surface: #ffffff; --surface-2: #f8fafc; --ink: #172033; --muted: #5d6b80; --line: #dfe5ee;
  --brand: #194a8d; --brand-2: #2f6fc4; --brand-soft: #eaf2ff;
  --success: #1f7a55; --success-soft: #e8f7f0; --warning: #8a5300; --warning-soft: #fff4da;
  --danger: #b42318; --danger-soft: #ffebe9; --violet: #6f4bc3; --violet-soft: #f2edff;
  --series-1: #2a78d6; --series-2: #eb6834; --grid: #e8ecf2;
  --shadow: 0 10px 26px rgba(23, 32, 51, .07); --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--brand-2); }
.topbar { background: linear-gradient(120deg, #103b74, #245da8 65%, #3479cb); color: #fff; padding: 16px 24px; box-shadow: 0 5px 18px rgba(16, 59, 116, .2); }
.topbar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.topbar .eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; font-weight: 800; opacity: .8; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; opacity: .92; }
.topbar button.link { background: rgba(255,255,255,.14); color: #fff; }
.main { max-width: 1400px; margin: 0 auto; padding: 20px 20px 48px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; color: var(--muted); border-radius: 9px 9px 0 0; padding: 10px 14px; font-weight: 750; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand-2); background: var(--surface); }
.tabs button:hover { transform: none; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px; }
.section { margin-top: 16px; }
.kpi { padding: 14px 16px; border-top: 4px solid var(--brand-2); }
.kpi.good { border-top-color: var(--success); } .kpi.warn { border-top-color: #d78a00; } .kpi.bad { border-top-color: var(--danger); } .kpi.violet { border-top-color: var(--violet); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-value { font-size: 26px; font-weight: 820; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 9px; font-size: 11.5px; font-weight: 750; background: #eef2f7; color: #3d4a5f; white-space: nowrap; }
.badge.ok { background: var(--success-soft); color: var(--success); } .badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.brand { background: var(--brand-soft); color: var(--brand); } .badge.violet { background: var(--violet-soft); color: var(--violet); }
button { border: 0; border-radius: 9px; padding: 9px 13px; font: inherit; font-size: 13px; font-weight: 750; cursor: pointer; background: var(--brand); color: #fff; transition: .12s ease; }
button:hover { filter: brightness(1.05); }
button.secondary { background: #e9eef6; color: #2c3c55; } button.ghost { background: #fff; border: 1px solid #cfd7e5; color: #344054; }
button.danger { background: var(--danger); } button.success { background: var(--success); }
button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.field { display: block; } .field > span { display: block; font-size: 12px; font-weight: 750; color: #475467; margin-bottom: 4px; }
input[type=text], input:not([type]), input[type=url], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; border: 1px solid #cfd7e5; border-radius: 9px; padding: 9px 10px; background: #fff; color: var(--ink); font: inherit; font-size: 13.5px; outline: none; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #6a9bd8; box-shadow: 0 0 0 3px rgba(47,111,196,.14); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.note { background: #f8fbff; border: 1px solid #d7e3f3; border-radius: 11px; padding: 11px 13px; color: #4b5a70; font-size: 12.5px; }
.note.warn { background: #fff8e6; border-color: #efcf8b; color: #6d4d00; } .note.danger { background: #fff1ef; border-color: #f3b8b0; color: #8f1f15; } .note.ok { background: #eefaf4; border-color: #b7e2cc; color: #1f5a40; }
.table-wrap { width: 100%; max-height: 620px; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
th { position: sticky; top: 0; z-index: 2; text-align: left; background: #eef3f9; color: #344054; font-weight: 800; padding: 8px 10px; border-bottom: 1px solid #cfd7e5; white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
tbody tr:hover td { background: #f7faff; }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.st-SATURACION { color: var(--danger); font-weight: 750; } .st-PARCIAL { color: var(--warning); font-weight: 750; } .st-LIBRE { color: var(--success); font-weight: 750; }
.st-FUERA_TURNO { color: var(--violet); font-weight: 750; } .st-SIN_DATO_TURNO { color: var(--muted); font-weight: 750; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.muted { color: var(--muted); }
.score { display: flex; align-items: baseline; gap: 6px; }
.score-value { font-size: 44px; font-weight: 900; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 10px; border-radius: 999px; background: #edf1f6; margin: 12px 0 6px; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--series-1); }
.meter > i { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.meter-legend { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--muted); }
.parts { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.parts div { border-top: 1px solid #edf0f4; padding-top: 6px; } .parts b { display: block; font-size: 15px; } .parts span { color: var(--muted); font-size: 11px; }
.list { display: grid; gap: 10px; }
.reject-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: grid; gap: 6px; }
.reject-card:hover { border-color: #9fbbe0; }
.reject-card .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.reject-card .when { font-weight: 800; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #e9eef6; border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { background: transparent; color: #344054; padding: 7px 11px; }
.seg button.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.tooltip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 9px; padding: 7px 10px; font-size: 12px; white-space: nowrap; z-index: 5; display: none; }
.tooltip b { display: block; margin-bottom: 2px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 25, 45, .45); display: none; align-items: flex-start; justify-content: center; z-index: 50; overflow-y: auto; padding: 24px 12px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: 16px; width: min(860px, 100%); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; }
.dl div > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 800; }
.dl div > b { font-size: 14px; font-weight: 700; }
.thread { display: grid; gap: 8px; }
.msg { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: var(--surface-2); }
.msg.admin { background: var(--brand-soft); border-color: #cfe0f7; }
.msg.superseded { opacity: .6; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #172033; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 80; box-shadow: var(--shadow); display: none; max-width: 92vw; }
.toast.error { background: var(--danger); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(140deg, #103b74, #2f6fc4); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 26px 24px; box-shadow: 0 30px 80px rgba(0,0,0,.25); display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 21px; } .login-card p { margin: 0; color: var(--muted); font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; }
.hidden { display: none !important; }
@media (max-width: 1000px) { .g4, .g6 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .main { padding: 14px 10px 40px; } .topbar { padding: 12px 14px; } .topbar h1 { font-size: 17px; }
  .g2, .g3, .g4, .g6 { grid-template-columns: 1fr 1fr; } .parts { grid-template-columns: 1fr 1fr; }
  .stack-mobile { grid-template-columns: 1fr !important; }
  .kpi.mini .kpi-label { font-size: 11.5px; } .kpi.mini { padding: 10px 12px; }
  .kpi-value { font-size: 22px; } .score-value { font-size: 38px; }
}
/* ───────── En directo ───────── */
.live-strip { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.live-strip .spacer { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); margin-right: 4px; vertical-align: 0; }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: pulse 1.6s ease-in-out infinite; }
.dot.off { background: #98a2b3; box-shadow: 0 0 0 3px #eef2f7; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--danger-soft); } }
@media (prefers-reduced-motion: reduce) { .dot.bad { animation: none; } }
.live-cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.driver-card .card-body { display: grid; gap: 8px; }
.driver-card .top, .svc .top, .alert-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.svc { border-top: 1px solid #edf0f4; padding-top: 6px; display: grid; gap: 5px; }
.progress { height: 6px; border-radius: 999px; background: #edf1f6; overflow: hidden; margin-top: 4px; min-width: 60px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }
.progress.over > span { background: var(--danger); }
.alert-item { border: 1px solid var(--line); border-left: 4px solid var(--brand-2); border-radius: 11px; padding: 10px 12px; background: #fff; display: grid; gap: 5px; }
.alert-item.sev-alta { border-left-color: var(--danger); } .alert-item.sev-media { border-left-color: #d78a00; } .alert-item.sev-info { border-left-color: var(--success); }
.alert-item.unread { background: #fffaf0; }
.alert-item.resolved { opacity: .65; border-left-color: #c8d1de; }
button.small { padding: 5px 9px; font-size: 12px; }
.tab-count { display: inline-block; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; line-height: 18px; margin-left: 4px; }
.checks { display: grid; gap: 6px; } .checks label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
h3.sub { margin: 0 0 8px; font-size: 14px; }
.now-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
@media (max-width: 1000px) { .live-cols { grid-template-columns: 1fr; } }
/* ───────── Turnos ───────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.week-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.week-nav .ghost { padding: 7px 12px; font-size: 16px; line-height: 1; }
.week-nav input[type=date] { width: 150px; padding: 7px 8px; }
.week-label { font-weight: 800; min-width: 210px; text-align: center; font-size: 13.5px; }
.week-label small { display: block; color: var(--muted); font-weight: 650; font-size: 11.5px; }
.notes-stack { display: grid; gap: 8px; padding-bottom: 0; }
select.auto { width: auto; min-width: 220px; }
.inline-label { font-size: 12.5px; font-weight: 750; color: #475467; }
.roster { table-layout: fixed; min-width: 1040px; }
.roster th, .roster td { border-right: 1px solid #edf0f4; }
.roster thead th { text-align: center; }
.roster thead th:first-child, .roster tbody th { text-align: left; }
.roster thead th.today { background: #dceafc; color: var(--brand); }
.roster thead th small { display: block; font-weight: 650; color: var(--muted); font-size: 11px; }
.roster col.who { width: 170px; }
.roster tbody th { position: sticky; left: 0; z-index: 1; background: #fff; font-weight: 800; padding: 8px 10px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
.roster thead th:first-child { position: sticky; left: 0; z-index: 3; }
.roster tbody th { white-space: normal; }
.roster tbody th small { display: block; font-weight: 600; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.roster td { padding: 5px; vertical-align: top; }
.roster td.today { background: #f5f9ff; }
.roster tbody tr:hover td { background: inherit; }
.rc { width: 100%; min-height: 54px; display: grid; gap: 1px; align-content: start; text-align: left; border-radius: 9px; padding: 7px 8px 6px; border: 1px solid transparent; border-left-width: 4px; background: #f3f5f8; color: #344054; font-weight: 600; position: relative; }
.rc:hover { filter: none; border-color: #9fbbe0; }
.rc:focus-visible { outline: 3px solid rgba(47,111,196,.35); outline-offset: 1px; }
.rc b { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rc span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.rc s { color: var(--muted); font-weight: 600; }
.rc.g-TRABAJO { background: var(--brand-soft); border-left-color: var(--brand-2); color: var(--brand); }
.rc.g-GUARDIA { background: var(--violet-soft); border-left-color: var(--violet); color: var(--violet); }
.rc.g-DESCANSO { background: #f3f5f8; border-left-color: #c3ccd9; color: #475467; }
.rc.g-AUSENCIA { background: var(--warning-soft); border-left-color: #d78a00; color: var(--warning); }
.rc.g-OTRO { background: #fff; border: 1px dashed #c3ccd9; border-left: 4px solid #c3ccd9; }
.rc.empty { background: #fff; border: 1px dashed #e0a39c; border-left: 4px dashed #e0a39c; color: var(--danger); }
.rc.inactive, .rc:disabled { background: repeating-linear-gradient(135deg, #f6f7f9 0 6px, #eef1f5 6px 12px); border-left-color: #d6dce5; color: var(--muted); cursor: not-allowed; opacity: 1; }
.rc .mark { position: absolute; top: 6px; right: 7px; font-size: 11px; color: var(--muted); font-weight: 800; }
.roster tfoot td, .roster tfoot th { position: static; background: var(--surface-2); border-top: 1px solid #cfd7e5; font-size: 11.5px; color: var(--muted); padding: 7px 8px; vertical-align: top; text-align: left; font-weight: 600; }
.roster tfoot th { position: sticky; left: 0; z-index: 1; color: #344054; font-weight: 800; }
.roster tfoot .ok { color: var(--success); font-weight: 750; }
.roster tfoot .warn { color: var(--warning); font-weight: 750; }
.roster-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -2px; border-left: 3px solid; }
.pick-groups { display: grid; gap: 10px; }
.pick-group { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: start; }
.pick-group > span { font-size: 12px; font-weight: 800; color: #475467; padding-top: 7px; }
.pick { background: #fff; color: #344054; border: 1px solid #cfd7e5; padding: 7px 11px; font-weight: 700; }
.pick.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pick.g-GUARDIA.active { background: var(--violet); border-color: var(--violet); }
.pick.g-AUSENCIA.active { background: #a86400; border-color: #a86400; }
.pick.g-DESCANSO.active { background: #475467; border-color: #475467; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; padding-top: 22px; }
label.check.flat { padding-top: 0; }
.day-meta { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .roster { min-width: 860px; } .roster col.who { width: 112px; } .pick-group { grid-template-columns: 1fr; } .pick-group > span { padding-top: 0; } .week-label { min-width: 0; flex: 1; } label.check { padding-top: 0; } }
/* ───────── Servicios, comisiones y cuadro de mando ───────── */
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); } .span2 { grid-column: span 2; }
@media (max-width: 1000px) { .g5 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .g5 { grid-template-columns: 1fr 1fr; } .span2 { grid-column: span 2; } .exp-row { flex-wrap: wrap; } }
.section-first { margin-top: 16px; } #svPendingCard.hidden + .section-first { margin-top: 0; }
.sv-sums { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 0; color: var(--muted); font-size: 12.5px; }
.sv-sums b { color: var(--ink); }
.sv-table td { white-space: nowrap; } .sv-table td.wrap { white-space: normal; min-width: 180px; }
.form-section { border-top: 1px solid var(--line); padding-top: 12px; }
.form-section h4 { margin: 0 0 10px; font-size: 13px; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; }
.exp-row { display: flex; gap: 6px; align-items: end; } .exp-row .field { flex: 1; }
.from-efi { background: #f0f7ff !important; border-color: #9fbbe0 !important; }
.efi-msg { font-size: 12.5px; }
.delta { font-size: 11.5px; font-weight: 750; } .delta.up { color: var(--success); } .delta.down { color: var(--danger); } .delta.flat { color: var(--muted); }
.bar-cell { position: relative; min-width: 120px; }
.bar-cell > i { position: absolute; left: 10px; top: 50%; height: 8px; margin-top: -4px; border-radius: 0 4px 4px 0; background: var(--series-1); opacity: .85; }
.bar-cell > span { position: relative; }
.bd-card .table-wrap { max-height: 380px; }
.edit-table input { width: 92px; padding: 5px 6px; font-size: 12.5px; text-align: right; }
.edit-table td { padding: 5px 8px; }
tr.total td { font-weight: 800; background: #f6f8fb; border-top: 1px solid #cfd7e5; }
tr.selected td { background: #eaf2ff !important; }
.cm-frac { color: var(--muted); font-size: 11.5px; }
input.hx { width: 70px; padding: 4px 6px; text-align: right; }
.kpi .delta { display: block; margin-top: 3px; }
@media print { .topbar, .tabs, button { display: none !important; } .card { box-shadow: none; } }

/* ───────── Menú y móvil ───────── */
.menu-btn, .tab-group, .menu-user { display: none; }
.tabs .tab-group + button { margin-left: 0; }
@media (min-width: 761px) { .tabs .tab-group:not(:first-child) { display: block; width: 1px; align-self: stretch; margin: 8px 6px; background: var(--line); font-size: 0; } }
.burger { display: inline-grid; gap: 4px; width: 18px; } .burger i { display: block; height: 2px; border-radius: 2px; background: currentColor; }
@media (max-width: 760px) {
  body { -webkit-text-size-adjust: 100%; }
  body.admin .topbar { position: sticky; top: 0; z-index: 40; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  body.admin .topbar-inner { flex-wrap: nowrap; gap: 8px; }
  body.admin .topbar .brand, body.admin .topbar .who, body.admin #pwBtn, body.admin #logoutBtn, body.admin .topbar .spacer { display: none; }
  /* Panel del gruista: título y botones arriba, el mes a todo el ancho */
  body:not(.admin) .topbar-inner { flex-wrap: wrap; gap: 8px 10px; }
  body:not(.admin) .topbar-inner > div:first-child { flex: 1; min-width: 0; }
  body:not(.admin) .topbar .spacer { display: none; }
  body:not(.admin) #month { order: 5; flex: 1 1 100%; min-width: 0 !important; width: 100% !important; }
  body:not(.admin) .topbar button.link { padding: 8px 12px; min-height: 38px; }
  .menu-btn { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 16.5px; font-weight: 800; padding: 11px 14px; border-radius: 12px; text-align: left; }
  .menu-btn span#menuLabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-btn::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); margin-top: -4px; transition: transform .15s; }
  .menu-btn[aria-expanded="true"]::after { transform: rotate(-135deg); margin-top: 4px; }
  .tabs { display: none; position: fixed; top: var(--topbar-h, 60px); left: 0; right: 0; bottom: 0; z-index: 39; margin: 0; padding: 6px 12px calc(24px + env(safe-area-inset-bottom));
    background: var(--surface); border: 0; flex-direction: column; flex-wrap: nowrap; gap: 2px; overflow-y: auto; box-shadow: 0 18px 40px rgba(15,25,45,.18); }
  .tabs.open { display: flex; }
  .tabs button { text-align: left; border-radius: 11px; padding: 13px 14px; font-size: 16px; border-bottom: 0; color: var(--ink); }
  .tabs button.active { background: var(--brand-soft); color: var(--brand); border-bottom: 0; }
  .tab-group { display: block; margin: 14px 6px 4px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .tab-group:first-child { margin-top: 6px; }
  .menu-user { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; font-size: 13px; color: var(--muted); }
  .menu-user #who2 { grid-column: 1 / -1; } .menu-user .spacer { display: none; } .menu-user button { justify-content: center; text-align: center; }
  .main { padding: 12px 10px 40px; }
  .card-head { flex-wrap: wrap; gap: 10px; padding: 14px; }
  .card-head > .actions, .card-head > button, .card-head > .seg, .card-head > .chips { width: 100%; }
  .card-head > button { justify-content: center; }
  .card-body { padding: 12px 14px; }
  button { min-height: 40px; }
  button.small, .pick, .rc { min-height: 0; }
  input[type=text], input:not([type]), input[type=url], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea { font-size: 16px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters.collapsed { display: none; }
  .filters-toggle { display: flex !important; }
  table { font-size: 12.5px; } th, td { padding: 8px 9px; }
  .table-wrap table:not(.roster):not(.cards) tbody td:first-child, .table-wrap table:not(.roster):not(.cards) thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
  .table-wrap table:not(.roster):not(.cards) thead th:first-child { z-index: 3; background: var(--surface-2, #f6f8fb); }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { width: 100%; min-height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
  .modal-body { padding: 14px 14px 0; flex: 1; }
  .modal-body > .actions:last-child { position: sticky; bottom: 0; background: var(--surface); margin: 0 -14px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 2; }
  .modal-body > .actions:last-child button { flex: 1; justify-content: center; }
  .kpi { padding: 12px 14px; } .kpi-value { font-size: 21px; }
  .seg { width: 100%; } .seg button { flex: 1; }
  .toast { left: 10px; right: 10px; transform: none; max-width: none; bottom: calc(14px + env(safe-area-inset-bottom)); }
}
.filters-toggle { display: none; width: 100%; justify-content: space-between; align-items: center; background: var(--surface-2, #f6f8fb); color: var(--ink); border: 1px solid var(--line); font-weight: 750; }
.filters-toggle b { color: var(--brand); }
/* Permisos: lo que solo puede usar quien tiene permiso de edición */
[data-edit].no-perm { display: none !important; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 22px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.perm-row > span { font-weight: 650; font-size: 13.5px; }
.perm-row .seg button[data-l="none"].active { color: var(--muted); }
.perm-row .seg button[data-l="edit"].active { color: #157f3b; }
.drive-pick { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.drive-pick .name { font-weight: 700; overflow-wrap: anywhere; } .drive-pick .when { font-size: 12px; color: var(--muted); }
.progress { height: 8px; border-radius: 6px; background: #e9eef6; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--brand-2); border-radius: 6px; transition: width .4s; }
@media (max-width: 760px) { .perm-row { flex-direction: column; align-items: stretch; gap: 6px; } .drive-pick { flex-wrap: wrap; } .drive-pick button { width: 100%; } }

/* Tablas como fichas en el móvil */
@media (max-width: 760px) {
  .table-wrap:has(> table.cards) { max-height: none !important; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  table.cards { min-width: 0 !important; border-collapse: separate; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tbody tr { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 8px 12px; background: var(--surface); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
  table.cards tbody tr.clickable:active { background: var(--brand-soft); }
  table.cards td { border: 0 !important; padding: 5px 0 !important; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; text-align: right; white-space: normal !important; position: static !important; box-shadow: none !important; background: transparent !important; }
  table.cards td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); }
  table.cards td[data-label=""]::before, table.cards td:not([data-label])::before { display: none; }
  table.cards td[data-label=""] { justify-content: flex-end; }
  table.cards td:first-child { font-weight: 800; font-size: 14.5px; text-align: left; justify-content: flex-start; padding-bottom: 7px !important; border-bottom: 1px solid var(--line) !important; margin-bottom: 3px; }
  table.cards td:first-child::before { display: none; }
  table.cards td:empty { display: none; }
  table.cards td.empty { text-align: center; justify-content: center; font-weight: 500; border: 0 !important; }
  table.cards td .actions, table.cards td.nowrap { flex-wrap: wrap; }
  table.cards td > button { flex: 0 0 auto; }
}
@media (max-width: 520px) { .g2 { grid-template-columns: minmax(0, 1fr); } .g2 > .span2, .span2 { grid-column: auto; } }
