/* Base común de la isla (21/11/2026): mundo «web japonesa de alta densidad».
   Módulos encajados con filete fino y pestaña de color, letra gótica compacta (Zen Kaku Gothic New),
   cifras tabulares, acento azul marino (kon) y el color de cada fase como única nota fuerte.
   La usan todas las páginas: oficina, móvil del taller, Henry, Horas, Presupuestos, Verificar, Agentes y Entrar.
   Iconos: public/js/iconos.js (trazo de línea, nunca emojis). */

@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@400;500;700;900&display=swap');

:root {
  color-scheme: light;
  /* Superficies */
  --fondo: #f1f2f4;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --hundido: #eceef1;
  /* Tinta */
  --tinta: #121417;
  --tinta-2: #444b54;
  --tinta-3: #858c95;
  --linea: #d9dde2;
  --linea-2: #e8ebee;
  /* Acento: azul marino (kon) */
  --acento: #233a8f;
  --acento-hover: #1b2e73;
  --acento-suave: #e8ecf8;
  --acento-texto: #ffffff;
  /* Estados (solo para estados, nunca de adorno) */
  --ok: #18804f;      --ok-suave: #e3f3ea;
  --atencion: #b7791f; --atencion-suave: #fbf1de;
  --error: #c0362c;   --error-suave: #fbe7e5;
  --info: #0e7fa8;    --info-suave: #e1f2f8;
  /* Fases de obra */
  --f-no_iniciada: #8b9199;
  --f-medicion: #0e8fb3;
  --f-dibujo: #7a4cc9;
  --f-fabricacion: #e05a00;
  --f-montaje: #c99700;
  --f-remates: #18925a;
  --f-pagos: #8a5a2b;
  /* Letra */
  --letra: 'Zen Kaku Gothic New', 'Hiragino Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --t-xs: 11px; --t-s: 12px; --t-m: 13.5px; --t-l: 15px; --t-xl: 18px; --t-xxl: 22px;
  /* Forma */
  --r: 3px; --r-l: 6px;
  --sombra-flota: 0 8px 28px rgba(18, 20, 23, .16), 0 2px 6px rgba(18, 20, 23, .08);
  /* Movimiento */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --rapido: 140ms; --medio: 220ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--tinta); font: 400 var(--t-m)/1.45 var(--letra); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
::selection { background: var(--acento-suave); }

