/* Tokens de STITCH (copiados de la app 1) + base visual de Control de Obra.
   Regla: fuera de este archivo ningún color se escribe a mano; todo sale de rgb(var(--c-*)). */
:root {
  --c-bg: 255 255 255;
  --c-card: 255 255 255;
  --c-border: 229 229 227;
  --c-border-subtle: 237 237 235;
  --c-stone-dark: 31 31 31;
  --c-stone-body: 63 63 63;
  --c-stone-muted: 107 107 107;
  --c-stone-subtle: 241 245 249;
  --c-stone-tint: 246 245 244;
  --c-accent: 0 102 204;
  --c-accent-hover: 0 87 173;
  --c-accent-light: 227 242 253;
  --c-accent-border: 183 214 240;
  --c-accent-text: 0 87 173;
  --c-accent-fg: 0 102 204;
  --c-accent-fg-hover: 0 87 173;
  --c-accent-ink: 255 255 255;
  --c-ok: 26 127 75;
  --c-err: 198 40 40;
  --c-err-bg: 253 236 236;
  --c-err-border: 243 185 185;
  --c-warn-bg: 255 251 235;
  --c-warn-border: 253 230 138;
  --c-warn-text: 146 64 14;
  --c-inverse: 31 31 31;
  --c-overlay: 31 31 31;
  --c-scroll-track: 246 245 244;
  --c-scroll-thumb: 212 212 209;
  --fuente: "Creacion UI", Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --radio: 10px;
  --esp: 16px;
}
html.dark {
  color-scheme: dark;
  --c-bg: 25 25 25;
  --c-card: 32 32 32;
  --c-border: 52 52 52;
  --c-border-subtle: 43 43 43;
  --c-stone-dark: 237 237 237;
  --c-stone-body: 207 207 207;
  --c-stone-muted: 160 160 160;
  --c-stone-subtle: 42 42 42;
  --c-stone-tint: 35 35 35;
  --c-accent: 0 102 204;
  --c-accent-hover: 10 106 214;
  --c-accent-light: 23 50 75;
  --c-accent-border: 47 94 140;
  --c-accent-text: 77 163 255;
  --c-accent-fg: 77 163 255;
  --c-accent-fg-hover: 125 187 255;
  --c-ok: 61 203 139;
  --c-err: 255 107 107;
  --c-err-bg: 58 31 31;
  --c-err-border: 107 43 43;
  --c-warn-bg: 58 48 32;
  --c-warn-border: 94 74 30;
  --c-warn-text: 245 194 107;
  --c-inverse: 58 58 58;
  --c-overlay: 0 0 0;
  --c-scroll-track: 32 32 32;
  --c-scroll-thumb: 69 69 69;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: rgb(var(--c-bg)); color: rgb(var(--c-stone-body)); font-family: var(--fuente); font-size: 14px; line-height: 1.45; }
h1, h2, h3 { color: rgb(var(--c-stone-dark)); margin: 0; font-weight: 700; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
a { color: rgb(var(--c-accent-text)); }
::placeholder { color: rgb(var(--c-stone-muted)); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgb(var(--c-scroll-track)); }
::-webkit-scrollbar-thumb { background: rgb(var(--c-scroll-thumb)); border-radius: 999px; }

.mudo { color: rgb(var(--c-stone-muted)); }
.ancho { width: 100%; }
.oculto { display: none !important; }
.tarjeta { background: rgb(var(--c-card)); border: 1px solid rgb(var(--c-border)); border-radius: var(--radio); padding: var(--esp); }
.barra-superior { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px;
  background: rgb(var(--c-card)); border-bottom: 1px solid rgb(var(--c-border)); position: sticky; top: 0; z-index: 5; }
.barra-superior .crece { flex: 1 1 160px; min-width: 0; }
.barra-superior strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: rgb(var(--c-stone-muted)); }
.estado::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: rgb(var(--c-ok)); }
.estado[data-estado="pendiente"]::before { background: rgb(var(--c-warn-text)); }
.estado[data-estado="sin_conexion"]::before { background: rgb(var(--c-err)); }

