/* SIACTI Service Desk — estilo basado en el prototipo (slate + brand azul) */
:root {
  --bg: #0f172a; --panel: #111c33; --panel2: #16223d; --side: #020617; --line: #1e293b; --line2: #2a3a57;
  --tx: #e2e8f0; --tx2: #94a3b8; --tx3: #64748b; --brand: #0284c7; --brand2: #0369a1; --brand-soft: rgba(2,132,199,.15);
  --green: #22c55e; --amber: #f59e0b; --red: #ef4444; --blue: #38bdf8; --indigo: #818cf8;
  --r: 12px; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f1f5f9; --panel: #ffffff; --panel2: #f8fafc; --side: #0b1222; --line: #e2e8f0; --line2: #cbd5e1;
  --tx: #0f172a; --tx2: #475569; --tx3: #94a3b8; --brand-soft: #e0f2fe; color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--tx);
       font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--tx3); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -4px; }
svg.i.sm { width: 15px; height: 15px; vertical-align: -3px; }

/* layout */
.app { display: flex; min-height: 100vh; }
.side { width: 240px; background: var(--side); border-right: 1px solid #1e293b; display: flex; flex-direction: column;
        position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; color: #cbd5e1; }
.logo { display: flex; gap: 10px; align-items: center; padding: 18px 18px 16px; border-bottom: 1px solid #1e293b; }
.logo .mk { background: var(--brand); color: #fff; padding: 8px; border-radius: 10px; display: flex; box-shadow: 0 6px 18px rgba(2,132,199,.35); }
.logo b { color: #fff; display: block; font-size: 15px; } .logo small { color: #64748b; font-size: 11.5px; }
.nav { padding: 10px; flex: 1; }
.nav .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #475569; padding: 14px 10px 6px; font-weight: 600; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; color: #cbd5e1; font-weight: 500; font-size: 13.5px; }
.nav a:hover { background: rgba(30,41,59,.7); color: #fff; text-decoration: none; }
.nav a.on { background: var(--brand); color: #fff; }
.nav a svg { color: #38bdf8; } .nav a.on svg { color: #fff; }
.nav .cnt { margin-left: auto; background: #1e293b; color: #cbd5e1; border-radius: 99px; font-size: 11px; padding: 0 7px; }
.nav a.on .cnt { background: rgba(255,255,255,.2); }
.side-foot { padding: 12px 14px; border-top: 1px solid #1e293b; font-size: 12px; color: #64748b; }
.side-foot .who { color: #e2e8f0; font-weight: 600; font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; gap: 12px; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel);
       position: sticky; top: 0; z-index: 20; }
.top form.search { flex: 1; max-width: 520px; position: relative; }
.top form.search input { padding-left: 34px; }
.top form.search svg { position: absolute; left: 10px; top: 9px; color: var(--tx3); }
.top .sp { flex: 1; }
.top .burger { display: none; }
.content { padding: 22px 24px 60px; max-width: 1500px; width: 100%; }
.page-h { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.page-h p { margin: 4px 0 0; color: var(--tx2); }
.page-h .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--tx3); margin-bottom: 4px; } .crumb a { color: var(--tx2); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .bd { padding: 16px; }
.card > .bd.np { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack > * + * { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: block; color: var(--tx); position: relative; overflow: hidden; }
.kpi:hover { text-decoration: none; border-color: var(--line2); }
.kpi .l { color: var(--tx2); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--tx3); margin-top: 2px; }
.kpi .s.warn { color: var(--amber); } .kpi .s.bad { color: var(--red); }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); opacity: .8; }
.kpi.amber::after { background: var(--amber); } .kpi.red::after { background: var(--red); } .kpi.green::after { background: var(--green); }

/* table */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 600; color: var(--tx2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
             padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel2); white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: rgba(56,189,248,.04); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t a.rowlink { color: var(--tx); font-weight: 600; }
.empty { padding: 34px 16px; text-align: center; color: var(--tx3); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
         white-space: nowrap; border: 1px solid transparent; }
.badge.green { background: rgba(34,197,94,.12); color: #4ade80; border-color: rgba(34,197,94,.25); }
.badge.amber { background: rgba(245,158,11,.12); color: #fbbf24; border-color: rgba(245,158,11,.25); }
.badge.red { background: rgba(239,68,68,.12); color: #f87171; border-color: rgba(239,68,68,.28); }
.badge.blue { background: rgba(56,189,248,.12); color: #7dd3fc; border-color: rgba(56,189,248,.25); }
.badge.indigo { background: rgba(129,140,248,.14); color: #a5b4fc; border-color: rgba(129,140,248,.28); }
.badge.gray { background: rgba(148,163,184,.12); color: #cbd5e1; border-color: rgba(148,163,184,.22); }
:root[data-theme="light"] .badge.green { color: #15803d; } :root[data-theme="light"] .badge.amber { color: #b45309; }
:root[data-theme="light"] .badge.red { color: #b91c1c; } :root[data-theme="light"] .badge.blue { color: #0369a1; }
:root[data-theme="light"] .badge.indigo { color: #4338ca; } :root[data-theme="light"] .badge.gray { color: #475569; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--tx3); }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); } .dot.green { background: var(--green); } .dot.blue { background: var(--blue); }

/* forms */
label.f { display: block; } label.f > span { display: block; font-size: 12.5px; color: var(--tx2); margin-bottom: 5px; font-weight: 500; }
label.f > span em { color: var(--red); font-style: normal; }
label.f small { display: block; color: var(--tx3); font-size: 11.5px; margin-top: 4px; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line2); color: var(--tx); border-radius: 9px;
  padding: 8px 11px; font: inherit; font-size: 14px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 88px; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); vertical-align: -3px; }
input[type=file] { padding: 6px; }
.chk { display: flex; gap: 8px; align-items: center; padding-top: 26px; color: var(--tx); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-acts { display: flex; gap: 10px; justify-content: flex-end; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters input, .filters select { width: auto; min-width: 150px; padding: 6px 10px; font-size: 13px; }
.filters input[type=checkbox] { min-width: 0; width: 16px; padding: 0; }
.filters label { display: inline-flex; gap: 6px; align-items: center; color: var(--tx2); }
.filters input[name=q] { min-width: 230px; flex: 1; max-width: 360px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; font: inherit; font-size: 13.5px; font-weight: 600;
       border: 1px solid var(--line2); background: var(--panel2); color: var(--tx); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: var(--tx3); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(2,132,199,.25); }
.btn.pri:hover { background: var(--brand2); }
.btn.ok { background: #15803d; border-color: #15803d; color: #fff; }
.btn.danger { color: #f87171; border-color: rgba(239,68,68,.35); background: transparent; }
.btn.danger:hover { background: rgba(239,68,68,.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--tx2); }
.btn.ghost:hover { color: var(--tx); background: var(--panel2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 7px; }
form.inline { display: inline; }

/* flashes */
.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; border: 1px solid; font-weight: 500; }
.flash.ok { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); color: #86efac; }
.flash.error { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.35); color: #fca5a5; }
:root[data-theme="light"] .flash.ok { color: #166534; } :root[data-theme="light"] .flash.error { color: #991b1b; }

/* detail */
dl.dv { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 18px; margin: 0; }
dl.dv div.wide { grid-column: 1 / -1; }
dl.dv dt { font-size: 11.5px; color: var(--tx3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
dl.dv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.secret { font-family: ui-monospace, monospace; filter: blur(5px); cursor: pointer; transition: filter .2s; user-select: none; }
.secret.show { filter: none; user-select: text; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 8px; overflow-x: auto; }
.tabs a { padding: 11px 12px; color: var(--tx2); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on, .tabs a:hover { color: var(--tx); text-decoration: none; border-color: var(--brand); }
.tabpane { display: none; } .tabpane.on { display: block; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line2); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); position: absolute; left: -6px; top: 15px; }
.timeline .meta { font-size: 12px; color: var(--tx3); }
.timeline .txt { white-space: pre-wrap; margin-top: 2px; }

.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--tx); }
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: rgba(56,189,248,.04); text-decoration: none; }
.alert-row .ttl { font-weight: 600; } .alert-row .sub { font-size: 12px; color: var(--tx3); }
.alert-row .grow { flex: 1; min-width: 0; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 8px 4px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b .col { width: 100%; max-width: 44px; background: linear-gradient(180deg, #38bdf8, #0284c7); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b .lb { font-size: 11.5px; color: var(--tx3); } .bars .b .vl { font-size: 11px; color: var(--tx2); font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.hbar .tr { grid-column: 1 / -1; height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.hbar .tr i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* lines editor */
table.lines td { padding: 6px 6px; } table.lines th { padding: 8px 6px; }
table.lines input, table.lines select { padding: 6px 8px; font-size: 13px; }
table.lines .c-tipo { width: 112px; } table.lines .c-item { width: 230px; } table.lines .c-cant { width: 90px; }
table.lines .c-precio { width: 120px; } table.lines .c-imp { width: 120px; } table.lines .c-del { width: 40px; }
.totals { margin-left: auto; width: 320px; max-width: 100%; display: grid; grid-template-columns: 1fr 140px; gap: 8px 12px; align-items: center; margin-top: 14px; }
.totals .lbl { text-align: right; color: var(--tx2); } .totals .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .big { font-size: 18px; color: var(--tx); }
.totals input { text-align: right; padding: 5px 8px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(2,132,199,.22), transparent), var(--bg); }
.login { width: 100%; max-width: 380px; }
.login .logo { border: 0; justify-content: center; padding: 0 0 20px; }
.login .logo b { color: var(--tx); font-size: 18px; }

/* modal */
dialog { background: var(--panel); color: var(--tx); border: 1px solid var(--line2); border-radius: 14px; padding: 0; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(2,6,23,.65); }
dialog .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .bd { padding: 18px; } dialog .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--tx2); font-size: 13px; }

.perm-tbl td, .perm-tbl th { text-align: center; } .perm-tbl td:first-child, .perm-tbl th:first-child { text-align: left; }

/* print (cotizaciones, facturas, reportes) */
.doc { background: #fff; color: #0f172a; border-radius: 12px; padding: 36px 40px; max-width: 900px; margin: 0 auto; font-size: 13px; }
.doc h1 { color: #0369a1; font-size: 22px; }
.doc .head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #0284c7; padding-bottom: 16px; margin-bottom: 18px; }
.doc .muted { color: #64748b; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.doc th { background: #f0f9ff; color: #0c4a6e; text-align: left; padding: 8px 10px; font-size: 12px; border-bottom: 1px solid #bae6fd; }
.doc td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.doc .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc .box { border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; }
.doc .lbl { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.doc .tot { margin-left: auto; width: 300px; margin-top: 10px; }
.doc .tot div { display: flex; justify-content: space-between; padding: 4px 10px; }
.doc .tot .g { background: #0284c7; color: #fff; border-radius: 6px; font-weight: 700; font-size: 15px; padding: 8px 10px; }
.doc .firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin-top: 70px; text-align: center; }
.doc .firmas div { border-top: 1px solid #94a3b8; padding-top: 6px; font-size: 12px; color: #475569; }
.doc .pre { white-space: pre-wrap; }

@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; }
  .side, .top, .no-print, .flashes { display: none !important; }
  .content { padding: 0 !important; max-width: none; }
  .doc { padding: 0; border-radius: 0; max-width: none; }
}

@media (max-width: 1100px) { .g-side, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .side { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .side.open { left: 0; box-shadow: 10px 0 40px rgba(0,0,0,.5); }
  .top .burger { display: inline-flex; }
  .top .sp { display: none; }
  .top form.search { min-width: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .v { font-size: 22px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px 16px 60px; }
  .top { padding: 10px 16px; }
  .doc { padding: 20px 16px; }
  .top .who-name { display: none; }
}

/* v2: editor de cotización */
.cot-lines tbody.ln tr:first-child td { border-bottom: 0; padding-bottom: 2px; }
.cot-lines tbody.ln tr.sub td { padding-top: 2px; border-bottom: 1px solid var(--line2); }
.cot-lines tbody.ln:hover td { background: rgba(56,189,248,.03); }
.flags { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--tx2); }
.flags label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.util { color: var(--tx3); }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line2); font-size: 12.5px; }
.hdr-counters { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.hdr-counters > * { padding: 8px 14px; border-right: 1px solid var(--line); color: var(--tx); display: flex; gap: 8px; align-items: center; }
.hdr-counters > *:last-child { border-right: 0; }
.hdr-counters b { display: block; font-size: 15px; } .hdr-counters small { color: var(--tx3); display: block; font-size: 11.5px; }
.prod-img { width: 120px; height: 120px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.arm-tbl input, .arm-tbl select { padding: 5px 7px; font-size: 13px; }
.arm-tbl td { padding: 6px 5px; vertical-align: middle; }
.arm-tbl .calc { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; color: var(--tx2); font-size: 12.5px; }
.arm-sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.arm-sum div { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.arm-sum b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; } .arm-sum span { font-size: 12px; color: var(--tx3); }
.up { color: #f87171; } .down { color: #4ade80; }
.tabpane > .bd, .tabpane > form.bd { padding: 16px; }
