/* videla-ui: componentes. Requiere tokens.css. Todas las medidas salen de la escala. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
/* Un elemento con escala o tema propio recalcula su letra y colores. */
body, [data-escala], [data-tema] {
  background: var(--background);
  color: var(--foreground);
  font: 400 var(--texto)/var(--texto-lh) var(--fuente);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; font: inherit; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
[hidden] { display: none !important; }
.v-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.v-gris { color: var(--muted-foreground); }
.v-num { font-variant-numeric: tabular-nums; }
.v-urgente { color: var(--urgente); }
.v-lnk { color: var(--acento); text-decoration: underline; text-underline-offset: 3px; }
.v-i { width: var(--icono); height: var(--icono); flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Texto */
.v-t1 { font-size: var(--titulo-1); line-height: var(--titulo-1-lh); font-weight: 600; letter-spacing: -.02em; }
.v-t2 { font-size: var(--titulo-2); line-height: var(--titulo-2-lh); font-weight: 600; letter-spacing: -.01em; }
.v-t3 { font-size: var(--titulo-3); line-height: var(--titulo-3-lh); font-weight: 600; }
.v-chico { font-size: var(--texto-2); line-height: var(--texto-2-lh); }
.v-cifra { font-size: var(--cifra); line-height: var(--cifra-lh); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* Contenedor */
.v-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
@media (min-width: 820px) { .v-wrap { padding-inline: 32px; } }

/* Cabecera */
.v-top { border-bottom: 1px solid var(--border); }
.v-top > .v-wrap { display: flex; align-items: center; gap: 16px; min-height: var(--cabecera); }
.v-marca { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; text-decoration: none; }
.v-logo { display: inline-flex; padding: 5px; border-radius: 8px; background: var(--acento); color: var(--acento-fg); }
.v-top .v-lado { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Botones */
.v-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control); padding: 0 var(--control-pad); border-radius: var(--radio-control);
  font-size: var(--control-texto); font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
  border: 1px solid var(--border); background: var(--background); box-shadow: var(--sombra);
}
.v-btn:hover { background: var(--hover); }
.v-btn.pri { background: var(--acento); color: var(--acento-fg); border-color: transparent; }
.v-btn.pri:hover { background: var(--acento-hover); }
.v-btn.fantasma { border-color: transparent; background: none; box-shadow: none; }
.v-btn.fantasma:hover { background: var(--hover); }
.v-btn.peligro { color: var(--urgente); }
.v-btn.icono { width: var(--control); padding: 0; }
.v-btn:disabled, .v-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* El área de toque llega a 44 aunque el botón se vea más bajo. */
.v-btn::after { content: ""; position: absolute; inset: min(0px, (var(--control) - 44px) / 2); }

/* Campos */
.v-campo { display: grid; gap: 6px; }
.v-campo > label, .v-etiqueta { font-size: var(--texto-2); line-height: var(--texto-2-lh); font-weight: 500; }
.v-campo .v-ayuda { font-size: var(--texto-2); line-height: var(--texto-2-lh); color: var(--muted-foreground); }
.v-campo .v-error { font-size: var(--texto-2); line-height: var(--texto-2-lh); color: var(--urgente); }
.v-input, .v-select {
  width: 100%; min-height: var(--control); padding: 0 var(--campo-pad); border-radius: var(--radio-control);
  border: 1px solid var(--input); background: var(--background); font-size: max(16px, var(--control-texto));
}
.v-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.v-input::placeholder { color: var(--muted-foreground); }
.v-input:focus-visible, .v-select:focus-visible { outline: 2px solid var(--acento); outline-offset: 0; border-color: transparent; }
.v-input[aria-invalid="true"] { border-color: var(--urgente); }
.v-input:disabled, .v-select:disabled { opacity: .5; cursor: not-allowed; }
.v-select { appearance: none; padding-right: calc(var(--campo-pad) + 20px); background: var(--background) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right var(--campo-pad) center; }
.v-check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.v-check input { width: var(--casilla); height: var(--casilla); margin: 0; accent-color: var(--acento); cursor: pointer; }

/* Pestañas y segmentado */
.v-tabs { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--muted); border-radius: calc(var(--radio-control) + 2px); }
.v-tabs > a, .v-tabs > button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: calc(var(--control) - 6px); padding: 0 var(--control-pad);
  border-radius: calc(var(--radio-control) - 1px); border: 1px solid transparent; background: none; cursor: pointer;
  font-size: var(--control-texto); font-weight: 500; color: var(--muted-foreground); text-decoration: none; white-space: nowrap;
}
.v-tabs > :hover { color: var(--foreground); }
.v-tabs > [aria-current], .v-tabs > [aria-pressed="true"], .v-tabs > [aria-selected="true"] { background: var(--background); color: var(--acento); border-color: var(--border); box-shadow: var(--sombra); }

