/* app.css — RRHH component & layout styles (Slice 1: shell + public core).
   Consumes design tokens from tokens.css exclusively (UI-R1): no hardcoded
   colors, no inline styles. Accessibility (UI-R7): normal-size text uses only
   AA pairs; teal/warning/success appear as fills, borders and accents only —
   never as text color (S11). */

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

body { margin: 0; font-family: var(--font-sans); font-size: 16px; line-height: 1.5; color: var(--color-primary); background: var(--color-bg); }

a { color: var(--color-action); }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--color-primary); line-height: 1.25; }

main { padding: var(--space-6); } /* Phase 8 (PR 7): full-bleed stage — the centered ~1400px cap clipped the 90deg wash into a band and squeezed the card grids into a middle column; the block now spans its grid column edge to edge. The phone padding override lives in the small-screen tail block below. */

/* Text-heavy single-column surfaces stay readable on the full-bleed stage:
   form flows cap internally (start-aligned) while lists, KPI/hub grids and
   cards-as-content go wide. Inline row forms shrink-to-fit, so the cap never
   touches them. Phase 9 (PR 8, feedback round 4, item 1): the inline-start
   margin is pinned to 0 explicitly — the period-generation flow showed
   floating in the middle of the wash; every capped flow must hug the start
   edge so no UA or later rule can ever re-center it. */
main form { max-width: 56rem; margin-inline-start: 0; }

/* ---------- Site header / nav (base shell) ---------- */
.site-header { background: var(--color-primary); color: var(--color-surface); }

.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-4); max-width: 72rem; margin: 0 auto; padding: var(--space-3) var(--space-5); }

.brand { display: inline-flex; align-items: center; color: var(--color-surface); text-decoration: none; }
.brand svg { width: 34px; height: 34px; border-radius: var(--radius-md); box-shadow: var(--elevation-1); }
.brand-lg svg { width: 44px; height: 44px; border-radius: var(--radius-md); box-shadow: var(--elevation-2); }
a.brand:hover { text-decoration: none; } /* logo lockup stays clean (global a:hover underlines) */

.nav-link { padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); color: var(--color-surface); opacity: 0.85; transition: opacity var(--motion-duration-1) var(--motion-easing), background-color var(--motion-duration-1) var(--motion-easing); }
.nav-link:hover { opacity: 1; text-decoration: none; background: rgba(255, 255, 255, 0.12); }

.nav-user { margin-left: auto; font-size: 0.875rem; color: var(--color-surface); opacity: 0.9; }

.logout-form { margin: 0; }

.site-footer { margin-top: var(--space-6); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); color: var(--color-muted); font-size: 0.875rem; text-align: center; }
/* Decorative "·" separator between footer labels — accent use, carries no
   readable text (S11: teal/warning/success only as fill/accent, never text) */
.footer-dot { color: var(--color-accent); }

/* ---------- Buttons (UI-R4/S5) ---------- */
.btn { display: inline-block; padding: var(--space-2) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-primary); font: inherit; text-align: center; text-decoration: none; cursor: pointer; transition: box-shadow var(--motion-duration-1) var(--motion-easing), background-color var(--motion-duration-1) var(--motion-easing); }
.btn:hover { text-decoration: none; box-shadow: inset 0 0 0 1000px var(--state-hover); } /* M3 state-layer overlay (UI-R10) */
.btn:active { box-shadow: inset 0 0 0 1000px var(--state-active); }

.btn-primary { background: var(--color-action); border-color: var(--color-action); color: var(--color-surface); /* white on action blue ≈ 5.17:1 — AA (R7) */ }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-primary); }
.btn-danger { background: var(--color-error); border-color: var(--color-error); color: var(--color-surface); }
.btn-sm { padding: var(--space-1) var(--space-2); font-size: 0.875rem; }
.btn-tonal { background: var(--surface-tonal); border: 1px solid var(--color-border); color: var(--color-primary); } /* tonal variant (UI-R10) */

/* ---------- Alerts (semantic accents; S11-safe text) ---------- */
.alert { padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-primary); margin: var(--space-4) 0; }

.alert-error { border: 1px solid var(--color-error); color: var(--color-error); } /* error on surface ≥ 4.5:1 — AA (R7) */
.alert-warning { border: 1px solid var(--color-warning); } /* accent only — warning ≥3:1 */
.alert-success { border: 1px solid var(--color-success); } /* accent only — success ≥3:1 */
.alert-info { border: 1px solid var(--color-info); color: var(--color-info); }

