/* ============================================================================
   Faden v2 · Recommended direction (base C) · styles.css
   Shared shell and components for screens 01–04. Mockup 17-10-2026, datos ficticios.
   Reads tokens.css only: no colour literal in this file (F14). Panels stack with
   @container (F16); only the drawer switch is a viewport query at 1023 px (Filament lg).
   ============================================================================ */

/* ---- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: var(--fd-text-body) var(--fd-font);
  color: var(--fd-text);
  background: var(--fd-bg);
}
h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
table { border-collapse: collapse; }
button { font: inherit; color: inherit; }
code { font-family: var(--fd-font-mono); }
a { color: var(--fd-link); text-underline-offset: 2px; }
a:hover { color: var(--fd-link-hover); }
:focus-visible { outline: 2px solid var(--fd-focus-ring); outline-offset: 2px; }
.fd-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;
}

/* Skip link: the first focusable element on every screen (F20). */
.fd-skip {
  position: absolute; left: 16px; top: -120px; z-index: 100;
  display: inline-flex; align-items: center; min-height: var(--fd-target); padding: 0 16px;
  background: var(--fd-surface); color: var(--fd-link); font-weight: 600;
  border: 2px solid var(--fd-focus-ring); border-radius: var(--fd-radius-control);
}
.fd-skip:focus { top: 8px; }

/* Icons: Heroicons v2, outline 24 (stroke 1.5) or mini 20, colour from the context. */
.fd-icon { width: var(--fd-icon-nav); height: var(--fd-icon-nav); flex: none; }
.fd-icon--sm { width: var(--fd-icon-inline); height: var(--fd-icon-inline); }
.fd-icon--panel { width: var(--fd-icon-panel); height: var(--fd-icon-panel); }

/* Icon tile (COMPARISON §3.4): 28 px, radius 6, 18 px icon; the only place a family tint appears (F7). */
.fd-tile {
  display: inline-grid; place-items: center; flex: none;
  width: var(--fd-tile); height: var(--fd-tile); border-radius: var(--fd-radius-control);
  background: var(--fd-tile-neutral-bg); color: var(--fd-tile-neutral-fg);
}
.fd-tile .fd-icon { width: var(--fd-icon-panel); height: var(--fd-icon-panel); }
.fd-tile--plan      { background: var(--fd-tile-plan-bg);      color: var(--fd-tile-plan-fg); }
.fd-tile--interview { background: var(--fd-tile-interview-bg); color: var(--fd-tile-interview-fg); }
.fd-tile--situation { background: var(--fd-tile-situation-bg); color: var(--fd-tile-situation-fg); }
.fd-tile--academic  { background: var(--fd-tile-academic-bg);  color: var(--fd-tile-academic-fg); }
.fd-tile--neutral   { background: var(--fd-tile-neutral-bg);   color: var(--fd-tile-neutral-fg); }
.fd-tile--overdue   { background: var(--fd-tile-overdue-bg);   color: var(--fd-tile-overdue-fg); }
.fd-tile--waiting   { background: var(--fd-tile-waiting-bg);   color: var(--fd-tile-waiting-fg); }
.fd-tile--ok        { background: var(--fd-tile-ok-bg);        color: var(--fd-tile-ok-fg); }
.fd-tile--draft     { background: var(--fd-tile-draft-bg);     color: var(--fd-tile-draft-fg); }
.fd-tile--progress  { background: var(--fd-tile-progress-bg);  color: var(--fd-tile-progress-fg); }

/* ---- Shell (COMPARISON §3.7) ---------------------------------------------- */
.fd-shell { display: grid; grid-template-columns: var(--fd-sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.fd-shell__body { display: flex; flex-direction: column; min-width: 0; }
.fd-shell__main {
  flex: 1; width: 100%; max-width: var(--fd-content-max); margin: 0 auto;
  padding: var(--fd-gap) var(--fd-gutter) var(--fd-gutter);
  display: flex; flex-direction: column; gap: var(--fd-gap);
}

/* Sidebar: light gray-50, 248 px, grouped items with one icon each (VIS2-D17 (a)). */
.fd-nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--fd-nav-bg); border-right: 1px solid var(--fd-border-hairline);
}
.fd-nav__brand { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 16px 12px 20px; }
.fd-nav__wordmark { display: flex; flex-direction: column; gap: 6px; font: 700 var(--fd-text-h1) var(--fd-font); color: var(--fd-text); }
/* Five-stitch mark under «Faden» (§3.8, F17): the LINK brand SVG, stroke primary-600, round caps. */
.fd-nav__stitches { display: block; line-height: 0; }
.fd-nav__stitches svg { display: block; width: 84px; height: 8px; }
.fd-nav__stitches path { fill: none; stroke: var(--fd-stitch); stroke-width: 2; stroke-linecap: round; }
.fd-nav__close { display: none; }
.fd-nav__groups { display: flex; flex-direction: column; gap: 16px; padding: 4px 12px 16px; }
.fd-nav__group-label { padding: 0 12px 4px; font: 600 var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted); }
.fd-nav__list { display: flex; flex-direction: column; gap: 2px; }
.fd-nav__item {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px;
  border: 1px solid transparent; border-left-width: 3px; border-radius: var(--fd-radius-control);
  color: var(--fd-text-muted); font-weight: 600; text-decoration: none;
}
.fd-nav__item .fd-icon { color: var(--fd-icon); }
.fd-nav__item:hover { background: var(--fd-nav-hover-bg); color: var(--fd-text); }
/* Active item: white card, 3 px accent bar as a border (F23), icon and label in text colour. */
.fd-nav__item[aria-current="page"] {
  background: var(--fd-nav-active-bg); color: var(--fd-text);
  border-color: var(--fd-border-hairline); border-left-color: var(--fd-action-marker);
}
.fd-nav__item[aria-current="page"] .fd-icon { color: var(--fd-text); }
.fd-nav__spacer { flex: 1; }
/* Institution navy bar, once per screen. */
.fd-nav__footer {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 20px;
  background: var(--fd-inst-primary); color: var(--fd-text-inverse); font: var(--fd-text-meta) var(--fd-font);
}
.fd-nav__footer strong { font-weight: 600; }
.fd-nav__footer span { color: var(--fd-inst-text-2); }
.fd-nav__footer :focus-visible { outline-color: var(--fd-focus-ring-on-dark); }
.fd-nav__backdrop { display: none; }

