/* Panel Diforza — estilos. Colores y tipografías de la marca (sitio: tokens.css). */
:root {
  --navy: #003568; --navy-950: #011c37; --navy-50: #eef3f8;
  --orange: #ff7e34; --orange-700: #c2561a; --orange-50: #fff4ec;
  --ink: #0f2236; --text: #23384d; --muted: #5c6873; --line: #d7e0e8; --line-soft: #e6eaee; --bg: #f2f4f6; --card: #fff;
  --ok: #25a55f; --ok-bg: #e7f6ee; --warn: #b7791f; --warn-bg: #fdf3e1; --bad: #c62828; --bad-bg: #fdecec; --info-bg: #e8f0fb;
  --r: 10px; --sh: 0 1px 2px rgb(0 20 42 / 6%), 0 4px 16px rgb(0 20 42 / 6%);
  --font: "Montserrat", Arial, sans-serif; --display: "Poppins", "Montserrat", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.hidden { display: none !important; }

/* ---------- barra superior ---------- */
.top { position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 15%); }
.top__in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 56px; }
.top__logo img { height: 26px; display: block; }
.top__tag { font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase; opacity: .75; border-left: 1px solid rgb(255 255 255 / 30%); padding-left: 12px; }
.nav { display: flex; gap: 4px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.nav a { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; opacity: .85; white-space: nowrap; }
.nav a:hover { background: rgb(255 255 255 / 10%); opacity: 1; }
.nav a.on { background: rgb(255 255 255 / 16%); opacity: 1; }
.top__user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.top__user a { color: #fff; opacity: .85; text-decoration: none; }
.top__user .role { font-size: 11px; background: var(--orange); color: var(--navy-950); padding: 2px 8px; border-radius: 99px; font-weight: 700; }
@media (max-width: 760px) {
  .top__in { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .top__tag { display: none; }
  .nav { order: 3; width: 100%; margin: 0; }
  .top__user .uname { display: none; }
}

/* ---------- estructura ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 120px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head p { margin: 4px 0 0; }
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--r); box-shadow: var(--sh); padding: 18px; margin-bottom: 16px; }
.card > h2 { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card > h2 .n { width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; display: inline-grid; place-items: center; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .wrap { padding: 14px 12px 140px; } }

/* ---------- formularios ---------- */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); position: relative; }
.in, select.in, textarea.in { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 14px; font-weight: 500; }
.in:focus { outline: 2px solid rgb(0 53 104 / 25%); border-color: var(--navy); }
textarea.in { min-height: 72px; resize: vertical; }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--navy); font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn.pri { background: var(--orange-700); border-color: var(--orange-700); color: #fff; }
.btn.pri:hover { background: #a9480f; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--muted); font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.err { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.note { background: var(--info-bg); color: var(--navy); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.note.warn { background: var(--warn-bg); color: #7a4f0b; }

/* ---------- login / instalación ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-950) 100%); }
.auth__box { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
.auth__box img { height: 34px; margin-bottom: 18px; }
.auth__box h1 { margin-bottom: 6px; }
.auth__box form { display: grid; gap: 12px; margin-top: 18px; }

/* ---------- listas ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .in { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 200px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 56px; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--navy-50); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 600; color: var(--navy); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.b-borrador { background: #eef1f4; color: #4a5a6a; } .b-enviada { background: var(--info-bg); color: var(--navy); }
.b-ganada { background: var(--ok-bg); color: #187a43; } .b-perdida { background: var(--bad-bg); color: var(--bad); }
.b-vencida { background: var(--warn-bg); color: #7a4f0b; } .b-anulada, .b-reemplazada { background: #f2f2f2; color: #888; }
.thumb { width: 44px; height: 55px; object-fit: contain; background: #fff; border: 1px solid var(--line-soft); border-radius: 6px; display: block; }
.thumb.ph { display: grid; place-items: center; color: var(--muted); font-size: 10px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
@media (max-width: 760px) {
  table.t.resp thead { display: none; }
  table.t.resp tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
  table.t.resp td { border: 0; padding: 0; }
  table.t.resp td[data-h]::before { content: attr(data-h) ": "; color: var(--muted); font-size: 11px; }
  table.t.resp td.hide-m { display: none; }
}

/* ---------- editor de cotización ---------- */
.ac { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--sh); margin-top: 4px; max-height: 260px; overflow: auto; }
.ac button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; font-size: 13px; }
.ac button:hover { background: var(--navy-50); }
.items { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 56px 1fr 120px 90px 120px 84px 120px 30px; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: #fff; }
.item.titulo { grid-template-columns: 1fr 30px; background: var(--navy-50); }
.item .nm { font-weight: 700; color: var(--ink); font-size: 13px; }
.item .sub { font-size: 11.5px; color: var(--muted); }
.item .lbl { display: none; font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.item .sum { text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.item .ref { font-size: 11px; color: var(--muted); text-align: right; }
.item .ref.dn { color: var(--orange-700); font-weight: 600; }
.items-head { display: grid; grid-template-columns: 56px 1fr 120px 90px 120px 84px 120px 30px; gap: 10px; padding: 0 10px; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.item-menu { display: flex; flex-direction: column; }
@media (max-width: 900px) {
  .items-head { display: none; }
  .item { grid-template-columns: 56px 1fr 1fr; grid-template-areas: "f n n" "t t t" "c p d" "s s x"; }
  .item > :nth-child(1) { grid-area: f; } .item > :nth-child(2) { grid-area: n; } .item > :nth-child(3) { grid-area: t; }
  .item > :nth-child(4) { grid-area: c; } .item > :nth-child(5) { grid-area: p; } .item > :nth-child(6) { grid-area: d; }
  .item > :nth-child(7) { grid-area: s; } .item > :nth-child(8) { grid-area: x; justify-self: end; }
  .item .lbl { display: block; }
  .item-menu { flex-direction: row; }
}
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.totals { margin-left: auto; max-width: 420px; display: grid; gap: 6px; font-variant-numeric: tabular-nums; }
.totals .row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.totals .row.big { font: 800 20px var(--display); color: var(--navy); border-top: 2px solid var(--navy); padding-top: 8px; margin-top: 4px; }
.totals .ars { font-size: 12px; color: var(--muted); text-align: right; }
.cond-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--line-soft); }
.cond-row:last-child { border: 0; }
.cond-row .tp { font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--muted); padding-top: 9px; }
@media (max-width: 760px) { .cond-row { grid-template-columns: 1fr; } .cond-row .tp { padding: 0; } }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 20 42 / 8%); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.actionbar__in { max-width: 1240px; margin: 0 auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actionbar .tot { font: 800 18px var(--display); color: var(--navy); margin-right: auto; }
.actionbar .tot small { display: block; font: 600 11px var(--font); color: var(--muted); }
.timeline { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }

/* ---------- selector de productos (modal) ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgb(1 28 55 / 55%); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; }
.modal__box { background: #fff; border-radius: 14px; width: 100%; max-width: 980px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 80px rgb(0 0 0 / 35%); }
.modal__box.sm { max-width: 520px; }
.modal__head { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); display: grid; gap: 10px; }
.modal__head .row1 { display: flex; align-items: center; gap: 10px; }
.modal__body { overflow: auto; padding: 12px 16px; flex: 1; }
.modal__foot { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgb(0 0 0 / 15%); }
.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pcard { border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: 64px 1fr; gap: 10px; cursor: pointer; background: #fff; text-align: left; }
.pcard:hover, .pcard.sel { border-color: var(--navy); box-shadow: 0 0 0 2px rgb(0 53 104 / 12%); }
.pcard img, .pcard .ph { width: 64px; height: 80px; object-fit: contain; border-radius: 6px; background: #fafbfc; }
.pcard .nm { font-weight: 700; font-size: 12.5px; color: var(--ink); line-height: 1.3; }
.pcard .mk { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pcard .pr { font-weight: 700; color: var(--navy); margin-top: 4px; font-size: 13px; }
.pcard .vars { grid-column: 1 / -1; display: grid; gap: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.subtabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--navy-950); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }

/* ---------- precios ---------- */
.price-in { width: 110px; }
.switch { position: relative; width: 38px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c9d4df; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ================= PDF / vista de impresión ================= */
.pdf-tools { position: sticky; top: 0; z-index: 10; background: var(--navy-950); color: #fff; padding: 10px 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pdf-tools .sp { flex: 1; }
.pdf-tools .btn { border-color: rgb(255 255 255 / 25%); background: transparent; color: #fff; }
.pdf-tools .btn.pri { background: var(--orange-700); border-color: var(--orange-700); }
.pdf-bg { background: #525659; padding: 24px 12px 60px; min-height: 100vh; }
.sheet { width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: #1d2b3a; padding: 14mm 14mm 12mm; box-shadow: 0 6px 30px rgb(0 0 0 / 35%); font-size: 10.5pt; line-height: 1.4; display: flex; flex-direction: column; }
@media (max-width: 860px) { .pdf-bg { padding: 0; } .sheet { width: 100%; min-height: auto; padding: 18px 14px; box-shadow: none; font-size: 12px; } }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 10px; border-bottom: 3px solid var(--navy); }
.q-head img { height: 54px; }
.q-head .co { font-size: 8.5pt; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.q-title { text-align: right; }
.q-title h1 { font: 800 20pt var(--display); color: var(--navy); letter-spacing: .06em; }
.q-title .num { font: 700 11pt var(--font); color: var(--orange-700); margin-top: 2px; }
.q-title .dt { font-size: 9pt; color: var(--muted); margin-top: 4px; }
.q-parties { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; margin: 14px 0; }
.q-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.q-box .lb { font: 700 7.5pt var(--font); color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.q-box .nm { font-weight: 700; color: var(--ink); font-size: 11pt; }
.q-box div { font-size: 9pt; }
.q-table { width: 100%; border-collapse: collapse; }
.q-table th { background: var(--navy); color: #fff; font: 700 7.5pt var(--font); letter-spacing: .06em; text-transform: uppercase; padding: 7px 8px; text-align: left; }
.q-table th.r, .q-table td.r { text-align: right; }
.q-table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 9.5pt; }
.q-table tr { page-break-inside: avoid; }
.q-table img { width: 46px; height: 56px; object-fit: contain; display: block; }
.q-table .nm { font-weight: 700; color: var(--ink); }
.q-table .meta { font-size: 8pt; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.q-table tr.tt td { background: var(--navy-50); font-weight: 700; color: var(--navy); text-transform: uppercase; font-size: 8.5pt; letter-spacing: .05em; }
.q-table tr.opt td { color: var(--muted); font-style: italic; }
.q-sum { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; page-break-inside: avoid; }
.q-sum .left { flex: 1; font-size: 8.5pt; color: var(--muted); }
.q-tot { width: 270px; font-variant-numeric: tabular-nums; }
.q-tot .row { display: flex; justify-content: space-between; padding: 4px 10px; font-size: 9.5pt; }
.q-tot .row.final { background: var(--navy); color: #fff; font: 800 12.5pt var(--display); border-radius: 6px; padding: 8px 10px; margin-top: 4px; }
.q-tot .ars { font-size: 8pt; color: var(--muted); text-align: right; padding: 4px 10px 0; }
.q-cond { margin-top: 14px; page-break-inside: avoid; }
.q-cond h3 { font: 700 8pt var(--font); color: var(--navy); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.q-cond ul { margin: 0; padding-left: 16px; font-size: 9pt; }
.q-cond li { margin: 2px 0; }
.q-obs { font-size: 9pt; white-space: pre-wrap; }
.q-foot { margin-top: auto; padding-top: 14px; }
.q-foot .legal { font-size: 8pt; color: var(--muted); text-align: center; margin-bottom: 8px; }
.q-foot .bar { background: var(--navy); color: #fff; border-radius: 6px; padding: 8px 12px; display: flex; justify-content: space-between; gap: 10px; font-size: 8.5pt; font-weight: 600; flex-wrap: wrap; }
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .no-print, .top, .pdf-tools, #toast { display: none !important; }
  .pdf-bg { background: #fff; padding: 0; }
  .sheet { box-shadow: none; margin: 0; width: 210mm; min-height: 297mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