/* ---------- Toasts (messages, rendered in the unswapped shell) ---------- */
.messages { margin: 0 0 var(--space-4); padding: 0; list-style: none; }

.toast { padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow); margin-bottom: var(--space-2); }
.toast-success { border: 1px solid var(--color-success); } /* accent only */
.toast-warning { border: 1px solid var(--color-warning); } /* accent only */
.toast-error { border: 1px solid var(--color-error); color: var(--color-error); }
.toast-info { border: 1px solid var(--color-info); color: var(--color-info); }

/* ---------- Form state classes (UI-R4/S6, zero markup change) ---------- */
.error,
.errorlist { color: var(--color-error); }

.errorlist { margin: var(--space-2) 0; padding: 0; list-style: none; }

.hint { color: var(--color-muted); font-size: 0.875rem; }

.warning { border: 1px solid var(--color-warning); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); } /* accent only */

/* ---------- Form fields (Django form.as_p markup) ---------- */
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select,
textarea { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-primary); font: inherit; transition: border-color var(--motion-duration-1) var(--motion-easing), box-shadow var(--motion-duration-2) var(--motion-easing); }

input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible,
textarea:focus-visible { box-shadow: var(--focus-ring); }

input[type="email"]:hover,
input[type="password"]:hover,
input[type="text"]:hover,
input[type="number"]:hover,
select:hover,
textarea:hover { border: 1px solid var(--color-action); } /* M3 input hover (UI-R10) */

/* Vertical rhythm for Django form.as_p: label above field, a comfortable gap
   between fields, and the submit sitting off the last field (no cramped
   forms across the app). */
form p { margin: 0 0 var(--space-5); }
form p label { display: block; margin-bottom: var(--space-2); color: var(--color-primary); font-weight: 600; }
form .btn { margin-top: var(--space-2); }

/* ---------- Cards (UI-R3 login card, dashboard stats) ---------- */
.card { padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow); }

.auth-card { max-width: 24rem; margin: var(--space-6) auto; padding: var(--space-6); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow); }
.auth-card .brand { display: flex; justify-content: center; margin-bottom: var(--space-3); color: var(--color-primary); font-size: 1.5rem; } /* centered logo on the light auth-card surface */
.auth-card h1 { margin-top: 0; text-align: center; }
.auth-card .btn { width: 100%; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-5); margin: var(--space-6) 0; } /* Phase 6: card groups flow as an elegant responsive grid across the screen */

.stat-card { padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--elevation-1); }
.stat-card:hover { box-shadow: var(--elevation-2); } /* stat emphasis (UI-R10) */
.stat-card h2 { margin: 0 0 var(--space-2); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--color-muted); }
.stat-card .stat-value { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--color-primary); }

/* ---------- Search (Slice 2) ---------- */
.search { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-primary); font: inherit; }
.search:focus-visible { box-shadow: var(--focus-ring); }

/* ---------- Badges (UI-R4; success as fill/accent only — R7/S11) ---------- */
.badge { display: inline-block; padding: 0 var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-muted); font-size: 0.75rem; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge-success { background: color-mix(in srgb, var(--color-success) 15%, var(--color-surface)); border: 1px solid var(--color-success); color: var(--color-primary); } /* muted-success fill keeps text AA */

/* ---------- Tables (UI-R5/S7: wrapped tables scroll horizontally) ---------- */
/* Phase 9 (PR 8, feedback round 4, item 3): content-hugging idiom — automatic
   layout so columns size to their content instead of stretching every column
   to fill the stage (the narrow status columns read as dead space), and
   one-line cells so money amounts and split names never fold mid-value. The
   horizontal scrollbar then appears ONLY when the single-line columns
   actually overflow the wrapper; vertically the wrapper rides content
   height. */
table { width: 100%; table-layout: auto; border-collapse: collapse; }
th, td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--color-muted); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
tbody tr:hover { background: var(--state-hover-surface); } /* S16: row hover state layer */
/* Phase 9 (PR 8, feedback round 4, item 2): the scroll wrapper is a purely
   HORIZONTAL device — max-height none is declared explicitly so no slice can
   ever hand its auto-computed vertical overflow a fixed body height (the
   run-detail provisions showed a blank scroll pit below two rows). It sizes
   to content; wide tables still scroll (S7). */
.table-responsive { overflow-x: auto; max-height: none; -webkit-overflow-scrolling: touch; }