/* Topbar: drawer toggle (< 1024), breadcrumb, fictitious-data notice, actor, exit. */
.fd-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; min-height: var(--fd-topbar-h); padding: 0 var(--fd-gutter);
  background: var(--fd-surface); border-bottom: 1px solid var(--fd-border-hairline);
}
.fd-topbar__menu { display: none; }
.fd-topbar__brand { display: none; font: 700 var(--fd-text-h2) var(--fd-font); }
.fd-topbar__spacer { flex: 1; }
.fd-breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: var(--fd-text-meta) var(--fd-font); }
.fd-breadcrumb li + li::before { content: "›"; margin-right: 6px; color: var(--fd-text-subtle); }
.fd-breadcrumb [aria-current="page"] { color: var(--fd-text); font-weight: 600; }
.fd-actor { display: flex; align-items: center; gap: 10px; }
.fd-actor__text { display: flex; flex-direction: column; text-align: right; }
.fd-actor__name { font: 600 var(--fd-text-meta) var(--fd-font); }
.fd-actor__role { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-avatar {
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px;
  border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-control);
  background: var(--fd-surface-sunken); color: var(--fd-text); font: 600 var(--fd-text-meta) var(--fd-font);
}
.fd-avatar--lg { width: 48px; height: 48px; font: 600 var(--fd-text-h2) var(--fd-font); }
.fd-exit {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 8px;
  border-radius: var(--fd-radius-control); color: var(--fd-link); font-weight: 600; text-decoration: none;
}
.fd-exit:hover { background: var(--fd-nav-hover-bg); }

/* ---- Record header and record tabs ---------------------------------------- */
.fd-record-header {
  padding: var(--fd-card-pad) var(--fd-card-pad) 0;
  background: var(--fd-surface); border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-card);
}
.fd-record-header__row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; }
.fd-record-header__id { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fd-record-header__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.fd-record-header h1 { font: 600 var(--fd-text-h1) var(--fd-font); }
.fd-record-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-record-header__meta li { display: inline-flex; align-items: center; gap: 6px; }
.fd-record-header__meta .fd-icon { color: var(--fd-icon); }
/* Header order (owner, 18-10-2026): name · course, RUN, head teacher · enrolment then plan · alerts · actions. */
.fd-record-header__status, .fd-record-header__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-record-header__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.fd-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border: 1px solid var(--fd-state-info-border); border-radius: var(--fd-radius-pill);
  background: var(--fd-state-info-bg); color: var(--fd-state-info-fg); font: 600 var(--fd-text-meta) var(--fd-font);
}
/* Record tabs wrap instead of scrolling, so the D9 marker popover is never clipped. */
.fd-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; margin-top: 12px; border-top: 1px solid var(--fd-border-hairline); }
.fd-tabs__item {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--fd-card-head-h); padding: 0 12px;
  border-bottom: 2px solid transparent; color: var(--fd-text-muted); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.fd-tabs__item .fd-icon { color: var(--fd-icon); }
.fd-tabs__item:hover { color: var(--fd-text); border-bottom-color: var(--fd-border-control); }
/* Selected record tab: the 2 px accent underline, a border (F23). */
.fd-tabs__item[aria-current="page"] { color: var(--fd-text); border-bottom-color: var(--fd-action-marker); }
.fd-tabs__item[aria-current="page"] .fd-icon { color: var(--fd-text); }
.fd-tabs__count, .fd-card__count {
  display: inline-block; min-width: 20px; padding: 0 6px; text-align: center;
  border-radius: var(--fd-radius-badge); background: var(--fd-state-neutral-bg); color: var(--fd-state-neutral-fg);
  font: 600 var(--fd-text-floor) var(--fd-font); font-variant-numeric: tabular-nums;
}

/* ---- Record grid (8/4 rail) and cards, stacked with @container (F16) ------ */
.fd-grid { container: record / inline-size; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--fd-gap); }
.fd-col-12 { grid-column: span 12; }
.fd-col-8 { grid-column: span 8; }
.fd-col-6 { grid-column: span 6; }
.fd-col-4 { grid-column: span 4; }
.fd-stack { display: flex; flex-direction: column; gap: var(--fd-gap); min-width: 0; }
@container record (max-width: 959px) {
  .fd-col-8 { grid-column: span 7; }
  .fd-col-4 { grid-column: span 5; }
}
@container record (max-width: 759px) {
  .fd-col-8, .fd-col-6, .fd-col-4 { grid-column: span 12; }
}

