/* Shared desktop workspace. Mobile keeps the established navigation and 44px controls. */
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; padding: 12px 18px; background: var(--primary); color: #fff; border-radius: 6px; }
.skip-link:focus { top: 12px; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
#main:focus { outline: none; }
:where(input, select, textarea, button, a) { scroll-margin-top: calc(var(--topbar-h) + 16px); scroll-margin-bottom: 90px; }
.topbar__context, .topbar__actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__actions { margin-left: auto; }
.topbar__home, .topbar__divider, .topbar__section, .user-avatar, .fab__label { display: none; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.dashboard-grid, .dashboard-primary, .dashboard-secondary { min-width: 0; }
.record-head { display: none; }
.record-list .badges { margin: 6px 0 0; }
.record-mobile { display: inline; }
.record-cell { display: none; }
.record-row { min-width: 0; }
.record-row .row__main { min-width: 0; }
.record-state { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.list-summary { margin: 0; font-size: 0.8rem; color: var(--text-muted); }
.list-panel__heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.list-panel__heading h2 { margin: 0; }

@media (min-width: 900px) {
  /* Valores por ancho (colores, --radius, --tap, --sidebar-w, --topbar-h): app.css `@media (min-width: 900px) :root`. */
  body { font-size: 14px; }
  h1, .display { font-size: 30px; letter-spacing: -0.025em; }
  h2, h3, .card__title, .sheet__title { font-family: var(--font-ui); letter-spacing: -0.01em; }
  .sidebar { padding: 0 12px 18px; gap: 2px; border-color: var(--border); z-index: 25; overscroll-behavior: contain; }
  .sidebar__brand { display: flex; align-items: center; gap: 10px; min-height: 92px; margin: 0 0 8px; padding: 16px 8px; color: var(--wine); font: 600 17px var(--font-display); text-decoration: none; }
  .sidebar__brand small { display: block; margin-top: 5px; color: var(--text-muted); font: 400 11px var(--font-ui); }
  .brand-mark { display: grid; place-items: center; width: 36px; height: 40px; flex-shrink: 0; background: var(--wine); color: var(--on-primary); border-radius: 10px; font-size: 31px; padding-bottom: 5px; }
  .sidebar__heading { margin: 18px 12px 7px; color: #776d77; font: 600 10px var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; }
  .sidebar__group:first-of-type .sidebar__heading { margin-top: 0; }
  .sidebar__item { gap: 12px; min-height: 39px; padding: 8px 12px; border-radius: 6px; font-size: 13px; color: #5e5660; margin: 2px 0; }
  .sidebar__item::before { content: ""; width: 18px; height: 18px; flex: 0 0 18px; background: currentColor; mask: var(--nav-icon) center / contain no-repeat; -webkit-mask: var(--nav-icon) center / contain no-repeat; }
  /* `[data-icon] → --nav-icon` vive en app.css (lo comparte la barra inferior). */
  .sidebar__item:hover { background: var(--surface-muted); color: var(--primary); }
  .sidebar__item.is-active { background: var(--primary-subtle); color: var(--primary); box-shadow: inset 3px 0 var(--primary); font-weight: 650; }
  .topbar { min-height: var(--topbar-h); padding: 10px 28px; border-bottom: 1px solid var(--border); }
  .has-nav .topbar__brand { display: none; }
  .topbar__home, .topbar__divider, .topbar__section { display: inline; font-size: 12px; white-space: nowrap; }
  .topbar__home { color: var(--text-muted); text-decoration: none; }
  .topbar__divider { color: #aba3ac; }
  .topbar__section { font-weight: 600; }
  .topbar__actions { gap: 20px; }
  .topbar__name { max-width: 135px; font-size: 12px; opacity: 1; color: var(--text-muted); }
  .user-avatar { display: grid; place-items: center; height: 30px; width: 30px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 50%; font-size: 11px; font-weight: 600; }
  .linkish { color: var(--primary); text-underline-offset: 3px; }
  .linkish:hover { text-decoration: underline; }
  .topbar .linkish { font-size: 12px; }
  .fab { position: static; display: inline-flex; gap: 7px; width: auto; height: 38px; min-height: 38px; border-radius: 7px; padding: 0 13px; background: var(--primary); font: 600 12px var(--font-ui); box-shadow: none; white-space: nowrap; }
  .fab__label { display: inline; }
  .fab__symbol { font-size: 19px; font-weight: 400; }
  .fab:hover { background: var(--primary-hover); }
  body.has-nav .main { max-width: 1440px; padding: 28px 28px 48px; margin: 0 auto; }
  body.has-nav .main > h1.display { margin-bottom: 22px; }
  body.has-nav .messages { max-width: 1384px; margin: 20px 28px 0; }
  .card { padding: 20px; margin-bottom: 18px; border-radius: 10px; }
  .card__title { font-size: 14px; font-weight: 650; margin-bottom: 16px; }
  .card--auth { margin-top: 64px; padding: 30px; }
  .btn { min-height: 38px; padding: 8px 13px; border-radius: 7px; font-size: var(--control-font); } /* SPEC §4: botón 13 en escritorio (UX-22; antes 12) · S16 */
  .btn--primary:hover { background: var(--primary-hover); }
  .btn--ghost { background: var(--surface); }
  .btn--ghost:hover { background: #f6f3f4; border-color: #c8bdc2; }
  button:disabled { opacity: 0.6; cursor: wait; }
  .field__label { font-size: 12px; margin-bottom: 6px; font-weight: 500; }
  .field :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { border-radius: 7px; padding: 9px 11px; font-size: var(--control-font); } /* S16: 13 px */
  .field :is(input, select, textarea):hover { border-color: var(--border-strong); }
  .toolbar { gap: 12px; margin-bottom: 18px; }
  /* S4: el buscador de las listas va sin marco de tarjeta (Figma: barra suelta). */
  form.toolbar[role="search"] .field--grow { max-width: 520px; }
  .chip, .range-custom > summary { border-radius: 6px; min-height: 34px; font-size: 12px; padding: 5px 12px; }
  .chip.is-active, .range-custom > summary.is-active { background: var(--chip-active-bg); border-color: var(--chip-active-border); color: var(--chip-active-fg); } /* S15: tokens por modo (app.css :root) */
  .row { padding: 12px 0; gap: 12px; }
  .row__title { font-size: 13px; font-weight: 550; }
  .row__amount { font-size: 13px; font-weight: 600; }
  .small { font-size: 12px; } /* piso de legibilidad (SPEC §4: hoy 11) */
  /* S19: valores en los tokens `--badge-*` del modo Escritorio (app.css); piso 11 (hoy 10). */
  .badge { padding: var(--badge-pad-y) var(--badge-pad-x); font-size: var(--badge-font); border-radius: var(--badge-radius); }
  .badges { gap: 5px; }
  .stat__value { font-family: var(--font-ui); font-size: 26px; letter-spacing: -0.03em; }
  .alert { padding: 12px 16px; font-size: 12px; border: 1px solid var(--warning-border); }
  .alert--err { border-color: var(--danger-border); }
  .alert--ok { border-color: var(--success-border); }
  .dashboard-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
  .kpi, .metric { padding: 18px; }
  .kpi__label, .metric__label { font-size: 12px; }
  .metric__value { font-size: clamp(18px, 1.65vw, 28px); margin-bottom: 10px; }
  .kpi__delta, .metric__note { font-size: 12px; }
  .dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
  .dashboard-secondary .card { background: #fdfdfc; }
  .dashboard-grid .row__side { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-grid .row__amount { font-size: 12px; }
  .dashboard-grid .row__main { min-width: 90px; }
  .dashboard-more { width: auto; border: 0; background: transparent; color: var(--primary); justify-content: flex-start; padding: 10px 0 0; margin-top: 4px; min-height: 34px; }
  .dashboard-more::after { content: "→"; margin-left: 4px; }
  .dashboard-more:hover { background: transparent; text-decoration: underline; }
  .dashboard-grid .row--web .row__side .badge { display: none; }
  .dashboard-grid .row--web .actions { margin-top: 4px; }
  .dashboard-secondary .row__title { font-size: 12px; }
  .dashboard-secondary .row__amount { font-size: 12px; }
  .dashboard-secondary .card__title { margin-bottom: 10px; }
  .dashboard-secondary .row { padding: 10px 0; }
  .record-head { display: grid; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 500; } /* piso 12 (UX-22; antes 11) */
  .record-head, .record-list .record-row { grid-template-columns: minmax(0, 1fr) minmax(140px, 0.5fr) 130px; gap: 20px; }
  .record-list .record-row { display: grid; align-items: center; }
  .record-list .record-row:hover { background: var(--surface-hover); }
  .record-head > :last-child, .record-list .row__amount { text-align: right; }
  .record-list .badges { margin: 0; }
  .record-list .row__main { gap: 5px; }
  .record-mobile { display: none; }
  .record-cell { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }
  .record-head--products, .record-list--products .record-row { grid-template-columns: minmax(0, 1fr) 100px 100px 130px; }
  .record-head--contacts, .record-list--contacts .record-row { grid-template-columns: minmax(0, 1fr) 160px minmax(120px, 0.6fr); }
  .record-head--contacts > :last-child { text-align: left; }
  .sheet { top: 50%; bottom: auto; transform: translateY(-50%); width: min(620px, calc(100vw - 48px)); max-height: calc(100dvh - 64px); overflow-y: auto; overscroll-behavior: contain; padding: 24px; border: 1px solid var(--border); border-radius: 12px; }
  .page-form:not(.page-lines):not(.page-bulk) .main { max-width: 980px; margin-inline: 0 auto; } /* S2: alineado a la izquierda (Figma) */
  .page-lines .main, .page-bulk .main, .page-reports .main { width: 100%; }
  .kpi .stat__value { font-size: 19px; }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .topbar { padding-inline: 20px; }
  .topbar__name { display: none; }
  .topbar__actions { gap: 12px; }
  body.has-nav .main { padding-inline: 20px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-secondary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .dashboard-metrics { gap: 10px; }
  .kpi, .metric { padding: 14px 12px; }
  .metric__value { font-size: 18px; }
  .page-lines .lines--grid { overflow-x: auto; padding-bottom: 12px; }
  .page-lines .lines--grid .lines-head, .page-lines .lines--grid .row--line-entry { min-width: 850px; }
  .record-head, .record-list .record-row { gap: 12px; grid-template-columns: minmax(0, 1fr) 135px 110px; }
  .record-head--products, .record-list--products .record-row { grid-template-columns: minmax(0, 1fr) 65px 70px 105px; }
  .record-head--contacts, .record-list--contacts .record-row { grid-template-columns: minmax(0, 1fr) 130px 110px; }
}

@media (max-width: 899px) {
  .dashboard-grid .row:not(.row--stack) { flex-wrap: wrap; }
  .dashboard-grid .row__side { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-grid .row__main { min-width: 100px; }
  .record-list .record-row { flex-wrap: wrap; }
  .record-list .record-state { flex-basis: 100%; order: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

@media (min-width: 1200px) {
  /* S18: las reglas `.dashboard-primary .row--web` (una línea, botones 11 px) salieron: Hoy las define en ui.css. */
  .dashboard-grid .row .btn--primary { background: #f3ebee; border-color: #e5d3da; color: var(--primary); }
  .dashboard-grid .row .btn--primary:hover { background: #ead9e0; }
}

@media (min-width: 900px) {
  .document-client > div > .btn--block, .page-lines .card > .btn--block { width: auto; }
  .document-client > div > .btn { margin-bottom: 14px; }
  .document-shipping { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
  .document-shipping > .card__title, .document-shipping > .field:last-child { grid-column: 1 / -1; }
  .document-shipping > .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-summary { max-width: 560px; margin-left: auto; }
  .page-lines .lines-search > .field { max-width: 600px; }
}

@media (min-width: 1200px) {
  .document-client { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; align-items: start; }
  .document-client > .card__title { grid-column: 1 / -1; }
  .document-client > div { grid-column: 1; }
  .document-client > .field { grid-column: 2; grid-row: 2; }
}
