/* Sistema de diseño — Asistencia del despacho.
   Identidad: azul marino del logo (`--ikb`) sobre papel blanco, líneas finas y tipografía firme. Todo local. */
:root {
  --ikb: #03376e; /* azul marino del logo (NAV-10); el nombre del token se conserva */
  --ikb-strong: #022550;
  --ikb-soft: #e8eef6;
  --ikb-line: #b7c6dc;
  --ink: #0b0f1a;
  --ink-2: #444b5e;
  --paper: #ffffff;
  --surface: #ffffff;
  --line: #d8d9de;
  --line-strong: #0b0f1a;
  --ok: #0f5a31;
  --ok-soft: #e2f2e8;
  --warn: #7a4a00;
  --warn-soft: #fff0d2;
  --bad: #9b1c14;
  --bad-soft: #fbe3e0;
  --radius: 4px;
  --font: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--font); }
:focus-visible { outline: 3px solid var(--ikb); outline-offset: 2px; }
a { color: var(--ikb); text-underline-offset: 3px; }
a:hover { color: var(--ikb-strong); }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(1.75rem, 3.6vw, 2.5rem); font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--ink-2); }
.eyebrow { display: block; margin: 0 0 .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--ikb); }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura ---------- */
.app-layout { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; padding: 0 clamp(1.25rem, 3vw, 2.5rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--ink); }
.brand-mark { display: block; width: 32px; height: 32px; flex: none; }
.brand-name { font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.brand-name small { display: block; font-size: .68rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.menu-btn { display: inline-flex; align-items: center; gap: .6rem; min-height: 48px; padding: 0 .25rem 0 1rem; border: 0; background: none; color: var(--ink); font-weight: 600; }
.menu-btn:hover { background: none; color: var(--ikb); }
.menu-icon { display: block; width: 20px; height: 2px; margin-bottom: 6px; background: currentColor; box-shadow: 0 6px 0 currentColor; }
.content { min-width: 0; padding: clamp(1.25rem, 3vw, 2.5rem); }
main { max-width: 1120px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line-strong); }

/* Hoja de menú: entra por la derecha; cerrada no recibe foco. */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(21 23 28 / .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: min(88vw, 22rem); display: flex; flex-direction: column; overflow-y: auto; padding: .5rem 1.5rem 1.5rem; background: var(--surface); box-shadow: -1px 0 0 var(--line); transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
.menu-open .scrim { opacity: 1; pointer-events: auto; }
.menu-open .sheet { transform: none; visibility: visible; transition-delay: 0s; }
.sheet-close { align-self: flex-end; min-height: 48px; padding: 0 0 0 1rem; border: 0; background: none; color: var(--ink-2); font-weight: 500; }
.sheet-close:hover { background: none; color: var(--ink); }
.nav-label { margin: 1.5rem 0 .25rem; font-size: .95rem; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link { display: flex; align-items: center; min-height: 52px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 1.15rem; }
.nav-link:hover { color: var(--ikb); }
.nav-link[aria-current="page"] { color: var(--ikb); font-weight: 700; }
.nav-more > summary { display: flex; align-items: center; min-height: 52px; color: var(--ink-2); cursor: pointer; list-style: none; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after { content: "+"; margin-left: .5rem; font-size: 1.25rem; }
.nav-more[open] > summary::after { content: "–"; }
.nav-more .nav-link { font-size: 1.05rem; }
.account { padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.account-btn { display: flex; text-decoration: none; align-items: center; gap: .75rem; width: 100%; min-height: 56px; padding: .25rem 0; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.account-btn:hover { color: var(--ikb); }
.account-btn[aria-current="page"] .account-name { color: var(--ikb); }
.about-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: auto; padding-top: 1.5rem; color: var(--ink-2); font-size: .95rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.sheet-logout { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.logout-btn { min-height: 48px; padding: 0; border: 0; background: none; color: var(--ink-2); font-weight: 500; font-size: .95rem; text-decoration: none; }
.logout-btn:hover { background: none; color: var(--ikb); text-decoration: underline; }
.account-name { font-weight: 600; font-size: 1.05rem; }
.avatar { display: inline-flex; flex: none; width: 2.5rem; height: 2.5rem; overflow: hidden; border-radius: 50%; background: #CFE4F6; box-shadow: inset 0 0 0 1px var(--line-strong); }
.avatar svg[hidden] { display: none; }
.avatar .avatar-svg { width: 100%; height: 100%; }
.account-page h3 { margin-top: 0; }
.avatar.avatar-sm { width: 1.75rem; height: 1.75rem; vertical-align: middle; margin-right: .4rem; }
.avatar.avatar-lg { width: 5rem; height: 5rem; }
.avatar.avatar-xl { width: 112px; height: 112px; } /* 8× el busto de 14 px: píxeles enteros */
.swatches { margin: 1.25rem 0 0; padding: 0; border: 0; }
.swatches[hidden] { display: none; }
.swatches .choice { display: inline-flex; align-items: center; margin: .35rem 1rem 0 0; font-weight: 500; }
.swatches legend { padding: 0; font-size: .9rem; font-weight: 600; }
.swatches .swatch { display: inline-block; margin: .35rem .5rem 0 0; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch-dot { display: block; width: 2.25rem; height: 2.25rem; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); cursor: pointer; }
.swatch input:checked + .swatch-dot { outline: 3px solid var(--ikb); outline-offset: 2px; }
.swatch input:focus-visible + .swatch-dot { outline: 3px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .scrim, .sheet { transition: none; } }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.1rem, 2.5vw, 1.75rem); margin: 0 0 1.25rem; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 1rem; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.25rem; }
.tile { display: block; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ink); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.tile:hover { border-top-color: var(--ikb); background: var(--ikb-soft); color: var(--ink); }
.tile.accent { border-top-color: var(--ikb); }
.tile.alert { border-top-color: var(--bad); }
.tile .value { display: block; font-size: 2.4rem; font-weight: 600; letter-spacing: -.03em; line-height: 1; margin: .35rem 0 .25rem; font-variant-numeric: tabular-nums; }
.tile .label { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.tile .note { font-size: .85rem; color: var(--ink-2); }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 2px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; background: var(--ikb-soft); color: var(--ikb-strong); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: #ececef; color: var(--ink-2); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); margin: .25rem 0 1.5rem; font-size: .95rem; }
th, td { padding: .7rem .9rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); background: #fbfbf9; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
tbody tr:hover { background: #fafaf7; }
tbody tr:last-child td { border-bottom: 0; }
ul.plain, ul.records { list-style: none; margin: 0; padding: 0; }
ul.records li, ul.plain li { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
ul.records li:first-child, ul.plain li:first-child { border-top: 0; }
.receipt { font-family: var(--mono); font-weight: 700; color: var(--ikb); letter-spacing: .04em; }
.empty { padding: 1.5rem; border: 1px dashed var(--line); text-align: center; color: var(--ink-2); background: var(--surface); }

/* Botones y formularios */
button, .button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .6rem 1.3rem; border: 1px solid var(--ikb); border-radius: var(--radius); background: var(--ikb); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .12s; }
button:hover, .button:hover, .btn:hover { background: var(--ikb-strong); border-color: var(--ikb-strong); color: #fff; }
button.secondary, .button.secondary, .btn.secondary { background: var(--surface); color: var(--ikb); }
button.secondary:hover, .button.secondary:hover, .btn.secondary:hover { background: var(--ikb-soft); color: var(--ikb-strong); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--ikb); text-decoration: underline; font-weight: 500; font-size: inherit; }
button:disabled { opacity: .55; cursor: not-allowed; }
label { display: block; margin: 1.1rem 0 .35rem; font-size: .9rem; font-weight: 600; }
input:not([type=checkbox]):not([type=radio]), select, textarea { display: block; width: 100%; max-width: 32rem; min-height: 48px; padding: .6rem .8rem; border: 1px solid #8a8f9e; border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit; }
textarea { min-height: 7rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ikb); }
input[type=checkbox], input[type=radio] { width: 1.15rem; height: 1.15rem; accent-color: var(--ikb); vertical-align: middle; margin-right: .4rem; }
form p { margin-bottom: 0; }
.errorlist { list-style: none; margin: .35rem 0 0; padding: 0; color: var(--bad); font-size: .9rem; font-weight: 600; }
.helptext { display: block; color: var(--ink-2); font-size: .85rem; margin-top: .25rem; }
form.inline { display: inline; }
details.disclosure > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; color: var(--ikb); }
details.disclosure[open] > summary::after { content: "−"; }

/* Avisos */
.messages { margin-bottom: 1.5rem; display: grid; gap: .5rem; }
.msg { padding: .75rem 1rem; border: 1px solid var(--ikb-line); border-left: 4px solid var(--ikb); background: var(--ikb-soft); border-radius: var(--radius); }
.msg.error { border-color: #e7b6b1; border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.msg.success { border-color: #b4d9c1; border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.msg.warning { border-color: #e6cd9a; border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.alert { color: var(--warn); }

/* Acceso (anónimo) */
.auth-layout { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: #f4f6f9; }
.auth-layout .content { padding: 0; width: 100%; max-width: 440px; }
.auth-layout main { max-width: none; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ikb); padding: clamp(1.5rem, 5vw, 2.5rem); }
.brand-logo { display: block; margin: 0 auto 1.75rem; width: min(300px, 78%); }
.brand-logo img { display: block; width: 100%; height: auto; }
.auth-layout h1 { font-size: 1.7rem; margin-bottom: 1.25rem; }
.auth-layout button[type=submit] { width: 100%; margin-top: 1.5rem; }

/* ---------- Teléfono ---------- */
@media (max-width: 900px) { .page-head { margin-bottom: 1.25rem; } }
@media (max-width: 560px) {
  th, td { padding: .55rem .6rem; }
  table { font-size: .88rem; }
}
@media print { .topbar, .scrim, .sheet { display: none; } }

/* Plantillas de allauth (restablecer contraseña, reautenticación, TOTP, etc.) */
.auth-layout form p, main form > p { margin-bottom: 0; }
.remember label { display: flex; align-items: center; font-weight: 500; margin-top: 1rem; }
main img[alt*="QR"], main svg { max-width: 220px; height: auto; }
.auth-layout main svg { display: block; margin: 1rem 0; }

/* Acciones secundarias y destructivas */
.btn-sm, button.btn-sm { min-height: 40px; padding: .3rem .9rem; font-size: .88rem; }
button.danger, .button.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
button.danger:hover, .button.danger:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
td .inline + a, td a + .inline { margin-left: .75rem; }

/* Formularios en rejilla y filtros en una fila */
form.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1.25rem; align-items: end; }
form.form-grid p { margin: 0; }
form.form-grid input:not([type=checkbox]):not([type=radio]), form.form-grid select, form.form-grid textarea { max-width: none; }
form.form-grid .wide { grid-column: 1 / -1; }
form.form-grid button { grid-column: 1 / -1; justify-self: start; margin-top: 1.25rem; }
form.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1rem; margin-bottom: 1.25rem; }
form.filters p, form.filters label { margin-bottom: 0; }
form.filters input { max-width: 12rem; }
form.filters button { margin-top: 1.1rem; }

/* Indicador de avance (horas reales frente al presupuesto) y cifras */
.bar { height: 6px; background: #ececef; margin-top: .35rem; min-width: 120px; }
.bar > span { display: block; height: 100%; background: var(--ikb); }
.bar.over > span { background: var(--bad); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); font-weight: 700; }
.sub { display: block; font-size: .82rem; color: var(--ink-2); font-weight: 400; }

/* allauth: acción de cancelar en el paso de 2FA y similares */
button[form="logout-from-stage"] { background: var(--surface); color: var(--ikb); }
button[form="logout-from-stage"]:hover { background: var(--ikb-soft); color: var(--ikb-strong); }
.auth-layout button[form="logout-from-stage"] { margin-top: .75rem; }

main > h2, main > form + h2, main > .scroll + h2 { margin-top: 2.25rem; }
td .badge { white-space: normal; }

/* Selector de rango de fechas (NAV-09) */
.range-field [hidden], .range-pop[hidden] { display: none !important; }
.range-field { position: relative; grid-column: 1 / -1; }
.range-label { display: block; margin: 1.1rem 0 .35rem; font-size: .9rem; font-weight: 600; }
button.range-trigger { display: flex; width: 100%; max-width: 32rem; min-height: 48px; padding: .6rem .8rem; justify-content: flex-start; text-align: left; border: 1px solid #8a8f9e; border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit; font-weight: 400; }
button.range-trigger .placeholder { color: var(--ink-2); }
.range-error { display: block; margin-top: .4rem; color: #a40e26; font-size: .9rem; }
.range-pop { position: absolute; z-index: 20; left: 0; top: 100%; width: min(100%, 20rem); margin-top: .35rem; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.range-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; text-transform: capitalize; }
.range-head button { min-height: 44px; min-width: 44px; padding: 0; }
.range-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.range-dow { font-size: .8rem; color: var(--ink-2); padding: .25rem 0; }
button.range-day { min-height: 40px; padding: 0; border: 0; border-radius: var(--radius); background: none; color: var(--ink); font-weight: 400; }
button.range-day:hover { background: var(--ikb-soft); color: var(--ink); }
button.range-day.between { background: #dbe6f3; }
button.range-day.edge { background: var(--ikb); color: #fff; }
.range-hint { margin: .6rem 0 0; font-size: .85rem; }
/* Los botones del selector no heredan la regla de `form.form-grid button` (ocupar toda la fila). */
form.form-grid .range-field button { grid-column: auto; justify-self: stretch; margin-top: 0; }
form.form-grid .range-field button.range-trigger { margin-top: 0; }

/* NAV-11: tarjetas con acción; el botón queda al pie y alineado entre tarjetas. */
.card-action { display: flex; flex-direction: column; }
.card-action .card-cta { margin-top: auto; padding-top: 12px; }

/* NAV-13: «Mi cuenta» ordenada: identidad, tarjeta de avatar y tarjetas de seguridad. */
.account-id { display: flex; flex-wrap: wrap; gap: .1rem .9rem; margin: .5rem 0 0; color: var(--ink-2); font-size: 1.0625rem; overflow-wrap: anywhere; }
.account-id strong { color: var(--ink); }
.account-grid { display: grid; gap: 1.5rem; align-items: start; }
.account-grid h2 { margin: 0 0 1rem; }
.account-card h2 { margin-bottom: 1.25rem; }
.account-security { display: grid; gap: 1.25rem; }
.account-security h2 { margin: 0; }
.account-security .card, .account-card.card { margin: 0; }
.account-security h3 { margin: 0 0 1rem; font-size: 1.125rem; }
.avatar-editor { display: grid; gap: 1.5rem; justify-items: start; }
.avatar-controls { display: grid; gap: 1.1rem; width: 100%; }
.avatar-controls .swatches { margin: 0; }
.avatar-controls .swatches legend { margin-bottom: .4rem; font-size: 1rem; }
.avatar-controls .swatches .swatch { margin: .25rem .4rem .25rem 0; padding: 2px; }
.swatch-dot { width: 2.25rem; height: 2.25rem; }
.segmented { display: flex; flex-wrap: wrap; gap: .5rem; }
.segmented legend { flex: 0 0 100%; }
.segmented .choice { position: relative; margin: 0; }
.segmented .choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented .choice span { display: inline-flex; align-items: center; justify-content: center; min-width: 7rem; min-height: 44px; padding: 0 1.1rem; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-weight: 600; cursor: pointer; }
.segmented .choice input:checked + span { border-color: var(--ikb); background: var(--ikb); color: #fff; }
.segmented .choice input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.account-save { justify-self: start; margin-top: .5rem; min-height: 44px; }
.password-form p { margin: 0 0 1rem; }
.password-form input { width: 100%; max-width: 26rem; }
.hint-line { margin: 0 0 1rem; color: var(--ink-2); font-size: .95rem; }
.mfa-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.mfa-row .badge { font-size: .95rem; padding: .3rem .75rem; }
@media (min-width: 56rem) {
  .account-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .avatar-editor { grid-template-columns: auto 1fr; align-items: start; }
}