.fd-card {
  container: card / inline-size;
  display: flex; flex-direction: column; min-width: 0;
  background: var(--fd-surface); border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-card);
  box-shadow: var(--fd-shadow-card);
}
/* An open decision popover lifts its card above the next one (cards are containment contexts). */
.fd-card:has(.fd-decision[open]) { z-index: 5; }
.fd-card__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  min-height: var(--fd-card-head-h); padding: 8px var(--fd-card-pad); border-bottom: 1px solid var(--fd-border-hairline);
}
.fd-card__title { font: 600 var(--fd-text-h2) var(--fd-font); }
.fd-card__meta { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-card__action { margin-left: auto; display: inline-flex; align-items: center; min-height: 28px; font: 600 var(--fd-text-meta) var(--fd-font); }
.fd-card__body { display: flex; flex-direction: column; gap: 12px; padding: var(--fd-card-pad); }
.fd-card__body--flush { gap: 0; padding: 0; }
.fd-card__foot {
  display: flex; flex-direction: column; gap: 4px; margin-top: auto; padding: 8px var(--fd-card-pad);
  border-top: 1px solid var(--fd-border-hairline); font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted);
}

/* Section heading (Académico): title + tile, provenance, publication subtabs. */
.fd-section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.fd-section-head__title { display: flex; align-items: center; gap: 10px; font: 600 var(--fd-text-h2) var(--fd-font); }
.fd-section-head .fd-provenance { margin-top: 4px; }
.fd-subtabs { display: flex; flex-wrap: wrap; gap: 0 4px; }
.fd-subtabs__item {
  display: flex; flex-direction: column; justify-content: center; min-height: var(--fd-card-head-h); padding: 2px 12px;
  border-bottom: 2px solid transparent; color: var(--fd-link); font-weight: 600; text-decoration: none;
}
.fd-subtabs__item:hover { border-bottom-color: var(--fd-border-control); }
/* Publication subtab underline: primary-600, never red (F19). */
.fd-subtabs__item[aria-current="true"] { color: var(--fd-text); border-bottom-color: var(--fd-subtab-marker); }
.fd-subtabs__detail { font: 400 var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }

