/* Horas a cliente — estilos propios. Los tokens y componentes vienen de tokens.css y bundle.css (sistema AGH Ibérica). */
/* ---- App ---- */
* { box-sizing: border-box; }
html { background: var(--paper); }
body { min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--space-4); }
@media (min-width: 720px) { .wrap { padding: 0 var(--space-5); } }

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: var(--space-4); }
.logo-box { display: inline-flex; padding: 4px 6px; border-radius: var(--radius-sm); background: var(--doc-paper); }
.logo-box img { height: 26px; width: auto; display: block; }
.brand-name { font-weight: 600; color: var(--ink); }
.steps-bar { padding: var(--space-4) 0; border-bottom: 1px solid var(--line); }

main { padding: var(--space-6) 0 var(--space-8); }
.screen-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.screen-head .display-l { color: var(--ink); margin-top: var(--space-2); }
.lead { color: var(--text); max-width: 62ch; margin-top: var(--space-3); }
.muted { color: var(--text-muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-5); }
.stack { display: grid; gap: var(--space-4); }
.stack-l { display: grid; gap: var(--space-6); }
.actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Paso 1 */
.upload-grid { display: grid; gap: var(--space-5); grid-template-columns: 1fr; }
@media (min-width: 900px) { .upload-grid { grid-template-columns: 3fr 2fr; } }
.agh-drop { cursor: pointer; min-height: 220px; align-content: center; }
.agh-drop strong { color: var(--ink); }
.how { display: grid; gap: var(--space-3); padding: 0; margin: 0; list-style: none; counter-reset: h; }
.how li { display: grid; grid-template-columns: 28px 1fr; gap: var(--space-2); font-size: 14px; line-height: 20px; }
.how li::before { counter-increment: h; content: counter(h); font-weight: 600; color: var(--red-dark); }

/* Carga */
.loading { display: grid; justify-items: center; gap: var(--space-4); padding: var(--space-8) 0; text-align: center; }
.breath { width: 56px; height: 56px; border: 4px solid var(--red); border-radius: 13px; animation: breath 1.8s ease-in-out infinite; }
@keyframes breath { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.86); opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .breath { animation: none; } }

/* Paso 2 */
.clients { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip { font: inherit; font-size: 14px; font-weight: 600; min-height: var(--control-h); padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); }
.chip:hover { background: var(--beige); }
.chip[aria-selected="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.chip .cnt { font-weight: 500; font-size: 13px; opacity: .8; }
.chip.off { color: var(--text-muted); border-style: dashed; }
.chip[aria-selected="true"].off { color: var(--paper); }
.chip:focus-visible, .cell:focus-visible, .dayh:focus-visible, .brush:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.client-head { display: flex; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; align-items: flex-start; }
.client-head .title { color: var(--ink); }
.kpis { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.kpi .label { color: var(--text-muted); text-transform: uppercase; display: block; }
.kpi .num { font-family: var(--font-display); font-size: 32px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .num.red { color: var(--red); }
.check { display: inline-flex; gap: var(--space-2); align-items: center; font-size: 14px; color: var(--ink); cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--red-dark); margin: 0; }

.toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; padding: var(--space-3); background: var(--beige); border-radius: var(--radius-md); }
.toolbar .agh-label { margin-right: var(--space-2); }
.brush { font: inherit; font-size: 14px; font-weight: 600; height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); }
.brush b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 4px; font-size: 12px; }
.brush[aria-pressed="true"] { border-color: var(--red-dark); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red-dark); }
.brush input { width: 52px; height: 28px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; font-size: 14px; text-align: center; background: var(--surface); color: var(--ink); }
.tool-help { font-size: 13px; color: var(--text-muted); flex-basis: 100%; padding: 0 var(--space-1); }
@media (min-width: 1000px) { .tool-help { flex-basis: auto; margin-left: auto; } }

