:root {
  --bg: #f4f6fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand-1: #6366f1;
  --brand-2: #0ea5e9;
  --brand-3: #14b8a6;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --chip: #eef2ff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 20px;
  --grad: linear-gradient(135deg, var(--brand-1), var(--brand-2) 55%, var(--brand-3));
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --bg-2: #0f172a;
    --card: #131c31;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --chip: #1e2742;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand-2); text-decoration: none; }

/* ---------- splash / entrada ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: #0f172a; }
.splash-logo { width: 84px; height: 84px; border-radius: 26px; background: var(--grad); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .75; } }
.entrada { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px calc(32px + var(--safe-b));
  background: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.55), transparent 60%),
              radial-gradient(900px 500px at 110% 10%, rgba(20,184,166,.45), transparent 60%), #0b1120; color: #fff; }
.entrada .logo { width: 72px; height: 72px; border-radius: 22px; background: url(/arqa_equipo/static/app/icon-192.png) center/cover; box-shadow: 0 16px 40px rgba(14,165,233,.4); }
.entrada h1 { font-size: 30px; letter-spacing: -.02em; margin: 22px 0 6px; }
.entrada p { color: #cbd5e1; margin: 0 0 26px; }
.entrada .campo { display: flex; gap: 10px; }
.entrada input { flex: 1; min-width: 0; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 16px;
  padding: 15px 16px; font-size: 22px; letter-spacing: .22em; text-align: center; color: #fff; outline: none; }
.entrada input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(14,165,233,.25); }
.entrada small { display: block; margin-top: 18px; color: #94a3b8; }

/* ---------- estructura ---------- */
.top { position: sticky; top: 0; z-index: 5; padding: calc(14px + var(--safe-t)) 18px 12px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); display: flex; align-items: center; gap: 12px; }
.top h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; flex: 1; }
.top .sub { color: var(--muted); font-size: 13px; font-weight: 500; }
.avatar { width: 40px; height: 40px; border-radius: 14px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; border: 0; cursor: pointer; flex: none; }
main { padding: 4px 16px calc(96px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + var(--safe-b)); background: color-mix(in srgb, var(--bg-2) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
  color: var(--muted); font-size: 11px; font-weight: 600; position: relative; cursor: pointer; }
.tab svg { width: 24px; height: 24px; transition: transform .2s; }
.tab.on { color: var(--brand-1); }
.tab.on svg { transform: translateY(-1px) scale(1.06); }
.tab .dot { position: absolute; top: 2px; left: 54%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; display: grid; place-items: center; }

/* ---------- tarjetas ---------- */
.sec { margin: 22px 4px 10px; display: flex; align-items: baseline; justify-content: space-between; }
.sec h2 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.sec span { color: var(--muted); font-size: 13px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; animation: up .35s ease both; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }
.list .item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:last-child { border-bottom: 0; }
.item .ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--chip); color: var(--brand-1); font-weight: 700; font-size: 13px; text-align: center; line-height: 1.05; }
.item .ico.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.item .ico.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.item .ico.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: #b45309; }
.item .txt { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { color: var(--muted); font-size: 12px; text-align: right; flex: none; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* ---------- fichaje ---------- */
.fichaje { position: relative; overflow: hidden; color: #fff; background: var(--grad); padding: 18px; }
.fichaje::after { content: ""; position: absolute; width: 260px; height: 260px; right: -90px; top: -110px; border-radius: 50%; background: rgba(255,255,255,.12); }
.fichaje .row { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.ring { width: 92px; height: 92px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.fichaje .estado { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.fichaje .donde { font-size: 16px; font-weight: 600; margin: 2px 0 10px; }
.fichaje .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; }
.btn.blanco { background: #fff; color: #0f172a; }
.btn.vidrio { background: rgba(255,255,255,.2); color: #fff; }
.btn.prim { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(99,102,241,.3); }
.btn.sec2 { background: var(--chip); color: var(--brand-1); }
.btn.peligro { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.btn.full { width: 100%; padding: 14px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--card); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 24px; letter-spacing: -.02em; }
.kpi span { color: var(--muted); font-size: 12px; line-height: 1.2; display: block; }
.kpi.bad b { color: var(--bad); }
.kpi.ok b { color: var(--ok); }

/* ---------- chips / segment ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 13px; cursor: pointer; color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); }
.seg { display: flex; background: var(--chip); border-radius: 14px; padding: 4px; margin: 6px 0 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.day { border: 0; background: var(--card); border-radius: 16px; padding: 8px 0; text-align: center; box-shadow: var(--shadow); cursor: pointer; color: var(--text); }
.day small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 700; }
.day b { font-size: 18px; }
.day.on { background: var(--grad); color: #fff; }
.day.on small { color: rgba(255,255,255,.8); }
.day i { display: block; width: 5px; height: 5px; border-radius: 3px; background: var(--brand-2); margin: 3px auto 0; }
.day.on i { background: #fff; }

.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--chip); color: var(--brand-1); margin-right: 4px; }
.tag.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: #b45309; }
.stars { color: #f59e0b; letter-spacing: -1px; }

/* ---------- hoja inferior ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 20; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow-y: auto; background: var(--bg-2);
  border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); animation: slide .28s cubic-bezier(.2,.9,.3,1) both; max-width: 760px; margin: 0 auto; }
@keyframes slide { from { transform: translateY(100%); } }
.sheet .grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 21px; margin: 4px 0 4px; letter-spacing: -.01em; }
.sheet .meta { color: var(--muted); margin-bottom: 14px; }
.acciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 12px 0; }
.accion { border: 0; background: var(--chip); border-radius: 16px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 12px; color: var(--brand-1); cursor: pointer; }
.accion svg { width: 22px; height: 22px; }
label.f { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 6px; }
.in { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; outline: none; }
.in:focus { border-color: var(--brand-1); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 18%, transparent); }
textarea.in { min-height: 90px; resize: vertical; }
.firma { width: 100%; height: 180px; border: 2px dashed var(--line); border-radius: 16px; background: #fff; touch-action: none; display: block; }
.fotos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.fotos img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }
.msg { padding: 10px 0; border-bottom: 1px solid var(--line); }
.msg b { font-size: 13px; }
.msg .w { color: var(--muted); font-size: 12px; margin-left: 6px; }
.msg p { margin: 4px 0 0; white-space: pre-wrap; }
.msg .adj { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.msg .adj img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 6px; padding-bottom: 80px; }
.bub { max-width: 82%; padding: 9px 13px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; }
.bub small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.bub.yo { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.bub.yo small { color: rgba(255,255,255,.8); }
.bub:not(.yo) { border-bottom-left-radius: 6px; }
.bub img { max-width: 220px; border-radius: 12px; display: block; margin-top: 4px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(64px + var(--safe-b)); display: flex; gap: 8px; padding: 10px 14px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); max-width: 760px; margin: 0 auto; }
.composer .in { border-radius: 22px; }
.composer .btn { border-radius: 22px; }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 600; opacity: 0; transition: all .25s; z-index: 40; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }
.skeleton { height: 64px; border-radius: 16px; background: linear-gradient(90deg, var(--card), var(--chip), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 10px; }
@keyframes sk { to { background-position: -200% 0; } }
.offline { background: var(--warn); color: #111; text-align: center; font-size: 12px; font-weight: 700; padding: 4px; }
.codigo-grande { font-size: 40px; letter-spacing: .18em; text-align: center; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 10px 0; font-variant-numeric: tabular-nums; }
.perfil-cab { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.perfil-cab .avatar { width: 56px; height: 56px; border-radius: 18px; font-size: 20px; }

/* ---------- cola sin conexión ---------- */
.cola { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 999px; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--warn) 18%, var(--card)); color: #92400e; font-size: 12px; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap; }
.cola[hidden] { display: none; }
.cola i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 0 rgba(245,158,11,.6); animation: latido 2s infinite; }
.cola.env i { background: var(--brand-2); animation: latido .9s infinite; }
.cola.mal { background: color-mix(in srgb, var(--bad) 16%, var(--card)); color: var(--bad); }
.cola.mal i { background: var(--bad); animation: none; }
@media (prefers-color-scheme: dark) { .cola { color: #fbbf24; } }
@keyframes latido { 0% { box-shadow: 0 0 0 0 rgba(245,158,11,.55); } 70% { box-shadow: 0 0 0 8px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
.tag.pend { background: rgba(255,255,255,.22); color: #fff; vertical-align: middle; }
@media (prefers-reduced-motion: reduce) { .cola i { animation: none; } }

/* ---------- presupuesto rápido ---------- */
.card.presu { padding: 16px; margin: 6px 0 14px; border: 1px solid color-mix(in srgb, var(--brand-1) 18%, var(--line)); }
.presu-cab { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.presu-cab svg { width: 40px; height: 40px; padding: 9px; border-radius: 14px; background: var(--grad); color: #fff; flex: none; }
.presu-cab b { display: block; font-size: 16px; }
.presu-cab small { color: var(--muted); font-size: 12px; }
.veredicto { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 16px; background: var(--chip); }
.veredicto b { font-size: 17px; letter-spacing: -.01em; }
.veredicto p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.v-ico { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none; background: var(--card); color: var(--muted); }
.veredicto.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); }
.veredicto.ok .v-ico { background: var(--ok); color: #fff; }
.veredicto.ok b { color: var(--ok); }
.veredicto.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.veredicto.warn .v-ico { background: var(--warn); color: #fff; }
.veredicto.warn b { color: #b45309; }
.veredicto.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.veredicto.bad .v-ico { background: var(--bad); color: #fff; }
.veredicto.bad b { color: var(--bad); }
@media (prefers-color-scheme: dark) { .veredicto.warn b { color: #fbbf24; } }
.horq { position: relative; height: 12px; border-radius: 6px; background: var(--line); margin: 30px 4px 8px; }
.horq-banda { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: var(--grad); }
.horq-medio { position: absolute; top: -4px; width: 3px; height: 20px; margin-left: -1.5px; border-radius: 2px; background: var(--text); }
.horq-cli { position: absolute; top: -7px; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%; border: 3px solid var(--card); background: var(--brand-1); box-shadow: var(--shadow); }
.horq-cli.ok { background: var(--ok); } .horq-cli.warn { background: var(--warn); } .horq-cli.bad { background: var(--bad); }
.horq-cli span { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.horq-cifras { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.horq-cifras small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.horq-cifras .c { text-align: center; } .horq-cifras .d { text-align: right; }
.presu-sug { margin-top: 12px; font-size: 14px; }
.presu-nota { color: var(--muted); font-size: 11px; margin: 10px 0 0; text-align: center; }
.presu-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.in.grande { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
