/* Приложение «Рынок»: одна колонка под телефон, крупные кнопки под палец. */

:root {
  --green: #2f6b3a;
  --green-dark: #24542d;
  --bg: #f4f2ed;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2dfd8;
  --warn: #b5541c;
  --ok: #2f6b3a;
  --radius: 14px;
  --gap: 12px;
  --tap: 52px; /* минимальная высота кнопки под палец */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161715;
    --card: #222420;
    --text: #ecebe6;
    --muted: #a3a29c;
    --line: #353731;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--green);
  color: #fff;
}
.topbar__title { margin: 0; font-size: 20px; flex: 1; }

.net { font-size: 14px; opacity: 0.9; }
.net--off { color: #ffd9c2; }

.icon-btn {
  min-width: 44px; min-height: 44px;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit; font-size: 22px;
}

.page {
  display: grid;
  gap: var(--gap);
  max-width: 560px;
  margin: 0 auto;
  padding: var(--gap) 16px calc(env(safe-area-inset-bottom) + 24px);
}

.page[hidden] { display: none; }

.card {
  display: grid;
  gap: var(--gap);
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
}
.card__title { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }

.pick { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--green);
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.btn--big { min-height: var(--tap); font-size: 18px; }
.btn--light { background: transparent; color: var(--green); }
.btn--small { min-height: 36px; padding: 0 12px; font-size: 15px; }
.btn--danger { color: var(--warn); border-color: var(--warn); }
.btn--primary:active, .btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.45; cursor: default; }
@media (prefers-color-scheme: dark) { .btn--light { color: #9fd3a8; border-color: #9fd3a8; } }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  margin: 0; padding: 0; list-style: none;
}
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.thumb__cap {
  position: absolute; left: 2px; right: 2px; bottom: 2px;
  padding: 1px 4px; border-radius: 6px;
  background: rgb(0 0 0 / 0.65); color: #fff;
  font-size: 13px; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb--selected img { outline: 3px solid var(--green); outline-offset: -3px; opacity: 0.8; }
.thumb--selected::after {
  content: "✓"; position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 15px; line-height: 24px; text-align: center;
}

/* Полоса фото с подписями */
.strip { display: grid; gap: 8px; }
.strip__bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.strip__sign { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.strip [hidden] { display: none; }

.field { display: grid; gap: 4px; }
.field__label { font-size: 14px; color: var(--muted); padding: 0; }

textarea, .input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
}

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; padding: 0; border: 0; }
.segmented legend { margin-bottom: 4px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span {
  display: flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; text-align: center;
}
.segmented input:checked + span { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

.hint { margin: 0; font-size: 14px; color: var(--muted); }
.hint:empty { display: none; }

.badge {
  padding: 2px 8px; border-radius: 999px;
  background: var(--warn); color: #fff; font-size: 13px;
}

.batches { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.batches:empty::before { content: "Пока ничего не отправляли"; color: var(--muted); font-size: 14px; }
.batch {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.batch:first-child { border-top: 0; }
.batch__note { overflow-wrap: anywhere; }
.batch__meta { grid-column: 1; font-size: 13px; color: var(--muted); }
.batch__status { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 14px; font-weight: 600; }
.batch__status--done { color: var(--ok); }
.batch__status--wait, .batch__status--blocked { color: var(--warn); }
.batch__error { grid-column: 1 / -1; font-size: 13px; color: var(--warn); }

.dialog { width: min(92vw, 420px); padding: 0; border: 0; border-radius: var(--radius); background: var(--card); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog__body { display: grid; gap: var(--gap); padding: 16px; }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.version { font-size: 12px; }

/* Вкладки «Съёмка / Списки» */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--green-dark);
}
.tabs__tab {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; color: #d8e8da; text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs__tab--on { color: #fff; border-bottom-color: #fff; }

.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.back { color: var(--green); font-weight: 600; text-decoration: none; min-height: 36px; display: inline-flex; align-items: center; }
@media (prefers-color-scheme: dark) { .back { color: #9fd3a8; } }

/* Строки списков и позиций */
.rows { display: grid; margin: 0; padding: 0; list-style: none; }
.rows:empty::before { content: "Пока пусто"; color: var(--muted); font-size: 14px; }
.rows__item { border-top: 1px solid var(--line); }
.rows__item:first-child { border-top: 0; }
.rows__link {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
  min-height: var(--tap); padding: 8px 0; color: inherit; text-decoration: none;
}
.rows__link > :not(.rows__thumb) { grid-column: 2; }
.rows__thumb { grid-row: 1 / span 2; width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--line); }
.rows__thumb--icon { display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--muted); }
.rows__title { overflow-wrap: anywhere; }
.rows__meta { font-size: 13px; color: var(--muted); }
.rows__item--done .rows__meta { color: var(--ok); }
.rows__item--topic .rows__title { font-weight: 600; }

/* Позиция */
.item-photo { display: flex; justify-content: center; }
.item-photo img { max-width: 100%; max-height: 42vh; border-radius: 10px; object-fit: contain; background: #fff; }
.reason { margin: 0; font-size: 14px; font-weight: 600; color: var(--warn); }
#item-fields { display: grid; gap: var(--gap); }
#item-fields[hidden], .item-photo[hidden], .reason[hidden] { display: none; }
.segmented--2 { grid-template-columns: 1fr 1fr; }
.segmented--2 span { min-height: var(--tap); font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip {
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: inherit; font: inherit; font-size: 15px;
}
.chip--on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.row--start { justify-content: flex-start; flex-wrap: nowrap; }
.input--grow { flex: 1; min-width: 0; }
.input--price { font-size: 24px; font-weight: 600; }
.price-line { margin: 0; font-size: 15px; font-weight: 600; }
.price-line:empty { display: none; }
.price-line--up { color: var(--warn); }
.price-line--down, .price-line--same { color: var(--ok); }
@media (prefers-color-scheme: dark) { .price-line--down, .price-line--same, .rows__item--done .rows__meta { color: #9fd3a8; } }
.dialog__photo { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 10px; }
