:root {
  --navy: #1a3a6b; --navy-2: #24508f; --pink: #e8899a; --pink-soft: #fbe9ec;
  --cream: #fbf7f2; --ink: #1d2433; --muted: #667085; --line: #e4e0da; --ok: #1f7a4d; --warn: #b54708; --bad: #b42318;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--cream); }
a { color: var(--navy-2); }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 10px 20px; background: var(--navy); color: #fff; }
.top .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
.top .brand img { width: 38px; height: 38px; border-radius: 50%; background: #fff; object-fit: cover; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px; }
.top nav a { color: #dbe4f3; text-decoration: none; padding: 6px 12px; border-radius: 999px; }
.top nav a:hover, .top nav a.on { background: rgba(255,255,255,.14); color: #fff; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
h1 { font-size: 1.5rem; margin: 0 0 14px; color: var(--navy); }
h2 { font-size: 1.1rem; margin: 0 0 12px; color: var(--navy); }
.flash { background: #e8f5ee; border: 1px solid #b7e0c8; color: var(--ok); padding: 10px 14px; border-radius: var(--radius); }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 1.6rem; color: var(--navy); }
.stat.warn { border-color: #f5c38b; background: #fff8ef; }
.stat.warn b { color: var(--warn); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .9rem; }
.tabs a.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f6f3ee; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf8f5; }
td.num, th.num { text-align: right; white-space: nowrap; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--navy); white-space: nowrap; }
.muted { color: var(--muted); font-size: .88rem; }
.warn-txt { color: var(--warn); font-weight: 600; font-size: .85rem; }
.st { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: #eef2f7; color: var(--navy); }
.st-nuevo { background: var(--pink-soft); color: #a3364d; }
.st-pago_confirmado { background: #fff4d6; color: #8a5a00; }
.st-pedido_proveedor { background: #e7efff; color: #2346a0; }
.st-recibido { background: #eaf4ff; color: #155e9c; }
.st-enviado { background: #e9f7f1; color: #17704a; }
.st-entregado { background: #dff3e7; color: var(--ok); }
.st-cancelado { background: #f2f2f2; color: #777; text-decoration: line-through; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid #cfc9c0; border-radius: 9px; font: inherit; background: #fff; }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 1px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--navy-2); }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.wa { background: #1f9d55; border-color: #1f9d55; }
.btn.sm { padding: 5px 12px; font-size: .85rem; }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; }
.totals td { font-weight: 700; }
.history { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.login { max-width: 380px; margin: 60px auto; }
.qr-prev { max-width: 160px; border: 1px solid var(--line); border-radius: 8px; display: block; margin: 6px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } .top nav a { padding: 6px 9px; } }
@media print {
  .top, .no-print, .actions, form.no-print { display: none !important; }
  body { background: #fff; }
  .box, .table-wrap { border: 0; padding: 0; }
}

/* --- Panel completo --- */
h3 { font-size: 1rem; margin: 14px 0 8px; color: var(--navy); }
.top .me { display: flex; flex-wrap: wrap; gap: 4px; font-size: .88rem; }
.top .me a { color: #c9d6ea; text-decoration: none; padding: 4px 10px; border-radius: 999px; }
.top .me a:hover { background: rgba(255,255,255,.14); color: #fff; }
.flash.bad { background: #fdecea; border-color: #f5c2bd; color: var(--bad); }
.filters input, .filters select { margin: 0; width: auto; min-width: 160px; }
.filters input[name=q] { flex: 1 1 260px; max-width: 420px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin: 0; }
label.inline input:not([type=checkbox]) { margin: 0; width: auto; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.pager a, .pager b { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; text-decoration: none; }
.pager b { background: var(--navy); color: #fff; border-color: var(--navy); }
.table-wrap.flat { border: 0; border-radius: 0; }
.table-wrap.flat td, .table-wrap.flat th { padding: 7px 8px; }
.results { border: 1px solid var(--line); border-radius: 10px; background: #fff; max-height: 360px; overflow-y: auto; margin: -4px 0 8px; box-shadow: 0 8px 24px rgba(26,58,107,.12); }
.results button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; font: inherit; cursor: pointer; }
.results button:hover { background: var(--pink-soft); }
.results p { padding: 10px 12px; margin: 0; }
.items-edit input, .items-edit select { margin: 0; padding: 6px 8px; }
.items-edit td:first-child { min-width: 260px; }
.items-edit small { display: block; }
.sm-input { margin-top: 4px !important; font-size: .85rem; }
.totals-box { margin: 14px 0 14px auto; max-width: 420px; display: grid; gap: 8px; }
.totals-box > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.totals-box input { width: 110px; margin: 0; }
.totals-box .grand { border-top: 2px solid var(--navy); padding-top: 8px; font-size: 1.15rem; color: var(--navy); }
.box.soft { background: #f7f4ef; }
tr.dim td { opacity: .55; }
tr.new-row td { background: #fbfaf7; }
.nowrap { white-space: nowrap; }
.bar-row { display: grid; grid-template-columns: 56px 1fr 110px 30px; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .9rem; }
.bar-row b { text-align: right; }
.bar { background: #eef1f6; border-radius: 6px; height: 14px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy), var(--navy-2)); border-radius: 6px; }
.danger-zone summary { cursor: pointer; color: var(--bad); font-weight: 600; }
pre { background: #f6f3ee; padding: 10px; border-radius: 8px; overflow-x: auto; }

/* Compras, finanzas, inventario y cupones */
.st-off { background: #f2f2f2; color: #777; }
.st-c-pedida { background: #fff4d6; color: #8a5a00; }
.st-c-en_transito { background: #e7efff; color: #2346a0; }
.st-c-recibida { background: #dff3e7; color: var(--ok); }
.st-c-cancelada { background: #f2f2f2; color: #777; text-decoration: line-through; }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .72rem; background: #e7efff; color: #2346a0; vertical-align: middle; }
.bar-row.two { grid-template-columns: 56px 1fr 110px 120px; }
.bar-row.two .bar { height: 8px; margin: 2px 0; }
.bar.out i { background: linear-gradient(90deg, #d16d80, #e8899a); }
td.actions form { display: inline; }