/* ============================================================
   Облік магазину: компоненти поверх теми Task Manager (style.css)
   ============================================================ */

/* На ноутбуці/касі контент по центру, таб-бар теж. */
@media (min-width: 900px) {
  .app { max-width: 1080px; margin: 0 auto; }
  .tabbar { max-width: 1080px; margin: 0 auto; border-radius: 22px 22px 0 0; border: 1px solid var(--border); }
  .sheet__panel { max-width: 760px; margin: 0 auto; }
}

.header__actions { display: flex; gap: 8px; align-items: center; }

.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, 'SF Mono', Consolas, monospace; letter-spacing: 0.02em; }

/* ------------------------------------------------------------- вхід --- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}

.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login__card .form { text-align: left; margin-top: 18px; }
.login__card .splash__logo { margin: 0 auto 12px; animation: none; }
.login__title { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.login__text { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }

/* --------------------------------------------------------- пошук/скан --- */

.search {
  position: relative;
  margin: 0 16px 12px;
}

.search .input { padding-left: 44px; }

.search__icon {
  position: absolute;
  left: 15px; top: 50%;
  transform: translateY(-50%);
  color: var(--violet-500);
  font-size: 17px;
  pointer-events: none;
}

.scan { position: relative; }

.scan .input {
  padding: 15px 16px 15px 48px;
  font-size: 16px;
  border-width: 2px;
  border-color: var(--violet-300);
}

.scan__icon {
  position: absolute;
  left: 15px; top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  pointer-events: none;
}

.scan.is-flash .input { border-color: var(--success); box-shadow: 0 0 0 4px rgba(36, 169, 127, 0.18); }
.scan.is-miss .input { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(226, 84, 124, 0.16); }

.suggest {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}

.suggest__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.suggest__item:hover, .suggest__item.is-active { background: var(--violet-050); }
.suggest__body { flex: 1; min-width: 0; }
.suggest__title { font-weight: 600; font-size: 14px; }
.suggest__meta { font-size: 12px; color: var(--text-muted); }
.suggest__price { font-weight: 700; font-size: 14px; white-space: nowrap; }
.suggest__empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 13.5px; }

/* --------------------------------------------------------------- фото --- */

.thumb {
  width: 46px; height: 46px;
  flex: 0 0 46px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--violet-100);
  display: grid;
  place-items: center;
  color: var(--violet-500);
  font-size: 18px;
  overflow: hidden;
}

.thumb--sm { width: 38px; height: 38px; flex-basis: 38px; border-radius: 10px; font-size: 15px; }

/* ------------------------------------------------------------ товари --- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 620px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.14s ease, box-shadow 0.18s ease;
}

.product-card:active { transform: scale(0.985); box-shadow: var(--shadow); }

.product-card__photo {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  background: linear-gradient(140deg, var(--violet-050), var(--violet-100));
  display: grid;
  place-items: center;
  font-size: 34px;
  color: var(--violet-300);
}

.product-card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card__name { font-weight: 650; font-size: 14px; line-height: 1.3; }
.product-card__meta { font-size: 12px; color: var(--text-muted); }
.product-card__row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding-top: 4px; }
.product-card__price { font-weight: 750; font-size: 15px; }

.badge--stock { background: var(--success-bg); color: var(--success); }
.badge--zero { background: var(--bg-soft); color: var(--text-soft); }
.badge--minus { background: var(--danger-bg); color: var(--danger); }

/* -------------------------------------------------- редактор товару --- */

.photos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.photos__item {
  position: relative;
  flex: 0 0 92px;
  height: 92px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--violet-100);
}

.photos__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos__item--main { outline: 3px solid var(--violet-500); outline-offset: -3px; }