/* ---- Figure / stat tile (32/36 tabular, text colour; F3, F6, F22) -------- */
.fd-figure-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: var(--fd-card-pad); }
@container card (max-width: 599px) { .fd-figure-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container card (max-width: 299px) { .fd-figure-strip { grid-template-columns: minmax(0, 1fr); } }
.fd-figure {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px;
  border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-control);
}
.fd-figure__head { display: flex; align-items: center; gap: 8px; }
.fd-figure__label { font: 600 var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-figure__value { font: 700 var(--fd-text-figure) var(--fd-font); color: var(--fd-figure); font-variant-numeric: tabular-nums; }
.fd-figure__value--date { font-size: 18px; } /* a date keeps the 36 px line so the strip stays aligned */
.fd-figure__sub { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-figure__link { align-self: flex-start; margin-top: auto; font: 600 var(--fd-text-meta) var(--fd-font); }
.fd-figure--overdue { background: var(--fd-overdue-bg); border-color: var(--fd-overdue-border); border-left-width: 3px; padding-left: 10px; }
.fd-figure--overdue .fd-figure__label, .fd-figure--overdue .fd-figure__sub { color: var(--fd-overdue-text); }
.fd-figure--plain { padding: 0; border: 0; }

/* ---- Key-value list, facts, chips, state badges --------------------------- */
.fd-kv { display: flex; flex-direction: column; gap: 10px; }
.fd-kv__label { display: flex; align-items: center; gap: 8px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-kv__label .fd-icon { color: var(--fd-icon); }
.fd-kv__value { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding-left: 24px; font-weight: 600; }
/* Guardian phone row: the phone icon travels inside the tel: link (F5), so label and value align at 24 px. */
.fd-kv__label--indent { padding-left: 24px; }
.fd-kv__value--tel { padding-left: 0; }
.fd-tel { display: inline-flex; align-items: center; gap: 8px; min-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fd-tel .fd-icon { color: var(--fd-link); }
.fd-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.fd-facts dt { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-facts dd { display: flex; align-items: center; gap: 6px; }
.fd-facts dd .fd-icon { color: var(--fd-icon); }

.fd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 2px 8px;
  border: 1px solid var(--fd-state-neutral-border); border-radius: var(--fd-radius-badge);
  background: var(--fd-state-neutral-bg); color: var(--fd-state-neutral-fg); font: 600 var(--fd-text-meta) var(--fd-font);
}
.fd-chip--info { border-color: var(--fd-state-info-border); background: var(--fd-state-info-bg); color: var(--fd-state-info-fg); }
.fd-chip--outline { border-color: var(--fd-border-control); background: var(--fd-surface); }
/* Overdue: warning text 700, 3 px warning-600 rule, warning-50 surface, bell-alert, «Vencido/a» and the date. */
.fd-chip--overdue {
  border-color: var(--fd-overdue-border); border-left-width: 3px;
  background: var(--fd-overdue-bg); color: var(--fd-overdue-text);
}

.fd-badge-state {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; white-space: nowrap;
  border: 1px solid var(--fd-state-neutral-border); border-radius: var(--fd-radius-badge);
  background: var(--fd-state-neutral-bg); color: var(--fd-state-neutral-fg); font: 600 var(--fd-text-meta) var(--fd-font);
}
.fd-badge-state[data-state="activo"], .fd-badge-state[data-state="en-curso"] {
  border-color: var(--fd-state-info-border); background: var(--fd-state-info-bg); color: var(--fd-state-info-fg);
}
.fd-badge-state[data-state="satisfecho"], .fd-badge-state[data-state="aprobada"] {
  border-color: var(--fd-state-success-border); background: var(--fd-state-success-bg); color: var(--fd-state-success-fg);
}
.fd-badge-state[data-state="en-revision"] {
  border-color: var(--fd-state-waiting-border); background: var(--fd-state-waiting-bg); color: var(--fd-state-waiting-fg);
}
.fd-badge-state[data-state="vencido"] {
  border-color: var(--fd-overdue-border); border-left-width: 3px; background: var(--fd-overdue-bg); color: var(--fd-overdue-text);
}

/* ---- Buttons, overdue alert, errors -------------------------------------- */
.fd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border: 1px solid transparent; border-radius: var(--fd-radius-control);
  font: 600 var(--fd-text-body) var(--fd-font); text-decoration: none; cursor: pointer;
}
/* The one filled primary button per screen (action red, VIS2-D3). */
.fd-btn--primary { background: var(--fd-action); color: var(--fd-text-inverse); }
.fd-btn--primary:hover { background: var(--fd-action-hover); color: var(--fd-text-inverse); }
.fd-btn--primary:active { background: var(--fd-action-active); }
.fd-btn--secondary { border-color: var(--fd-secondary); background: var(--fd-surface); color: var(--fd-secondary-text); }
.fd-btn--secondary:hover { background: var(--fd-state-info-bg); color: var(--fd-link-hover); }
.fd-btn--link { padding-inline: 8px; color: var(--fd-link); }
.fd-btn--link:hover { text-decoration: underline; }

.fd-alert--overdue {
  display: grid; grid-template-columns: var(--fd-icon-nav) minmax(0, 1fr); gap: 2px 10px; padding: 10px 12px;
  border-left: 3px solid var(--fd-overdue-border); border-radius: var(--fd-radius-control);
  background: var(--fd-overdue-bg); color: var(--fd-overdue-text);
}
.fd-alert--overdue > .fd-icon { grid-row: 1 / span 3; }
.fd-alert__title { font-weight: 600; }
.fd-alert__links { font: 600 var(--fd-text-meta) var(--fd-font); }
/* Errors: crimson outline and text, never a fill (F21). */
.fd-alert--error {
  display: grid; grid-template-columns: var(--fd-icon-nav) minmax(0, 1fr); gap: 2px 10px; padding: 10px 12px;
  border: 1px solid var(--fd-error-border); border-left-width: 3px; border-radius: var(--fd-radius-control);
  background: var(--fd-error-bg); color: var(--fd-error-text);
}
.fd-field-error { display: flex; align-items: center; gap: 4px; font: 600 var(--fd-text-meta) var(--fd-font); color: var(--fd-error-text); }
.fd-input--error { border-color: var(--fd-error-border); }

/* ---- Tables --------------------------------------------------------------- */
.fd-table-wrap { width: 100%; }
.fd-table { width: 100%; font: var(--fd-text-table) var(--fd-font); }
.fd-table caption { padding: 8px var(--fd-card-pad); text-align: left; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-table th, .fd-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--fd-border-hairline); }
.fd-table th:first-child, .fd-table td:first-child { padding-left: var(--fd-card-pad); }
/* Table headers are never sticky (F14). */
.fd-table thead th { background: var(--fd-surface-sunken); font: 600 var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted); white-space: nowrap; }
.fd-table tbody th { font-weight: 600; }
.fd-table tbody tr:last-child > * { border-bottom: 0; }
.fd-num { text-align: right; font-variant-numeric: tabular-nums; }
/* One body type in every table (owner, 18-10-2026): values, empty states («Sin …») and second lines all use the
   table size; values and empty states share the text colour, only second lines (dates, due notes) are muted. */
.fd-cell-note { display: block; font: 400 var(--fd-text-table) var(--fd-font); color: var(--fd-text-muted); }
.fd-cell-muted { color: var(--fd-text); }
.fd-cell-icon { display: inline-flex; align-items: center; gap: 6px; }
.fd-cell-icon .fd-icon { color: var(--fd-icon); }
/* A value the export omits: a dash with the verbatim sentence as hidden text; the source line explains the dash (owner, 18-10-2026). */
.fd-na { font: 400 var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); white-space: normal; }
.fd-table .fd-na { font: 400 var(--fd-text-table) var(--fd-font); }

/* Stacked rows when the card is narrow: each cell carries its column label, on its own line above the value, so a long
   label never collides with the next row and the row grows with its content (owner, 27-10-2026). */
