/* Letras del rediseño: Space Grotesk (solo títulos) e IBM Plex Sans (todo lo demás), alojadas en la app (fuentes/,
   woff2 variables con el subconjunto latino de Google Fonts; licencia OFL en fuentes/OFL.txt). Ya no se pide nada a
   Google Fonts: el service worker las guarda con la app y se ven igual sin conexión. */
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url("../fuentes/space-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fuentes/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Kresko · componentes para apps de páginas, bloques y tablas. Todo color, medida y radio sale de tokens.css.
   Rediseño premium (parte 1): sin degradados, bordes de 1 px, sombras casi nulas y un solo acento verde. */
html, body { margin: 0; background: var(--surface-page); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
.k-stack { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); }
.k-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
:where(.k-btn, .k-check, .k-side-item, .k-table button):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---- Button: un solo botón con relleno por pantalla (primary); los demás con borde o como texto ---- */
.k-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid transparent; font-family: var(--font-body); font-weight: 500; font-size: 14px; cursor: pointer; transition: background var(--dur) ease, border-color var(--dur) ease, color var(--dur) ease; }
.k-btn .ico { width: 16px; height: 16px; }
.k-btn--primary { background: var(--acento); color: var(--sobre-acento); }
.k-btn--primary:hover { background: color-mix(in srgb, var(--acento) 88%, var(--texto)); }
.k-btn--secondary { background: var(--superficie); color: var(--text); border-color: var(--borde); }
.k-btn--secondary:hover { background: var(--surface-hover); }
.k-btn--ghost { background: transparent; color: var(--secundario); }
.k-btn--ghost:hover { background: var(--surface-hover); color: var(--text); }
.k-btn--pop { background: var(--acento); color: var(--sobre-acento); } /* antes con degradado */
.k-btn--sm { height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.k-btn:disabled { opacity: .45; cursor: default; }

/* ---- Tag: las etiquetas son texto gris, sin píldora de color (regla 4) ---- */
.k-tag { display: inline-flex; align-items: center; gap: 6px; min-height: 20px; padding: 0; border-radius: 0; background: none; color: var(--secundario); font-size: 13px; font-weight: 500; white-space: nowrap; }
.k-tag--red { color: var(--peligro); }

/* ---- Todo (bloque de tarea) ---- */
.k-todo { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-1) 0; }
.k-check { flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--texto) 35%, transparent); background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; transition: background var(--dur) ease, border-color var(--dur) ease; }
.k-check svg { width: 12px; height: 12px; fill: none; stroke: var(--sobre-acento); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity var(--dur) ease; }
.k-check[aria-checked="true"] { background: var(--acento); border-color: var(--acento); }
.k-check[aria-checked="true"] svg { opacity: 1; }
.k-todo__text { flex: 1; min-width: 0; }
.k-todo__meta { display: block; font-size: 13px; color: var(--text-muted); }
.k-todo--done .k-todo__text > span:first-child { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--text-faint); }

/* ---- Callout (cuadro destacado): tarjeta con borde, como la referencia ---- */
.k-callout { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); background: var(--superficie); border: 1px solid var(--borde); }
.k-callout__icon { font-size: 18px; line-height: 24px; flex: none; color: var(--secundario); }
.k-callout__icon .ico { width: 16px; height: 16px; margin-top: 4px; }
.k-callout__body { min-width: 0; }
.k-callout__body strong { font-weight: 600; }
.k-callout--teal, .k-callout--lime, .k-callout--amber { background: var(--superficie); border-color: var(--borde); }

/* ---- Sidebar ---- */
.k-sidebar { width: 260px; max-width: 100%; background: var(--barra); border-right: 1px solid var(--borde); padding: var(--space-3) var(--space-2); display: flex; flex-direction: column; gap: 2px; box-sizing: border-box; }
.k-sidebar__ws { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border-radius: var(--radius-sm); }
.k-sidebar__ws img { width: 26px; height: 26px; flex: none; border-radius: 6px; }
.k-sidebar__ws-texto { display: flex; flex-direction: column; min-width: 0; }
.k-sidebar__ws-nombre { font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 18px; color: var(--texto); }
.k-sidebar__ws small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 12px; line-height: 16px; color: var(--secundario); }
.k-sidebar__label { font-family: var(--font-body); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tenue); padding: var(--space-4) var(--space-2) var(--space-1); }
.k-side-item { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 0 var(--space-2); border-radius: var(--radius-sm); color: var(--texto); font-size: 14px; font-weight: 400; text-decoration: none; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; }
.k-side-item:hover { background: var(--surface-hover); }
.k-side-item[aria-current="page"] { background: color-mix(in srgb, var(--texto) 6%, transparent); font-weight: 500; }
.k-side-item__icon { width: 16px; display: inline-grid; place-items: center; flex: none; color: var(--secundario); }
.k-side-item__count { margin-left: auto; font-size: 12px; color: var(--tenue); }
.k-side-item--child { padding-left: 30px; }

