/* Estilos del sistema */
:root {
  --nav: #083b20;
  --nav-2: #0c5229;
  --nav-line: #297347;
  --paper: #fff;
  --ink: #14251a;
  --muted: #617165;
  --line: #d8e8dc;
  --page: #f4faf4;
  --brand: #29a64b;
  --brand-dark: #208e3e;
  --sky: #e8f7eb;
  --green: #238b3b;
  --amber: #b87708;
  --amber-bg: #fff5df;
  --red: #c94d4d;
  --red-bg: #fdeeee;
  --blue: #2f6fd6;
  --blue-bg: #eaf1fd;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
a { color: var(--brand-dark); }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Botones y campos ---------------------------------------------------------- */
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid #c9ddce; border-radius: 9px; background: #fff; color: var(--ink);
  padding: 9px 14px; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
}
.btn:hover:not(:disabled) { background: #f0f8f1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 14px #b7e7c1; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #efc9c9; }
.btn.danger:hover:not(:disabled) { background: var(--red-bg); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.link { border: 0; background: none; padding: 4px 6px; color: var(--brand-dark); }
.btn.link:hover:not(:disabled) { background: var(--sky); }
.btn.link.danger { color: var(--red); }
.btn.link.danger:hover:not(:disabled) { background: var(--red-bg); }

label { display: block; font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%; padding: 9px 11px; margin-top: 5px;
  border: 1px solid #cce0d0; border-radius: 8px; background: #fff; color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid #8fd6a0; outline-offset: 1px; border-color: var(--brand);
}
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--brand); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }

/* Estructura ---------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 240px; flex-shrink: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--nav), var(--nav-2)); color: #c2dbc7;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--nav-line); color: #fff; }
.brand .mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--brand); font-weight: 900; font-size: 18px; }
.brand b { display: block; font-size: 16px; }
.brand small { color: #9dc9a8; font-size: 12px; }
.side nav { flex: 1; padding: 12px 10px; }
.nav-title { font-size: 10px; letter-spacing: .1em; font-weight: 800; margin: 14px 11px 6px; color: #9dc9a8; }
.side nav a {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px;
  color: inherit; text-decoration: none;
}
.side nav a:hover { background: #176537; color: #fff; }
.side nav a.active { background: var(--brand); color: #fff; font-weight: 650; }
.ico { width: 18px; text-align: center; font-size: 16px; }
.side-foot { padding: 14px 20px; border-top: 1px solid var(--nav-line); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 64px; background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 0 26px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 5;
}
.top-left { display: flex; gap: 14px; align-items: center; min-width: 0; }
.menu-btn { display: none; font-size: 22px; border: 0; background: none; color: var(--ink); }
.crumb { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu { position: relative; }
.user-btn { display: flex; gap: 10px; align-items: center; border: 0; background: none; padding: 4px; border-radius: 10px; color: var(--ink); }
.user-btn:hover { background: var(--sky); }
.user-btn .who { text-align: right; font-size: 13px; line-height: 1.2; }
.user-btn .who small { display: block; font-size: 11px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #1d8038, #79cf79); color: #fff; font-weight: 800; font-size: 13px;
}
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 34px rgba(12, 72, 33, .14); padding: 6px; z-index: 20;
}
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 11px; border-radius: 7px; }
.dropdown button:hover { background: var(--sky); }

.content { width: 100%; max-width: 1400px; margin: 0 auto; padding: 26px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; letter-spacing: .12em; font-weight: 800; color: var(--brand-dark); margin: 0 0 4px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 18px; }

/* Métricas ------------------------------------------------------------------ */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 23px; margin: 4px 0 2px; }
.metric small { font-size: 12px; }
.metric.warn strong { color: var(--amber); }
.metric.alert strong { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 18px; }