@container card (max-width: 559px) {
  .fd-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fd-table--stack, .fd-table--stack tbody, .fd-table--stack tr, .fd-table--stack th, .fd-table--stack td { display: block; }
  .fd-table--stack tr { padding: 10px var(--fd-card-pad); border-bottom: 1px solid var(--fd-border-hairline); }
  .fd-table--stack tbody tr:last-child { border-bottom: 0; }
  .fd-table--stack tbody th, .fd-table--stack td { padding: 3px 0; border: 0; }
  .fd-table--stack tbody th:first-child, .fd-table--stack td:first-child { padding-left: 0; }
  .fd-table--stack [data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font: 600 var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted);
  }
}

/* Labelled scroller for wide tables (F9): role="region", tabindex="0", aria-labelledby. */
/* position: relative keeps the cells' absolutely positioned .fd-sr-only text inside the scroller, so it never widens the page. */
.fd-table-wrap--scroll {
  position: relative;
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--fd-surface) 30%, var(--fd-surface-clear)) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--fd-surface) 30%, var(--fd-surface-clear)) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--fd-shadow-color), var(--fd-surface-clear)) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--fd-shadow-color), var(--fd-surface-clear)) right / 10px 100% no-repeat scroll;
}
.fd-table-wrap--scroll:focus-visible { outline-offset: -2px; }
.fd-scroll-hint { display: none; padding: 8px var(--fd-card-pad) 0; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
@container card (max-width: 799px) { .fd-scroll-hint { display: block; } }

/* Grade table: one cell per exported field, centred, compact 7px 8px cells (F2, F4). */
.fd-table--grades th, .fd-table--grades td { padding: 7px 8px; text-align: center; vertical-align: middle; font-variant-numeric: tabular-nums; }
.fd-table--grades thead th { white-space: nowrap; }
.fd-table--grades .fd-group-start { border-left: 1px solid var(--fd-border-hairline); }
.fd-table--grades .fd-term { background: var(--fd-surface-sunken); font-weight: 600; }
/* The subject column stays pinned horizontally inside the scroller; no header row is sticky. */
.fd-table--grades tbody th, .fd-table--grades thead tr:first-child th:first-child {
  position: sticky; left: 0; z-index: 1; min-width: 180px; text-align: left; white-space: normal;
}
.fd-table--grades tbody th { background: var(--fd-surface); }

/* ---- Plan block: subheads, activities, requirements ----------------------- */
.fd-subhead { display: flex; align-items: center; gap: 8px; padding: 10px var(--fd-card-pad) 6px; font: 600 var(--fd-text-body) var(--fd-font); }
.fd-subhead .fd-icon { color: var(--fd-icon); }
.fd-activity { padding: 12px var(--fd-card-pad); border-top: 1px solid var(--fd-border-hairline); }
.fd-activity__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 12px; }
.fd-activity__title { font: 600 var(--fd-text-body) var(--fd-font); }
.fd-activity__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-activity__meta li { display: inline-flex; align-items: center; gap: 6px; }
.fd-activity__meta .fd-icon { color: var(--fd-icon); }
.fd-reqs { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.fd-req {
  display: grid; grid-template-columns: var(--fd-icon-inline) minmax(0, 1fr) auto; gap: 2px 8px; align-items: start; padding: 8px 10px;
  border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-control); font: var(--fd-text-table) var(--fd-font);
}
.fd-req > .fd-icon { margin-top: 2px; color: var(--fd-icon); }
.fd-req__title { font-weight: 600; }
.fd-req__note { grid-column: 2 / span 2; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-req--overdue {
  padding-left: 8px; border-color: var(--fd-overdue-bg); border-left: 3px solid var(--fd-overdue-border);
  background: var(--fd-overdue-bg); color: var(--fd-overdue-text);
}
.fd-req--overdue > .fd-icon, .fd-req--overdue .fd-req__note { color: var(--fd-overdue-text); }
@container card (max-width: 479px) {
  .fd-req { grid-template-columns: var(--fd-icon-inline) minmax(0, 1fr); }
  .fd-req .fd-badge-state { grid-column: 2; justify-self: start; }
  .fd-req__note { grid-column: 2; }
}
.fd-empty-line { margin-top: 8px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }

/* ---- Situation, update, narrative, dates list ----------------------------- */
.fd-situation__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 12px; }
.fd-situation__title { font: 600 var(--fd-text-body) var(--fd-font); }
.fd-update { display: grid; grid-template-columns: var(--fd-icon-inline) minmax(0, 1fr); gap: 2px 10px; padding-top: 12px; border-top: 1px solid var(--fd-border-hairline); }
.fd-update > .fd-icon { grid-row: 1 / span 2; margin-top: 1px; color: var(--fd-icon); }
.fd-update__meta { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-narrative__meta { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-narrative__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-dates { display: flex; flex-direction: column; }
.fd-dates__item { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 0 10px; padding: 8px 0; border-top: 1px solid var(--fd-border-hairline); font: var(--fd-text-table) var(--fd-font); }
.fd-dates__item:first-child { padding-top: 0; border-top: 0; }
.fd-dates__date { grid-row: 1 / span 2; font-weight: 600; font-variant-numeric: tabular-nums; }
.fd-dates__who { grid-column: 2; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }

/* ---- Staff e-mail (VIS2-D4): same row as the guardian phone; long addresses wrap inside the rail ---- */
.fd-mail { max-width: 100%; overflow-wrap: anywhere; font-variant-numeric: normal; }

/* ---- Academic figures on the Resumen (VIS2-D14): two exported values, a big muted dash when none ---- */
.fd-figure-strip--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 480px; }
.fd-figure__value.fd-na { font: 700 var(--fd-text-figure) var(--fd-font); color: var(--fd-text-muted); }

/* ---- Acta pipeline on the record (VIS2-D15): derived label and three steps, never the original ---- */
.fd-acta { margin: 0 var(--fd-card-pad) 12px; padding: 12px; border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-control); background: var(--fd-surface-sunken); }
.fd-acta__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.fd-acta__title { font: 600 var(--fd-text-body) var(--fd-font); }
.fd-acta__steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; padding: 0; list-style: none; }
.fd-acta__step { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 22px 12px 0 0; }
/* Dot: hollow gray (next), filled primary (done), amber ring (current, the «En revisión» waiting tone). */
.fd-acta__step::before {
  content: ""; position: absolute; z-index: 1; top: 0; left: 0; box-sizing: border-box; width: 14px; height: 14px;
  border: 2px solid var(--fd-border-control); border-radius: 50%; background: var(--fd-surface);
}
.fd-acta__step::after { content: ""; position: absolute; top: 6px; left: 18px; right: 4px; height: 2px; border-radius: 1px; background: var(--fd-border-hairline); }
.fd-acta__step:last-child::after { display: none; }
.fd-acta__step[data-step="done"]::before { border-color: var(--fd-primary-700); background: var(--fd-primary-700); }
.fd-acta__step[data-step="done"]::after { background: var(--fd-primary-700); }
.fd-acta__step[data-step="current"]::before { border-color: var(--fd-state-waiting-fg); background: var(--fd-state-waiting-bg); box-shadow: 0 0 0 3px var(--fd-state-waiting-border); }
.fd-acta__label { font: 600 var(--fd-text-meta) var(--fd-font); color: var(--fd-text); }
.fd-acta__step[data-step="next"] .fd-acta__label { color: var(--fd-text-muted); }
.fd-acta__when { font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-acta__note { display: flex; align-items: center; gap: 6px; margin-top: 12px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-acta__note .fd-icon { flex: none; color: var(--fd-icon); }
@container card (max-width: 479px) {
  .fd-acta__steps { grid-template-columns: minmax(0, 1fr); }
  .fd-acta__step { padding: 0 0 12px 24px; }
  .fd-acta__step:last-child { padding-bottom: 0; }
  .fd-acta__step::before { top: 2px; }
  .fd-acta__step::after { top: 20px; bottom: 0; left: 6px; right: auto; width: 2px; height: auto; }
}

/* ---- Timeline: date, 28 px tile, text, author ------------------------------ */
.fd-timeline { display: flex; flex-direction: column; }
.fd-timeline__item {
  display: grid; grid-template-columns: 112px var(--fd-tile) minmax(0, 1fr); gap: 0 10px; align-items: start;
  padding: 8px var(--fd-card-pad) 8px calc(var(--fd-card-pad) - 3px);
  border-top: 1px solid var(--fd-border-hairline); border-left: 3px solid transparent;
}
.fd-timeline__item:first-child { border-top-color: transparent; }
.fd-timeline__date { grid-column: 1; grid-row: 1 / span 2; font: var(--fd-text-meta) var(--fd-font); line-height: var(--fd-tile); color: var(--fd-text-muted); font-variant-numeric: tabular-nums; }
.fd-timeline__item > .fd-tile { grid-column: 2; grid-row: 1 / span 2; }
.fd-timeline__text { grid-column: 3; padding-top: 4px; font: var(--fd-text-table) var(--fd-font); }
.fd-timeline__meta { grid-column: 3; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-timeline__item--overdue { border-left-color: var(--fd-overdue-border); background: var(--fd-overdue-bg); color: var(--fd-overdue-text); }
.fd-timeline__item--overdue .fd-timeline__date, .fd-timeline__item--overdue .fd-timeline__meta { color: var(--fd-overdue-text); }
@container card (max-width: 479px) {
  .fd-timeline__item { grid-template-columns: var(--fd-tile) minmax(0, 1fr); }
  .fd-timeline__item > .fd-tile { grid-column: 1; grid-row: 1 / span 3; }
  .fd-timeline__date { grid-column: 2; grid-row: auto; line-height: 18px; }
  .fd-timeline__text { padding-top: 0; }
  .fd-timeline__text, .fd-timeline__meta { grid-column: 2; }
}

/* ---- Decision marker (F13): a visible chip that opens the question, keyboard reachable ---- */
.fd-decision { position: relative; display: inline-block; vertical-align: middle; font-weight: 400; }
.fd-decision > summary {
  display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 1px 6px 1px 4px;
  border: 1px dashed var(--fd-border-control); border-radius: var(--fd-radius-badge);
  background: var(--fd-surface); color: var(--fd-text-muted);
  font: 600 var(--fd-text-floor) var(--fd-font); white-space: nowrap; list-style: none; cursor: pointer;
}
.fd-decision > summary::-webkit-details-marker { display: none; }
.fd-decision > summary .fd-icon { width: var(--fd-icon-inline); height: var(--fd-icon-inline); color: var(--fd-icon); }
.fd-decision > summary:hover, .fd-decision[open] > summary { border-style: solid; color: var(--fd-text); }
.fd-decision__q {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0;
  width: max-content; max-width: min(320px, 80vw); padding: 10px 12px;
  background: var(--fd-surface); border: 1px solid var(--fd-border-hairline); border-radius: var(--fd-radius-control);
  box-shadow: var(--fd-shadow-popover); color: var(--fd-text); font: 400 var(--fd-text-meta) var(--fd-font);
  text-align: left; white-space: normal;
}
.fd-decision--end .fd-decision__q { left: auto; right: 0; }
.fd-decision--up .fd-decision__q { top: auto; bottom: calc(100% + 6px); }

/* Provenance line: circle-stack + muted meta text. */
.fd-provenance { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-provenance .fd-icon { color: var(--fd-icon); }

/* ---- Attendance: monthly strip, daily grid, legend ------------------------- */
.fd-month-strip { width: 100%; table-layout: fixed; font: var(--fd-text-table) var(--fd-font); }
.fd-month-strip th, .fd-month-strip td { padding: 6px 2px; text-align: center; border-left: 1px solid var(--fd-border-hairline); }
.fd-month-strip th:first-child, .fd-month-strip td:first-child { border-left: 0; }
.fd-month-strip thead th { background: var(--fd-surface-sunken); border-bottom: 1px solid var(--fd-border-hairline); font: 600 var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted); }
.fd-month-strip td { font: 700 var(--fd-text-h2) var(--fd-font); color: var(--fd-figure); font-variant-numeric: tabular-nums; }

.fd-grid-attendance { width: 100%; min-width: 420px; table-layout: fixed; font: var(--fd-text-table) var(--fd-font); }
.fd-grid-attendance th, .fd-grid-attendance td { padding: 4px 2px; text-align: center; border: 1px solid var(--fd-border-hairline); }
.fd-grid-attendance thead th { height: 32px; background: var(--fd-surface-sunken); font: 600 var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted); }
.fd-grid-attendance tbody th { background: var(--fd-surface-sunken); font: 600 var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted); }
/* Daily cells (owner, 18-10-2026): only the day number; present = light green, absent = the same red ramp at the
   green's lightness (accent-700 on accent-50, 7,44:1, with an accent-200 ring), other = gray with a dashed rule.
   Since both tints are light, absent also carries a 3 px accent-400 base line and a bolder number, so it reads
   without hue; the state is hidden text in each cell too (WCAG 1.4.1). */
.fd-grid-attendance { border-collapse: separate; border-spacing: 4px; }
.fd-grid-attendance th, .fd-grid-attendance td { border: 0; border-radius: var(--fd-radius-badge); }
.fd-grid-attendance td { height: 40px; font: 600 var(--fd-text-table) var(--fd-font); font-variant-numeric: tabular-nums; }
.fd-att__day { display: block; }
.fd-grid-attendance td:has(.fd-att__code--present) { background: var(--fd-success-50); color: var(--fd-success-700); box-shadow: inset 0 0 0 1px var(--fd-success-200); }
.fd-grid-attendance td:has(.fd-att__code--absent) { background: var(--fd-accent-50); color: var(--fd-accent-700); font-weight: 700; box-shadow: inset 0 0 0 1px var(--fd-accent-200), inset 0 -3px 0 var(--fd-accent-400); }
.fd-grid-attendance td:has(.fd-att__code--other) { background: var(--fd-gray-100); color: var(--fd-gray-700); box-shadow: inset 0 0 0 1px var(--fd-gray-400); outline: 1px dashed var(--fd-gray-500); outline-offset: -4px; }
.fd-attendance-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font: var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-attendance-legend li { display: inline-flex; align-items: center; gap: 6px; }
.fd-att-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.fd-att-swatch--present { background: var(--fd-success-50); box-shadow: inset 0 0 0 1px var(--fd-success-400); }
.fd-att-swatch--absent { background: var(--fd-accent-50); box-shadow: inset 0 0 0 1px var(--fd-accent-400), inset 0 -3px 0 var(--fd-accent-400); }
.fd-att-swatch--other { background: var(--fd-gray-100); box-shadow: inset 0 0 0 1px var(--fd-gray-500); }
.fd-provenance__note { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--fd-border-hairline); }
/* ---- Disclosure: protected NAPSIS annotations; opening is audited ---------- */
.fd-disclosure > summary {
  display: flex; align-items: center; gap: 8px; min-height: var(--fd-card-head-h); padding: 6px var(--fd-card-pad);
  font: 600 var(--fd-text-body) var(--fd-font); color: var(--fd-link); list-style: none; cursor: pointer;
}
.fd-disclosure > summary::-webkit-details-marker { display: none; }
.fd-disclosure__note { font: 400 var(--fd-text-meta) var(--fd-font); color: var(--fd-text-muted); }
.fd-disclosure__chev { margin-left: auto; color: var(--fd-icon); }
.fd-disclosure[open] .fd-disclosure__chev { transform: rotate(180deg); }
.fd-disclosure[open] > summary { border-bottom: 1px solid var(--fd-border-hairline); }

