/* TalyxOS shell: components and layout (WS-0.3 B-1).
   Reads tokens only (tokens.css), never a hex value. Ported from the PR #7 mockups'
   component CSS (docs/ux/mockups/_tokens.mjs BASE) with the mockup chrome removed and
   `@container app` turned into `@media` at the one breakpoint, 768px (handoff §3).
   Phone navigation: docs/brand/talyxos-phone-navigation.md v1.3 §7 (reference CSS).
   Inter is capped at 600; Montserrat 700 only for page titles, empty-state titles and the logo. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-ui); font-size: var(--fs-body);
  line-height: var(--lh-body); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1 { font-family: var(--font-brand); font-weight: 700; letter-spacing: var(--ls-headline); text-wrap: balance; margin: 0;
  font-size: var(--fs-headline); line-height: var(--lh-headline); }
h2, h3 { font-family: var(--font-ui); font-weight: 600; text-wrap: balance; margin: 0; line-height: var(--lh-subtitle); }
p { margin: 0; }
b, strong, th, optgroup { font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(svg) { width: 20px; height: 20px; flex: none; }
:where(a) { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.num, td.n, .tabular { font-variant-numeric: tabular-nums; }
code, .code { font-family: var(--font-code); }
.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; }
[hidden] { display: none !important; }

/* Focus: one ring, everywhere, never removed (handoff §6 rule 5). */
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-sm); position: relative; z-index: 2; }

/* ============================================================ APP SHELL */
.app { display: grid; grid-template-areas: "head" "main" "tabs"; grid-template-rows: auto 1fr auto;
  height: 100vh; height: 100dvh; background: var(--bg); position: relative; }
.app__head { grid-area: head; position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--border); min-height: var(--topbar-height-phone);
  display: flex; align-items: center; gap: var(--space-2); padding: env(safe-area-inset-top) var(--space-2) 0 var(--space-3); }
.app__head .iconbtn--tabbed { display: none; }
.app__main { grid-area: main; overflow-y: auto; overscroll-behavior-y: contain; scroll-padding-top: var(--space-4); }
.app__body { padding: var(--space-4) var(--space-4) var(--space-6); display: grid; gap: var(--space-5); align-content: start; }

.brand { display: flex; align-items: center; gap: var(--space-2); min-width: 0; margin-right: auto; }
.logo-tx { display: block; width: 120px; height: auto; }
.head-title { display: none; flex: 1; min-width: 0; font-weight: 600; font-size: var(--fs-body);
  color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Icon button: 44px target, 20px glyph. */
.iconbtn { width: var(--touch-target); height: var(--touch-target); flex: none; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: var(--radius-md); color: var(--text-muted);
  position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent; text-decoration: none;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease); }
.iconbtn:hover { background: var(--gray-100); color: var(--text); }
.iconbtn svg { width: 20px; height: 20px; }

/* Top-bar user menu (brand book "App shell"; QA F1): avatar on phones, avatar + name from 768px. */
.usermenu { position: relative; flex: none; }
.usermenu__btn { min-width: var(--touch-target); min-height: var(--touch-target); display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-1); border: 0; background: transparent; border-radius: var(--radius-md); color: var(--text);
  font: inherit; font-size: var(--fs-body); font-weight: 500; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.usermenu__btn:hover { background: var(--gray-100); }
.usermenu__btn[aria-expanded="true"] { background: var(--gray-100); }
.av--sm { width: 32px; height: 32px; }
.usermenu__name { display: none; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usermenu__pop { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: 40; min-width: 240px; max-width: calc(100vw - var(--space-4));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-2); }
.usermenu__pop[hidden] { display: none; }
.usermenu__who { display: grid; gap: 2px; padding: var(--space-2) var(--space-3) var(--space-3); margin: 0;
  border-bottom: 1px solid var(--border); font-size: var(--fs-body); overflow-wrap: anywhere; }
.usermenu__who span { font-size: var(--fs-label); color: var(--text-muted); }
.usermenu__list { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.usermenu__item { width: 100%; min-height: var(--touch-target); display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-3); border: 0; background: transparent; border-radius: var(--radius-md); color: var(--text);
  font: inherit; font-size: var(--fs-body); text-align: left; cursor: pointer; }
.usermenu__item:hover { background: var(--gray-100); }
.usermenu__item svg { width: 20px; height: 20px; flex: none; }
.usermenu__item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }

/* Bottom tab bar, under 768px only (spec §2, §7). */
.tabbar { grid-area: tabs; position: sticky; bottom: 0; z-index: 20; display: flex;
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
.tabbar > a, .tabbar > button { flex: 1; min-width: 0; min-height: calc(var(--tabbar-height) - 1px); position: relative; isolation: isolate;
  display: grid; justify-items: center; align-content: center; gap: 2px;
  padding: var(--space-1); text-decoration: none; border: 0; background: none; margin: 0; appearance: none;
  color: var(--text-muted); font: 500 var(--fs-caption)/var(--lh-caption) var(--font-ui);
  white-space: nowrap; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: color var(--duration) var(--ease); }
.tabbar svg { width: 22px; height: 22px; }
.tabbar__ind { width: var(--tabbar-indicator-width); height: var(--tabbar-indicator-height);
  border-radius: var(--radius-pill); background: transparent; margin-bottom: 2px;
  transition: background var(--duration) var(--ease); }
.tabbar [aria-current="page"], .app[data-sheet="open"] .tabbar__more { color: var(--link); font-weight: 600; }
.app[data-sheet="open"] .tabbar [aria-current="page"]:not(.tabbar__more) { color: var(--text-muted); font-weight: 500; }
.app[data-sheet="open"] .tabbar [aria-current="page"]:not(.tabbar__more) .tabbar__ind { background: transparent; }
.tabbar [aria-current="page"] .tabbar__ind, .app[data-sheet="open"] .tabbar__more .tabbar__ind { background: var(--primary); }
.tabbar > a:active::before, .tabbar > button:active::before { content: ""; position: absolute; inset: var(--space-1);
  border-radius: var(--radius-md); background: var(--gray-100); z-index: -1; }
.tabbar > a:focus-visible, .tabbar > button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); border-radius: var(--radius-md); }
@media (hover: hover) { .tabbar > a:hover, .tabbar > button:hover { color: var(--text); } }
@media (max-width: 359.98px) { .tabbar > a, .tabbar > button { padding-inline: 0; min-width: auto; } }
.app[data-keyboard="open"] .tabbar, .app[data-flow="fullscreen"] .tabbar,
.app[data-drawer="open"] .tabbar, .app[data-modal="open"] .tabbar { display: none; }

/* "Más" sheet (spec §4): a dialog above the tab bar. */
.sheet-scrim { position: fixed; inset: 0 0 calc(var(--tabbar-height) + env(safe-area-inset-bottom)) 0; z-index: 40;
  background: var(--overlay); }
.sheet { position: fixed; z-index: 45; left: 0; right: 0;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  max-height: min(var(--sheet-max-height), calc(100dvh - var(--tabbar-height) - var(--space-8)));
  display: grid; grid-template-rows: auto 1fr; background: var(--surface-raised);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg);
  animation: sheetin var(--duration-slow) var(--ease) both; }
@keyframes sheetin { from { transform: translateY(100%); } }
.sheet__grab { display: grid; place-items: center; min-height: var(--space-6); cursor: grab; touch-action: none; }
.sheet__grab span { width: 32px; height: 4px; border-radius: var(--radius-pill); background: var(--gray-300); }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--space-2) var(--space-4); display: grid; gap: var(--space-2); align-content: start; }
.sheet__who { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border); }
.sheet__whoText { display: grid; gap: 2px; min-width: 0; font-size: var(--fs-label); line-height: var(--lh-label); color: var(--text-muted); }
.sheet__whoText b { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text); }
.sheet__grp { display: grid; gap: var(--space-1); }
.sheet__grp + .sheet__grp { border-top: 1px solid var(--border); padding-top: var(--space-2); }
.sheet__label { font-size: var(--fs-overline); line-height: var(--lh-overline); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--ls-overline); color: var(--text-muted); padding: var(--space-2) var(--space-3) 0; }
.sheet__list { list-style: none; margin: 0; padding: 0; display: grid; }
.sheet__row { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 56px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); text-decoration: none; color: var(--text); font-size: var(--fs-body); font-weight: 500;
  background: none; border: 0; text-align: left; transition: background var(--duration) var(--ease); }