.chart { height: 210px; display: flex; align-items: flex-end; gap: 12px; padding: 20px 18px 30px; }
.chart .bar { flex: 1; position: relative; background: linear-gradient(#67c974, var(--brand)); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.chart .bar span { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.chart .bar em { position: absolute; top: -18px; left: -10px; right: -10px; text-align: center; font-size: 10px; font-style: normal; color: var(--muted); white-space: nowrap; }

.quick { display: grid; gap: 8px; padding: 14px; }
.quick a {
  display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); text-decoration: none;
}
.quick a:hover { border-color: var(--brand); background: #f6fcf7; }
.quick b { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--sky); color: var(--brand); }
.quick small { display: block; }

/* Tablas -------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-top: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.table thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 12px; background: #fafdfb; white-space: nowrap; }
.table tbody tr:hover { background: #f8fcf9; }
.table tr.clickable { cursor: pointer; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table td small { display: block; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar input, .toolbar select { margin: 0; width: auto; }
.toolbar .grow { flex: 1; min-width: 200px; }

.pill { display: inline-block; font-size: 11.5px; padding: 3px 9px; border-radius: 99px; font-weight: 700; background: var(--sky); color: #197237; white-space: nowrap; }
.pill.amber { background: var(--amber-bg); color: #9d6510; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.gray { background: #eef1ef; color: var(--muted); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* Formularios en diálogo ---------------------------------------------------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 24px));
  max-height: calc(100vh - 24px); box-shadow: 0 24px 70px #0a3c2060; color: var(--ink);
}
dialog.wide { width: min(820px, calc(100% - 24px)); }
dialog::backdrop { background: #07381f88; }
.modal { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.modal-head { padding: 20px 22px 6px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.modal-body { padding: 10px 22px 6px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px 20px; border-top: 1px solid var(--line); margin-top: 10px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fields .full { grid-column: 1 / -1; }
.form-error { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin-top: 12px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; margin: 0; }
legend { font-size: 13px; font-weight: 700; padding: 0 6px; }
.perm-group { margin-top: 10px; }
.perm-group b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.perm-group .check { margin: 5px 0; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 6px; }

/* Nueva venta --------------------------------------------------------------- */
.pos { display: grid; grid-template-columns: 1fr 420px; gap: 18px; align-items: start; }
.pos-results { max-height: 520px; overflow-y: auto; }
.pos-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--line); cursor: pointer; }
.pos-item:hover { background: #f6fcf7; }
.pos-item small { display: block; }
.cart-line { display: grid; grid-template-columns: 1fr 64px 110px 28px; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.cart-line input { margin: 0; padding: 6px 8px; }
.cart-line small { display: block; }
.totals { display: grid; gap: 6px; margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 20px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 8px; }
.stack { display: grid; gap: 12px; }
.customer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.field-label { display: block; font-size: 13px; font-weight: 650; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 5px; padding: 4px; background: #eef5ef; border-radius: 10px; }
.segmented button { border: 0; background: none; padding: 9px; border-radius: 7px; font-weight: 650; color: var(--muted); }
.segmented button.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(12, 72, 33, .15); }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented a { padding: 9px; border-radius: 7px; font-weight: 650; color: var(--muted); text-align: center; text-decoration: none; }
.segmented a.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(12, 72, 33, .15); }
.tabs-wide { max-width: 520px; }
.profit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 14px; }
.profit-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.profit-card .eyebrow { margin: 0; }
.profit-card strong { font-size: 24px; color: var(--brand-dark); margin-top: 6px; }
.profit-card strong.neg { color: var(--red); }
.profit-card dl { margin: 10px 0 0; display: grid; gap: 4px; font-size: 13px; }
.profit-card dl div { display: flex; justify-content: space-between; gap: 8px; }
.profit-card dt { color: var(--muted); }
.profit-card dd { margin: 0; font-weight: 600; }
.warn-text { color: var(--amber); margin-top: 6px; }
.profit-card .three { display: grid; gap: 6px; margin-top: 8px; }
.profit-card .three div { display: grid; gap: 1px; }
.profit-card .three span { font-size: 12px; color: var(--muted); }
.profit-card .three b { font-size: 17px; white-space: nowrap; }
.profit-card dd { white-space: nowrap; }
.profit-card .three .total { border-top: 1px solid var(--line); padding-top: 6px; }
.profit-card .three .total span { color: var(--ink); font-weight: 700; }
.profit-card .three .total b { font-size: 22px; color: var(--brand-dark); }
.profit-card .three b.neg, .profit-card .three .total b.neg { color: var(--red); }
.profit-card .three b.neg-soft { color: #8a5a0b; }
.scan-bar { gap: 8px; }
.scan-bar .scan-icon { font-size: 20px; color: var(--brand-dark); }
.scan-bar input:focus { box-shadow: 0 0 0 3px #bfe9c9; }
.inline-field { display: flex; gap: 6px; align-items: center; margin-top: 5px; }
.inline-field input { margin: 0; flex: 1; }
.cart-line.flash { animation: flash 1.2s ease-out; }
.imei-box { padding: 0 0 10px; display: grid; gap: 6px; }
.imei-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.imei-grid input { margin: 0; padding: 6px 8px; font-family: ui-monospace, monospace; font-size: 13px; }
.imei-grid.with-color { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.imei-pair { display: grid; grid-template-columns: 1.4fr 1fr; gap: 4px; }
.imei-pair.with-network { grid-template-columns: 1.4fr 1fr 1fr; }
.imei-grid.with-color:has(.with-network) { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.imei-pair select { margin: 0; padding: 6px 8px; font-size: 13px; }
.imei-grid .imei-pair input.color-input { font-family: inherit; }
input.invalid { border-color: var(--red); background: var(--red-bg); }
.ti-customer { margin-top: 5px; padding: 9px 11px; border: 1px dashed #cce0d0; border-radius: 8px; background: #fafdfb; }
@keyframes flash { from { background: #c9f2d3; } to { background: transparent; } }
fieldset.trade-in { padding-top: 6px; }
fieldset.trade-in legend { padding: 0 4px; }
.notice { background: var(--amber-bg); color: #7a4f08; border-radius: 10px; padding: 11px 14px; margin: 0 0 16px; font-size: 14px; }
.notice.ok { background: var(--sky); color: #197237; }
.notice.danger { background: var(--red-bg); color: var(--red); }
.panel.alert-panel { border: 1px solid #efc9c9; }
.panel.alert-panel .panel-head h2 { color: var(--red); }
.table tr.overdue td { background: var(--red-bg); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f5f8f6; }
.table tr.open td { background: #eef5f0; }
.table tr.units-row > td { background: #fafcfb; padding: 10px 14px 16px; }
.change-box { display: flex; justify-content: space-between; align-items: center; background: var(--sky); color: #197237; border-radius: 10px; padding: 10px 14px; font-weight: 700; }
.change-box.short { background: var(--red-bg); color: var(--red); }
.nav-badge { margin-left: auto; background: #f2b632; color: #3d2a00; border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 800; }
.steps { list-style: none; margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; counter-reset: paso; }
.steps li { counter-increment: paso; display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.steps li b { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--sky); color: var(--brand-dark); }
.steps li:not(.done) b::before { content: counter(paso); }
.steps li.done { background: #f3fbf5; }
.steps li.done b { background: var(--brand); color: #fff; }
.steps li span { flex: 1; }
.steps li small { display: block; }
@media (max-width: 1100px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }
.commission-box { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; background: #f3fbf5; border-color: #b9e2c3; }
.commission-box strong { display: block; font-size: 22px; color: var(--brand-dark); }
.commission-box .eyebrow { margin: 0; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.detail-grid dt { font-size: 12px; color: var(--muted); }
.detail-grid dd { margin: 2px 0 0; font-weight: 600; }

/* Aviso flotante ------------------------------------------------------------ */
.toast-box { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px #0004; font-size: 14px; max-width: 360px; }
.toast.error { background: var(--red); }

/* Inicio de sesión ---------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #dff3e3, transparent 50%), var(--page); }
.login-card { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(12, 72, 33, .12); }
.login-card img { display: block; width: 190px; margin: 0 auto 10px; mix-blend-mode: multiply; }
.login-card h1 { font-size: 20px; text-align: center; }
.login-card > p { text-align: center; color: var(--muted); margin: 6px 0 18px; }
.login-card form { display: grid; gap: 14px; }
.login-card .btn { width: 100%; padding: 12px; }

.loading { padding: 60px; text-align: center; color: var(--muted); }

/* Responsivo ---------------------------------------------------------------- */
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .pos { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .side { position: fixed; z-index: 30; height: 100vh; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 60px #0006; }
  .menu-btn { display: block; }
  .content { padding: 16px; }
  .top { padding: 0 14px; }
  .user-btn .who { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 16px; white-space: nowrap; }
  .fields { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .toolbar .grow { min-width: 100%; }
}

/* Impresión de facturas ----------------------------------------------------- */
@media print {
  .side, .top, .no-print, .toast-box { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .panel { border: 0; }
  .print-only { display: block !important; }
  /* Solo el cajero puede imprimir la factura: para los demás la impresión sale vacía. */
  .no-invoice { display: none !important; }
  .content:has(.no-invoice)::after { content: 'Solo el cajero puede imprimir facturas.'; display: block; padding: 40px; font-size: 18px; }
}
.print-only { display: none; }
/* Encabezado y pie de "Mi empresa" en documentos impresos */
.print-company { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: start; border-bottom: 2px solid #000; padding-bottom: 10px; }
.print-company img { max-width: 150px; max-height: 90px; object-fit: contain; }
.print-company small { display: block; font-size: 11px; color: #222; }
.print-company-name { font-size: 18px; }
.print-doc { text-align: right; }
.print-doc h2 { margin: 0; }
.print-doc p { margin: 4px 0 0; font-size: 12px; }
.print-terms { margin-top: 10px; font-size: 11px; }
.print-terms p { margin: 2px 0 0; white-space: pre-wrap; }
.print-thanks { text-align: center; font-weight: 700; margin-top: 14px; }
.mono { font-family: ui-monospace, monospace; }
.imei-chip { display: inline-flex; align-items: center; gap: 4px; font-family: ui-monospace, monospace; }
.chip-x { border: 0; background: none; color: inherit; font-weight: 800; padding: 0 2px; line-height: 1; }
.imei-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; max-height: 340px; overflow-y: auto; }
.attach-box { display: grid; gap: 6px; padding: 10px 12px; border: 1px dashed #c9d6cf; border-radius: 10px; }
.attach-box.done { border-style: solid; border-color: #b8dcc4; background: var(--sky); }
.attach-pick { justify-self: start; cursor: pointer; }
.attach-preview { display: flex; gap: 12px; align-items: center; }
.attach-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid #0001; }
.attach-preview small { display: block; }
.attach-pdf { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 8px; background: var(--red-bg); color: var(--red); font-weight: 800; }
.invoice-thumb { max-width: 100%; max-height: 420px; border-radius: 10px; border: 1px solid #0001; display: block; }
.purchase-row td { vertical-align: top; }
.ti-note { white-space: pre-wrap; color: #5b4a1e; background: var(--amber-bg); border-radius: 6px; padding: 3px 6px; margin-top: 4px; }
.unit-rows { display: grid; gap: 6px; }
.unit-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr .9fr 1.1fr; gap: 6px; align-items: center; }
.unit-row input, .unit-row select { margin: 0; padding: 6px 8px; font-size: 13px; }
.unit-row input:first-child { font-family: ui-monospace, monospace; }
.unit-head span { font-size: 12px; font-weight: 700; color: var(--muted); }
@media (max-width: 640px) { .unit-row { grid-template-columns: 1fr 1fr; } .unit-head { display: none; } }
#splitBox .inline-field { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }
#splitBox .inline-field select, #splitBox .inline-field input { margin: 0; width: 100%; }
#splitBox .split-bank { margin: 0; width: 100%; }
.pct-amount { display: block; margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--green-dark, #197237); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.check-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid #e6ece8; border-radius: 8px; font-weight: 600; font-size: 14px; }
.check-row select { margin: 0; width: auto; min-width: 150px; padding: 5px 8px; font-size: 13px; }

/* Gráficas de barras horizontales (Panel → Gráficas de ventas) */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; padding: 16px 18px 18px; }
.chart-grid .full { grid-column: 1 / -1; }
.chart-grid h3 { font-size: 14px; margin: 0 0 10px; }
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 4px; align-items: end; font-size: 13px; }
.hbar .hbar-label { grid-column: 1; grid-row: 1; }
.hbar .hbar-track { grid-column: 1; grid-row: 2; }
.hbar .hbar-value { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.hbar-label { min-width: 0; }
.hbar-label b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--soft, #eef3ee); border-radius: 7px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, #67c974, var(--brand)); border-radius: 7px; }
.hbar-value { text-align: right; font-weight: 700; white-space: nowrap; }
.hbar-value small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

/* ERP: pestañas, estados financieros y tablas contables ---------------------- */
.erp-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #eef5ef; border-radius: 10px; margin-bottom: 16px; }
.erp-tabs a { padding: 8px 13px; border-radius: 7px; font-weight: 650; font-size: 13.5px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.erp-tabs a:hover { color: var(--brand-dark); }
.erp-tabs a.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(12, 72, 33, .15); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.statement { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.statement td { padding: 7px 14px; border-top: 1px solid var(--line); }
.statement td.num { text-align: right; white-space: nowrap; }
.statement tr.group td { font-weight: 700; background: #fafdfb; }
.statement tr.total td { font-weight: 800; border-top: 2px solid var(--ink); }
.statement tr.sub td:first-child { padding-left: 32px; }
.statement tr.deep td:first-child { padding-left: 50px; color: var(--muted); }
.entry { border-top: 1px solid var(--line); padding: 10px 18px; }
.entry-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.entry-lines { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.entry-lines td { padding: 3px 8px; }
.entry-lines td.num { text-align: right; width: 130px; white-space: nowrap; }
.entry-lines tr.cr td:first-child { padding-left: 34px; }
.split-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lines-editor { display: grid; gap: 8px; }
.lines-editor .row { display: grid; grid-template-columns: 2.4fr 1fr 1fr auto; gap: 8px; align-items: center; }
.lines-editor .row.po { grid-template-columns: 2.4fr .8fr 1fr auto; }
.lines-editor input, .lines-editor select { margin: 0; }
.kpi-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: #eef3ee; }
.kpi-bar > span { display: block; height: 100%; background: var(--brand); }
.kpi-bar > span.over { background: var(--red); }
.alert-list { display: grid; gap: 8px; padding: 14px 18px; }
.alert-list a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 9px; background: var(--amber-bg); color: var(--ink); text-decoration: none; font-size: 13.5px; }
.alert-list a.red { background: var(--red-bg); }
.alert-list a.ok { background: var(--sky); }
.month-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 150px; padding: 14px 18px 4px; }
.month-bars .col { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; }
.month-bars .bar { border-radius: 4px 4px 0 0; min-height: 2px; }
.month-bars .bar.in { background: var(--brand); }
.month-bars .bar.out { background: #f0b4b4; }
.month-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; padding: 0 18px 12px; font-size: 11px; color: var(--muted); text-align: center; }
.scan-box { display: flex; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.scan-box input { flex: 1; min-width: 220px; margin: 0; }
.check-list { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.check-list label { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-top: 1px solid var(--line); font-weight: 500; margin: 0; }
.check-list label:first-child { border-top: 0; }
.check-list input { width: auto; margin: 0; }
@media (max-width: 760px) {
  .split-cols { grid-template-columns: 1fr; }
  .lines-editor .row, .lines-editor .row.po { grid-template-columns: 1fr 1fr; }
  .lines-editor .row > :first-child { grid-column: 1 / -1; }
}
