:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #64748b;
  --line: #d8dee8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --warn: #b7791f;
  --ok: #16803c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 16px;
}
a { color: inherit; text-decoration: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--primary-dark); }
.topbar nav { display: flex; gap: 8px; font-size: 13px; white-space: nowrap; }
.page { max-width: 980px; margin: 0 auto; padding: 12px; }
h1 { margin: 0 0 8px; font-size: 24px; line-height: 1.1; }
h2 { margin: 16px 0 8px; font-size: 18px; }
p { margin: 0 0 12px; }
.muted, small { color: var(--muted); }
.hero, .scan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.scan-head h1 {
  font-size: 32px;
  line-height: 1.05;
}
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions form { margin: 0; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.danger { background: #fff5f5; border-color: #fecaca; color: var(--danger); }
.button.small { min-height: 36px; padding: 7px 10px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.panel, .session-card, .item-card, .empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.panel { padding: 16px; margin-bottom: 12px; }
.panel.narrow { max-width: 420px; margin: 24px auto; }
.panel.compact { padding: 10px 12px; }
.subdetails {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.subdetails summary { cursor: pointer; font-weight: 800; }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 5px; font-weight: 700; }
input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font: inherit;
}
input:focus { outline: 3px solid rgba(15, 118, 110, .18); border-color: var(--primary); }
.flash {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.flash.error { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.list { display: grid; gap: 8px; }
.session-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
}
.session-card span:first-child { display: grid; gap: 3px; min-width: 0; }
.pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef2f7;
  font-weight: 800;
  white-space: nowrap;
}
.scan-form {
  display: grid;
  grid-template-columns: 1fr 72px 64px;
  gap: 8px;
  position: sticky;
  top: 55px;
  z-index: 9;
  padding: 8px 0 12px;
  background: var(--bg);
}
.scanner-hidden-form { display: none; }
.scanner-status {
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  color: #115e59;
  font-weight: 800;
  font-size: 13px;
}
.ean-input { font-size: 22px; font-weight: 800; }
.qty-input { text-align: center; font-weight: 800; }
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.kpis div {
  display: grid;
  gap: 2px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.kpis strong { font-size: 20px; }
.kpis span { color: var(--muted); font-size: 12px; }
.items { display: grid; gap: 10px; }
.item-card { display: grid; gap: 10px; padding: 12px; }
.item-card.last { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.item-card.missing { border-color: #fecaca; background: #fffafa; }
.item-main { display: grid; gap: 2px; }
.item-main strong { font-size: 18px; }
.qty-box {
  display: flex;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 800;
}
.qty-box.ok { color: var(--ok); background: #ecfdf5; }
.qty-box.warn { color: var(--warn); background: #fffbeb; }
.qty-box.over { color: #7c3aed; background: #f5f3ff; }
.price-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.price-grid div {
  padding: 8px;
  background: #f8fafc;
  border-radius: 8px;
  min-width: 0;
}
.price-grid span { display: block; color: var(--muted); font-size: 11px; }
.price-grid b { display: block; font-size: 14px; overflow-wrap: anywhere; }
.price-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}
.empty { padding: 18px; color: var(--muted); text-align: center; }
.catalog-search {
  display: grid;
  grid-template-columns: 1.3fr .8fr auto auto;
  gap: 8px;
  margin-bottom: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
}
.check input { width: auto; min-height: auto; }
.inline-check { justify-content: flex-start; }
.verify-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 10px;
  margin-bottom: 12px;
}
.verify-main, .verify-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.verify-card {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.verify-code {
  font-size: 22px;
  font-weight: 900;
  overflow-wrap: anywhere;
}
.verify-name {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}
.verify-qty, .verify-prices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.verify-qty div, .verify-prices div {
  display: grid;
  gap: 2px;
  padding: 9px;
  border-radius: 8px;
  background: #f8fafc;
}
.verify-qty span, .verify-prices span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.verify-qty strong {
  font-size: 28px;
  line-height: 1;
}
.verify-prices b {
  font-size: 16px;
  overflow-wrap: anywhere;
}
.danger-box {
  background: #fff1f2 !important;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.ok-text { color: var(--ok); }
.warn-text { color: var(--danger); }
.qty-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.qty-actions.single { grid-template-columns: repeat(2, 1fr); }
.qty-button {
  width: 100%;
  min-height: 52px;
  font-size: 18px;
}
.set-qty-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.set-qty-form input {
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}
.full-button { width: 100%; }
.verify-list {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: 68vh;
  overflow: auto;
}
.verify-list-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 6px 2px 8px;
  background: #fff;
  font-size: 20px;
  font-weight: 900;
}
.verify-row-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.verify-row-wrap.active {
  border-color: var(--primary);
  background: #f0fdfa;
}
.verify-row-wrap.cost-up {
  border-color: #fecaca;
}
.verify-row {
  list-style: none;
  cursor: pointer;
}
.verify-row::-webkit-details-marker { display: none; }
.verify-row a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  padding: 9px;
}
.verify-row strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}
.verify-row span {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.verify-row b {
  font-size: 16px;
}
.verify-row em {
  justify-self: start;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff1f2;
  color: var(--danger);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.row-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}
.row-edit-form label {
  gap: 3px;
  font-size: 12px;
}
.row-edit-form input {
  min-height: 36px;
  padding: 6px 8px;
}
.row-edit-form button {
  grid-column: 1 / -1;
}
.row-delete-form {
  padding: 0 8px 8px;
  background: #f8fafc;
}
.row-delete-form button {
  width: 100%;
}
.catalog-list { display: grid; gap: 8px; }
.product-row {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) 115px 82px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.product-code { font-weight: 800; overflow-wrap: anywhere; }
.product-name { display: grid; gap: 3px; min-width: 0; }
.product-price, .product-stock { display: grid; gap: 2px; text-align: right; font-weight: 800; }
.product-stock.low { color: var(--danger); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; }
.movement-list { display: grid; gap: 7px; }
.movement-row {
  display: grid;
  grid-template-columns: 150px 80px 120px 1fr;
  gap: 8px;
  align-items: center;
  padding: 9px;
  background: #f8fafc;
  border-radius: 8px;
}
.inline-form {
  margin-top: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.inline-form button { grid-column: 1 / -1; }
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.section-title h2 { margin: 0; }
.section-title span { color: var(--muted); font-size: 13px; font-weight: 700; }
.inbound-entry {
  border-color: rgba(15, 118, 110, .35);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .06);
}
.lookup-box {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  min-height: 44px;
  padding: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}
.lookup-box.found {
  border-style: solid;
  border-color: #99f6e4;
  background: #f0fdfa;
  color: var(--text);
}
.lookup-box.missing {
  border-style: solid;
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}
.history-table {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}
.history-row {
  display: grid;
  grid-template-columns: 140px minmax(180px, 1.3fr) minmax(110px, .8fr) 70px 90px 70px 70px 80px;
  gap: 8px;
  align-items: center;
  min-width: 880px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.history-row.head {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.progress { display: grid; gap: 10px; margin: 14px 0; }
.progress-bar {
  height: 18px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width .2s ease;
}
.log {
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  background: #111827;
  color: #d1fae5;
  border-radius: 8px;
  font-size: 12px;
  white-space: pre-wrap;
}

@media (max-width: 540px) {
  .topbar nav a { font-size: 12px; }
  .page { padding: 10px; }
  h1 { font-size: 21px; }
  .scan-head { align-items: flex-start; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .price-grid { grid-template-columns: repeat(2, 1fr); }
  .price-form { grid-template-columns: 1fr 1fr; }
  .price-form button { grid-column: 1 / -1; }
  .inline-form { grid-template-columns: 1fr; }
  .section-title { display: grid; }
  .head-actions { flex-direction: column; align-items: stretch; }
  .verify-layout { grid-template-columns: 1fr; }
  .verify-list { max-height: none; }
  .verify-qty strong { font-size: 25px; }
  .qty-actions { grid-template-columns: repeat(2, 1fr); }
  .set-qty-form { grid-template-columns: 1fr; }
  .catalog-search { grid-template-columns: 1fr; }
  .product-row { grid-template-columns: 1fr; }
  .product-price, .product-stock { text-align: left; }
  .movement-row { grid-template-columns: 1fr 70px; }
  .movement-row small { grid-column: 1 / -1; }
}