.sheet__row svg { width: 20px; height: 20px; color: var(--text-muted); }
.sheet__chev { margin-left: auto; display: grid; }
.sheet__chev svg { width: 18px; height: 18px; }
.sheet__row:hover { background: var(--gray-100); }
.sheet__row[aria-current="page"] { background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 600; }
.sheet__row[aria-current="page"] svg { color: var(--on-primary-soft); }
.sheet__row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); border-radius: var(--radius-md); }

/* Sidebar, 768px and up. */
.rail { display: none; grid-area: rail; background: var(--sidebar); color: var(--text-on-dark-muted);
  padding: var(--space-4) var(--space-3); gap: var(--space-1); align-content: start; overflow-y: auto; }
.rail a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch-target);
  padding: 0 var(--space-3); border-radius: var(--radius-md); text-decoration: none;
  color: var(--text-on-dark-muted); font-size: var(--fs-body); font-weight: 500;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease); }
.rail a svg { width: 20px; height: 20px; flex: none; }
.rail a:hover { background: var(--sidebar-hover); color: var(--text-on-dark); }
.rail a[aria-current="page"] { background: var(--primary); color: var(--on-primary); font-weight: 600;
  box-shadow: inset var(--sidebar-marker-width) 0 0 var(--sidebar-marker); }
.rail a:focus-visible { box-shadow: var(--focus-ring-on-dark); }
.rail__head { padding: 0 var(--space-1) var(--space-4); }
.rail__head img { width: 160px; height: auto; display: block; }
.rail__head .rail__tenant { width: auto; max-width: 200px; max-height: 40px; }
.rail__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.rail__foot { margin-top: var(--space-6); padding: var(--space-4) var(--space-3) 0; border-top: 1px solid var(--sidebar-hover);
  font-size: var(--fs-caption); color: var(--text-on-dark-muted); display: flex; align-items: center; gap: var(--space-2); }
.rail__foot img { width: 88px; height: auto; display: block; }

@media (min-width: 768px) {
  .app { grid-template-areas: "rail head" "rail main"; grid-template-columns: var(--sidebar-width) 1fr; grid-template-rows: auto 1fr; }
  .rail { display: grid; }
  .tabbar, .sheet, .sheet-scrim { display: none !important; }
  .app__head .iconbtn--tabbed { display: grid; }
  .app__head { padding-inline: var(--space-5); min-height: var(--topbar-height); }
  .app__head .brand { display: none; }
  .head-title { display: block; }
  .usermenu__name { display: block; }
  .usermenu__btn { padding: 0 var(--space-3) 0 var(--space-1); }
  .app__body { padding: var(--space-6) var(--space-6) var(--space-8); max-width: var(--content-max); }
}

/* ============================================================ PRIMITIVES */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card--clip { overflow: hidden; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch-target); padding: 0 var(--space-5); border-radius: var(--radius-md);
  border: 1px solid transparent; font-size: var(--fs-body); font-weight: 600; line-height: 1.2;
  text-decoration: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--gray-100); }
.btn--quiet { background: transparent; color: var(--link); padding-inline: var(--space-3); }
.btn--quiet:hover { background: var(--primary-soft); color: var(--link); }
.btn--block { width: 100%; }
.btn[aria-disabled="true"] { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-300); cursor: not-allowed; }
.btnrow { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.chip { display: inline-flex; width: fit-content; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: var(--radius-pill); font-size: var(--fs-label); font-weight: 600; line-height: 1.2;
  background: var(--gray-100); color: var(--text); white-space: nowrap; }
.chip:not(:has(svg))::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip svg { width: 14px; height: 14px; }
.chip--ok { background: var(--success-bg); color: var(--success); }
.chip--warn { background: var(--warning-bg); color: var(--warning); }
.chip--danger { background: var(--danger-bg); color: var(--danger); }
.chip--info { background: var(--info-bg); color: var(--info); }
.chip--scope { min-height: 32px; padding-inline: var(--space-3); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 68px;
  padding: var(--space-3) var(--space-4); background: transparent; border: 0; text-align: left; color: inherit; text-decoration: none; }
.row__av, .av { width: 40px; height: 40px; flex: none; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--on-primary-soft); display: grid; place-items: center;
  font-size: var(--fs-label); font-weight: 600; }