/* ---------- Timeclock entries: day-grouped readability (UI) ---------- */
/* Day headers stand out so one day reads apart from the next: bold accent
   text on a tonal action fill, with a solid left accent rule. Meal marks
   (Comida inicio/fin) get a lighter tonal wash so the meal block is
   distinguishable from work marks at a glance. */
tr.entries-day-header td {
  background: var(--surface-tonal);
  color: var(--color-primary);
  font-weight: 700;
  border-bottom: 2px solid var(--color-action);
  letter-spacing: 0.02em;
}
tr.entries-meal td {
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  color: var(--color-primary);
}
tr.entries-meal td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); }

/* Active-filter feedback banner (entries table): renders above the day rows
   when from/to/employee filters are applied, so a filter whose results
   overlap the unfiltered page 1 (e.g. September) is never invisible. */
tr.entries-filter-banner td {
  background: color-mix(in srgb, var(--color-info) 8%, var(--color-surface));
  border-bottom: 1px solid var(--color-info);
  font-size: 0.875rem;
}
.entries-filter-banner__label { font-weight: 600; color: var(--color-primary); margin-right: var(--space-2); }
.entries-filter-banner__count { margin-left: var(--space-3); color: var(--color-muted); }
.entries-filter-banner__clear { margin-left: var(--space-3); color: var(--color-action); font-weight: 600; text-decoration: none; }
.entries-filter-banner__clear:hover { text-decoration: underline; }

/* ---------- Definition lists (employee/company detail) ---------- */
dl { margin: var(--space-4) 0; }
dl dt { color: var(--color-muted); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
dl dd { margin: 0 0 var(--space-2); }

/* ---------- Employee card grid (list) + detail grid (restyle) ---------- */
/* Cards flow into as many columns as the screen fits — proportional to the
   viewport via auto-fill minmax; ≤480px forces a single column. */
.employee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: var(--space-5); margin: var(--space-6) 0; }
.employee-card { padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--elevation-1); display: flex; flex-direction: column; gap: var(--space-4); }
.employee-card:hover { box-shadow: var(--elevation-2); } /* same emphasis as stat-card */
.employee-card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.employee-card__name { margin: 0; font-size: 1.125rem; }
.employee-card__doc { margin: 0; color: var(--color-muted); }
.employee-card__actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-3); margin-top: auto; } /* Phase 8 (PR 7): pin children to their own height — the default stretch turned the action buttons into tall columns beside the terminate form */
/* The terminate form stacks inside the card column; the inline labels become
   stacked label-above-field rows and inputs stretch to the card width. */
