@import url("/shared/tokens.css");

body { background: var(--bg); }
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex: none;
}
.topbar .titles { min-width: 0; }
.topbar h1 { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav button {
  border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: 12.5px;
  padding: 7px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.nav button.active { background: var(--surface-2); color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.role-chip {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.role-chip.admin { background: var(--ok-bg); color: var(--ok); }
.role-chip.gerente { background: var(--warn-bg); color: var(--warn); }

.main { flex: 1; padding: 18px 16px 60px; max-width: 900px; margin: 0 auto; width: 100%; }
.main.narrow { max-width: 640px; }
.screen[hidden] { display: none; }

/* ---------- Login ---------- */
.login-wrap { max-width: 360px; margin: 12vh auto 0; }
.login-wrap .mark-lg {
  width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; margin: 0 auto 16px;
}

/* ---------- Section head ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }

/* ---------- Store / inventory rows (manage view) ---------- */
.store-card { margin-bottom: 12px; }
.store-card .store-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 10px; }
.store-card .store-head .t { font-size: 15px; font-weight: 800; }
.store-card .store-head .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.store-card .chevron { color: var(--muted); transition: transform .15s ease; flex: none; }
.store-card.open .chevron { transform: rotate(90deg); }
.store-card .store-body { margin-top: 14px; display: none; }
.store-card.open .store-body { display: block; }

.inv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  cursor: pointer; margin-bottom: 8px;
}
.inv-row:hover { border-color: var(--accent); }
.inv-row .t { font-size: 13.5px; font-weight: 700; }
.inv-row .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.inv-row .badges { display: flex; gap: 6px; flex: none; }

.badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 999px; }
.badge.open { background: var(--ok-bg); color: var(--ok); }
.badge.closed { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.new-inv-form { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }

/* ---------- Inventory detail ---------- */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-header .titles h2 { margin: 0 0 2px; font-size: 19px; }
.detail-header .titles .store { font-size: 12.5px; color: var(--muted); }
.stat-row { display: flex; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.stat-row .stat .v { font-family: var(--font-mono); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row .stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.export-btn { display: flex; align-items: center; gap: 12px; text-align: left; padding: 13px; }
.export-btn .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.export-btn .t { font-size: 13px; font-weight: 700; }
.export-btn .s { font-size: 11px; color: var(--muted); margin-top: 1px; }

.table-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.table-toolbar input { flex: 1; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13.5px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 9px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.unknown-row { background: var(--warn-bg); }
td.b { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
td.d { max-width: 220px; }
td.d .who { font-size: 11px; color: var(--muted); margin-top: 1px; }
td.scanners { font-size: 11.5px; color: var(--muted); }
td.q { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
td.q input { width: 62px; text-align: right; padding: 5px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-family: var(--font-mono); font-size: 13px; }
td.act { text-align: right; white-space: nowrap; }
.icon-btn { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }

.activity-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.activity-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.activity-item:last-child { border-bottom: none; }
.activity-item .who { font-weight: 700; }
.activity-item .when { color: var(--muted); font-size: 11px; white-space: nowrap; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kv-grid .kv .v { font-family: var(--font-mono); font-size: 17px; font-weight: 700; }
.kv-grid .kv .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

.code-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-family: var(--font-mono); font-size: 12.5px; overflow-x: auto; white-space: pre; }
.empty-state { text-align: center; padding: 26px 16px; color: var(--muted); font-size: 13px; }

/* ---------- Team / users ---------- */
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
}
.user-row .t { font-size: 13.5px; font-weight: 700; }
.user-row .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.user-row .acts { display: flex; gap: 6px; flex: none; }
.user-row.inactive { opacity: 0.55; }

/* ---------- Scan screen (camera) ---------- */
.camera-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #0a0a0a; aspect-ratio: 4 / 3; border: 1px solid var(--line); }
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-off { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #cfcfcf; background: #0a0a0a; text-align: center; padding: 20px; }
.camera-off .icon { font-size: 30px; opacity: 0.8; }
.camera-off .msg { font-size: 12.5px; color: #9a9a9a; max-width: 260px; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 2px solid rgba(255,255,255,0.85); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,0.28); pointer-events: none; }
.scan-frame::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); box-shadow: 0 0 8px 1px var(--accent); animation: scanline 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .scan-frame::before { animation: none; top: 50%; } }
@keyframes scanline { 0% { top: 0%; } 50% { top: 96%; } 100% { top: 0%; } }
.camera-controls { display: flex; gap: 8px; margin-top: 10px; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.status-line .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }

.details { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.details summary { padding: 12px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.details summary::-webkit-details-marker { display: none; }
.details summary::after { content: "+"; font-size: 16px; color: var(--muted); }
.details[open] summary::after { content: "\2212"; }
.details .body { padding: 0 14px 14px; }

.search-results { margin-top: 6px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.search-results .row { padding: 9px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.search-results .row:last-child { border-bottom: none; }
.search-results .row:hover { background: var(--surface-2); }
.search-results .row .b { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.search-results .empty { padding: 10px; font-size: 12.5px; color: var(--muted); text-align: center; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(10,10,8,0.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: 100%; max-width: 640px; background: var(--surface); border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 30px rgba(0,0,0,0.25); animation: sheetup .18s ease; }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
@keyframes sheetup { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; margin-bottom: 10px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.sheet .barra { font-family: var(--font-mono); font-size: 20px; font-weight: 700; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.sheet .desc { font-size: 14.5px; margin-top: 3px; line-height: 1.4; }
.sheet .chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sheet .already { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.qty-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.qty-step { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 20px; font-weight: 700; cursor: pointer; flex: none; }
.qty-input { flex: 1; height: 44px; text-align: center; font-family: var(--font-mono); font-size: 20px; font-weight: 700; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-variant-numeric: tabular-nums; }
.qty-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet .actions > * { flex: 1; }

.footer-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 10px; z-index: 15; }
.footer-stats { display: flex; gap: 16px; }
.footer-stats .stat .v { font-family: var(--font-mono); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.footer-stats .stat .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.pick-item .t { font-weight: 700; font-size: 14px; }
.pick-item .s { font-size: 12px; color: var(--muted); margin-top: 1px; }
