:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --border: #d1d5db;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #4f46e5;
  --danger: #e11d48;
}

* { box-sizing: border-box; }
html, body { font-size: 14px !important; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
.app { min-height: 100vh; display: flex; flex-direction: column; width: 100% !important; max-width: none !important; margin: 0 !important; }
.app, .app * { line-height: 1.25; }
.hidden { display: none !important; }

.header {
  min-height: 54px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand {
  font-size: 13px !important;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  height: 30px;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 9px;
  background: transparent;
  color: #374151;
  font-size: 12px !important;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  white-space: nowrap;
}
.tab.active {
  background: #eef2ff;
  color: #4338ca;
  border-bottom-color: #4f46e5;
}

.right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.input,
.select {
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px !important;
  width: 100%;
  background: #fff;
}

.btn {
  height: 32px;
  border: 0;
  border-radius: 4px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px !important;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-indigo { background: #4f46e5; }
.btn-red { background: #e11d48; }
.btn-orange { background: #d97706; }
.btn-gray { background: #64748b; }
.btn-green { background: #16a34a; }
.btn-blue { background: #2563eb; }
.btn-purple { background: #9333ea; }

.badge {
  min-height: 32px;
  display: flex;
  align-items: center;
  background: #c7d2fe;
  color: #4338ca;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px !important;
  font-weight: 700;
  justify-content: center;
}

.register {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
  height: calc(100vh - 58px);
}

.panel {
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel-right {
  border-right: 0;
  background: var(--bg);
}

table { width: 100%; border-collapse: collapse; }
th {
  background: #f3f4f6;
  font-size: 11px !important;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid var(--border);
  height: 30px;
}
td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  font-size: 11px !important;
  height: 28px;
  line-height: 1.2;
}

.cart-wrap { flex: 1; overflow: auto; }
.row-sel { background: #eef2ff; }

.totals {
  padding: 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}
.tot-line {
  display: flex;
  justify-content: space-between;
  font-size: 11px !important;
  line-height: 1.3;
}
.tot-grand {
  font-size: 14px !important;
  color: #4338ca;
  font-weight: 800;
}

.controls { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: #6b7280; font-weight: 600; }

.products-filter {
  padding: 10px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scan { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.cards { padding: 10px; overflow: auto; }
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  cursor: pointer;
  width: 100%;
  max-width: 340px;
  min-height: 84px;
  margin-bottom: 8px;
}
.card:hover { border-color: #6366f1; }
.price {
  color: #4338ca;
  font-size: 13px !important;
  font-weight: 800;
}
.stock {
  background: #dcfce7;
  color: #166534;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px !important;
}

.status {
  position: fixed;
  top: 64px;
  right: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid;
  z-index: 10;
  font-size: 12px;
  font-weight: 600;
}
.ok { background: #dcfce7; border-color: #86efac; color: #166534; }
.err { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.box {
  background: #fff;
  border-radius: 6px;
  width: min(96vw, 1000px);
  max-height: 85vh;
  overflow: auto;
  padding: 12px;
}

.section { padding: 10px; }
.table-shell { background: #fff; border: 1px solid var(--border); }
.kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.k { padding: 8px; border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 4px; }
.k h4 { margin: 0; color: #1d4ed8; font-size: 12px; }
.k b { font-size: 14px; }
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; height: 200px; }
.bar { background: #3b82f6; height: 24px; }
.bar2 { background: #16a34a; height: 24px; }
.title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }

/* Hard safety: keep all UI text compact */
#app .brand,
#app .tab,
#app .btn,
#app .badge,
#app .input,
#app .select,
#app td,
#app th {
  letter-spacing: 0;
}

@media (max-width: 1100px) {
  .register { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--border); }
  .panel-right { min-height: 360px; }
  .header { min-height: 54px; }
}

@media (max-width: 820px) {
  .header { flex-direction: column; align-items: stretch; }
  .left, .right { width: 100%; }
  .left { justify-content: space-between; }
  .right { justify-content: flex-start; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .kpi { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .brand { font-size: 14px; }
  .tab { font-size: 12px; }
  .btn, .input, .select, .badge { font-size: 12px; }
  .tot-grand { font-size: 16px; }
  .grid3 { grid-template-columns: 1fr; }
  .scan { grid-template-columns: 1fr; }
}