.employee-card .form-inline { display: flex; flex-direction: column; gap: var(--space-3); align-items: stretch; }
.employee-card .form-inline label { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: 0.875rem; }
.employee-card .form-inline input, .employee-card .form-inline select { width: 100%; }
.employee-grid__empty { grid-column: 1 / -1; margin: 0; color: var(--color-muted); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-5); margin: var(--space-6) 0; }
.detail-item { padding: var(--space-4) var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.detail-item:hover { box-shadow: var(--elevation-1); }
.detail-item__label { display: block; color: var(--color-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: var(--space-2); }
.detail-item__value { display: block; color: var(--color-primary); }

/* ---------- Inline forms (S13: replaced inline style=) ---------- */
.form-inline { display: inline; margin: 0; }
.form-inline label { margin-right: var(--space-2); }
.form-inline input, .form-inline select, .form-inline textarea { width: auto; }

/* Vertical spacing for hand-written forms whose fields are direct <label>
   siblings (the clock screen, request forms) — not Django form.as_p and not
   the .form-inline filter rows — so every input field keeps the same
   comfortable rhythm. */
form:not(.form-inline) > label { display: block; margin-bottom: var(--space-5); }
form:not(.form-inline) > label:last-child { margin-bottom: 0; }
form > p label { margin-bottom: var(--space-2); }

/* Keep the employee-row action group (edit/detail/terminate) on one line;
   the .table-responsive wrapper scrolls horizontally when space runs out. */
.employee-actions { white-space: nowrap; }

/* ---------- Pagination (summary day/week nav) ---------- */
.pagination { display: flex; gap: var(--space-2); margin: var(--space-3) 0; padding: 0; list-style: none; }
.pagination a { padding: var(--space-1) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-primary); text-decoration: none; }
.pagination a:hover { border: 1px solid var(--color-action); text-decoration: none; }
.pagination .current,
.pagination .disabled { padding: var(--space-1) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.pagination .current { background: var(--color-action); border-color: var(--color-action); color: var(--color-surface); font-weight: 600; }
.pagination .disabled { color: var(--color-muted); opacity: 0.6; }

/* ---------- Open entries list (Slice 2) ---------- */
.entries-list { margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.entries-list li { padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
.entries-list li:last-child { border-bottom: 0; }

/* ---------- Payroll / admin surfaces (Slice 3) ---------- */
/* Cards stack with generous air so sections never read as one block; panel
   sections inside a card get the same breathing room. */
.card + .card { margin-top: var(--space-6); }
.card section + section { margin-top: var(--space-5); } /* panel sections stack */
.table-responsive.table-wide table { min-width: 80rem; } /* 16-col run detail scrolls (S7) */

/* ---------- Focus (UI-R7) ---------- */
:focus-visible { outline: 2px solid var(--color-action); outline-offset: 2px; box-shadow: var(--focus-ring); }

/* ---------- Breakpoints (UI-R5) ---------- */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; } /* stack stat tiles */
}

@media (max-width: 480px) {
  .site-nav { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .nav-user { margin-left: 0; }
  main { padding: var(--space-4); }
  .employee-grid { grid-template-columns: 1fr; } /* one card per row on phones */
}

/* ---------- M3 selection controls & fields (ui-m3-components Slice 1) ------
   Native inputs rebuilt purely in CSS (UI-R12/S18, design D6): appearance:none
   control boxes with ::before marks, switches = checkboxes carrying
   [role="switch"], segmented buttons = a radio group inside a GET form.
   Everything consumes tokens; keyboard focus keeps var(--focus-ring). */

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  border: 2px solid var(--color-muted);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  vertical-align: middle;
  cursor: pointer;
  transition: background-color var(--motion-duration-1) var(--motion-easing), border-color var(--motion-duration-1) var(--motion-easing);
}

input[type="radio"] { border-radius: var(--radius-full); }

input[type="checkbox"]:hover,
input[type="radio"]:hover { border-color: var(--color-action); } /* M3 state layer (UI-R10) */

input[type="checkbox"]:checked,
input[type="radio"]:checked { background: var(--color-action); border-color: var(--color-action); }

/* Checked marks drawn without assets: check stroke / radio dot */
input[type="checkbox"]:checked::before {
  content: "";
  width: 0.625rem;
  height: 0.3125rem;
  border-left: 2px solid var(--color-surface);
  border-bottom: 2px solid var(--color-surface);
  transform: rotate(-45deg);
}

input[type="radio"]:checked::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-surface);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Switch: checkbox carrying role="switch" — handle-on-track pill (D6) */
input[type="checkbox"].m3-switch[role="switch"] {
  width: 3.25rem;
  height: 2rem;
  border-color: transparent;
  background: var(--color-muted);
  border-radius: var(--radius-full);
  transition: background-color var(--motion-duration-2) var(--motion-easing);
}

input[type="checkbox"].m3-switch[role="switch"]::before {
  content: "";
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--elevation-1);
  transition: translate var(--motion-duration-2) var(--motion-easing);
}

input[type="checkbox"].m3-switch[role="switch"]:hover { border-color: transparent; }

input[type="checkbox"].m3-switch[role="switch"]:checked { background: var(--color-action); }

input[type="checkbox"].m3-switch[role="switch"]:checked::before { translate: 0.875rem 0; }

input[type="checkbox"].m3-switch[role="switch"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Segmented buttons: radio group in a GET form (D6). The radios stay
   keyboard-focusable while visually hidden; selected/focus states ride the
   adjacent label through sibling selectors. */
.m3-segmented {
  display: inline-flex;
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
}

.m3-segmented input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.m3-segmented label {
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--motion-duration-1) var(--motion-easing), box-shadow var(--motion-duration-1) var(--motion-easing);
}

.m3-segmented label:hover { background: var(--state-hover-surface); }

.m3-segmented input[type="radio"]:checked + label {
  background: var(--surface-tonal);
  color: var(--color-action);
}

.m3-segmented input[type="radio"]:focus-visible + label { outline: none; box-shadow: var(--focus-ring); }

/* Outlined fields anchor their helper/error slots beneath the control.
   Django form.as_p emits help_text as <span class="helptext"> and errors as
   <ul class="errorlist"> inside each field paragraph. */
.helptext {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-muted);
  font-size: 0.875rem;
}

form p .errorlist { display: block; } /* errors anchor under the outlined control */

