@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg: #12151a; --panel: #1a1f26; --panel-raised: #212832; --border: #2a323c;
  --text: #edeff2; --muted: #8b95a1;
  --copper: #d98e4a; --copper-soft: rgba(217,142,74,0.14);
  --green: #5fa777; --green-soft: rgba(95,167,119,0.14);
  --blue: #6b9bd8; --blue-soft: rgba(107,155,216,0.14);
  --danger: #e0665a; --danger-soft: rgba(224,102,90,0.14);
  --r-sm: 7px; --r-md: 10px; --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.28);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1100px 620px at 14% -8%, rgba(217,142,74,0.07), transparent 60%),
              radial-gradient(900px 500px at 100% 0%, rgba(107,155,216,0.05), transparent 55%),
              var(--bg);
  background-attachment: fixed;
  color: var(--text); font-family: 'Inter', sans-serif; min-height: 100vh;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }
.mono { font-family: 'JetBrains Mono', monospace; }
.display { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.01em; }

/* scrollbars: finos y a tono con la paleta oscura */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-raised); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
* { scrollbar-color: var(--panel-raised) transparent; scrollbar-width: thin; }

.header { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--panel-raised), var(--panel)); gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--copper-soft); color: var(--copper); display: flex; align-items: center; justify-content: center; border: 1px solid rgba(217,142,74,0.35); box-shadow: var(--shadow-sm); }
.brand-mark-img { background: #000; border-color: var(--border); overflow: hidden; padding: 0; }
.brand-mark-img img { width: 100%; height: 100%; object-fit: cover; }
.login-brand .brand-mark-img { width: 76px; height: 76px; border-radius: var(--r-lg); box-shadow: var(--shadow-md); }
.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }

.ticker { display: flex; align-items: center; gap: 10px; background: #0d1013; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.02); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); position: relative; }
.dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--green); opacity: 0.5; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.7; } 100% { transform: scale(1.8); opacity: 0; } }
.ticker-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.ticker-val { font-size: 15px; font-weight: 600; color: var(--green); }
.spin { animation: spin-anim 0.8s linear infinite; display: inline-block; }
@keyframes spin-anim { to { transform: rotate(360deg); } }

.session { display: flex; align-items: center; gap: 8px; background: var(--panel-raised); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px 10px; font-size: 13px; }
.role-tag { font-size: 10px; padding: 1px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.role-tag.Admin { background: var(--copper-soft); color: var(--copper); }
.role-tag.Vendedor { background: var(--blue-soft); color: var(--blue); }

.tabs { display: flex; gap: 2px; padding: 10px 26px 0; border-bottom: 1px solid var(--border); }
.tab { display: flex; align-items: center; gap: 6px; padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; user-select: none; background: none; border-top: none; border-left: none; border-right: none; border-radius: var(--r-sm) var(--r-sm) 0 0; transition: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease); }
.tab.active { color: var(--text); border-bottom-color: var(--copper); background: linear-gradient(180deg, rgba(217,142,74,0.08), transparent); }
.tab:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.03); }

.body { flex: 1; overflow: auto; padding: 20px 26px 30px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 11px; min-width: 240px; transition: border-color 0.15s var(--ease); }
.search:focus-within { border-color: rgba(217,142,74,0.45); }
.search input { background: transparent; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--copper-soft); color: var(--copper); border: 1px solid rgba(217,142,74,0.35); padding: 9px 14px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.btn:hover { background: rgba(217,142,74,0.22); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { color: var(--text); background: var(--panel-raised); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(224,102,90,0.35); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible, .tab:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); }
table.tbl tbody td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr { transition: background 0.12s var(--ease); }
table.tbl tbody tr:hover { background: rgba(255,255,255,0.025); }
tr.low-stock td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--panel-raised); color: var(--muted); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 4px; }
.badge.danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(224,102,90,0.35); }
.badge.green { color: var(--green); background: var(--green-soft); border-color: rgba(95,167,119,0.35); }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }

.icon-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; transition: background 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease); }
.icon-btn:hover { color: var(--text); background: var(--panel-raised); transform: translateY(-1px); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.modal-overlay { position: fixed; inset: 0; background: rgba(5,6,8,0.7); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; animation: overlay-in 0.15s var(--ease); }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); width: 100%; max-width: 460px; padding: 22px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-md); animation: modal-in 0.18s var(--ease); position: relative; }
.modal-close-btn { position: absolute; top: 14px; right: 14px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; display: flex; align-items: center; gap: 8px; padding-right: 28px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select { width: 100%; background: var(--panel-raised); border: 1px solid var(--border); color: var(--text); padding: 9px 10px; border-radius: var(--r-sm); font-size: 13px; outline: none; transition: border-color 0.15s var(--ease); }
.field input:focus, .field select:focus { border-color: rgba(217,142,74,0.5); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-inline { display: flex; gap: 8px; }
.field-inline input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.segmented { display: flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.segmented button { flex: 1; padding: 10px; background: var(--panel-raised); color: var(--muted); border: none; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.15s var(--ease), color 0.15s var(--ease); }
.segmented button.active.entrada { background: var(--green-soft); color: var(--green); }
.segmented button.active.salida { background: var(--danger-soft); color: var(--danger); }
.error-text { color: var(--danger); font-size: 12.5px; margin: -4px 0 10px; }
.hint { font-size: 11.5px; color: var(--muted); background: var(--panel-raised); border: 1px dashed var(--border); border-radius: var(--r-sm); padding: 9px 11px; margin-top: 14px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); padding: 15px 17px; overflow-x: auto; box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(217,142,74,0.1); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-size: 21px; font-weight: 600; font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.01em; }

.hist-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; transition: background 0.12s var(--ease); }
.hist-item:hover { background: rgba(255,255,255,0.02); }
.hist-time { color: var(--muted); font-size: 11.5px; min-width: 130px; }
.hist-user { color: var(--copper); font-weight: 600; min-width: 110px; }

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

.barcode-card { background: #fff; border-radius: var(--r-md); padding: 18px; text-align: center; color: #12151a; }
.barcode-card .name { font-weight: 700; margin-bottom: 10px; font-family: 'Space Grotesk', sans-serif; }
.barcode-card .code { font-family: 'JetBrains Mono', monospace; letter-spacing: 0.1em; margin-top: 8px; font-size: 13px; }
.barcode-card .price { margin-top: 6px; font-size: 19px; font-weight: 700; }

.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow-md); animation: modal-in 0.2s var(--ease); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 36px; }
.pass-eye { position: absolute; right: 6px; top: 6px; background: none; border: none; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 5px; transition: color 0.15s var(--ease); }
.pass-eye:hover { color: var(--text); }

.banner-error { background: rgba(224,102,90,0.12); color: var(--danger); font-size: 12.5px; padding: 8px 26px; border-bottom: 1px solid rgba(224,102,90,0.25); }
.banner-info { font-size: 10.5px; color: var(--muted); padding: 5px 26px 0; }

svg.icon { display: inline-block; vertical-align: -3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 24px; color: #000; background: #fff; }
  .print-area .price { color: #000 !important; }
}

@media (max-width: 640px) {
  .header { padding: 12px 16px; flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: space-between; }
  .ticker { flex: 1; justify-content: space-between; }
  .session { justify-content: space-between; }

  .tabs { padding-left: 16px; padding-right: 16px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; padding: 9px 11px; font-size: 12.5px; }

  .body, .banner-error, .banner-info { padding-left: 16px; padding-right: 16px; }
  table.tbl { font-size: 12px; }
  .hist-time, .hist-user { min-width: unset; }
  .hist-item { flex-wrap: wrap; }

  .toolbar { gap: 10px; }
  .search { min-width: 0; width: 100%; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .stat-value { font-size: 18px; }

  .modal { padding: 16px; max-width: 100%; }
  .field-row { flex-direction: column; gap: 0; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn, .modal-actions .btn.ghost { flex: 1; justify-content: center; }

  /* punto de venta: el carrito pasa de una fila a dos, más cómodo para tocar con el pulgar */
  #venta-cart > div { flex-wrap: wrap; row-gap: 8px; }
  #venta-cart > div > div:first-child { flex-basis: 100%; }
  #venta-cart input[data-qty] { width: 60px; }
  #btn-camera-scan { width: 100%; justify-content: center; }
}