/* ---- Page footer: screen identification and palette decisions -------------- */
.fd-footer {
  width: 100%; max-width: var(--fd-content-max); margin: 0 auto; padding: 0 var(--fd-gutter) 20px;
  font: var(--fd-text-floor) var(--fd-font); color: var(--fd-text-muted);
}
.fd-footer p, .fd-footer__decisions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding-top: 6px; }
.fd-footer > :first-child { padding-top: 12px; border-top: 1px solid var(--fd-border-hairline); }

/* ---- Below 1024 px (Filament lg): the sidebar is a drawer, targets ≥ 44 px (F16, F18) ---- */
@media (max-width: 1023px) {
  :root { --fd-gutter: 16px; }
  .fd-shell { grid-template-columns: minmax(0, 1fr); }
  .fd-nav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(var(--fd-sidebar-w), 86vw); height: auto;
    transform: translateX(-100%); visibility: hidden; box-shadow: var(--fd-shadow-popover);
  }
  .fd-nav[data-open="true"] { transform: none; visibility: visible; }
  .fd-nav__close {
    display: inline-grid; place-items: center; width: var(--fd-target); height: var(--fd-target); margin: -8px -8px 0 0;
    border: 0; border-radius: var(--fd-radius-control); background: var(--fd-surface-clear); color: var(--fd-text); cursor: pointer;
  }
  .fd-nav__backdrop { position: fixed; inset: 0; z-index: 40; background: var(--fd-backdrop); }
  .fd-nav[data-open="true"] + .fd-nav__backdrop { display: block; }
  .fd-topbar { gap: 8px; }
  .fd-topbar__menu {
    display: inline-grid; place-items: center; width: var(--fd-target); height: var(--fd-target); margin-left: -8px;
    border: 0; border-radius: var(--fd-radius-control); background: var(--fd-surface-clear); color: var(--fd-text); cursor: pointer;
  }
  .fd-topbar__brand { display: inline; }
  .fd-actor__text, .fd-exit__label {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .fd-nav__item, .fd-btn, .fd-exit, .fd-tabs__item, .fd-subtabs__item, .fd-disclosure > summary { min-height: var(--fd-target); }
  .fd-exit { min-width: var(--fd-target); justify-content: center; }
  .fd-card__action, .fd-figure__link, .fd-tel, .fd-breadcrumb a, .fd-alert__links a {
    display: inline-flex; align-items: center; min-height: var(--fd-target);
  }
  .fd-decision > summary { min-width: var(--fd-target); min-height: var(--fd-target); }
}
@media (max-width: 639px) {
  .fd-breadcrumb { display: none; }
  .fd-record-header__actions { width: 100%; }
}