/* Divider utility: separates content sections on a shared surface */
.divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}
/* --- M3 overlays & feedback (ui-m3-components Slice 2) ------------------ */
/* Singleton confirm dialog host: scrim + centered surface. The host lives
   outside every HTMX swap target (base.html), so an open dialog can never
   be destroyed mid-confirmation. */
.m3-dialog-scrim {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  z-index: 40;
}

.m3-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 26rem);
  z-index: 50;
}

.m3-dialog[hidden],
.m3-dialog-scrim[hidden] { display: none; }

.m3-dialog__surface {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-3);
  padding: var(--space-5);
}

.m3-dialog__surface h2 {
  margin-top: 0;
  color: var(--color-primary);
}

.m3-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* Snackbar: rides swapped payloads; m3.js activates, auto-dismisses after
   its timeout and caps the stack at three (oldest removed). */
.m3-snackbar {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-surface);
  box-shadow: var(--elevation-2);
  animation: m3-snackbar-in var(--motion-duration-2) var(--motion-easing);
}

@keyframes m3-snackbar-in {
  from { opacity: 0; transform: translateY(var(--space-1)); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dropdown menu shell (nav-user collapse lands in Slice 3) */
.m3-menu {
  position: absolute;
  min-width: 12rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-2);
  padding: var(--space-1) 0;
  z-index: 30;
}

.m3-menu[hidden] { display: none; }

.m3-menu a,
.m3-menu .m3-menuitem {
  display: block;
  padding: var(--space-2) var(--space-4);
  color: inherit;
  text-decoration: none;
}

.m3-menu a:hover { background: var(--state-hover-surface); }

/* --- M3 navigation & surfaces (ui-m3-components Slice 3) ---------------- */
/* Tabs (UI-R16/S27): query-param driven links — activation is server-rendered
   (D5), so the indicator is a plain border/color state on aria-selected. */
.m3-tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}

.m3-tab {
  padding: var(--space-2) var(--space-4);
  border-bottom: 2px solid transparent;
  color: var(--color-muted);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--motion-duration-1) var(--motion-easing), border-color var(--motion-duration-1) var(--motion-easing);
}

.m3-tab:hover { color: var(--color-primary); text-decoration: none; }

.m3-tab[aria-selected="true"] {
  border-bottom-color: var(--color-action); /* selected-tab indicator */
  color: var(--color-action);
}

.m3-tab:focus-visible { outline: none; border-radius: var(--radius-sm); box-shadow: var(--focus-ring); }

.m3-tabpanel[hidden] { display: none; }

/* Extended FAB (UI-R16/S28): text-based pill for the clock-in action */
.fab-extended {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-tonal);
  color: var(--color-action);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--elevation-2);
  transition: box-shadow var(--motion-duration-2) var(--motion-easing), background-color var(--motion-duration-1) var(--motion-easing);
}

.fab-extended:hover { box-shadow: var(--elevation-3); }

.fab-extended:active { box-shadow: inset 0 0 0 1000px var(--state-active); }

.fab-extended:focus-visible { outline: none; box-shadow: var(--elevation-2), var(--focus-ring); }

.fab-extended__icon { font-size: 1.25rem; line-height: 1; }

/* Disabled extended-FAB state (uniform-buttons UX): the inapplicable clock
   action stays visible but inert — no wrong-click bugs. UX-only guard; the
   service layer still enforces the invariants server-side (S55/S60-S62). */
.fab-extended[disabled],
.fab-extended:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.fab-extended[disabled]:hover,
.fab-extended:disabled:hover {
  box-shadow: none;
  background: var(--surface-tonal);
}

button[disabled] { cursor: not-allowed; }

/* Two extended FABs sharing one form (admin clock screen) sit apart. */
form .fab-extended + .fab-extended { margin-left: var(--space-2); }

/* List items (UI-R16/S30): status dot + body + trailing action */
.m3-list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.entries-list .m3-list-item:last-child { border-bottom: 0; }

.m3-list-item__dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-success); /* status fill only, never text (S11) */
}

.m3-list-item__action { white-space: nowrap; }

/* Nav-user collapse (UI-R16/S29): desktop email becomes the menu trigger
   wired to the dormant Slice-2 menu module; mobile keeps flat links. */
.nav-user-area { position: relative; margin-left: auto; }

.nav-user-toggle {
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-surface);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity var(--motion-duration-1) var(--motion-easing), background-color var(--motion-duration-1) var(--motion-easing);
}

.nav-user-toggle:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }

