/* SincroPOS — tema oscuro táctil */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273549;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --green: #22c55e;
  --green-dark: #16a34a;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
input, textarea, select { user-select: text; }

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-2);
  transition: filter .1s, transform .05s;
}
button:active { transform: scale(.97); filter: brightness(1.15); }
button:disabled { opacity: .4; pointer-events: none; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn { padding: 14px 20px; font-size: 16px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-green { background: var(--green-dark); color: #fff; }
.btn-red { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #1e3a5f 0%, var(--bg) 60%);
}
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px; width: 380px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 { font-size: 26px; text-align: center; }
.login-card h1 span { color: var(--accent); }
.login-card .error { color: var(--red); font-size: 14px; text-align: center; min-height: 18px; }

/* ---------- Layout caja ---------- */
.caja {
  display: grid;
  grid-template-rows: 60px 1fr;
  height: 100vh;
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 0 14px;
}
.topbar .brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.topbar .brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; white-space: nowrap;
}
.chip.ok { border-color: var(--green); color: var(--green); }
.chip.warn { border-color: var(--amber); color: var(--amber); }
.badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 12px; padding: 1px 8px; margin-left: 6px; font-weight: 700;
}

.main {
  display: grid;
  grid-template-columns: 1fr 420px;
  overflow: hidden;
}

/* ---------- Panel catálogo ---------- */
.catalogo { display: flex; flex-direction: column; overflow: hidden; padding: 12px; gap: 10px; }
.cat-header { display: flex; align-items: center; gap: 10px; }
.cat-header h2 { font-size: 18px; flex: 1; text-align: center; }
.btn-volver { padding: 12px 22px; font-size: 16px; background: var(--amber); color: #111; font-weight: 700; }
.grid-botones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  overflow-y: auto;
  align-content: start;
  padding-bottom: 20px;
}
.btn-cat, .btn-prod {
  min-height: 86px; padding: 10px; font-size: 16px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  text-transform: uppercase;
}
.btn-cat { border-left: 5px solid var(--accent); font-size: 17px; }
.btn-prod .precio { color: var(--accent); font-size: 15px; font-weight: 600; }

/* ---------- Panel pedido ---------- */
.pedido {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border-left: 1px solid var(--border);
}
.pedido-head { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.pedido-head .fila { display: flex; gap: 8px; align-items: center; }
.pedido-num { font-weight: 700; color: var(--amber); white-space: nowrap; }
.puestos { display: flex; gap: 8px; flex-wrap: wrap; }
.puesto-chip {
  min-width: 56px; height: 48px; border-radius: 12px; font-size: 16px; font-weight: 700;
  border: 1px solid var(--border);
}
.puesto-chip.activo { background: var(--accent); color: #fff; border-color: var(--accent); }

.items { flex: 1; overflow-y: auto; padding: 0 8px; }
.item-row {
  display: grid; grid-template-columns: 44px 1fr auto auto; gap: 8px;
  align-items: center; padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}
.item-row .p-badge {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; text-align: center; padding: 8px 0; font-weight: 700; font-size: 14px;
}
.item-row .nombre { font-size: 15px; font-weight: 600; }
.item-row .nombre small { display: block; color: var(--muted); font-weight: 400; }
.item-row .cant { display: flex; align-items: center; gap: 6px; }
.item-row .cant button {
  width: 38px; height: 38px; font-size: 18px; font-weight: 700; border-radius: 10px;
}
.item-row .total { font-weight: 700; text-align: right; min-width: 74px; }
.item-row .del { color: var(--red); background: transparent; font-size: 18px; width: 34px; height: 38px; }
.item-row.pendiente { background: rgba(14,165,233,.07); }

.pedido-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.total-grande { display: flex; justify-content: space-between; align-items: baseline; }
.total-grande .valor { font-size: 34px; font-weight: 800; color: var(--green); }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acciones .btn { min-height: 58px; font-size: 17px; }
.acciones .full { grid-column: 1 / -1; }

/* ---------- Modales ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  width: 560px; max-width: 94vw; max-height: 92vh; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 20px; }
.modal .fila { display: flex; gap: 10px; align-items: center; }
.modal .fila > * { flex: 1; }
.modal-close { position: sticky; float: right; background: transparent; font-size: 22px; color: var(--muted); }

.medios-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-medio { min-height: 56px; font-size: 16px; font-weight: 700; border: 1px solid var(--border); }
.btn-medio.activo { background: var(--accent); color: #fff; }
.billetes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.billetes button { min-height: 48px; font-weight: 700; }
.cambio-linea { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; }
.cambio-linea .ok { color: var(--green); }
.cambio-linea .falta { color: var(--red); }

.lista-abiertos { display: flex; flex-direction: column; gap: 8px; }
.pedido-abierto {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  text-align: left; padding: 14px; border: 1px solid var(--border);
}
.pedido-abierto .num { color: var(--amber); font-weight: 800; font-size: 17px; }
.pedido-abierto .tot { font-weight: 700; color: var(--green); }

table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tabla th, table.tabla td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; }
table.tabla td.num, table.tabla th.num { text-align: right; }

/* ---------- Impresión 80mm ---------- */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    display: block !important;
    position: absolute; left: 0; top: 0;
    width: 72mm;
    color: #000; background: #fff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
  }
  @page { margin: 2mm; size: 80mm auto; }
}
#print-area .t-center { text-align: center; }
#print-area .t-right { text-align: right; }
#print-area .t-bold { font-weight: bold; }
#print-area .t-grande { font-size: 14px; font-weight: bold; }
#print-area hr { border: none; border-top: 1px dashed #000; margin: 4px 0; }
#print-area table { width: 100%; border-collapse: collapse; font-size: 11px; }
#print-area td { padding: 1px 0; vertical-align: top; }
#print-area .puesto-titulo { font-weight: bold; margin-top: 4px; }