.campo { display: block; margin-bottom: 12px; }
.campo span { display: block; font-size: 12px; font-weight: 600; color: rgb(var(--c-stone-muted)); margin-bottom: 4px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: rgb(var(--c-stone-dark));
  background: rgb(var(--c-card)); border: 1px solid rgb(var(--c-border)); border-radius: 8px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid rgb(var(--c-accent)); outline-offset: 1px; }

.boton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; border-radius: 8px;
  border: 1px solid rgb(var(--c-border)); background: rgb(var(--c-card)); color: rgb(var(--c-stone-dark)); }
.boton-primario { background: rgb(var(--c-accent)); border-color: rgb(var(--c-accent)); color: rgb(var(--c-accent-ink)); }
.boton-primario:hover { background: rgb(var(--c-accent-hover)); }
.boton-suave { background: rgb(var(--c-stone-tint)); }
.boton:disabled { opacity: .55; cursor: default; }
.aviso { color: rgb(var(--c-err)); font-size: 13px; margin: 0 0 12px; }
.aviso[data-tipo="ok"] { color: rgb(var(--c-ok)); }
.etiqueta { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgb(var(--c-stone-tint)); color: rgb(var(--c-stone-muted)); }
.grid-botones { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
.boton-bloque { flex-direction: column; align-items: flex-start; min-height: 88px; text-align: left; padding: 12px; gap: 4px; }
.boton-bloque small { color: rgb(var(--c-stone-muted)); font-weight: 400; }
.marco { width: 100%; max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.pagina { padding: 16px; max-width: 1100px; margin: 0 auto; }

/* Avisos flotantes (ui.js) */
#ui-avisos { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.ui-aviso { background: rgb(var(--c-inverse)); color: rgb(var(--c-accent-ink)); padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 90vw; }
.ui-aviso[data-tipo="error"] { background: rgb(var(--c-err)); color: rgb(var(--c-accent-ink)); }
#ui-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: rgb(var(--c-overlay) / .45); }
#ui-modal .caja { background: rgb(var(--c-card)); border: 1px solid rgb(var(--c-border)); border-radius: var(--radio);
  padding: var(--esp); width: 100%; max-width: 420px; }
#ui-modal .pie { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ===== Armazón estándar (U0): riel, barra superior y barra inferior =====
   Medidas copiadas de la app 1 (PUBLICADO/01_proyectos). Todos los colores salen de tokens. */
:root {
  --riel: 84px; --fila-tabla: 36px; --barra-inferior: 40px;
  --c-rail: 237 243 250; --c-rail-ink: 80 80 80; --c-rail-on: 214 230 246; --c-rail-on-ink: 0 87 173;
  --c-marca: 0 102 204; --c-marca-ink: 255 255 255;
}
html.dark {
  --c-rail: 33 33 33; --c-rail-ink: 170 170 170; --c-rail-on: 42 62 84; --c-rail-on-ink: 125 187 255;
  --c-marca: 0 102 204; --c-marca-ink: 255 255 255;
}
body.con-riel { padding-left: var(--riel); padding-bottom: var(--barra-inferior); }

.riel { position: fixed; left: 0; top: 0; bottom: var(--barra-inferior); width: var(--riel); z-index: 45;
  display: flex; flex-direction: column; align-items: stretch; gap: 1px; padding: 10px 6px;
  background: rgb(var(--c-rail)); color: rgb(var(--c-rail-ink));
  border-right: 1px solid rgb(var(--c-border) / .7); overflow-x: hidden; overflow-y: auto; scrollbar-width: none; }
.riel::-webkit-scrollbar { display: none; }
.riel, .riel * { box-sizing: border-box; }
.riel-marca { width: 36px; height: 36px; flex: none; margin: 0 auto 10px; display: grid; place-items: center;
  border-radius: 9px; background: rgb(var(--c-marca)); color: rgb(var(--c-marca-ink));
  font: inherit; font-size: 15px; font-weight: 700; text-decoration: none; }
.riel-item { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 2px 0; border: 0; border-radius: 8px;
  background: none; color: inherit; font: inherit; font-size: 10px; line-height: 1.15;
  letter-spacing: -.005em; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; }
.riel-item .riel-ic { width: 40px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  transition: background-color 150ms ease; }
.riel-item.activo { color: rgb(var(--c-rail-on-ink)); font-weight: 600; }
.riel-item.activo .riel-ic { background: rgb(var(--c-rail-on)); }
.riel-item:not(.activo):hover .riel-ic { background: rgb(var(--c-rail-on) / .6); }
.riel hr { flex: none; border: 0; border-top: 1px solid rgb(var(--c-rail-ink) / .18); margin: 6px 12px; width: auto; }
.riel-esp { flex: 1 0 6px; }
.riel-pie { margin-top: 2px; }

.barra-superior { min-height: calc(var(--fila-tabla) + 12px); padding: 0 14px; }
.miga { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: rgb(var(--c-stone-muted)); }
.miga span { color: rgb(var(--c-stone-muted)); }
.barra-superior strong { font-size: 14px; }
.usuario { width: 28px; height: 28px; flex: none; border-radius: 999px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: rgb(var(--c-accent-light)); color: rgb(var(--c-accent-text)); }
.boton-icono { width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  border: 1px solid rgb(var(--c-border)); border-radius: 8px; background: rgb(var(--c-card));
  color: rgb(var(--c-stone-body)); font: inherit; font-size: 14px; cursor: pointer; }
.riel-menu { display: none; }

.barra-inferior { position: fixed; left: 0; right: 0; bottom: 0; height: var(--barra-inferior); z-index: 44;
  display: flex; align-items: center; gap: 8px; padding: 0 14px; font-size: 11.5px;
  background: rgb(var(--c-card)); border-top: 1px solid rgb(var(--c-border)); }
.boton-texto { border: 0; background: none; font: inherit; font-size: 11.5px; color: rgb(var(--c-stone-dark));
  padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.boton-texto:hover { background: rgb(var(--c-stone-tint)); }

.contenido-armazon { padding: 16px; max-width: 1400px; margin: 0 auto; }

/* Tabla densa (app 1) */
thead th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: rgb(var(--c-stone-muted)); text-align: left; }
tbody td { height: var(--fila-tabla); }

/* Calculadora flotante */
.calc { position: fixed; right: 16px; bottom: calc(var(--barra-inferior) + 12px); z-index: 80; width: 224px;
  background: rgb(var(--c-card)); border: 1px solid rgb(var(--c-border)); border-radius: var(--radio);
  padding: 10px; box-shadow: 0 8px 30px rgb(var(--c-overlay) / .25); }
.calc[hidden] { display: none; }
.calc-cerrar { position: absolute; top: 4px; left: 6px; width: 22px; height: 22px; border: 0; border-radius: 6px;
  background: none; color: rgb(var(--c-stone-muted)); font: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.calc-pantalla { min-height: 42px; margin: 0 0 8px; padding: 10px 8px; border-radius: 8px; text-align: right;
  background: rgb(var(--c-stone-tint)); color: rgb(var(--c-stone-dark)); font-size: 20px; font-weight: 600;
  font-variant-numeric: tabular-nums; overflow: hidden; }
.calc-teclas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-teclas button { min-height: 36px; border: 1px solid rgb(var(--c-border)); border-radius: 8px;
  background: rgb(var(--c-card)); color: rgb(var(--c-stone-dark)); font: inherit; cursor: pointer; }
.calc-teclas button:hover { background: rgb(var(--c-stone-tint)); }
.calc-teclas button.calc-igual { background: rgb(var(--c-accent)); border-color: rgb(var(--c-accent)); color: rgb(var(--c-accent-ink)); }

@media (max-width: 900px) {
  body.con-riel { padding-left: 0; }
  .riel { bottom: 0; transform: translateX(-100%); transition: transform 180ms ease; z-index: 55;
    box-shadow: 8px 0 24px rgb(var(--c-overlay) / .18); }
  body.riel-abierto .riel { transform: none; }
  .riel-menu { display: grid; }
}