/* The foot cluster lives at the bottom of the 100vh rail: menus open UPWARD
   (bottom-anchored) so a fully rendered dropdown never spills past the
   viewport's bottom edge. */
.nav-user-area .m3-menu { top: auto; bottom: calc(100% + var(--space-1)); right: 0; }

.m3-menu .m3-menuitem {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  border: 0;
  background: none;
  color: var(--color-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.m3-menu .m3-menuitem:hover { background: var(--state-hover-surface); }

/* Rail notification bell (dashboard-ui-redesign Phase 10, unit B): a
   feather-style bell rides the rail text pair inside the foot trigger; the
   unread bubble overlays its top-right corner ONLY while unread rows exist
   (AA white-on-error pair, 4.83:1; the template caps past nine
   as "9+"). Dropdown rows pair the event label with the portal's date idiom
   (label left, muted meta right); the mark-all action is the last row under
   a hairline separator. Zero new tokens, zero new media rules: the bell
   simply flows inside the foot (mobile strip rules untouched). */
.notif-bell {
  position: relative;
  display: inline-flex;
  color: var(--sidebar-text);
}

.notif-bell svg { width: 1.25rem; height: 1.25rem; }

.notif-bell__count {
  position: absolute;
  top: -0.4rem;
  right: -0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  background: var(--color-error);
  color: var(--color-surface);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
}

.notif-menu {
  min-width: 20rem;
  /* BADGE_LIMIT caps rows at five, but a short viewport gets internal
     scroll instead of a panel taller than the screen. */
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

/* The 20rem panel is wider than the 15.5rem rail: anchor its left edge to
   the bell cluster so it grows RIGHT into the content column (the foot
   `right: 0` anchor pushed the panel past the viewport's left edge — the
   clipped labels). The id selector outranks `.nav-user-area .m3-menu`. */
#notif-menu { left: 0; right: auto; }

.m3-menu .notif-menu__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Muted small-caps-adjacent meta: the repo .section-label typography on the
   timestamp (the digits themselves carry the es-CR d/m/Y H:i portal idiom). */
.notif-menu__time {
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.notif-menu__actions {
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--color-border);
}

/* Clickable dropdown rows (WU1): a resolvable notification renders as an
   anchor, so the row gains a pointer cursor and its label underlines on
   hover. The hover fill itself is the generic menu-anchor rule the dropdown
   already shares (state-hover-surface token) — nothing new is painted. */
a.notif-menu__row { cursor: pointer; }

a.notif-menu__row:hover .notif-menu__label { text-decoration: underline; }

@media (min-width: 769px) {
  .logout-form-flat { display: none; } /* menu owns logout on desktop */
}

/* The ≤768px counterpart (.nav-user-area collapse) lives in the mobile
   top-strip tail block at the end of this file (dashboard-ui-redesign
   Phase 4): strip overrides must sit after the shell base rules to win
   the cascade, and that last block re-emits the marker the nav-user
   rindex pins read. */

/* Button variants (UI-R16/S30): outlined and text treatments on .btn */
.btn-outlined {
  border-color: var(--color-action);
  background: transparent;
  color: var(--color-action);
}

.btn-text {
  border-color: transparent;
  background: transparent;
  color: var(--color-action);
}

.btn-text:hover { box-shadow: none; background: var(--state-hover); }

/* Progress glue (UI-R16/S30, D2): htmx toggles the htmx-request class around
   declared hx-indicator targets natively — no progress JS module. */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--motion-duration-1) var(--motion-easing);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

.m3-progress {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  vertical-align: middle;
}

.m3-progress::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-action);
  border-radius: var(--radius-full);
  animation: m3-progress-spin 800ms linear infinite;
}

@keyframes m3-progress-spin { to { transform: rotate(360deg); } }

/* Tooltips (UI-S26): popups are server-rendered siblings shown on hover AND
   keyboard focus; m3.js positions them within the viewport. */
.m3-tooltip__popup {
  position: fixed;
  z-index: 35;
  max-width: 18rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-surface); /* overrides the muted .hint text in popups */
  font-size: 0.875rem;
  box-shadow: var(--elevation-2);
}

.m3-tooltip__popup[hidden] { display: none; }

/* Screen-reader-only text (portal vacation cards): visually hidden, still
   readable by assistive tech — carries the full "label: value" balance
   string so both the test contract and screen readers keep the exact text. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Single reduced-motion rule disables all m3 motion (D1 contract) */
