:root {
  --fs: 14px;
  --c-bg:      #0f172a;
  --c-surface: #1e293b;
  --c-header:  #1e3a5f;
  --c-border:  #334155;
  --c-border2: #1a2740;
  --c-text:    #e2e8f0;
  --c-text2:   #cbd5e1;
  --c-text3:   #94a3b8;
  --c-text4:   #64748b;
  --c-text5:   #475569;
  --c-acc:     #2563eb;
  --c-acc-h:   #1d4ed8;
  --c-acc-l:   #60a5fa;
  --c-acc-p:   #93c5fd;
  --c-acc-b:   #3b82f6;
  --c-ok:      #34d399;
  --c-ok2:     #4ade80;
  --c-err:     #f87171;
  --c-warn:    #fbbf24;
  --c-scheme:  dark;
}
body.light {
  --c-bg:      #f1f5f9;
  --c-surface: #ffffff;
  --c-header:  #1e40af;
  --c-border:  #cbd5e1;
  --c-border2: #e2e8f0;
  --c-text:    #1e293b;
  --c-text2:   #334155;
  --c-text3:   #475569;
  --c-text4:   #64748b;
  --c-text5:   #94a3b8;
  --c-acc-l:   #2563eb;
  --c-acc-p:   #1d4ed8;
  --c-acc-b:   #2563eb;
  --c-ok:      #059669;
  --c-ok2:     #16a34a;
  --c-err:     #dc2626;
  --c-warn:    #d97706;
  --c-scheme:  light;
  color-scheme: light;
}
body.light input, body.light select, body.light textarea { color-scheme: light; }