.grid-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
table.cal { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 100%; user-select: none; -webkit-user-select: none; }
.cal th, .cal td { padding: 0; text-align: center; border-bottom: 1px solid var(--line); }
.cal thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.cal .namecol { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; border-right: 1px solid var(--line); min-width: 168px; padding: var(--space-2) var(--space-3); }
.cal thead .namecol { z-index: 3; }
.dayh { font: inherit; width: 100%; min-width: 24px; height: 46px; border: 0; background: transparent; color: var(--ink); cursor: pointer; display: grid; place-content: center; line-height: 16px; padding: 0 2px; }
.dayh span { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.dayh:hover { background: var(--beige); }
.dayh.we { cursor: default; color: var(--text-muted); }
.dayh.we:hover { background: transparent; }
.dayh.fest { background: var(--red-soft); color: var(--red-dark); }
.dayh.fest span { color: var(--red-dark); }
td.we, th.we { background: var(--paper); }
td.fest, th.fest { background: var(--red-soft); }
.cell { font: inherit; width: 100%; min-width: 24px; height: 38px; border: 0; background: transparent; color: var(--text); cursor: crosshair; padding: 0; touch-action: none; }
.cell:hover { background: var(--beige); }
.cell.abs { color: var(--red-dark); font-weight: 700; background: var(--red-soft); }
.cell.part { color: var(--edited); font-weight: 700; background: var(--edited-soft); }
.cell.f { color: var(--red-dark); font-weight: 700; cursor: default; }
.cell[disabled] { cursor: default; }
.cell[disabled]:hover { background: transparent; }
.totc { font-weight: 700; color: var(--ink); padding: 0 var(--space-2) !important; white-space: nowrap; }
.totc.first { border-left: 1px solid var(--line); }
tr.excl td:not(.namecol) { opacity: .35; }
tr.excl .pname { text-decoration: line-through; color: var(--text-muted); }
.pname { font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; display: block; background: none; border: 0; padding: 0; cursor: text; text-align: left; }
.pname:hover { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.pname:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pname-in { min-height: 30px; height: 30px; font-weight: 600; font-size: 13px; padding: 0 var(--space-2); width: 160px; }
.pmeta { display: flex; gap: var(--space-2); align-items: center; font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; }
.pmeta input { width: 14px; height: 14px; accent-color: var(--red-dark); margin: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); display: inline-block; }
tfoot td { border-bottom: 0; font-weight: 700; color: var(--ink); background: var(--beige); height: 44px; }
tfoot .namecol { background: var(--beige); }

.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2); }
.sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }

.notices { display: grid; gap: var(--space-2); }
.agh-notice .n-body { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.agh-notice b { color: var(--ink); }

.bottom-bar { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow-overlay); }
.bottom-bar .wrap { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); min-height: 72px; flex-wrap: wrap; padding-top: var(--space-3); padding-bottom: var(--space-3); }

@media (max-width: 600px) { #bar-info { display: none; } .bottom-bar .wrap { min-height: 64px; flex-wrap: nowrap; } .topbar #periodo { display: none; } }

/* Paso 3 */
.texts { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .texts { grid-template-columns: 1fr 1fr; } }
textarea.agh-field { min-height: 128px; }
.mail-card { display: grid; gap: var(--space-4); }
.mail-fields { display: grid; gap: var(--space-4); grid-template-columns: 1fr; align-items: start; }
.agh-field-wrap { align-content: start; }
@media (min-width: 900px) { .mail-fields { grid-template-columns: 1fr 1.4fr; } }
.preview { background: var(--doc-paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-5); overflow-x: auto; color: #000; }

.toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: var(--space-3) var(--space-5); border-radius: var(--radius-pill); box-shadow: var(--shadow-overlay); font-size: 14px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px); }

/* ---- Acceso, navegación, historial y usuarios ---- */
.topbar .brand { text-decoration: none; }
.topnav { display: flex; gap: var(--space-1); margin-left: auto; flex-wrap: wrap; }
.topnav .agh-btn:not([aria-current]) { border-color: transparent; }
.user-pill { width: 36px; height: 36px; border-radius: var(--radius-pill); background: var(--beige); color: var(--ink); display: grid; place-items: center; font-size: 13px; font-weight: 600; text-decoration: none; }
.user-pill:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.user-pill:focus-visible, .brand:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.login { max-width: 440px; margin: 8vh auto 0; display: grid; gap: var(--space-6); }
.login img { height: 56px; width: auto; }
.login .display-l { color: var(--ink); }
.narrow { max-width: 560px; }
.card .title { color: var(--ink); }

.filters { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--space-5); }
.filters .agh-field-wrap { flex: 1 1 200px; }
.filters .agh-field-wrap.grow { flex: 2 1 260px; }
.tabla-caja { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.tabla { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 14px; }
.tabla th { text-align: left; padding: var(--space-3) var(--space-4); color: var(--text-muted); white-space: nowrap; }
.tabla td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); vertical-align: middle; color: var(--text); }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla td.num { color: var(--ink); font-weight: 600; }
.tabla td.strong { color: var(--ink); font-weight: 600; }
.tabla tr.grp td { background: var(--beige); color: var(--ink); }
.row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.estado-sel { min-height: 36px; height: 36px; padding-top: 0; padding-bottom: 0; font-size: 14px; min-width: 180px; }
.estado-sel.est-pend { border-color: var(--warning); }
.estado-sel.est-ok { border-color: var(--ink); font-weight: 600; }
.empty { display: grid; justify-items: start; gap: var(--space-3); }
.empty .title { color: var(--ink); }
.mail-fields .agh-field-wrap select { max-width: 260px; }
@media (max-width: 720px) { .topnav { order: 3; flex-basis: 100%; margin-left: 0; } }
a.agh-btn, .topbar .brand { text-decoration: none; }