/* ---- Motion (§3.7): hover and focus only, 150 ms, behind the reduced-motion guard ---- */
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-motion='reduced']) .fd-nav__item,
  :root:not([data-motion='reduced']) .fd-tabs__item,
  :root:not([data-motion='reduced']) .fd-subtabs__item,
  :root:not([data-motion='reduced']) .fd-btn,
  :root:not([data-motion='reduced']) .fd-exit,
  :root:not([data-motion='reduced']) .fd-decision > summary {
    transition: background-color var(--fd-motion-fast) var(--fd-ease), color var(--fd-motion-fast) var(--fd-ease),
      border-color var(--fd-motion-fast) var(--fd-ease);
  }
}

/* ---- Forced colours (F23): rules, markers, tiles and chips keep a visible edge ---- */
@media (forced-colors: active) {
  .fd-nav__item, .fd-tabs__item, .fd-subtabs__item, .fd-timeline__item { border-color: Canvas; }
  .fd-nav__item[aria-current="page"] { border-color: Highlight; }
  .fd-tabs__item[aria-current="page"], .fd-subtabs__item[aria-current="true"] { border-bottom-color: Highlight; }
  .fd-figure--overdue, .fd-chip--overdue, .fd-badge-state[data-state="vencido"], .fd-req--overdue,
  .fd-alert--overdue, .fd-timeline__item--overdue { border-color: CanvasText; }
  .fd-tile, .fd-chip, .fd-badge-state, .fd-pill, .fd-tabs__count, .fd-card__count, .fd-avatar { border: 1px solid CanvasText; }
  .fd-decision__q, .fd-nav { border-color: CanvasText; }
  .fd-nav__stitches path { stroke: CanvasText; }
  .fd-btn--primary { border-color: ButtonText; }
  .fd-acta { border-color: CanvasText; }
  .fd-acta__step::before { border-color: CanvasText; }
  .fd-acta__step[data-step="done"]::before, .fd-acta__step[data-step="current"]::before { background: CanvasText; }
  .fd-acta__step::after { background: CanvasText; }
}

/* ---- Print ---------------------------------------------------------------- */
@media print {
  .fd-nav, .fd-nav__backdrop, .fd-topbar__menu, .fd-skip { display: none; }
  .fd-shell { display: block; }
  body { background: var(--fd-surface); }
  .fd-topbar { position: static; }
  .fd-card, .fd-record-header { break-inside: avoid; }
  .fd-table-wrap--scroll { overflow: visible; background: none; }
  .fd-decision__q { position: static; box-shadow: none; }
}