.row__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row__t { font-size: var(--fs-body); font-weight: 600; overflow-wrap: anywhere; }
.row__s { font-size: var(--fs-label); color: var(--text-muted); overflow-wrap: anywhere; }
.row__m { font-size: var(--fs-caption); color: var(--text-muted); overflow-wrap: anywhere; }
.row__end { flex: none; display: grid; gap: var(--space-1); justify-items: end; text-align: right; }

.field { display: grid; gap: var(--space-2); }
.field > label { font-size: var(--fs-label); font-weight: 600; }
.field .hint { font-size: var(--fs-caption); color: var(--text-muted); }
.field input, .field select {
  min-height: var(--touch-target); height: var(--touch-target); padding: 0 var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-body-lg);
  width: 100%; transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease); }
.field input:hover, .field select:hover { border-color: var(--text-muted); }
.field input:focus-visible, .field select:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); border-radius: var(--radius-md); }
.field select:disabled { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-300); }
.field--err input { border-color: var(--danger); border-width: 2px; }
.pwd { position: relative; display: flex; }
.pwd input { padding-right: 96px; }
.pwd .btn { position: absolute; right: 0; top: 0; min-width: var(--touch-target); font-size: var(--fs-label); }

.banner { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--fs-label); align-items: flex-start; border: 1px solid transparent; }
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.banner--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, var(--danger-bg)); }
.banner--warn { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, var(--warning-bg)); }

/* DataTable; becomes a row list under 768px (no sideways scroll on a phone). */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
table.data th, table.data td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: var(--fs-caption); color: var(--text-muted); font-weight: 600; background: var(--table-header); position: sticky; top: 0; z-index: 1; }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.wrap { white-space: normal; min-width: 160px; }
table.data .id { font-family: var(--font-code); font-size: var(--fs-label); color: var(--text-muted); }

/* ============================================================ SKELETONS (handoff §5) */
.sk { background: var(--gray-100); border-radius: var(--radius-sm); position: relative; overflow: hidden; display: block; }
.sk::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 75%, transparent), transparent);
  transform: translateX(-100%); animation: skpulse 1200ms ease-in-out infinite; }
@keyframes skpulse { to { transform: translateX(100%); } }
.sk--line { height: 12px; }
.sk--title { height: 18px; }
.sk--chip { height: 22px; width: 72px; border-radius: var(--radius-pill); }
.sk--av { width: 40px; height: 40px; border-radius: var(--radius-pill); flex: none; }
.w90 { width: 90%; } .w75 { width: 75%; } .w60 { width: 60%; } .w45 { width: 45%; } .w30 { width: 30%; }
.sk-row { display: flex; align-items: center; gap: var(--space-3); min-height: 68px; padding: var(--space-3) var(--space-4); }
.sk-row__main { flex: 1; min-width: 0; display: grid; gap: var(--space-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .sk::after { display: none; }
}

/* ============================================================ STATES (book: EmptyState) */
.state { display: grid; gap: var(--space-3); justify-items: center; text-align: center; padding: var(--space-12) var(--space-5); }
.state__ico { width: 64px; height: 64px; border-radius: var(--radius-pill); display: grid; place-items: center;
  background: var(--primary-soft); color: var(--on-primary-soft); }
.state__ico svg { width: 28px; height: 28px; }
.state--err .state__ico { background: var(--danger-bg); color: var(--danger); }
.state--off .state__ico { background: var(--gray-100); color: var(--text); }
.state h2, .state h1 { font-family: var(--font-brand); font-weight: 700; font-size: var(--fs-headline); line-height: var(--lh-headline); letter-spacing: var(--ls-headline); max-width: 20ch; }
.state p { font-size: var(--fs-body); color: var(--text-muted); max-width: 44ch; }
.state .ref { font-size: var(--fs-caption); color: var(--text-muted); }
.state .ref code { background: var(--gray-100); color: var(--text); padding: 2px 6px; border-radius: var(--radius-sm); -webkit-user-select: all; user-select: all; }

/* Dialog (book): surface-raised, radius-lg, shadow-lg, max 480px. */
.scrim { position: fixed; inset: 0; z-index: 55; background: var(--overlay); }
.modal { position: fixed; z-index: 60; inset: auto var(--space-4) var(--space-4); max-width: 480px; margin-inline: auto;
  background: var(--surface-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--space-6); display: grid; gap: var(--space-4); }
.modal h2 { font-size: var(--fs-title); line-height: var(--lh-title); }
.modal p { font-size: var(--fs-body); color: var(--text-muted); }
@media (min-width: 768px) { .modal { inset: 50% 0 auto 0; transform: translateY(-50%); } }

/* Toast (book). Text only, never HTML (handoff §4.1 rule 1). */
.toasts { position: fixed; z-index: 70; left: var(--space-3); right: var(--space-3);
  bottom: calc(var(--tabbar-height) + var(--space-3) + env(safe-area-inset-bottom));
  display: grid; gap: var(--space-2); pointer-events: none; }
@media (min-width: 768px) { .toasts { left: auto; width: 420px; bottom: var(--space-5); right: var(--space-5); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3);
  border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); font-size: var(--fs-label); }