@media (prefers-reduced-motion: reduce) {
  .m3-snackbar { animation: none; }
  .m3-progress::before { animation: none; }
  input[type="checkbox"].m3-switch[role="switch"],
  input[type="checkbox"].m3-switch[role="switch"]::before,
  .m3-segmented label,
  .m3-tab,
  .fab-extended,
  .htmx-indicator { transition: none; }
}

/* ---------- Print ----------------------------------------------------------------
   The print block lives at the END of this file (relocated in the
   dashboard-ui-redesign Phase 4 tail move): the rail class joins the hidden
   set, and no rail selector text may precede the base rule the first-match
   test pins read. Behaviour unchanged: same block, same media. */

/* ---------- Reference card language (dashboard-ui-redesign, UI-R19/S39) ---
   Additive token-driven utilities: dashboard KPI cards and the employee-hub
   header adopt them in a later phase. Every color consumes the additive
   token set — zero hex (UI-S40), accent-family tokens fill only, never text
   color (UI-S11). */

/* Accent variants bind the hairline fill (D4) and the 12px card radius;
   --radius-md stays untouched for existing surfaces (UI-R1 additive set). */
.card-accent-teal { --card-accent: var(--accent-teal); border-radius: var(--radius-card); }
.card-accent-green { --card-accent: var(--accent-green); border-radius: var(--radius-card); }
.card-accent-red { --card-accent: var(--accent-red); border-radius: var(--radius-card); }

.card-accent-teal,
.card-accent-green,
.card-accent-red { position: relative; }

/* 3px top hairline drawn by a shared pseudo-element (D4): fills only, so the
   card content never shifts the way a border-top would. */
.card-accent-teal::before,
.card-accent-green::before,
.card-accent-red::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent);
}

/* Icon chip (D5): rounded-square pale fill from the --chip-*-bg color-mix
   tokens, holding an inline SVG glyph only — icon libraries stay a non-goal. */
.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: var(--chip-teal-bg);
}

.icon-chip--green { background: var(--chip-green-bg); }
.icon-chip--red { background: var(--chip-red-bg); }

.icon-chip svg { width: 1.25rem; height: 1.25rem; }

/* Stat-dot row bullets beside names: accent fills, never text (S11). */
.stat-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent-teal);
}

.stat-dot--green { background: var(--accent-green); }
.stat-dot--red { background: var(--accent-red); }

/* AA numeric text (UI-R7/D6): colored values ride the dedicated
   --color-value-* tokens — the restricted accent/success pairs never do.
   Phase 6 semantic map: blue = neutral counts, green = healthy/ok,
   red = warnings/at-limit, teal (accent) = money. */
.value-positive { color: var(--color-value-positive); }
.value-negative { color: var(--color-value-negative); }
.value-accent { color: var(--color-value-accent); }
.value-blue { color: var(--color-value-blue); }

/* Dashboard payroll report (WU2, dashboard-charts): the period rows are now
   a Chart.js bar canvas — the totals strip keeps the count/bruto/neto/
   provisión readout. The three chart cards flow as an auto-fit grid and
   each canvas rides a fixed-height frame so the responsive charts keep a
   stable non-aspect-ratio box. Desktop base rules; no new media blocks. */
.report-totals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}

.report-totals p { margin: 0; }

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
}

.chart-box {
  position: relative;
  height: 260px;
}

.notif-inbox__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-1) 0;
}

.notif-inbox__actions {
  margin-top: var(--space-2);
}

/* Small-caps section label: the .stat-card h2 treatment as a reusable
   utility for card and hub headers. */
.section-label {
  margin: 0 0 var(--space-2);
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Shell grid + sidebar rail (dashboard-ui-redesign, UI-R17/S32) ---
   Grid body (D1): dark role-nav rail in column one, light wash-backed content
   column in two. Pure layout + rail skin — zero URLs/forms changed, zero media
   queries added (the tail-pair rindex contract: strip rules only ever join the
   LAST small-screen block, a later phase). All colors consume tokens (UI-S40);
   rail text rides the AA-verified sidebar pair (UI-R7). Phase 10 (unit A): the
   wash is painted HERE, on the shell box, so it spans the full height of the
   document and reaches the bottom of the screen — the old capped band on the
   content stage ended mid-viewport in a hard horizontal edge. A 90deg gradient
   is vertically uniform (no vertical stop, no seam); the rail paints opaquely
   over the wash and the stage/footer stay transparent, so the tint only shows
   right of the rail. Semantics: background-attachment default scroll — one
   paint across the whole document height; short pages stay washed via the 1fr
   row the 100vh rail stretches. */

body.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr auto;
  background: linear-gradient(90deg, var(--grad-left) 0%, var(--grad-mid) 35%, var(--grad-right) 70%);
}