/* Modo claro: elementos que siempre tienen fondo oscuro (--c-header) */
body.light .menubar,
body.light .statusbar { color: #bfdbfe; }
body.light .menu-item { color: #bfdbfe; }
body.light .statusbar span { color: #93c5fd; }
body.light .modal h2,
body.light .caja-grid th,
body.light table.admin th,
body.light .modal-buscar th { color: #bfdbfe; }
body.light .btn-billete,
body.light .mp2-btn:not(.activo),
body.light .btn-cambiar-cli { color: #bfdbfe; }
body.light .caja-grid tr:hover td,
body.light table.admin tr:hover td,
body.light .modal-buscar tr:hover td { color: #e2e8f0; }
body.light .btn-cancelar { background: #e2e8f0; color: #1e293b; }
body.light .btn-sec:hover { background: var(--c-acc); border-color: var(--c-acc); color: white; }
body.light .dropdown { box-shadow: 0 4px 12px rgba(0,0,0,.15); }

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; font-size: var(--fs); }
html { color-scheme: var(--c-scheme); }
body { background: var(--c-bg); color: var(--c-text); }

/* MENUBAR */
.menubar { background: var(--c-header); color: var(--c-text); display: flex; padding: 2px 4px; gap: 2px; user-select: none; border-bottom: 1px solid var(--c-acc); position: relative; }
.menu-item { padding: 3px 12px; cursor: pointer; border-radius: 3px; color: var(--c-text2); }
.menu-item:hover { background: var(--c-acc); color: white; }
a.menu-item-link { text-decoration: none; display: inline-block; }

/* DROPDOWNS */
.dropdown { display: none; position: absolute; background: var(--c-surface); border: 1px solid var(--c-border); z-index: 1000; min-width: 230px; box-shadow: 0 4px 16px rgba(0,0,0,0.6); }
.dropdown.open { display: block; }
.dropdown a { display: block; padding: 7px 16px; color: var(--c-text2); text-decoration: none; border-bottom: 1px solid var(--c-surface); }
.dropdown a:hover { background: var(--c-acc); color: white; }
#m-usuario { position: fixed !important; right: 0 !important; left: auto !important; top: 36px !important; min-width: 220px; }
#overlay { display: none; position: fixed; inset: 0; z-index: 999; }
#overlay.active { display: block; }

/* CONTENT */
.content { padding: 8px; }

/* CAJA */
.caja-wrapper { display: grid; grid-template-columns: 1fr 290px; grid-template-rows: auto 1fr; gap: 6px; height: calc(100vh - 60px); }
.caja-top { grid-column: 1; display: flex; align-items: center; gap: 8px; background: var(--c-surface); border: 1px solid var(--c-border); padding: 6px 10px; border-radius: 4px; }
.caja-top label { font-weight: bold; color: var(--c-acc-l); }
.caja-top input { background: var(--c-bg); border: 2px solid var(--c-acc); color: var(--c-text); padding: 4px 7px; width: 160px; font-size: 14px; border-radius: 3px; }
.caja-top input:focus { outline: none; border-color: var(--c-acc-l); }
.caja-top .qty-input { width: 60px; }
.btn-buscar { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text2); padding: 5px 12px; cursor: pointer; border-radius: 3px; display: flex; align-items: center; gap: 4px; }
.btn-buscar:hover { background: var(--c-acc); color: white; border-color: var(--c-acc); }
.lista-select { background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 4px 6px; border-radius: 3px; }

.caja-grid { grid-column: 1; background: var(--c-surface); border: 1px solid var(--c-border); overflow-y: auto; border-radius: 4px; }
.caja-grid table { width: 100%; border-collapse: collapse; }
.caja-grid th { background: var(--c-header); color: var(--c-acc-p); padding: 5px 8px; text-align: left; position: sticky; top: 0; font-weight: 600; border-bottom: 2px solid var(--c-acc); }
.caja-grid td { padding: 5px 8px; border-bottom: 1px solid var(--c-surface); color: var(--c-text2); }
.caja-grid tr:hover td { background: var(--c-header); }
.caja-grid tr.selected td { background: var(--c-acc-h); color: white; }
.caja-grid td.num { text-align: right; }

.caja-bottom-left { grid-column: 1; display: flex; flex-direction: column; gap: 6px; }
.comprobante-box, .cliente-box { background: var(--c-surface); border: 1px solid var(--c-border); border-top: 2px solid var(--c-acc); border-radius: 4px; padding: 8px 12px; }
.comprobante-box legend, .cliente-box legend { color: var(--c-acc-l); font-weight: bold; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; display: block; }
.form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.form-row label { min-width: 90px; color: var(--c-acc-l); font-weight: 600; }
.form-row input, .form-row select, .form-row textarea { background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 3px 6px; border-radius: 3px; }
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--c-acc); }
.form-row textarea { width: 100%; resize: none; height: 40px; }

.caja-panel { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.panel-seccion { background: var(--c-surface); border: 1px solid var(--c-border); border-top: 2px solid var(--c-acc); border-radius: 4px; padding: 8px 10px; flex-shrink: 0; }
.panel-sec-titulo { color: var(--c-acc-l); font-weight: bold; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.panel-field { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.panel-field label { color: var(--c-text4); font-size: 10px; text-transform: uppercase; white-space: nowrap; }
.panel-field input, .panel-field select { background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 3px 5px; border-radius: 3px; font-size: 11px; min-width: 0; }
.panel-field input:focus, .panel-field select:focus { outline: none; border-color: var(--c-acc); }
.panel-field select { flex: 1; }
.panel-field textarea { flex: 1; background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 3px 5px; border-radius: 3px; font-size: 11px; resize: none; height: 34px; min-width: 0; }
.panel-cli-val { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.btn-cambiar-cli { background: var(--c-header); border: 1px solid var(--c-acc); color: var(--c-acc-l); padding: 2px 8px; border-radius: 3px; font-size: 10px; cursor: pointer; }
.btn-cambiar-cli:hover { background: var(--c-acc); color: white; }
.cli-panel-buscar-wrap { position: relative; margin-bottom: 5px; }
.cli-panel-buscar-wrap input { width: 100%; background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 4px 26px 4px 7px; border-radius: 3px; font-size: 11px; box-sizing: border-box; }
.cli-panel-buscar-wrap input:focus { outline: none; border-color: var(--c-acc); }
.cli-panel-buscar-wrap .cli-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--c-text5); cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }
.cli-panel-buscar-wrap .cli-clear:hover { color: var(--c-text3); }
.cli-panel-lista { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 3px; max-height: 150px; overflow-y: auto; margin-bottom: 5px; }
.cli-panel-item { padding: 5px 8px; cursor: pointer; border-bottom: 1px solid var(--c-surface); }
.cli-panel-item:last-child { border-bottom: none; }
.cli-panel-item:hover { background: var(--c-header); }
.cli-panel-item.activo { background: var(--c-acc-h); }
.cli-panel-item.activo .cli-panel-item-nombre { color: #fff; }
.cli-panel-item.activo .cli-panel-item-tel { color: var(--c-acc-p); }
.cli-panel-item-nombre { font-weight: 600; font-size: 11px; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cli-panel-item-tel { font-size: 10px; color: var(--c-text4); }
.totales-box { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 4px; padding: 10px 12px; }
.totales-box .t-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--c-text3); font-size: 13px; }
.totales-box .t-total { font-size: 30px; font-weight: bold; color: var(--c-ok); text-align: right; margin-top: 6px; }
.totales-box .t-label { font-size: 12px; color: var(--c-text4); text-transform: uppercase; letter-spacing: 0.5px; }
.btn-cobrar { background: var(--c-acc); color: white; border: none; padding: 14px; font-size: 18px; font-weight: bold; cursor: pointer; border-radius: 4px; width: 100%; letter-spacing: 0.5px; }
.btn-cobrar:hover { background: var(--c-acc-h); }
.btn-row { display: flex; gap: 4px; }
.btn-sec { flex: 1; background: var(--c-surface); color: var(--c-text2); border: 1px solid var(--c-border); padding: 10px 4px; font-size: 12px; font-weight: bold; cursor: pointer; border-radius: 4px; text-align: center; }
.btn-sec:hover { background: var(--c-border); color: white; }
.depto-box { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.btn-depto { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text3); padding: 8px 4px; cursor: pointer; border-radius: 3px; text-align: center; font-size: 11px; }
.btn-depto:hover { background: var(--c-acc); color: white; border-color: var(--c-acc); }

.acciones-row { display: flex; gap: 4px; flex-wrap: wrap; padding: 2px 0; }
.btn-accion { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text2); padding: 5px 12px; cursor: pointer; border-radius: 3px; }
.btn-accion:hover { background: var(--c-border); color: white; }

.statusbar { background: var(--c-header); border-top: 1px solid var(--c-acc); padding: 3px 10px; display: flex; gap: 20px; font-size: 11px; color: var(--c-text3); position: fixed; bottom: 0; left: 0; right: 0; }
.statusbar span { font-weight: bold; color: var(--c-acc-l); }

/* MODAL COBRAR */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 2000; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal { background: var(--c-surface); border: 1px solid var(--c-border); padding: 16px; width: 500px; max-width: 95vw; border-radius: 6px; box-shadow: 0 8px 32px rgba(0,0,0,0.6); }
.modal h2 { background: var(--c-header); color: var(--c-acc-p); margin: -16px -16px 14px; padding: 10px 16px; font-size: 14px; border-radius: 6px 6px 0 0; border-bottom: 2px solid var(--c-acc); }
.modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.medios-pago { display: flex; flex-direction: column; gap: 7px; }
.medio-seccion { border: 1px solid var(--c-header); border-radius: 5px; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; background: var(--c-bg); }
.medio-row { display: flex; align-items: center; gap: 6px; }
.medio-row label { width: 140px; font-weight: 600; color: var(--c-text3); }
.medio-row label.label-medio { cursor: pointer; }
.medio-row label.label-medio:hover { color: var(--c-acc-l); }
.medio-row input { width: 110px; background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); padding: 5px 7px; text-align: right; border-radius: 3px; }
.medio-row input:focus { outline: none; border-color: var(--c-acc); }
/* Nuevo modal cobro */
.mp2-row { display: flex; align-items: center; gap: 8px; }
.mp2-btn { width: 160px; flex-shrink: 0; background: var(--c-header); border: 1px solid var(--c-acc)55; color: var(--c-acc-p); font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 4px; cursor: pointer; text-align: left; transition: background .15s; }
.mp2-btn:hover { background: var(--c-acc-h); color: #fff; }
.mp2-btn.activo { background: var(--c-acc); border-color: var(--c-acc); color: #fff; }
.mp2-inp { width: 110px; flex-shrink: 0; background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 7px 10px; text-align: right; border-radius: 4px; font-size: 15px; font-weight: 700; min-width: 0; }
.mp2-inp:focus { outline: none; border-color: var(--c-acc); background: var(--c-surface); }
.totales-pago { display: flex; flex-direction: column; gap: 8px; }
.tp-box { background: var(--c-bg); border: 1px solid var(--c-border); padding: 10px 14px; text-align: center; border-radius: 4px; }
.tp-box .tp-label { font-size: 11px; color: var(--c-text4); text-transform: uppercase; letter-spacing: 0.5px; }
.tp-box .tp-val { font-size: 22px; font-weight: bold; color: var(--c-ok); }
.tp-box.rojo .tp-val { color: var(--c-err); }
.billetes { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.btn-billete { background: var(--c-header); border: 1px solid var(--c-acc); color: var(--c-acc-p); padding: 6px 10px; cursor: pointer; border-radius: 3px; font-weight: bold; }
.btn-billete:hover { background: var(--c-acc); color: white; }
.tarjetas-row { display: flex; gap: 4px; flex-wrap: wrap; }
.cheque-inp { background: var(--c-surface); border: 1px solid #f59e0b66; color: var(--c-text); padding: 5px 8px; border-radius: 4px; font-size: 12px; width: 100%; box-sizing: border-box; }
.cheque-inp:focus { outline: none; border-color: #f59e0b; }
.cheque-inp::placeholder { color: var(--c-text5); }
.btn-tarjeta { background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text4); padding: 4px 10px; cursor: pointer; border-radius: 4px; font-size: 11px; transition: all .15s; }
.btn-tarjeta:hover { border-color: var(--c-acc); color: var(--c-acc-p); background: var(--c-surface); }
.btn-tarjeta.activa { background: var(--c-acc); border-color: var(--c-acc); color: #fff; font-weight: 700; }
.modal-footer { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.btn-confirmar { background: var(--c-acc); color: white; border: none; padding: 9px 32px; font-size: 14px; font-weight: bold; cursor: pointer; border-radius: 4px; }
.btn-confirmar:hover { background: var(--c-acc-h); }
.btn-cancelar { background: #374151; color: var(--c-text); border: none; padding: 9px 20px; cursor: pointer; border-radius: 4px; }
.btn-cancelar:hover { background: #4b5563; }

/* BUSCAR ARTÍCULO MODAL */
.modal-buscar { width: 620px; }
.modal-buscar table { width: 100%; border-collapse: collapse; margin-top: 8px; max-height: 300px; display: block; overflow-y: auto; }
.modal-buscar th { background: var(--c-header); color: var(--c-acc-p); padding: 5px 10px; }
.modal-buscar td { padding: 5px 10px; border-bottom: 1px solid var(--c-surface); cursor: pointer; color: var(--c-text2); }
.modal-buscar tr:hover td { background: var(--c-header); color: white; }
.modal-buscar tr.selected td { background: var(--c-header); color: var(--c-acc-p); }
.btn-edit-art { background: none; border: none; color: var(--c-text4); cursor: pointer; font-size: 13px; padding: 2px 5px; border-radius: 3px; }
.btn-edit-art:hover { color: var(--c-acc-p); background: var(--c-border); }

/* TABLAS ADMIN */
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.admin-header h1 { font-size: 17px; color: var(--c-acc-l); font-weight: 600; letter-spacing: 0.3px; }
.btn-nuevo { background: var(--c-acc); color: white; border: none; padding: 7px 16px; cursor: pointer; border-radius: 4px; font-weight: bold; }
.btn-nuevo:hover { background: var(--c-acc-h); }
.search-bar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.search-bar input { flex: 1; background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); padding: 6px 10px; border-radius: 4px; }
.search-bar input:focus { outline: none; border-color: var(--c-acc); }
.search-bar label { color: var(--c-text3); }
.search-bar input[type=date] { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); padding: 5px 8px; border-radius: 4px; flex: none; }
table.admin { width: 100%; border-collapse: collapse; background: var(--c-surface); border-radius: 6px; overflow: hidden; }
table.admin th { background: var(--c-header); color: var(--c-acc-p); padding: 7px 10px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--c-acc); }
table.admin td { padding: 6px 10px; border-bottom: 1px solid var(--c-border2); color: var(--c-text2); }
table.admin tr:hover td { background: var(--c-header); }
table.admin td.num { text-align: right; }
.btn-edit { background: var(--c-acc-h); color: white; border: none; padding: 3px 10px; cursor: pointer; border-radius: 3px; }
.btn-edit:hover { background: var(--c-acc); }
.btn-del  { background: #991b1b; color: white; border: none; padding: 3px 10px; cursor: pointer; border-radius: 3px; }
.btn-del:hover { background: var(--c-err); }

/* FORM MODAL */
.form-modal { width: 430px; }
.fm-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.fm-row label { font-weight: 600; color: var(--c-text3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.fm-row input, .fm-row select { background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); padding: 7px 9px; border-radius: 4px; }
.fm-row input:focus, .fm-row select:focus { outline: none; border-color: var(--c-acc); }

/* VUELTO MODAL */
.modal-vuelto { width: 280px; text-align: center; }
.vuelto-val { font-size: 52px; font-weight: bold; color: var(--c-ok); margin: 20px 0; }
.btn-opcion-venta { width:100%; padding:11px 16px; border:1px solid var(--c-border); background:var(--c-surface); color:var(--c-text); cursor:pointer; border-radius:6px; font-size:14px; text-align:left; transition:background .15s; }
.btn-opcion-venta:hover { background:var(--c-acc); border-color:var(--c-acc); color:#fff; }
.btn-opcion-neutro { color:var(--c-text4); font-size:13px; }

/* INPUTS GLOBALES */
input, select, textarea { color-scheme: var(--c-scheme); }

/* MODAL BUSCAR INPUT */
.modal-buscar > input, .modal > input[type=text] {
  background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text);
  padding: 7px 10px; border-radius: 4px; width: 100%;
}
.modal-buscar > input:focus { outline: none; border-color: var(--c-acc); }

/* TOTALES VENTA DETALLE */
.t-sep { border-top: 1px solid var(--c-border); margin: 6px 0; }