.poweredby { padding: var(--space-5) var(--space-4) var(--space-6); display: flex; align-items: center; justify-content: center;
  gap: var(--space-2); font-size: var(--fs-caption); color: var(--text-muted); }
.poweredby img { width: 88px; height: auto; display: block; }

.pagetitle { font-size: var(--fs-headline); line-height: var(--lh-headline); }
.stack { display: grid; gap: var(--space-3); align-content: start; }
.inline { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.muted { color: var(--text-muted); font-size: var(--fs-label); }
.micro { color: var(--text-muted); font-size: var(--fs-caption); }

/* ============================================================ WS-0.3 B-2: shared components
   Ported from the PR #7 mockups' component CSS (_tokens.mjs BASE, _p4.mjs, _p5.mjs) with
   `@container app` turned into `@media` at 768px. Tokens only. */

/* A wide table scrolls inside its .tablewrap; it never widens the page grid. */
.app__body { grid-template-columns: minmax(0, 1fr); }

/* Interactive rows (button / a) get the hover fill; static rows (div) do not (D13). */
.row:is(button, a) { touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: background var(--duration) var(--ease); }
.row:is(button, a):hover { background: var(--primary-soft); }
.row:is(button, a):focus-visible { box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0; }
.row__chev { flex: none; color: var(--text-muted); display: grid; }
.row__chev svg { width: 18px; height: 18px; }
.btn--sm { min-height: 36px; padding-inline: var(--space-3); } /* dense desktop tables only (handoff §4) */
table.data tbody tr:hover { background: var(--primary-soft); }

.banner strong { display: block; font-size: var(--fs-body); }
.banner__body { min-width: 0; display: grid; gap: var(--space-1); }
.banner .btnrow { margin-top: var(--space-2); }
.banner .btn { min-height: var(--touch-target); padding-inline: var(--space-4); font-size: var(--fs-label); }
.banner--info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, var(--info-bg)); }

.sec { display: grid; gap: var(--space-3); }
.sec__head { display: flex; align-items: center; gap: var(--space-3); }
.sec__head h2 { font-size: var(--fs-title); line-height: var(--lh-title); margin-right: auto; }
a.selflink { font-size: var(--fs-label); font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--touch-target); min-width: var(--touch-target); }
.spread { display: flex; align-items: center; gap: var(--space-3); justify-content: space-between; flex-wrap: wrap; }
.stack--tight { gap: var(--space-2); }

/* KPI tile: states the action, never a bare number (UX review #37). */
.tiles { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { display: grid; gap: var(--space-1); padding: var(--space-4); background: var(--surface); font: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-lg); text-align: left; box-shadow: var(--shadow-sm);
  text-decoration: none; color: inherit; min-height: 96px; align-content: start; width: 100%;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease); }
.tile:hover { border-color: var(--primary); }
.tile:focus-visible { border-radius: var(--radius-lg); }
.tile__k { font-size: var(--fs-label); font-weight: 500; color: var(--text-muted); }
.tile__v { font-family: var(--font-ui); font-size: 1.75rem; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: var(--ls-headline); }
.tile__a { font-size: var(--fs-label); color: var(--link); font-weight: 600; }