/* The rail: viewport-sticky dark column spanning both grid rows so the dark
   surface reaches the page bottom behind the footer. The rail itself never
   clips: the foot dropdown (notifications) must be able to grow past the
   15.5rem column into the content side. Internal scroll lives on the nav
   block below (flex child with min-height:0) so a long nav still scrolls
   while the foot stays pinned. */
.app-sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  /* Above the content grid item (DOM-order stacking): the escaping foot
     dropdown must paint over cards/tables. Below tooltips (35)/dialogs (40+);
     ignored on mobile where the rail is static. */
  z-index: 30;
}

/* Bare bodies (no shell class) never show the rail (D2): auth-bare pages opt
   out of the whole column via this suppression. */
body:not(.app-shell) .app-sidebar { display: none; }

.app-sidebar__brand { display: flex; justify-content: center; padding-bottom: var(--space-3); }

.app-sidebar__nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; min-height: 0; overflow-y: auto; }

.app-sidebar__foot { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-3); }

/* Small-caps group labels — the reference language on the dark surface,
   riding the AA-verified rail text pair (never a restricted token, S11). */
.sidebar-label {
  margin: var(--space-3) 0 var(--space-1);
  color: var(--sidebar-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
}

.sidebar-link:hover {
  text-decoration: none;
  color: var(--sidebar-active-text);
  background: rgba(255, 255, 255, 0.08);
}

/* Current-section tonal pill (UI-R18): --sidebar-active-bg fill + white label. */
.sidebar-link--active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

/* Content column: grid slot two, transparent stage (Phase 10, unit A). The
   cyan wash moved to the shell rule above — no height cap, no repeat trick:
   the stage bleeds the full-height wash and the seam it used to cut at the
   band's bottom edge cannot exist without a band. */
body.app-shell .app-content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

body.app-shell .site-footer { grid-column: 2; grid-row: 2; }

/* ---------- Mobile top strip (dashboard-ui-redesign Phase 4, UI-R5/S7/D3) ---
   Rail → full-width dark top strip via media queries ONLY — zero JS bytes
   (UI-S45, m3.js untouched). Tail-appended after the shell base rules so the
   overrides win the cascade; as the LAST small-screen (768) block it owns the
   rindex region the nav-user desktop pins read and re-emits their
   .nav-user-area collapse there. 480px needs no new rules: stat tiles already
   stack at ≤768 (.stats-grid) and tables keep the .table-responsive scroll. */
@media (max-width: 768px) {
  .nav-user-area { display: none; } /* menu collapses; flat logout rides the strip */

  body.app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .app-sidebar {
    grid-row: 1;
    position: static;    /* no sticky viewport column on phones */
    height: auto;        /* content-height band, not 100vh */
    align-self: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-2) var(--space-3);
    overflow-y: visible;
    border-right: 0;                              /* the band sits above content */
    border-bottom: 1px solid var(--sidebar-border); /* separator rotates with the strip */
  }
  .app-sidebar__brand { padding-bottom: 0; }
  .app-sidebar__nav {
    flex: 1;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: var(--space-1);
    overflow-x: auto;    /* links scroll INSIDE the strip: no page overflow (S7) */
  }
  .sidebar-label { margin: 0; white-space: nowrap; }
  .sidebar-link { flex-shrink: 0; white-space: nowrap; }
  .app-sidebar__foot {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    padding-top: 0;
  }
  body.app-shell .app-content { grid-column: 1; grid-row: 2; }
  body.app-shell .site-footer { grid-column: 1; grid-row: 3; }
}

/* ---------- Print (PAYSLIP-R5/D6: the recibo prints as ONE sheet) --------
   Hiding the base chrome (rail/site header, footer, messages, logout,
   `.no-print` action toolbars) so only the recibo sheet prints (S7/S8,
   UI-S42). Phase 4 adds `.app-sidebar` to the hidden set; the block sits
   after the shell rules so the rail class never precedes its base selector
   (first-match pins), keeping test_payslip.py's membership list untouched. */
@media print {
  .site-header,
  .site-footer,
  .messages,
  .logout-form,
  .no-print,
  .app-sidebar { display: none; }
  .payslip-sheet { page-break-inside: avoid; break-inside: avoid; }
}