.photos__tools {
  position: absolute;
  left: 4px; right: 4px; bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.photos__btn {
  width: 26px; height: 26px;
  border: 0;
  border-radius: 9px;
  background: rgba(20, 12, 50, 0.55);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.photos__add {
  flex: 0 0 92px;
  height: 92px;
  border-radius: 16px;
  border: 2px dashed var(--violet-300);
  background: var(--violet-050);
  color: var(--violet-600);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.photos__add span { font-size: 24px; line-height: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.variants { display: flex; flex-direction: column; gap: 8px; }

.variant-row {
  display: grid;
  grid-template-columns: 0.9fr 1.2fr 1.6fr 34px;
  gap: 6px;
  align-items: center;
}

.variant-row .input { padding: 10px 11px; font-size: 14px; border-radius: 12px; }
.variant-row__stock { grid-column: 1 / -1; margin: -2px 0 4px 4px; font-size: 12px; color: var(--text-muted); }

.icon-btn {
  width: 34px; height: 34px;
  border: 0;
  border-radius: 11px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon-btn--danger { background: var(--danger-bg); color: var(--danger); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  cursor: pointer;
}

.check input { width: 20px; height: 20px; accent-color: var(--violet-600); }

/* ------------------------------------------------------------- каса --- */

.pos {
  display: grid;
  gap: 14px;
  padding: 4px 16px 20px;
}

@media (min-width: 900px) {
  .pos { grid-template-columns: 1fr 360px; align-items: start; }
  .pos__side { position: sticky; top: 16px; }
}

.cart { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.line {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  animation: fade 0.2s ease;
}

.line--warn { border-color: var(--warn); background: var(--warn-bg); }
.line__body { flex: 1; min-width: 0; }
.line__title { font-weight: 650; font-size: 14.5px; line-height: 1.3; }
.line__meta { font-size: 12px; color: var(--text-muted); }
.line__sum { font-weight: 750; font-size: 15px; white-space: nowrap; text-align: right; min-width: 74px; }

/* На вузькому екрані кількість/ціна переносяться під назву. */
@media (max-width: 720px) {
  .line { flex-wrap: wrap; row-gap: 8px; }
  .line__body { flex-basis: calc(100% - 60px); }
  .line__body + .qty, .line__cost { margin-left: 56px; }
  .line__sum { margin-left: auto; }
}

.qty {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 3px;
  flex: 0 0 auto;
}

.qty button {
  width: 30px; height: 30px;
  border: 0;
  border-radius: 9px;
  background: var(--surface);
  color: var(--violet-700);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.qty input {
  width: 38px;
  border: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}

.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.line__cost { width: 96px; flex: 0 0 auto; }
.line__cost .input { padding: 8px 10px; font-size: 13.5px; border-radius: 11px; }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  font-size: 14.5px;
}

.total-row--big {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px dashed var(--border-strong);
}

.total-row--big span:first-child { font-size: 15px; font-weight: 650; color: var(--text-muted); letter-spacing: 0; }

.change {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--success-bg);
  color: var(--success);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}

.change--bad { background: var(--danger-bg); color: var(--danger); }

.inline-fields { display: flex; gap: 8px; align-items: center; }
.inline-fields .input { padding: 10px 12px; }
.inline-fields .chip { padding: 9px 12px; }

.pos .segmented { margin: 0 0 12px; }

.receipt-done { text-align: center; padding: 10px 0 6px; }

.receipt-done__icon {
  width: 70px; height: 70px;
  margin: 0 auto 10px;
  border-radius: 24px;
  display: grid; place-items: center;
  font-size: 32px;
  color: #fff;
  background: linear-gradient(135deg, #34c896, #17936c);
  box-shadow: 0 10px 26px rgba(36, 169, 127, 0.3);
}

/* ----------------------------------------------------------- залишки --- */

.stock-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
}

.stock-row__body { flex: 1; min-width: 0; }
.stock-row__title { font-weight: 650; font-size: 14.5px; }
.stock-row__meta { font-size: 12px; color: var(--text-muted); }
.stock-row__nums { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.loc-qty {
  min-width: 58px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}

.loc-qty b { display: block; font-size: 15px; color: var(--text); }
.loc-qty--minus b { color: var(--danger); }

.stats--auto { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat__sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ------------------------------------------------------------- чеки --- */

.card__sum { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.card--return::before { background: var(--danger); }
.card--receive::before { background: var(--success); }
.card--transfer::before { background: var(--info); }
.card--writeoff::before { background: var(--danger); }

.card__names {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
}

.date-range { display: flex; gap: 8px; padding: 0 16px 12px; }
.date-range .input { padding: 10px 12px; font-size: 14px; }

.item-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.item-line:last-child { border-bottom: 0; }
.item-line__name { flex: 1; min-width: 0; }
.item-line__sum { font-weight: 700; white-space: nowrap; }

/* ----------------------------------------------------------- цінники --- */

.label-preview {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.label-preview__paper {
  background: #fff;
  color: #000;
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}

/* ------------------------------------------------------------ діалог --- */

.dialog { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }

.dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 24, 82, 0.42);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

.dialog__panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: fade 0.2s ease;
}

.dialog__title { margin: 0 0 8px; font-size: 18px; font-weight: 750; }
.dialog__text { margin: 0 0 16px; color: var(--text-muted); font-size: 14.5px; white-space: pre-line; }

/* ------------------------------------------------ лічильник у таб-барі --- */

.tab-badge-wrap { position: relative; }

.tab-badge {
  position: absolute;
  top: -6px;
  right: -12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.info-row__value a { color: var(--violet-600); font-weight: 650; text-decoration: none; }