/* Barra de abajo (teléfono) */
.v-bajo { position: fixed; z-index: 20; inset: auto 0 0; background: color-mix(in srgb, var(--background) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }
.v-bajo nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.v-bajo a { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 16px; font-weight: 500; color: var(--muted-foreground); text-decoration: none; }
.v-bajo a .v-i { width: 24px; height: 24px; stroke-width: 1.75; }
.v-bajo a[aria-current] { color: var(--acento); }
@media (min-width: 820px) { .v-bajo { display: none; } }

/* Tarjeta: solo para un objeto aparte (gráfico, resumen). Listas y tablas van sobre el fondo. */
.v-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radio-caja); box-shadow: var(--sombra); padding: var(--caja-pad); }

/* Encabezado de sección */
.v-sec { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 8px; }
.v-sec p { color: var(--muted-foreground); font-size: var(--texto-2); line-height: var(--texto-2-lh); }

/* Tabla */
.v-tabla { width: 100%; border-collapse: collapse; }
.v-tabla th { text-align: left; font-size: var(--texto-2); font-weight: 500; color: var(--muted-foreground); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.v-tabla td { padding: 0 12px; height: var(--fila); border-bottom: 1px solid var(--border); vertical-align: middle; }
.v-tabla th:first-child, .v-tabla td:first-child { padding-left: 0; }
.v-tabla th:last-child, .v-tabla td:last-child { padding-right: 0; }
.v-tabla .der { text-align: right; font-variant-numeric: tabular-nums; }
.v-tabla .sub { display: block; font-size: var(--texto-2); line-height: var(--texto-2-lh); color: var(--muted-foreground); }

/* Filas de lista (teléfono y listas cortas) */
.v-filas > li { display: flex; align-items: center; gap: 12px; min-height: var(--fila); padding: 10px 0; border-top: 1px solid var(--border); }
.v-filas > li:last-child { border-bottom: 1px solid var(--border); }
.v-filas .tx { flex: 1; min-width: 0; }
.v-filas .sub { display: block; font-size: var(--texto-2); line-height: var(--texto-2-lh); color: var(--muted-foreground); }
.v-filas .monto { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.v-filas .hecho .tt, .v-tabla .hecho .tt { color: var(--muted-foreground); text-decoration: line-through; }

/* Barra de avance */
.v-pista { height: 8px; border-radius: 4px; background: var(--muted); overflow: hidden; }
.v-pista > i { display: block; height: 100%; border-radius: 4px; background: var(--acento); }
.v-pista.alerta > i { background: var(--urgente); }

/* Aviso en línea y emergente */
.v-nota { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radio-control); background: var(--muted); }
.v-nota.urgente { color: var(--urgente); }
.v-aviso { position: fixed; z-index: 30; left: 50%; bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px); width: min(calc(100% - 32px), 440px); transform: translate(-50%, 8px); opacity: 0; visibility: hidden; transition: opacity .15s, transform .15s, visibility .15s; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radio-caja); box-shadow: 0 4px 12px rgba(0, 0, 0, .12); }
.v-aviso.ver { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.v-aviso .m { flex: 1; }
@media (min-width: 820px) { .v-aviso { bottom: 24px; } }

/* Diálogo: centrado en escritorio, hoja desde abajo en el teléfono */
.v-dialogo { border: 1px solid var(--border); border-radius: var(--radio-caja); padding: 0; background: var(--card); color: var(--foreground); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); width: min(calc(100% - 32px), 480px); max-height: calc(100% - 32px); overflow: auto; }
.v-dialogo::backdrop { background: var(--velo); }
.v-dialogo > form, .v-dialogo > div { padding: var(--caja-pad); display: grid; gap: 16px; }
.v-dialogo .pie { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 819px) {
  .v-dialogo { margin: auto auto 0; width: 100%; max-width: none; border-radius: var(--radio-caja) var(--radio-caja) 0 0; border-bottom: 0; }
  .v-dialogo .pie .v-btn { flex: 1; min-height: 48px; }
}

/* Zona para soltar archivos */
.v-zona { display: grid; justify-items: center; gap: 8px; padding: 32px 16px; border: 1.5px dashed var(--input); border-radius: var(--radio-caja); text-align: center; cursor: pointer; }
.v-zona:hover, .v-zona.encima { border-color: var(--acento); background: var(--hover); }

/* Estado vacío: dice por qué y la acción que lo llena */
.v-vacio { display: grid; justify-items: start; gap: 12px; padding: 24px 0; color: var(--muted-foreground); }

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