/* ---------- iconos ---------- */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ico.s { width: 15px; height: 15px; vertical-align: -2px; }
.ico.l { width: 22px; height: 22px; }
.ico.xl { width: 28px; height: 28px; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--linea); border-radius: var(--r); background: var(--panel); color: var(--tinta); font-weight: 500; font-size: var(--t-m); white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--rapido), border-color var(--rapido), color var(--rapido), transform var(--rapido) var(--ease); }
.btn:hover { border-color: var(--tinta-3); background: var(--panel-2); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primario { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); }
.btn.primario:hover { background: var(--acento-hover); border-color: var(--acento-hover); }
.btn.verde, .btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.peligro { color: var(--error); }
.btn.peligro:hover { background: var(--error-suave); border-color: var(--error); }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: var(--hundido); }
.btn.mini { height: 26px; padding: 0 8px; font-size: var(--t-s); }
.btn.grande { height: 44px; padding: 0 18px; font-size: var(--t-l); font-weight: 700; }
.btn.activa, .btn[aria-pressed="true"] { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.btn.icono { width: 32px; padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn select { border: 0; background: transparent; font-weight: 500; cursor: pointer; padding: 0; height: auto; }

/* ---------- campos ---------- */
input, select, textarea { min-width: 0; border: 1px solid var(--linea); border-radius: var(--r); background: var(--panel); padding: 6px 9px; font-size: var(--t-m); transition: border-color var(--rapido), box-shadow var(--rapido); }
input:hover, select:hover, textarea:hover { border-color: var(--tinta-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
textarea { resize: vertical; min-height: 56px; width: 100%; line-height: 1.45; }
input[type=checkbox], input[type=radio] { accent-color: var(--acento); width: 16px; height: 16px; }
input[type=color] { padding: 2px; height: 32px; width: 100%; }
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-s); color: var(--tinta-2); font-weight: 500; }
.campos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.campos .ancho { grid-column: 1 / -1; }
.fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fila > input:not([type=checkbox]):not([type=radio]), .fila > select { flex: 1; }

/* Buscador grande, siempre a la vista */
.buscador { position: relative; display: flex; align-items: center; flex: 1; max-width: 560px; }
.buscador .ico { position: absolute; left: 11px; color: var(--tinta-3); pointer-events: none; }
.buscador input { width: 100%; height: 36px; padding-left: 36px; padding-right: 34px; background: var(--panel-2); font-size: var(--t-l); }
.buscador input:focus { background: var(--panel); }
.buscador kbd { position: absolute; right: 9px; font: 500 11px var(--letra); color: var(--tinta-3); border: 1px solid var(--linea); border-radius: 3px; padding: 0 5px; line-height: 17px; background: var(--panel); }

/* ---------- módulo: la pieza básica (caja con filete y pestaña) ---------- */
.mod { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--r); min-width: 0; display: flex; flex-direction: column; }
.mod > .mod-cab { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px 0 0; border-bottom: 1px solid var(--linea); }
.mod > .mod-cab > .tab { align-self: stretch; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--c, var(--acento)); color: #fff; font-weight: 700; font-size: var(--t-s); letter-spacing: .02em; border-radius: var(--r) 0 0 0; }
.mod > .mod-cab > h2, .mod > .mod-cab > h3 { font-size: var(--t-m); font-weight: 700; }
.mod > .mod-cab .cuenta { margin-left: auto; color: var(--tinta-3); font-size: var(--t-s); font-weight: 500; }
.mod > .mod-cuerpo { padding: 10px; min-width: 0; }
.mod > .mod-cuerpo.sin-relleno { padding: 0; }

/* Mosaico de módulos: encajan borde con borde, sin huecos */
.mosaico { display: grid; gap: 8px; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: row dense; align-items: stretch; }
.mosaico > .c3 { grid-column: span 3; } .mosaico > .c4 { grid-column: span 4; } .mosaico > .c5 { grid-column: span 5; } .mosaico > .c6 { grid-column: span 6; }
.mosaico > .c7 { grid-column: span 7; } .mosaico > .c8 { grid-column: span 8; } .mosaico > .c9 { grid-column: span 9; } .mosaico > .c12 { grid-column: 1 / -1; }
@media (max-width: 1280px) { .mosaico > .c3 { grid-column: span 6; } .mosaico > .c4, .mosaico > .c5 { grid-column: span 6; } .mosaico > .c7, .mosaico > .c8, .mosaico > .c9 { grid-column: 1 / -1; } }
@media (max-width: 860px) { .mosaico > * { grid-column: 1 / -1 !important; } }

/* Rejilla de fichas pequeñas (tarjetas que sustituyen a las listas) */
.fichas { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(var(--min, 230px), 1fr)); align-content: start; grid-auto-rows: max-content; }
.ficha-mini { position: relative; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--linea); border-radius: var(--r); min-width: 0; text-align: left; color: inherit; font: inherit; padding: 0;
  transition: border-color var(--rapido), box-shadow var(--rapido), transform var(--medio) var(--ease); }
