@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #012d5f;
  --brand-ink: #001a38;
  --brand-2: #a5cafd;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --brand-line: color-mix(in srgb, var(--brand) 28%, white);
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e5e9f0;
  --line-2: #d6dce5;
  --amber: #b45309; --amber-bg: #fef3c7;
  --blue: #1d4ed8; --blue-bg: #dbeafe;
  --green: #047857; --green-bg: #d1fae5;
  --red: #b91c1c; --red-bg: #fee2e2;
  --gray: #475569; --gray-bg: #e2e8f0;
  --r: 14px; --r-sm: 10px;
  --sh-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 1px rgba(15, 23, 42, .03);
  --sh-2: 0 8px 24px -12px rgba(15, 23, 42, .18), 0 2px 6px -2px rgba(15, 23, 42, .06);
  --sh-3: 0 30px 70px -25px rgba(15, 23, 42, .35);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.edc-pow { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: inherit; white-space: nowrap; }
.edc-pow img { width: 20px; height: 20px; border-radius: 6px; background: #fff; padding: 2px; object-fit: contain; flex: none; }
.edc-foot { text-align: center; font-size: 11.5px; color: var(--muted); padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: .15s ease; box-shadow: var(--sh-1); text-decoration: none; }
.btn:hover { border-color: #b9c3d0; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(15, 23, 42, .05); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.icon { width: 38px; padding: 0; }
.btn.block { width: 100%; }

/* ---------- formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.field .req { color: var(--red); margin-left: 2px; }
.inp, select.inp, textarea.inp { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.inp { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.inp:disabled, .inp[readonly] { background: var(--surface-2); color: var(--ink-2); }
.inp.flash { animation: flash 1.4s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px rgba(59, 130, 246, .45); border-color: #3b82f6; } 100% { box-shadow: none; } }
.hint { font-size: 12px; color: var(--muted); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid .w2 { grid-column: span 2; } .grid .w3 { grid-column: 1 / -1; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr 1fr; } .grid .w2, .grid .w3 { grid-column: 1 / -1; } }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.chk { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; cursor: pointer; user-select: none; transition: .12s; font-size: 13px; line-height: 1.3; min-height: 44px; }
.chk:hover { border-color: #b9c3d0; }
.chk input { appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 1.6px solid #9aa5b4; flex: none; display: grid; place-items: center; margin: 0; transition: .12s; background: #fff; }
.chk input:checked { background: var(--brand); border-color: var(--brand); }
.chk input:checked::after { content: ''; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.chk:has(input:checked) { border-color: var(--brand-line); background: var(--brand-soft); font-weight: 600; }
.chk:has(input:disabled) { cursor: default; }
.cgroups { display: grid; gap: 8px; }
.devs { display: grid; gap: 8px; }
.dev-cap { margin-left: auto; margin-right: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--amber-bg, #fff4dc); color: var(--amber, #a15c00); }
.dev-cap.ok { background: var(--green-bg); color: var(--green); }
.dev-cap.muted { background: var(--bg); color: var(--muted); font-weight: 600; }
.cgroup.dev > summary::after { margin-left: 0; }
.dev-b { padding: 12px; display: grid; gap: 12px; }
.dev-total { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dev-total label { flex: 1 1 100%; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.dev-total input { width: 120px; }
.dev-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dev-bulk select { width: auto; min-width: 200px; }
.dev-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.dev-st { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; }
.dev-st.on { border-color: var(--brand-line); background: var(--brand-soft); }
.dev-st span { font-weight: 700; font-size: 13px; min-width: 44px; }
.dev-st select { height: 36px; font-size: 13px; }
.dev-sum { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 12px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--line-2); }
.dev-sum .group-title { flex: 1 1 100%; }
.dev-n { padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.dev-n b { color: var(--ink); margin-right: 3px; }
.dev-n.on { border-color: var(--brand-line); color: var(--brand); }
.dev-n.repo { border-style: dashed; }
.dev-n.repo.on { border-style: solid; border-color: #e7a9a9; color: #9b1c1c; background: #fff5f5; }
.dev-n.pend { border-color: #f0c36d; color: #8a5a00; }
.dev-n.tot { background: var(--brand); border-color: var(--brand); color: #fff; }
.dev-n.tot b { color: #fff; }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--brand-soft); border: 1px solid var(--brand-line); color: var(--brand); font-size: 13px; font-weight: 600; }
.pchip button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--brand); font-size: 16px; line-height: 1; cursor: pointer; }
.pchip button:hover { background: #fff; }
.potro { display: flex; gap: 8px; margin-top: 8px; }
.potro input { flex: 1; min-width: 0; }
.qty { display: flex; gap: 8px; }
.qty input { flex: 1 1 40%; min-width: 0; }
.qty select { flex: 1 1 60%; min-width: 0; }
.dosis-f { display: grid; gap: 8px; }
.dosis-n { display: flex; flex-wrap: wrap; gap: 8px; }
.dosis-n label { display: flex; align-items: center; gap: 8px; flex: 1 1 160px; font-size: 13px; color: var(--muted); }
.dosis-n input { width: 110px; flex: none; color: var(--ink); font-weight: 600; }
.add-pick { height: 50px; font-weight: 600; color: var(--brand); border-style: dashed; border-color: var(--brand-line); background-color: var(--brand-soft); cursor: pointer; }
.cgroup-ev { margin: 0 12px 12px; padding: 4px 12px 12px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--line-2); }
.cgroup-ev .group-title { margin-top: 8px; }
.chk-niv { display: grid; gap: 6px; padding: 6px; border: 1px solid var(--brand-line); border-radius: 12px; background: var(--brand-soft); }
.chk-niv .chk { border-color: transparent; background: transparent; padding: 4px 6px; min-height: 36px; }
.chk-niv select.inp { height: 38px; font-size: 13px; background-color: #fff; }
.cgroup { border: 1px solid var(--line-2); border-radius: 12px; background: #fff; }
.cgroup > summary { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 700; color: var(--ink); user-select: none; }
.cgroup > summary::-webkit-details-marker { display: none; }
.cgroup > summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.cgroup[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.cgroup[open] > summary { border-bottom: 1px solid var(--line); }
.cgroup-n { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px; display: grid; place-items: center; }
.cgroup-n[hidden] { display: none; }
.cgroup > .checks { padding: 12px; }
.group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 10px 0 6px; grid-column: 1 / -1; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: 12px; background: var(--surface-2); }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 99px; background: #cbd5e1; position: relative; flex: none; transition: .2s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 19px; }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.amber { color: var(--amber); background: var(--amber-bg); }
.chip.blue { color: var(--blue); background: var(--blue-bg); }
.chip.green { color: var(--green); background: var(--green-bg); }
.chip.gray { color: var(--gray); background: var(--gray-bg); }
.chip.red { color: var(--red); background: var(--red-bg); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: #eef2f6; color: var(--ink-2); font-size: 11.5px; font-weight: 600; margin: 1px 3px 1px 0; }
.folio { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-weight: 700; letter-spacing: .02em; }

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-b { padding: 20px; }

/* ---------- celular: modales desde abajo, toasts a lo ancho ---------- */
@media (max-width: 640px) {
  .modal-bg { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheet .28s cubic-bezier(.2,.9,.3,1); }
  .modal-h { padding: 18px 18px 0; } .modal-b { padding: 14px 18px; } .modal-f { padding: 12px 18px 16px; }
  .modal-f .btn { flex: 1; }
  #toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 9999; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--sh-3); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: tin .25s ease; line-height: 1.4; }
.toast.ok { background: #064e3b; } .toast.err { background: #7f1d1d; } .toast.info { background: #1e3a8a; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 900; background: rgba(15, 23, 42, .5); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; animation: fin .2s ease; }
@keyframes fin { from { opacity: 0; } }
.modal { background: #fff; border-radius: 18px; box-shadow: var(--sh-3); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: min .25s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { width: min(860px, 100%); }
@keyframes min { from { transform: translateY(16px) scale(.98); opacity: 0; } }
.modal-h { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-h h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-h p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-b { padding: 18px 24px; overflow: auto; }
.modal-f { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); }

/* ---------- firma ---------- */
.sigpad { position: relative; border: 1.5px dashed var(--line-2); border-radius: 12px; background: repeating-linear-gradient(0deg, transparent, transparent 34px, #f1f5f9 34px, #f1f5f9 35px), #fff; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: 180px; cursor: crosshair; }
.sigpad .base { position: absolute; left: 24px; right: 24px; bottom: 36px; border-bottom: 1.5px solid #cbd5e1; pointer-events: none; }
.sigpad .x { position: absolute; left: 14px; bottom: 40px; color: #94a3b8; font-weight: 700; pointer-events: none; }
.sigpad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; font-size: 13px; pointer-events: none; }
.sigpad .clear { position: absolute; top: 8px; right: 8px; }
.sig-img { max-width: 100%; max-height: 110px; display: block; margin: 0 auto; }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--brand); border: 2px solid #fff; flex: none; }
.avatars { display: flex; } .avatars .avatar + .avatar { margin-left: -8px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg.i { width: 40px; height: 40px; stroke-width: 1.3; color: #94a3b8; margin-bottom: 8px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: #cbd5e1; border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
.err-list { margin: 0; padding: 12px 14px 12px 32px; background: var(--red-bg); color: #7f1d1d; border-radius: 10px; font-size: 13px; line-height: 1.6; }

/* ---------- selector segmentado (compartido) ---------- */
.seg { display: inline-flex; background: #e7ebf1; padding: 4px; border-radius: 12px; gap: 4px; }
.seg button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--sh-1); }
.seg button svg.i { width: 16px; height: 16px; }
