@font-face { font-family: Barlow; font-weight: 400; font-display: swap; src: url(fonts/barlow-400.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(fonts/barlow-500.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(fonts/barlow-600.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 700; font-display: swap; src: url(fonts/barlow-700.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700.woff2) format('woff2'); }

/* Paleta Voracys (identidad de las apps de obra) */
:root {
  --bg: #F4F8FD; --surface: #FFFFFF; --ink: #16324F; --muted: #52627A; --faint: #7A8AA0;
  --line: #D6E2F0; --line-strong: #9FB6D1; --tint: #EAF3FE;
  --brand: #60A4F4; --primary: #1F5FAE; --on-primary: #FFFFFF;
  --orange: #FF7B0F; --orange-halo: #FFE7D4; --warn-ink: #8A3D00; --warn-tint: #FFF1E4;
  --red: #C62828; --red-tint: #FDECEC; --ok-ink: #1E6B43; --ok-tint: #DDF1E5;
  --shadow: 0 10px 30px rgba(22, 50, 79, .18);
  --cond: 'Barlow Condensed', 'Arial Narrow', Barlow, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101820; --surface: #1B2430; --ink: #E8F0FA; --muted: #A3B3C8; --faint: #7A8AA0;
    --line: #2D3E52; --line-strong: #46617F; --tint: #22344A;
    --primary: #60A4F4; --on-primary: #0F2238; --orange-halo: #3D2A18;
    --warn-ink: #FFB06B; --warn-tint: #3D2A18; --red: #FF9A93; --red-tint: #4A2523; --ok-ink: #6FD09A; --ok-tint: #1D3A2B;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101820; --surface: #1B2430; --ink: #E8F0FA; --muted: #A3B3C8; --faint: #7A8AA0;
  --line: #2D3E52; --line-strong: #46617F; --tint: #22344A;
  --primary: #60A4F4; --on-primary: #0F2238; --orange-halo: #3D2A18;
  --warn-ink: #FFB06B; --warn-tint: #3D2A18; --red: #FF9A93; --red-tint: #4A2523; --ok-ink: #6FD09A; --ok-tint: #1D3A2B;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 15px/1.4 Barlow, system-ui, sans-serif; color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; margin: 0; line-height: 1.1; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.upper { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Estructura */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 3px solid var(--brand);
  padding: max(8px, env(safe-area-inset-top)) 8px 8px 16px; display: flex; align-items: center; gap: 4px; }
.topbar .t { flex: 1; min-width: 0; }
.topbar h1 { font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }

/* Botones */
.btn { min-height: 48px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--primary);
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-family: var(--cond); font-size: 21px; font-weight: 700; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; border-radius: 10px; color: var(--ink); flex: none; }
.icon-btn:hover { background: var(--tint); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }

/* Tarjetas y listas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card h2 { font-size: 20px; margin-bottom: 8px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 12px 10px 16px; border: 0; border-top: 1px solid var(--line);
  background: none; text-align: left; color: var(--ink); }
.item:first-child { border-top: 0; }
button.item:hover { background: var(--tint); }
.item .nombre { font-weight: 600; font-size: 17px; }
.item .meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.item .chev { color: var(--line-strong); }
.item.grande .nombre { font-size: 19px; }
.vacio { padding: 24px 16px; text-align: center; color: var(--muted); }
.vacio svg.i { width: 32px; height: 32px; color: var(--line-strong); display: block; margin: 0 auto 8px; }

/* Etiquetas de estado: fondo claro + texto oscuro, siempre con texto */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; border-radius: 4px; padding: 2px 8px; color: var(--primary); background: var(--tint); white-space: nowrap; }
.tag.aviso { color: var(--warn-ink); background: var(--warn-tint); }
.tag.critico { color: var(--red); background: var(--red-tint); }
.tag.ok { color: var(--ok-ink); background: var(--ok-tint); }
.tag.gris { color: var(--muted); background: var(--bg); border: 1px solid var(--line); }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Segmentos */
.seg { display: flex; gap: 6px; overflow-x: auto; }
.seg button { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label { font-size: 14px; font-weight: 600; color: var(--muted); }
.campo .ayuda { font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=url], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
textarea { min-height: 90px; resize: vertical; }
.form { display: flex; flex-direction: column; gap: 14px; }
.error { color: var(--red); background: var(--red-tint); border-radius: 8px; padding: 10px 12px; font-weight: 500; }
.aviso { color: var(--warn-ink); background: var(--warn-tint); border-radius: 8px; padding: 10px 12px; }
.token { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: var(--tint); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
details summary { cursor: pointer; color: var(--primary); font-weight: 600; min-height: 32px; }

/* Pantalla de entrada */
.entrar { max-width: 420px; width: 100%; margin: 0 auto; padding: 48px 16px; display: flex; flex-direction: column; gap: 20px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca img { width: 56px; height: 56px; border-radius: 14px; }
.marca h1 { font-size: 30px; }

/* Hoy */
.hoy-fecha { font-family: var(--cond); font-weight: 700; font-size: 22px; }
.acciones { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.accion { min-height: 84px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 600; }
.accion.grabar { background: var(--orange); border-color: var(--orange); color: #16324F; box-shadow: 0 0 0 5px var(--orange-halo); }
.accion svg.i { width: 26px; height: 26px; }
.accion:disabled { opacity: .55; cursor: default; }

/* Ventana modal */
.modal-fondo { position: fixed; inset: 0; z-index: 30; background: rgba(16, 24, 32, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.modal h2 { font-size: 24px; margin-bottom: 14px; }
@media (min-width: 600px) { .modal-fondo { align-items: center; } .modal { border-radius: 16px; } }

/* Avisos breves */
.toasts { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; font-weight: 500; box-shadow: var(--shadow); max-width: 480px; }
.toast.err { background: var(--red-tint); color: var(--red); border: 1px solid var(--red); }
