/* ============================================================
   CAFETERÍA COFFEE FIT — Estilos del punto de venta
   Identidad: rosado y beige de la marca, café oscuro del logo
   para textos y barra lateral, panel de ticket con borde
   perforado como recibo térmico.
   ============================================================ */
:root {
  --ink: #3d2420;
  --ink-2: #4a2c26;
  --ink-3: #5a3931;
  --surface: #f6efe7;
  --card: #fffdfa;
  --line: #eadfd2;
  --text: #3a2a25;
  --muted: #8a6a5e;
  --primary: #c2586f;
  --primary-strong: #a84158;
  --primary-soft: #f9e4e9;
  --amber: #a9761c;
  --amber-soft: #f9efdc;
  --danger: #b3402a;
  --danger-soft: #f9e9e4;
  --blue-soft: #f0e4dc;
  --blue: #7a5546;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(61, 36, 32, .06), 0 4px 14px rgba(61, 36, 32, .08);
  --mono: "Consolas", "Menlo", "Liberation Mono", monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
.hidden { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  background: var(--ink); color: #fff; transition: background .12s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #97331f; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #f4ece2; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: 7px;
  background: transparent; color: var(--muted); border: 1px solid transparent;
}
.btn-icon:hover { background: #f3eadf; color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(194, 88, 111, .16); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- Pantalla de acceso ---------- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  background-image: radial-gradient(ellipse at 20% 10%, #5a352c 0%, var(--ink) 55%);
  padding: 20px;
}
.login-card {
  width: 380px; max-width: 100%; background: #fff; border-radius: 12px 12px 0 0;
  padding: 34px 32px 30px; position: relative; box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.login-card::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -9px; height: 9px;
  background:
    linear-gradient(45deg, #fff 5px, transparent 0),
    linear-gradient(-45deg, #fff 5px, transparent 0);
  background-size: 11px 9px; background-repeat: repeat-x;
}
.login-card .eyebrow { color: var(--primary); }
.login-logo {
  display: block; width: 92px; height: 92px; object-fit: contain;
  margin: 0 auto 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary-soft);
}
.login-card h1 { font-size: 24px; margin: 4px 0 20px; letter-spacing: -.01em; }
.login-error {
  background: var(--danger-soft); color: var(--danger); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 12px;
}
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Estructura de la aplicación ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: none; background: var(--ink); color: #e7d3c8;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 16px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex; align-items: center; gap: 10px;
}
.brand-logo {
  width: 42px; height: 42px; flex: none; object-fit: contain;
  border-radius: 50%; background: #fff; border: 2px solid rgba(255, 255, 255, .25);
}
.brand-text { min-width: 0; }
.brand .eyebrow { color: #bd9384; }
.brand-name { color: #fff; font-weight: 700; font-size: 16px; margin-top: 3px; line-height: 1.25; word-break: break-word; }
.nav { padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-btn {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: transparent; border: 0; color: #e7d3c8;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  text-align: left; transition: background .12s, color .12s;
}
.nav-btn svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-btn.active { background: var(--primary); color: #fff; }
.nav-btn.active svg { opacity: 1; }
.sidebar-user {
  padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex: none;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .role { font-size: 11px; color: #bd9384; text-transform: capitalize; }
.sidebar-user .btn-icon { color: #bd9384; }
.sidebar-user .btn-icon:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 18px; letter-spacing: -.01em; }
.cash-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.cash-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.cash-pill.open { border-color: #eccbd4; background: var(--primary-soft); color: var(--primary-strong); }
.cash-pill.open .dot { background: var(--primary); }
.cash-pill.closed { border-color: #f0d9b0; background: var(--amber-soft); color: var(--amber); }
.cash-pill.closed .dot { background: var(--amber); }

.content { padding: 22px; flex: 1; }
.view { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar .input { width: auto; }
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}
.search-wrap .input { padding-left: 32px; min-width: 230px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .value.pos { color: var(--primary-strong); }
.stat .value.neg { color: var(--danger); }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid #f3ece2; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fbf6ef; }
table.data td.r, table.data th.r { text-align: right; }
table.data .actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px;
}
.badge-green { background: var(--primary-soft); color: var(--primary-strong); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-gray { background: #f0e8dd; color: var(--muted); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- Punto de venta ---------- */
.pos-layout {
  display: grid; grid-template-columns: 1fr 370px; gap: 18px;
  align-items: start;
}
.pos-search-row { display: flex; gap: 10px; margin-bottom: 12px; }
.pos-search-row .search-wrap { flex: 1; }
.pos-search-row .input { width: 100%; padding: 12px 12px 12px 34px; font-size: 15px; }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 13px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip:hover { border-color: #cdb2a5; color: var(--text); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.product-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 6px;
  min-height: 96px; transition: border-color .1s, box-shadow .1s;
}
.product-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(194, 88, 111, .14); }
.product-card:disabled { opacity: .45; }
.product-card .p-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.product-card .p-meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.product-card .p-price { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--primary-strong); }
.product-card .p-stock { font-size: 11px; color: var(--muted); }
.product-card .p-stock.low { color: var(--amber); font-weight: 700; }
.product-card .p-stock.out { color: var(--danger); font-weight: 700; }

/* Panel de ticket (firma visual: recibo con borde perforado) */
.ticket-panel {
  background: #fff; border: 1px solid var(--line); border-radius: 10px 10px 0 0;
  position: sticky; top: 76px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.ticket-panel::after {
  content: ""; position: absolute; left: -1px; right: -1px; bottom: -9px; height: 9px;
  background:
    linear-gradient(45deg, #fff 5px, transparent 0),
    linear-gradient(-45deg, #fff 5px, transparent 0);
  background-size: 11px 9px; background-repeat: repeat-x;
  filter: drop-shadow(0 2px 1px rgba(61, 36, 32, .08));
}
.ticket-head {
  padding: 13px 16px; border-bottom: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.ticket-head .eyebrow { color: var(--text); }
.ticket-items { max-height: 42vh; overflow-y: auto; padding: 6px 0; }
.ticket-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 8px 16px; border-bottom: 1px solid #f4ede3;
}
.ticket-item:last-child { border-bottom: 0; }
.ticket-item .t-name { font-size: 13.5px; font-weight: 600; }
.ticket-item .t-line { font-family: var(--mono); font-weight: 700; font-size: 14px; text-align: right; align-self: center; }
.ticket-item .t-controls { display: flex; align-items: center; gap: 6px; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.qty-stepper button {
  width: 26px; height: 26px; border: 0; background: #f4ede3; font-size: 15px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.qty-stepper button:hover { background: #eadfd2; }
.qty-stepper input {
  width: 44px; height: 26px; border: 0; text-align: center; font-family: var(--mono);
  font-size: 13px; outline: none; -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ticket-item .unit-price { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.ticket-empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.ticket-totals { border-top: 1px dashed var(--line); padding: 12px 16px; font-family: var(--mono); }
.ticket-totals .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 2px 0; }
.ticket-totals .row.big { font-size: 21px; font-weight: 700; color: var(--text); padding-top: 7px; }
.ticket-actions { padding: 12px 16px 18px; display: flex; gap: 10px; }
.ticket-actions .btn-primary { flex: 1; padding: 13px; font-size: 16px; }

.pos-blocked {
  padding: 18px; background: var(--amber-soft); border: 1px solid #f0d9b0;
  border-radius: 10px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center;
  color: var(--amber); font-weight: 600; font-size: 14px;
}
.pos-blocked .btn { margin-left: auto; }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(46, 26, 22, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 18px;
}
.modal {
  background: #fff; border-radius: 12px; width: 480px; max-width: 100%;
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.modal.wide { width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }

/* Modal de cobro */
.pay-total { text-align: center; margin-bottom: 16px; }
.pay-total .label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.pay-total .amount { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 14px; }
.segmented button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 9px 6px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.segmented button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.quick-cash { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.quick-cash button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 6px 12px; font-size: 13px; font-family: var(--mono); font-weight: 700;
}
.quick-cash button:hover { border-color: var(--primary); color: var(--primary-strong); }
.change-line {
  display: flex; justify-content: space-between; align-items: baseline;
  background: #f4ede3; border-radius: 8px; padding: 11px 14px; margin-top: 12px;
}
.change-line .amount { font-family: var(--mono); font-size: 24px; font-weight: 700; }
.change-line.neg .amount { color: var(--danger); }

/* Vista previa del ticket */
.ticket-preview-wrap { display: flex; justify-content: center; background: #efe6da; border-radius: 10px; padding: 18px; max-height: 55vh; overflow-y: auto; }

/* ---------- Barras de reporte ---------- */
.bar-list { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .bar-track { background: #f0e8dd; border-radius: 6px; height: 20px; overflow: hidden; }
.bar-row .bar-fill { background: var(--primary); height: 100%; border-radius: 6px; min-width: 2px; }
.bar-row .bar-val { font-family: var(--mono); font-weight: 700; white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.section-gap { margin-bottom: 16px; }

/* ---------- Avisos (toasts) ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast {
  background: var(--ink); color: #fff; border-radius: 9px; padding: 11px 16px;
  font-size: 14px; box-shadow: 0 10px 26px rgba(0, 0, 0, .3);
  animation: pop .15s ease; max-width: 340px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary-strong); }

/* ---------- Impresión de tickets ---------- */
#print-area { display: none; }
.ticket-doc {
  font-family: var(--mono); color: #000; background: #fff;
  width: 72mm; padding: 2mm 1mm; font-size: 12px; line-height: 1.4;
}
.ticket-doc.w58 { width: 48mm; font-size: 10.5px; }
.ticket-doc .t-logo {
  display: block; width: 30mm; margin: 0 auto 1.5mm;
  filter: grayscale(1);
}
.ticket-doc.w58 .t-logo { width: 24mm; }
.ticket-doc .t-center { text-align: center; }
.ticket-doc .t-bold { font-weight: 700; }
.ticket-doc .t-big { font-size: 14px; }
.ticket-doc.w58 .t-big { font-size: 12px; }
.ticket-doc hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.ticket-doc table { width: 100%; border-collapse: collapse; }
.ticket-doc td { padding: 1px 0; vertical-align: top; font-size: inherit; }
.ticket-doc td.r { text-align: right; white-space: nowrap; }
.ticket-doc .t-foot { margin-top: 8px; }

@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  body { background: #fff; }
  @page { margin: 0; }
}

/* ---------- Adaptación a pantallas pequeñas ---------- */
@media (max-width: 1000px) {
  .pos-layout { grid-template-columns: 1fr; }
  .ticket-panel { position: static; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { border-bottom: 0; padding: 12px 14px; flex: none; }
  .nav { flex-direction: row; padding: 8px; }
  .nav-btn { padding: 8px 10px; }
  .nav-btn span { display: none; }
  .sidebar-user { border-top: 0; margin-left: auto; }
  .sidebar-user .who { display: none; }
  .content { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; }
}

/* Enfoque visible con teclado */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-btn:focus-visible, .btn:focus-visible { outline-offset: 1px; }

/* ---------- Sucursal activa (barra superior) ---------- */
.branch-wrap {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid #eccbd4; background: var(--primary-soft);
  border-radius: 999px; padding: 4px 6px 4px 12px;
}
.branch-wrap svg { width: 15px; height: 15px; color: var(--primary-strong); flex: none; }
.branch-select {
  border: 0; background: transparent; font-size: 13px; font-weight: 700;
  color: var(--primary-strong); outline: none; max-width: 190px; cursor: pointer;
}
.branch-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid #eccbd4; background: var(--primary-soft);
  color: var(--primary-strong); border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 700;
}
.branch-pill svg { width: 15px; height: 15px; }
.branch-pill.warn { border-color: #f0d9b0; background: var(--amber-soft); color: var(--amber); }

/* ---------- Indicador de conexión / ventas pendientes ---------- */
.net-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 600; font-family: var(--mono);
  border: 1px solid #eccbd4; background: var(--primary-soft); color: var(--primary-strong);
  cursor: pointer;
}
.net-pill.off {
  background: #f9e9e4; border-color: #e8c4b6; color: var(--danger);
}
