/* Componentes reutilizables. Capa: components.
   Estados de tono: ok | warn | bad (+ info | neutral en badges). Todos los tonos llevan
   texto además del color (badges, tiles, celdas): el color nunca es el único canal. */

@layer components {

  /* ---------- Botones ---------- */
  .btn,
  .btn--secondary,
  .btn--primary,
  .btn--ghost,
  .btn--text,
  .btn--danger,
  .primario,
  .peligro {
    --btn-bg: var(--surface);
    --btn-fg: var(--ink-strong);
    --btn-bd: var(--control);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--hit);
    padding: 0 var(--s-4);
    border-radius: var(--r-md);
    border: 1px solid var(--btn-bd);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    justify-self: start;
    transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .btn span { min-width: 0; }
  .btn:hover:not(:disabled) { box-shadow: inset 0 0 0 999px rgb(127 140 160 / 0.12); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .btn--primary,
  .primario {
    --btn-bg: var(--brand);
    --btn-fg: var(--on-brand);
    --btn-bd: var(--brand);
  }
  .btn--primary:hover:not(:disabled),
  .primario:hover:not(:disabled) { box-shadow: inset 0 0 0 999px rgb(0 0 0 / 0.1); }

  .btn--ghost,
  .btn--text {
    --btn-bg: transparent;
    --btn-fg: var(--brand-ink);
    --btn-bd: transparent;
  }
  .btn--ghost:hover:not(:disabled),
  .btn--text:hover:not(:disabled) { background: var(--brand-soft); box-shadow: none; }

  .btn--danger,
  .peligro {
    --btn-bg: var(--surface);
    --btn-fg: var(--bad-ink);
    --btn-bd: var(--bad);
  }
  .btn--danger:hover:not(:disabled),
  .peligro:hover:not(:disabled) { background: var(--bad-soft); box-shadow: none; }

  .btn--sm { font-size: var(--fs-xs); padding: 0 var(--s-3); }
  .btn--md { }
  .btn-back {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    min-height: var(--hit);
    padding: 0 var(--s-2) 0 var(--s-1);
    margin-left: calc(var(--s-1) * -1);
    color: var(--brand-ink);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    border-radius: var(--r-md);
  }
  .btn-back:hover { background: var(--brand-soft); }
  .btn-back svg { width: 18px; height: 18px; }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    width: var(--hit);
    height: var(--hit);
    min-width: var(--hit);
    border-radius: var(--r-md);
    color: var(--ink);
  }
  .icon-btn:hover { background: var(--surface-2); color: var(--ink-strong); }
  .icon-btn svg { width: 20px; height: 20px; }

  .chip {
    display: inline-flex;
    align-items: center;
    min-height: var(--hit);
    padding: 0 var(--s-3);
    border-radius: 999px;
    border: 1px solid var(--control);
    background: var(--surface);
    color: var(--ink-strong);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    white-space: nowrap;
  }
  .chip--bad {
    background: var(--bad-soft);
    border-color: var(--bad);
    color: var(--bad-ink);
  }

  /* ---------- Icono ---------- */
  svg[aria-hidden="true"]:not(.sparkline):not(.grafico) { flex: 0 0 auto; }
  .btn svg, .btn-foto svg { width: 18px; height: 18px; flex: 0 0 auto; }

  /* ---------- Segmentado ---------- */
  .segmented, .seg-toggle {
    display: flex;
    max-width: 100%;
    gap: 2px;
    padding: 3px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--line);
    /* 40px de botón + padding y borde: sin esto, dentro de una grilla la barra colapsa a 8px y oculta las etiquetas */
    min-height: 48px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .segmented::-webkit-scrollbar, .seg-toggle::-webkit-scrollbar { display: none; }
  .segmented > button, .seg-toggle > button {
    flex: 1 0 auto;
    min-height: 40px;
    padding: 0 var(--s-3);
    border-radius: calc(var(--r-md) - 3px);
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    white-space: nowrap;
  }
  .segmented > button:hover, .seg-toggle > button:hover { color: var(--ink-strong); }
  .segmented > button[aria-pressed="true"], .seg-toggle > button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--brand-ink);
    font-weight: var(--fw-semibold);
    box-shadow: var(--shadow-1), inset 0 0 0 1px var(--control);
  }

  /* ---------- Campos ---------- */
  .field, .campo {
    display: grid;
    gap: var(--s-1);
    min-width: 0;
  }
  .field > label, .campo > span, .campo > label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--ink-strong);
  }
  .campo > small, .field-help { font-size: var(--fs-xs); color: var(--muted); }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea {
    width: 100%;
    min-height: var(--hit);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    border: 1px solid var(--control);
    background: var(--surface);
    color: var(--ink-strong);
    font-size: var(--fs-base);
    line-height: 1.3;
  }
  textarea { min-height: 96px; resize: vertical; }
  select { appearance: auto; }
  input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
  input:disabled, select:disabled, textarea:disabled { opacity: 0.6; }
  .field--error input, .field--error select, .field--error textarea,
  input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] {
    border-color: var(--bad-fill);
    box-shadow: inset 0 0 0 1px var(--bad-fill);
  }
  .field-error, .error { color: var(--bad-ink); font-size: var(--fs-xs); font-weight: var(--fw-medium); }
  .error-bloque {
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    background: var(--bad-soft);
    color: var(--bad-ink);
    border: 1px solid var(--bad);
  }

  .check {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: var(--hit);
    padding: var(--s-1) 0;
    font-size: var(--fs-md);
    cursor: pointer;
  }
  .check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    accent-color: var(--brand);
  }

  fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s-3) var(--s-4) var(--s-4);
    display: grid;
    gap: var(--s-2);
  }
  legend { padding: 0 var(--s-1); font-size: var(--fs-sm); color: var(--ink-strong); }

  /* ---------- Tarjetas ---------- */
  .card {
    position: relative;
    display: grid;
    gap: var(--s-3);
    min-width: 0;
    padding: var(--s-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
  }
  .card .card { background: var(--surface-2); box-shadow: none; }
  .card.estado-ok { box-shadow: inset 4px 0 0 var(--ok-fill), var(--shadow-1); }
  .card.estado-warn { box-shadow: inset 4px 0 0 var(--warn-fill), var(--shadow-1); }
  .card.estado-bad { box-shadow: inset 4px 0 0 var(--bad-fill), var(--shadow-1); }
  details.card { display: block; }
  details.card > :not(summary) { margin-top: var(--s-3); }
  .card > summary { list-style: none; }
  .card > summary::-webkit-details-marker { display: none; }
  details.card > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--hit);
    gap: var(--s-2);
  }
  details.card > summary::after {
    content: "";
    width: 8px; height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform var(--dur) var(--ease);
    flex: 0 0 auto;
  }
  details[open].card > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
  details.card > summary h2, details.card > summary strong { margin: 0; }
  details.card[open] > summary { margin-bottom: var(--s-1); }

  .section-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--ink-strong);
    margin-top: var(--s-2);
  }
  .page-sub { color: var(--muted); font-size: var(--fs-sm); max-width: 62ch; }

  /* ---------- Cabecera de página ---------- */
  .page-head {
    display: grid;
    gap: var(--s-2);
    padding: var(--s-2) 0 var(--s-4);
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--s-4);
  }
  .page-head-row { display: grid; gap: var(--s-3); align-items: start; }
  .page-head-texto { display: grid; gap: var(--s-1); min-width: 0; }
  .page-head-texto h1 { margin: 0; }
  .page-head-badge { margin-top: var(--s-1); }
  .page-head-accion { display: flex; flex-wrap: wrap; gap: var(--s-2); }

  /* ---------- Insignias ---------- */
  .badge {
    --b-bg: var(--neutral-soft);
    --b-fg: var(--neutral-ink);
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    min-height: 24px;
    padding: 2px var(--s-2) 2px var(--s-2);
    border-radius: 999px;
    background: var(--b-bg);
    color: var(--b-fg);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .badge svg { width: 14px; height: 14px; }
  .badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
  }
  .badge--ok { --b-bg: var(--ok-soft); --b-fg: var(--ok-ink); }
  .badge--warn { --b-bg: var(--warn-soft); --b-fg: var(--warn-ink); }
  .badge--bad { --b-bg: var(--bad-soft); --b-fg: var(--bad-ink); }
  .badge--info { --b-bg: var(--brand-soft); --b-fg: var(--brand-ink); }
  .badge--neutral { --b-bg: var(--neutral-soft); --b-fg: var(--neutral-ink); }

  /* ---------- KPI (tile) ---------- */
  .tile {
    --t-fg: var(--ink-strong);
    display: grid;
    align-content: start;
    gap: var(--s-1);
    min-width: 0;
    min-height: var(--hit);
    padding: var(--s-3) var(--s-4);
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
  }
  .tile .etiqueta {
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--muted);
    line-height: 1.3;
  }
  .tile .valor {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-semibold);
    line-height: 1.1;
    color: var(--t-fg);
    font-variant-numeric: tabular-nums;
  }
  .tile .kpi-sub { font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
  .tile.ok { --t-fg: var(--ok); box-shadow: inset 4px 0 0 var(--ok-fill), var(--shadow-1); }
  .tile.warn { --t-fg: var(--warn); box-shadow: inset 4px 0 0 var(--warn-fill), var(--shadow-1); }
  .tile.bad { --t-fg: var(--bad); box-shadow: inset 4px 0 0 var(--bad-fill), var(--shadow-1); }
  button.tile { cursor: pointer; font: inherit; color: inherit; }
  button.tile:hover { border-color: var(--control); }

  /* ---------- Progreso ---------- */
  .progress {
    --p-fill: var(--brand);
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
  }
  .progress-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--p-fill);
    transition: width 200ms var(--ease);
  }
  .progress--ok { --p-fill: var(--ok-fill); }
  .progress--warn { --p-fill: var(--warn-fill); }
  .progress--bad { --p-fill: var(--bad-fill); }
  .progress-marca { margin-top: var(--s-1); font-size: var(--fs-xs); color: var(--muted); }

  /* ---------- Acordeón ---------- */
  .acc {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
    min-width: 0;
  }
  .acc.acc--ok { box-shadow: inset 4px 0 0 var(--ok-fill), var(--shadow-1); }
  .acc.acc--warn { box-shadow: inset 4px 0 0 var(--warn-fill), var(--shadow-1); }
  .acc.acc--bad { box-shadow: inset 4px 0 0 var(--bad-fill), var(--shadow-1); }
  .acc-h { font-size: inherit; color: inherit; margin: 0; }
  .acc-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    min-height: 56px;
    padding: var(--s-3) var(--s-4);
    text-align: left;
    color: var(--ink-strong);
    border-radius: var(--r-lg);
  }
  .acc-head:hover { background: var(--surface-2); }
  .acc-num {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    font-variant-numeric: tabular-nums;
  }
  .acc-texto { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
  .acc-title { font-weight: var(--fw-semibold); font-size: var(--fs-md); overflow-wrap: anywhere; }
  .acc-meta { font-size: var(--fs-xs); color: var(--muted); }
  .acc-chev { display: inline-grid; color: var(--muted); transition: transform var(--dur) var(--ease); }
  .acc-chev svg { width: 20px; height: 20px; }
  .acc.abierto .acc-chev { transform: rotate(180deg); }
  .acc-body { padding: 0 var(--s-4) var(--s-4); display: grid; gap: var(--s-3); }
  .acc-body[hidden] { display: none; }

  /* ---------- Tablas ---------- */
  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
  }
  table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-sm);
  }
  table.data th {
    position: sticky;
    top: 0;
    padding: var(--s-2) var(--s-3);
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
  }
  table.data td {
    padding: var(--s-3);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--ink);
    min-width: 0;
    overflow-wrap: anywhere;
  }
  table.data tbody tr:last-child td { border-bottom: 0; }
  table.data tbody tr:hover td { background: var(--surface-2); }
  table.data .tabla-num, table.data th.tabla-num { text-align: right; }
  table.data caption { caption-side: top; }
  td.tabla-num { font-variant-numeric: tabular-nums; }
  .celda-pct { font-weight: var(--fw-semibold); white-space: nowrap; }
  .celda-pct.ok { color: var(--ok); }
  .celda-pct.warn { color: var(--warn); }
  .celda-pct.bad { color: var(--bad); }

  /* ---------- Listas y definiciones ---------- */
  .list { list-style: none; padding: 0; margin: 0; display: grid; }
  .list-item { padding: var(--s-1) 0; border-bottom: 1px solid var(--line); }
  .list-item:last-child { border-bottom: 0; }
  .list-item > .btn { width: 100%; justify-content: flex-start; }

  .kv { display: grid; margin: 0; }
  .kv-fila {
    display: grid;
    grid-template-columns: minmax(96px, 40%) minmax(0, 1fr);
    gap: var(--s-3);
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-sm);
  }
  .kv-fila:last-child { border-bottom: 0; }
  .kv dt { color: var(--muted); }
  .kv dd { margin: 0; color: var(--ink-strong); overflow-wrap: anywhere; }

  /* ---------- Vacío, carga y superposiciones ---------- */
  .empty {
    display: grid;
    justify-items: center;
    gap: var(--s-2);
    padding: var(--s-8) var(--s-4);
    text-align: center;
    border: 1px dashed var(--control);
    border-radius: var(--r-lg);
    color: var(--muted);
  }
  .empty-icono {
    display: inline-grid;
    place-items: center;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--brand-ink);
  }
  .empty-icono svg { width: 24px; height: 24px; }
  .empty-titulo { font-weight: var(--fw-semibold); color: var(--ink-strong); font-size: var(--fs-md); }
  .empty-texto { font-size: var(--fs-sm); max-width: 40ch; }
  .empty-accion { margin-top: var(--s-2); }

  .skeleton { display: grid; gap: var(--s-3); padding: var(--s-4) 0; }
  .skeleton-linea {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
    background-size: 200% 100%;
    animation: pulso 1.2s var(--ease) infinite;
  }
  .skeleton-linea--corta { width: 60%; }
  @keyframes pulso { from { background-position: 100% 0; } to { background-position: -100% 0; } }

  .spinner {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    animation: girar 800ms linear infinite;
  }
  @keyframes girar { to { transform: rotate(360deg); } }

  .overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: var(--s-4);
    background: rgb(8 12 18 / 0.55);
  }
  .overlay-box {
    display: grid;
    justify-items: center;
    gap: var(--s-3);
    width: min(320px, 100%);
    padding: var(--s-6);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    text-align: center;
  }
  .overlay-box .progress { width: 100%; }

  /* Hoja modal: bottom sheet en móvil, centrada desde 600px */
  dialog#sheet:not([open]) { display: none; }
  dialog#sheet {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    max-height: min(88dvh, 100%);
    padding: 0;
    border: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  dialog#sheet[open] { animation: subir var(--dur) var(--ease); }
  dialog#sheet::backdrop { background: rgb(8 12 18 / 0.55); }
  @keyframes subir { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-2) var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
  }
  .sheet-head h2 { margin: 0; font-size: var(--fs-lg); }
  .sheet-body {
    display: grid;
    flex: 1 1 auto;
    min-height: 0; /* deja que el cuerpo encoja dentro de la hoja y scrollee */
    gap: var(--s-4);
    padding: var(--s-4);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom));
  }
  .sheet-body > form { display: grid; gap: var(--s-3); }
  dialog#sheet.cuenta .sheet-body { gap: var(--s-3); }

  .toasts {
    position: fixed;
    left: var(--s-4);
    right: var(--s-4);
    bottom: calc(72px + env(safe-area-inset-bottom));
    z-index: 70;
    display: grid;
    gap: var(--s-2);
    justify-items: center;
    pointer-events: none;
  }
  .toast {
    max-width: 480px;
    width: 100%;
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    background: var(--ink-strong);
    color: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
    animation: subir var(--dur) var(--ease);
  }
  .toast.ok { box-shadow: inset 4px 0 0 var(--ok-fill), var(--shadow-2); }
  .toast.bad { box-shadow: inset 4px 0 0 var(--bad-fill), var(--shadow-2); }
  .toast.saliendo { opacity: 0; transform: translateY(6px); }

  /* ---------- Gráficos ---------- */
  .grafico { width: 100%; height: auto; overflow: visible; }
  .grafico text.ejeTxt { fill: var(--muted); font-size: 12px; font-family: var(--font); }
  .grafico line.grid { stroke: var(--line); stroke-width: 1; }
  .grafico line.umbral { stroke-width: 1.5; stroke-dasharray: 5 4; }
  .grafico line.umbral.ok { stroke: var(--ok-fill); }
  .grafico line.umbral.warn { stroke: var(--warn-fill); }
  .grafico line.umbral.bad { stroke: var(--bad-fill); }
  .grafico circle.dot { stroke: var(--surface); stroke-width: 2; }
  .grafico circle.dot.ok { fill: var(--ok-fill); }
  .grafico circle.dot.warn { fill: var(--warn-fill); }
  .grafico circle.dot.bad { fill: var(--bad-fill); }
  .sparkline { width: 72px; height: 24px; }
  .sparkline polyline { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

  /* ---------- Escala de calificación (opciones) ---------- */
  .opciones {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-2);
  }
  .opciones.e5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .op {
    --o-fg: var(--ink-strong);
    --o-soft: var(--surface);
    --o-line: var(--control);
    min-height: 52px;
    padding: var(--s-2) var(--s-1);
    border-radius: var(--r-md);
    border: 1px solid var(--o-line);
    background: var(--o-soft);
    color: var(--o-fg);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
  }
  .op:hover { background: var(--surface-2); }
  .op[aria-pressed="true"] {
    background: var(--o-soft);
    box-shadow: inset 0 0 0 2px var(--o-line);
    font-weight: var(--fw-bold);
  }
  .op.v-ok { --o-fg: var(--ok-ink); --o-line: var(--ok-fill); }
  .op.v-warn { --o-fg: var(--warn-ink); --o-line: var(--warn-fill); }
  .op.v-bad { --o-fg: var(--bad-ink); --o-line: var(--bad-fill); }
  .op.v-na { --o-fg: var(--neutral-ink); --o-line: var(--control); }
  .op.v-ok[aria-pressed="true"] { --o-soft: var(--ok-soft); }
  .op.v-warn[aria-pressed="true"] { --o-soft: var(--warn-soft); }
  .op.v-bad[aria-pressed="true"] { --o-soft: var(--bad-soft); }
  .op.v-na[aria-pressed="true"] { --o-soft: var(--neutral-soft); }
  .op[aria-pressed="true"]::after { content: none; }
  .ref {
    display: flex;
    justify-content: space-between;
    gap: var(--s-2);
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  /* ---------- Fotos ---------- */
  .fotos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: var(--s-2);
  }
  .fotos-item { position: relative; }
  .fotos-ver {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--line);
  }
  .fotos-ver img { width: 100%; height: 100%; object-fit: cover; }
  .fotos-borrar {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ink-strong);
    color: var(--surface);
    font-size: 13px;
    line-height: 1;
    box-shadow: var(--shadow-1);
  }
  .fotos-borrar:hover { background: var(--bad-ink); }
  .btn-foto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 96px;
    padding: var(--s-2);
    border: 1px dashed var(--control);
    border-radius: var(--r-md);
    color: var(--brand-ink);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    text-align: center;
    cursor: pointer;
    position: relative;
  }
  .btn-foto:hover { background: var(--brand-soft); }
  .btn-foto:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
  .btn-foto input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
  }
}
