:root {
  --bg: #15120f; --panel: #1f1a16; --panel-2: #2a231d; --line: #3a3029;
  --text: #f4ece4; --muted: #a8998b; --accent: #e85d3a; --accent-2: #f0a030;
  --ok: #3fb27f; --warn: #f0a030; --bad: #e5484d; --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.error { color: var(--bad); min-height: 1em; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* Botones */
a.btn { text-decoration: none; color: inherit; display: inline-block; }
.btn { border: 1px solid var(--line); background: var(--panel-2); padding: 9px 14px; border-radius: 10px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 18px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.check { cursor: pointer; user-select: none; }
/* Interruptor moderno para todas las casillas (propina, productos, configuración…) */
.check input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 38px; height: 22px; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 99px; background: var(--bg); position: relative; cursor: pointer;
  transition: background .2s, border-color .2s, box-shadow .2s; }
.check input[type=checkbox]::before { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .2s cubic-bezier(.4,1.4,.6,1), background .2s; }
.check input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.check input[type=checkbox]:checked::before { transform: translateX(16px); background: #fff; }
.check:hover input[type=checkbox]:not(:checked) { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.check input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.check input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #3a2016, var(--bg) 60%); }
.login-card { width: 340px; background: var(--panel); padding: 28px; border-radius: 20px; display: grid; gap: 14px; border: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.logo { color: var(--accent); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad button { padding: 14px; font-size: 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.pinpad button:active { background: var(--accent); }

/* Layout app */
.app { display: grid; grid-template-columns: 210px minmax(0, 1fr); height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; }
#nav { display: grid; gap: 4px; }
#nav a { padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; cursor: pointer; }
#nav a:hover { background: var(--panel-2); color: var(--text); }
#nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.user-line { display: grid; }
.shift-badge { font-size: 12px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.shift-badge.open { border-left: 3px solid var(--ok); }
.shift-badge.closed { border-left: 3px solid var(--bad); }
main { overflow: auto; padding: 22px; min-width: 0; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; height: calc(100vh - 44px); }
.pos-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.cat { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.cat.active { background: var(--text); color: var(--bg); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow: auto; padding-bottom: 8px; align-content: start; }
.prod { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c, var(--accent)); border-radius: 12px; padding: 12px; cursor: pointer; text-align: left; display: grid; gap: 6px; min-height: 92px; transition: transform .08s; }
.prod:active { transform: scale(.97); }
.prod:hover { border-color: var(--muted); }
.prod b { font-size: 14px; font-weight: 600; }
.prod .price { color: var(--accent-2); font-weight: 700; }
.prod .stock { font-size: 11px; color: var(--muted); }
.prod.out { opacity: .4; }
.ticket { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.ticket-head { padding: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.lines { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px; overscroll-behavior-y: contain;
  --fade-t: 0px; --fade-b: 0px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-t), #000 calc(100% - var(--fade-b)), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-t), #000 calc(100% - var(--fade-b)), transparent 100%); }
.lines.more-top { --fade-t: 32px; } .lines.more-bottom { --fade-b: 32px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 10px 6px; border-bottom: 1px dashed var(--line); }
.line .qty { display: flex; gap: 6px; align-items: center; }
.line .qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.line .tag { font-size: 11px; color: var(--accent-2); }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }
.totals { padding: 12px 16px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 22px; font-weight: 800; margin-top: 4px; }
.ticket-actions { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ticket-actions .full { grid-column: 1 / -1; }
/* Barra de mesas: scroll horizontal fino, aparece al pasar el mouse; bordes difuminados indican que hay más */
.tables { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; max-width: 100%; min-height: 58px;
  padding: 2px 2px 10px; scroll-snap-type: x proximity; overscroll-behavior-x: contain;
  --fade-l: 0px; --fade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%); }
.tables.more-left { --fade-l: 40px; } .tables.more-right { --fade-r: 40px; }
/* Scroll moderno (barra de mesas y carrito): fino, redondeado, aparece al pasar el mouse en el color de acento */
.tables, .lines { scrollbar-width: thin; scrollbar-color: transparent transparent; transition: scrollbar-color .25s; }
.tables:hover, .lines:hover { scrollbar-color: color-mix(in srgb, var(--accent) 55%, transparent) transparent; }
.tables::-webkit-scrollbar { height: 6px; } .lines::-webkit-scrollbar { width: 6px; }
.tables::-webkit-scrollbar-track { background: transparent; margin: 0 12px; }
.lines::-webkit-scrollbar-track { background: transparent; margin: 10px 0; }
.tables::-webkit-scrollbar-thumb, .lines::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; transition: background .25s; }
.tables:hover::-webkit-scrollbar-thumb, .lines:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.tables::-webkit-scrollbar-thumb:hover, .tables::-webkit-scrollbar-thumb:active,
.lines::-webkit-scrollbar-thumb:hover, .lines::-webkit-scrollbar-thumb:active { background: var(--accent); }
.table-chip { flex: 0 0 auto; scroll-snap-align: start; transition: border-color .15s, transform .15s, background .15s; padding: 8px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; white-space: nowrap; font-size: 13px; }
.table-chip.active { border-color: var(--accent); }

/* Tablas */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
.pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); }
.pill.closed { color: var(--ok); } .pill.voided { color: var(--bad); } .pill.open { color: var(--warn); }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.charts-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bar-label { fill: var(--muted); font-size: 10px; }
.legend { display: grid; gap: 6px; font-size: 13px; }
.legend span.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(560px, 94vw); max-height: 92vh; overflow: auto; display: grid; gap: 14px; align-content: start; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { padding: 6px 10px; font-size: 13px; }
.big-total { font-size: 34px; font-weight: 800; text-align: center; }
.diff.pos { color: var(--ok); } .diff.neg { color: var(--bad); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: .25s; z-index: 60; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); color: #fff; }

/* Recibo (impresión térmica 80mm) */
#print-area { display: none; }
.receipt { font-family: "Courier New", monospace; font-size: 12px; color: #000; background: #fff; width: 72mm; padding: 2mm; }
.receipt .c { text-align: center; } .receipt hr { border: none; border-top: 1px dashed #000; margin: 4px 0; }
.receipt table td { padding: 1px 0; border: none; font-size: 12px; color: #000; }
.receipt .r { text-align: right; } .receipt .b { font-weight: bold; } .receipt .big { font-size: 15px; }
.receipt .qr { width: 30mm; height: 30mm; margin: 4px auto; display: block; }
.receipt .warn { border: 1px solid #000; padding: 2px; text-align: center; font-size: 10px; margin-top: 4px; }

/* Reporte tamaño carta */
.report { font-family: "Segoe UI", Arial, sans-serif; font-size: 10.5px; color: #000; background: #fff; }
.report h1 { font-size: 17px; margin: 0; color: #000; } .report h2 { font-size: 13px; margin: 14px 0 6px; color: #000; border-bottom: 2px solid #000; padding-bottom: 3px; }
.report table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.report th, .report td { color: #000; padding: 2px 5px; border-bottom: 1px solid #ccc; font-size: 10.5px; text-transform: none; letter-spacing: 0; }
.report th { background: #eee; font-weight: 600; }
.report .r { text-align: right; } .report .b { font-weight: 700; } .report .muted { color: #555; }
.report .sale { break-inside: avoid; border: 1px solid #999; border-radius: 4px; padding: 5px 7px; margin-bottom: 6px; }
.report .sale-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 3px; flex-wrap: wrap; }
.report .voided { background: #f3f3f3; } .report .tag-void { border: 1px solid #000; padding: 0 4px; font-size: 9px; }
.report .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.report .total-row td { font-size: 13px; font-weight: 800; border-top: 2px solid #000; }
.report .breakdown { break-inside: avoid; }

@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: minmax(0, 1fr); } .sidebar { flex-direction: row; overflow-x: auto; padding: 10px; }
  #nav { grid-auto-flow: column; } .sidebar-foot { margin: 0; grid-auto-flow: column; }
  .pos { grid-template-columns: minmax(0, 1fr); height: auto; } .charts, .charts-2 { grid-template-columns: 1fr; }
}
.table-chip.disabled { opacity: .5; cursor: default; }

/* Tiempo real */
.live { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #c0392b; display: inline-block; }
.live-dot.on { background: #3fb27f; box-shadow: 0 0 6px #3fb27f; }
.live-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; border-color: var(--accent-2); }

.table-chip:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.table-chip.active { background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); }