button.ficha-mini, .ficha-mini.click { cursor: pointer; }
button.ficha-mini:hover, .ficha-mini.click:hover { border-color: var(--tinta); box-shadow: 0 2px 10px rgba(18,20,23,.08); }
.ficha-mini > .franja { display: flex; align-items: center; gap: 6px; padding: 2px 8px; min-height: 22px; background: var(--c, var(--tinta-3)); color: #fff; font-size: var(--t-xs); font-weight: 700; border-radius: var(--r) var(--r) 0 0; }
.ficha-mini > .franja .der { margin-left: auto; opacity: .92; }
.ficha-mini > .franja.clara { background: var(--hundido); color: var(--tinta-2); }
.ficha-mini > .cuerpo { padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ficha-mini .titulo { font-size: var(--t-l); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.ficha-mini .sub { font-size: var(--t-s); color: var(--tinta-2); }
.ficha-mini > .casillas { display: flex; border-top: 1px solid var(--linea-2); margin-top: auto; }
.ficha-mini > .casillas > div { flex: 1; min-width: 0; padding: 4px 8px; border-right: 1px solid var(--linea-2); font-weight: 700; font-size: var(--t-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ficha-mini > .casillas > div:last-child { border-right: 0; }
.ficha-mini > .casillas small { display: block; font-weight: 400; color: var(--tinta-3); font-size: 10.5px; }

/* Tira de fases (7 tramos) */
.tira-fases { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.tira-fases i { height: 4px; background: var(--linea-2); border-radius: 1px; }
.tira-fases i.h { background: var(--tinta-2); }
.tira-fases i.a { background: var(--c); }

/* ---------- piezas pequeñas ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border: 1px solid var(--linea); background: var(--panel); font-size: var(--t-s); border-radius: 11px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; margin: 1px 3px 1px 0; vertical-align: middle; }
.chip.click, .click { cursor: pointer; }
.chip.click:hover { border-color: var(--tinta); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip.ok, .chip.verde { background: var(--ok-suave); border-color: transparent; color: var(--ok); }
.chip.atencion, .chip.ambar { background: var(--atencion-suave); border-color: transparent; color: #8a5a10; }
.chip.error, .chip.rojo { background: var(--error-suave); border-color: transparent; color: var(--error); }
.chip.info, .chip.azul { background: var(--acento-suave); border-color: transparent; color: var(--acento); }
.insignia { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--acento); color: #fff; font: 700 10.5px/1 var(--letra); font-style: normal; }
.insignia.error { background: var(--error); }
.insignia.ok { background: var(--ok); }
.punto { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; vertical-align: 0; }
.fase { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 2px; background: var(--c); color: #fff; font-size: var(--t-xs); font-weight: 700; white-space: nowrap; }
.vacio { color: var(--tinta-3); font-size: var(--t-m); padding: 6px 0; }
.sub { color: var(--tinta-2); font-size: var(--t-s); }
.barra-h { height: 6px; background: var(--hundido); border-radius: 3px; overflow: hidden; position: relative; min-width: 40px; }
.barra-h > i { position: absolute; inset: 0 auto 0 0; background: var(--c, var(--ok)); border-radius: 3px; transition: width var(--medio) var(--ease); }
.barra-h.pasada > i { background: var(--error); }

/* Pestañas en línea (como en las webs japonesas: pestaña activa unida al contenido) */
.tabs, .pestanas { display: flex; gap: 2px; border-bottom: 2px solid var(--tinta); margin: 0 0 10px; overflow-x: auto; scrollbar-width: none; }
.tabs button, .pestanas .btn { height: 30px; border: 0; border-radius: var(--r) var(--r) 0 0; background: var(--hundido); color: var(--tinta-2); padding: 0 12px; font-weight: 500; font-size: var(--t-m); cursor: pointer; white-space: nowrap; box-shadow: none; transition: background var(--rapido), color var(--rapido); }
.tabs button:hover, .pestanas .btn:hover { background: var(--linea); }
.tabs button.activa, .pestanas .btn.activa { background: var(--tinta); color: #fff; }
.tabs button em { font-style: normal; background: var(--acento); color: #fff; border-radius: 8px; font-size: 10.5px; padding: 0 5px; margin-left: 4px; }

/* Tablas: solo para datos de verdad (cuentas, horas). Densas, con filete fino. */
table.tabla { width: 100%; border-collapse: collapse; font-size: var(--t-m); }
.tabla th { text-align: left; font-size: var(--t-xs); font-weight: 700; color: var(--tinta-3); padding: 6px 8px; border-bottom: 1px solid var(--tinta); white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.tabla td { padding: 6px 8px; border-bottom: 1px solid var(--linea-2); vertical-align: middle; }
.tabla tr.click:hover td { background: var(--panel-2); }
.tabla td.num { text-align: right; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* ---------- avisos flotantes y diálogos ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--tinta); color: #fff; border-radius: var(--r-l); box-shadow: var(--sombra-flota); padding: 10px 12px 10px 14px; display: flex; gap: 12px; align-items: center; font-size: var(--t-m); font-weight: 500; animation: toast-entra var(--medio) var(--ease) both; }
.toast.error { background: var(--error); }
.toast button { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: var(--r); font-weight: 700; height: 26px; padding: 0 10px; cursor: pointer; }
.toast button:hover { background: rgba(255,255,255,.24); }
@keyframes toast-entra { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog { padding: 0; max-width: min(520px, calc(100vw - 24px)); width: 100%; border: 1px solid var(--linea); border-radius: var(--r-l); background: var(--panel); color: var(--tinta); box-shadow: var(--sombra-flota); }
dialog[open] { animation: dialogo-entra var(--medio) var(--ease) both; }
dialog > * { margin-left: 18px; margin-right: 18px; }
dialog > :first-child { margin-top: 16px; }
dialog > :last-child { margin-bottom: 16px; }
dialog::backdrop { background: rgba(18, 20, 23, .38); animation: velo-entra var(--medio) both; }
dialog h2 { font-size: var(--t-xl); margin-bottom: 10px; }
@keyframes dialogo-entra { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes velo-entra { from { opacity: 0; } }
.dialogo-pie { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }

/* Entradas suaves */
.entra { animation: entra var(--medio) var(--ease) both; animation-delay: calc(min(var(--i, 0), 16) * 16ms); }
@keyframes entra { from { opacity: 0; transform: translateY(5px); } }
.esqueleto { background: linear-gradient(90deg, var(--hundido) 25%, var(--linea-2) 50%, var(--hundido) 75%); background-size: 200% 100%; animation: brillo 1.2s infinite linear; border-radius: var(--r); }
@keyframes brillo { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

/* ---------- Versión de móvil, común a todas las páginas (21/11/2026) ----------
   La clase «es-movil» en <html> la pone iconos.js cuando la página se abre en un teléfono (Android o iPhone,
   cualquier navegador, de pie o tumbado). */
html.es-movil { -webkit-tap-highlight-color: transparent; }
html.es-movil body { overscroll-behavior-y: none; }
/* 16 px en los campos: con menos, el iPhone hace zoom al tocarlos y descuadra la página. */
html.es-movil input:not([type=checkbox]):not([type=radio]):not([type=color]), html.es-movil select, html.es-movil textarea { font-size: 16px; }
html.es-movil input[type=checkbox], html.es-movil input[type=radio] { width: 20px; height: 20px; }
html.es-movil .btn { min-height: 38px; height: auto; }
html.es-movil .btn.mini { min-height: 32px; }
html.es-movil .campos { grid-template-columns: minmax(0, 1fr); }
html.es-movil .campo { min-width: 0; }
html.es-movil .campo > input:not([type=checkbox]):not([type=radio]), html.es-movil .campo > select, html.es-movil .campo > textarea, html.es-movil select { max-width: 100%; }
html.es-movil .campo > input:not([type=checkbox]):not([type=radio]), html.es-movil .campo > select, html.es-movil .campo > textarea { width: 100%; }
/* Botones con textos largos (nombres de archivo): parten la línea en vez de salirse. */
html.es-movil .btn { max-width: 100%; white-space: normal; line-height: 1.2; padding-top: 4px; padding-bottom: 4px; text-align: left; }
html.es-movil .mosaico > * { grid-column: 1 / -1 !important; }
/* Las tablas anchas se deslizan de lado dentro de su caja, sin mover la página. */
html.es-movil table.tabla { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
html.es-movil dialog { max-width: calc(100vw - 16px); max-height: calc(100dvh - 32px); overflow-y: auto; }
html.es-movil dialog > * { margin-left: 14px; margin-right: 14px; }
html.es-movil #toasts { left: 50%; width: calc(100% - 24px); bottom: calc(16px + env(safe-area-inset-bottom)); }
html.es-movil .toast { width: 100%; }
html.es-movil .buscador kbd { display: none; }
html.es-movil img, html.es-movil video { max-width: 100%; }
html.es-movil .pestanas { overflow-x: auto; scrollbar-width: none; } html.es-movil .pestanas .btn { white-space: nowrap; flex: none; }