/* Definition pairs (drawer facts). */
.dl { display: grid; gap: 0; margin: 0; }
.dl > div { display: flex; align-items: baseline; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { font-size: var(--fs-label); color: var(--text-muted); margin-right: auto; }
.dl dd { margin: 0; font-size: var(--fs-body); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* Progress. Widths come from --w, set through the CSSOM (no style attribute: CSP). */
.bar { height: 8px; border-radius: var(--radius-pill); background: var(--gray-100); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--w, 0); border-radius: var(--radius-pill); background: var(--primary); }
.bar--ok > i { background: var(--success); }

/* Skeleton shapes added for B-2 (handoff §5). */
.sk--amount { height: 34px; width: 60%; }
.sk--bar { height: 8px; border-radius: var(--radius-pill); }
.sk-tile { min-height: 96px; padding: var(--space-4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); display: grid; gap: var(--space-2); align-content: start; }

/* Module sub-navigation: links with aria-current, not tabs (handoff §4). */
.subnav { display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { min-height: var(--touch-target); padding: 0 var(--space-3); display: inline-flex; align-items: center; white-space: nowrap;
  font-size: var(--fs-body); font-weight: 500; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { color: var(--link); font-weight: 600; border-bottom-color: var(--primary); }
.subnav a:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }

/* Cajón: bottom sheet under 768px (88% max), right drawer of 460px from 768px. */
.drawer-scrim { position: fixed; inset: 0; z-index: 48; background: var(--overlay); }
.drawer { position: fixed; z-index: 50; background: var(--surface-raised); display: grid; grid-template-rows: auto auto 1fr;
  overscroll-behavior: contain; left: 0; right: 0; bottom: 0; max-height: 88dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg);
  animation: drawerup var(--duration-slow) var(--ease) both; }
@keyframes drawerup { from { transform: translateY(100%); } }
@keyframes drawerin { from { transform: translateX(100%); } }
.drawer__grab { width: 40px; height: 4px; border-radius: 2px; background: var(--gray-300); margin: var(--space-2) auto 0; }
.drawer__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.drawer__head > div { min-width: 0; margin-right: auto; display: grid; gap: var(--space-1); }
.drawer__head h2 { font-size: var(--fs-title); line-height: var(--lh-title); overflow-wrap: anywhere; }
.drawer__head p { font-size: var(--fs-label); color: var(--text-muted); }
.drawer__body { overflow-y: auto; padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); display: grid; gap: var(--space-4); align-content: start; }
@media (min-width: 768px) {
  .drawer { left: auto; top: 0; bottom: 0; width: 460px; max-height: none; grid-template-rows: auto 1fr;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg); animation-name: drawerin; }
  .drawer__grab { display: none; }
}

/* Inicio (mockups 04, 16). */
.greet { display: grid; gap: var(--space-2); }
.greet h1 { font-size: var(--fs-headline); line-height: var(--lh-headline); }
.recents { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.recents a { min-width: 0; padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  text-decoration: none; color: inherit; display: grid; gap: var(--space-1); min-height: var(--touch-target); }
.recents a:hover { border-color: var(--primary); }
.recents a:focus-visible { border-radius: var(--radius-md); }
.recents b { font-size: var(--fs-label); }
.pend-empty { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-4); }
.pend-empty svg { width: 22px; height: 22px; flex: none; color: var(--success); }
.pend-empty .micro { display: block; }

/* Buscar (mockup 15). */
.buscar .search { position: relative; }
.buscar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.buscar .search input { padding-left: 40px; }
.search-scope { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.resgroup { display: grid; gap: var(--space-2); }
.resgroup__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.resgroup__head h2 { font-size: var(--fs-subtitle); line-height: var(--lh-subtitle); }

/* ============================================================ LOGIN (handoff §14, brand book "Login screen") */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; background: var(--bg); }
.login__panel { background: var(--sidebar); display: grid; place-items: center; padding: calc(var(--space-6) + env(safe-area-inset-top)) var(--space-4) var(--space-6); }
.login__panel img { width: 200px; height: auto; display: block; }
.login__main { display: grid; align-content: start; justify-items: center; padding: var(--space-6) var(--space-4) env(safe-area-inset-bottom); }
.login__card { width: 100%; max-width: 400px; display: grid; gap: var(--space-5); }
.login__form { display: grid; gap: var(--space-4); }
.login__msg { display: grid; gap: var(--space-1); }
.login .state { padding: var(--space-6) 0; }
@media (min-width: 768px) {
  .login { grid-template-rows: none; grid-template-columns: minmax(320px, 2fr) 3fr; }
  .login__panel img { width: 280px; }
  .login__main { align-content: center; padding: var(--space-8); }
}