/* ---- Page header ---- */
.k-page { background: var(--surface-page); }
.k-page__cover { height: 160px; background: var(--barra); }
.k-page__inner { padding: 0 var(--space-8) var(--space-6); }
.k-page__icon { width: 56px; height: 56px; border-radius: var(--radius-md); background: var(--acento-suave); display: grid; place-items: center; font-size: 32px; color: var(--acento); }
.k-page__title { margin: var(--space-4) 0 var(--space-2); font-family: var(--font-display); font-size: 34px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }
.k-props { display: grid; grid-template-columns: 160px 1fr; gap: 2px var(--space-4); font-size: 14px; }
.k-props dt { color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.k-props dd { margin: 0; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---- Database table ---- */
.k-table-wrap { overflow-x: auto; }
.k-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.k-table th { text-align: left; font-family: var(--font-body); font-weight: 400; font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--tenue); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--borde-suave); white-space: nowrap; }
.k-table td { padding: 0 var(--space-3); height: 44px; border-bottom: 1px solid var(--borde-suave); vertical-align: middle; }
.k-table tbody tr:hover { background: var(--surface-hover); }
.k-table .k-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Progress ---- */
.k-progress { display: flex; align-items: center; gap: var(--space-2); min-width: 120px; }
.k-progress__track { flex: 1; height: 4px; border-radius: var(--radius-pill); background: var(--borde); overflow: hidden; }
.k-progress__fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--acento); }
.k-progress__val { font-size: 12px; color: var(--text-muted); min-width: 34px; text-align: right; }
.k-progress--risk .k-progress__fill { background: var(--peligro); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== Acabado Kresko (21/10, del lienzo) =====================================================
   La misma letra pequeña que en Floro y en la Nube: cifras que no bailan, el toque que se siente,
   las tarjetas que entran una detrás de otra, y el grano que mata el bandeado de los fondos
   oscuros. Todo el movimiento va detrás de «prefers-reduced-motion». Los colores no se tocan. */

/* 1. Cifras tabulares: una columna de números no se mueve al cambiar un dígito. */
body, table, .k-tabla, .k-cifra, .k-card { font-variant-numeric: tabular-nums; }

/* 2. Pulsación: 0.96 en 150 ms con transition, nunca con keyframes (un keyframe no se puede
      interrumpir a media pulsación y se ve como un tic). */
button, .k-btn, .k-chip, [role="button"] { transition: transform .15s var(--curva), background-color .15s, border-color .15s; }
button:active:not(:disabled), .k-btn:active, .k-chip:active, [role="button"]:active { transform: scale(.96); }

/* 3. Entradas escalonadas cada 100 ms con la curva de Kresko. */
@keyframes kr-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.k-card, .k-panel { animation: kr-entra .4s var(--curva) both; }
.k-card:nth-of-type(1), .k-panel:nth-of-type(1) { animation-delay: 0s; }
.k-card:nth-of-type(2), .k-panel:nth-of-type(2) { animation-delay: .1s; }
.k-card:nth-of-type(3), .k-panel:nth-of-type(3) { animation-delay: .2s; }
.k-card:nth-of-type(4), .k-panel:nth-of-type(4) { animation-delay: .3s; }
.k-card:nth-of-type(n+5), .k-panel:nth-of-type(n+5) { animation-delay: .4s; }

/* 4. Grano al 4 % con mix-blend-mode: overlay, solo en los temas oscuros. En un fondo oscuro el
      ojo ve escalones (bandeado); un grano muy leve los rompe. No recibe clics ni tapa nada. */
[data-theme="dark"] body::after, [data-theme="black"] body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* 5. Quien pidió no ver movimiento, no lo ve. */
@media (prefers-reduced-motion: reduce) {
  .k-card, .k-panel { animation: none; }
  button, .k-btn, .k-chip, [role="button"] { transition: none; }
  button:active:not(:disabled), .k-btn:active, .k-chip:active, [role="button"]:active { transform: none; }
}
