/* Шинный склад — интерфейс в духе iOS 27: сгруппированные списки, капсулы, «жидкое стекло» на плавающих элементах. */
:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --card-2: #F7F7FA;
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .2);
  --label: #000000;
  --label-2: rgba(60, 60, 67, .62);
  --label-3: rgba(60, 60, 67, .32);
  --sep: rgba(60, 60, 67, .16);
  --blue: #007AFF;
  --on-blue: #FFFFFF;
  --green: #248A3D;
  --red: #D70015;
  --c-summer: #C93400;
  --c-winter: #0062CC;
  --c-aseason: #248A3D;
  --c-disk: #5B5B60;
  --c-other: #8E44AD;
  --glass: rgba(255, 255, 255, .64);
  --glass-edge: rgba(0, 0, 0, .10);
  --glass-hi: rgba(255, 255, 255, .95);
  --glass-low: rgba(0, 0, 0, .04);
  --shadow: rgba(0, 0, 0, .14);
  --backdrop: rgba(0, 0, 0, .28);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --bg: #000000; --card: #1C1C1E; --card-2: #2C2C2E;
    --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
    --label: #FFFFFF; --label-2: rgba(235, 235, 245, .62); --label-3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .55);
    --blue: #0A84FF; --on-blue: #FFFFFF; --green: #30D158; --red: #FF453A;
    --c-summer: #FF9F0A; --c-winter: #64D2FF; --c-aseason: #30D158; --c-disk: #AEAEB2; --c-other: #BF5AF2;
    --glass: rgba(36, 36, 40, .58); --glass-edge: rgba(0, 0, 0, .55); --glass-hi: rgba(255, 255, 255, .2); --glass-low: rgba(0, 0, 0, .3);
    --shadow: rgba(0, 0, 0, .5); --backdrop: rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-scheme="dark"] {
  --bg: #000000; --card: #1C1C1E; --card-2: #2C2C2E;
  --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
  --label: #FFFFFF; --label-2: rgba(235, 235, 245, .62); --label-3: rgba(235, 235, 245, .3);
  --sep: rgba(84, 84, 88, .55);
  --blue: #0A84FF; --on-blue: #FFFFFF; --green: #30D158; --red: #FF453A;
  --c-summer: #FF9F0A; --c-winter: #64D2FF; --c-aseason: #30D158; --c-disk: #AEAEB2; --c-other: #BF5AF2;
  --glass: rgba(36, 36, 40, .58); --glass-edge: rgba(0, 0, 0, .55); --glass-hi: rgba(255, 255, 255, .2); --glass-low: rgba(0, 0, 0, .3);
  --shadow: rgba(0, 0, 0, .5); --backdrop: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--label); font-family: var(--font); font-size: 17px; line-height: 1.3; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Каркас ---------- */
.page {
  max-width: 560px; margin: 0 auto;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 112px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 38px; }
.date { font-size: 15px; color: var(--label-2); }
.title { font-size: 34px; font-weight: 700; letter-spacing: .2px; margin: -8px 0 0; }
.sec-cap { font-size: 13px; color: var(--label-2); margin: 0 16px -10px; }
.sec-note { font-size: 13px; color: var(--label-2); margin: -8px 16px 0; line-height: 1.35; }

/* ---------- Стекло ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: .5px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-low), 0 8px 28px var(--shadow);
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.g-round { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--label); }
.g-round svg { width: 20px; height: 20px; }

/* ---------- Группы и ячейки ---------- */
.grp { background: var(--card); border-radius: 22px; overflow: hidden; }
.cell { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; min-height: 48px; width: 100%; text-align: left; position: relative; }
.cell + .cell::before, .cell + .cell-wrap::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.cell.tap:active { background: var(--fill); }
.cell .grow { flex: 1; min-width: 0; }
.cell .r { text-align: right; flex: none; }
.sub { font-size: 14px; color: var(--label-2); }
.small { font-size: 13px; color: var(--label-2); }
.muted { color: var(--label-3); }
.blue { color: var(--blue); }
.green { color: var(--green); }
.red { color: var(--red); }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--label-3); width: 16px; height: 16px; }

/* ---------- Карточки итогов ---------- */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--card); border-radius: 20px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Поиск и сегменты ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 999px; padding: 0 14px; height: 40px; color: var(--label-2); }
.search svg { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--label); font-size: 17px; }
.search input::placeholder { color: var(--label-2); }
.seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; background: var(--fill); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border-radius: 999px; padding: 7px 4px; font-size: 14px; font-weight: 500; color: var(--label); white-space: nowrap; }
.seg button.on { background: var(--card); box-shadow: 0 2px 8px var(--shadow), inset 0 .5px 0 var(--glass-hi); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 999px; background: var(--fill); font-size: 15px; }
.chip.on { background: var(--blue); color: var(--on-blue); }

/* ---------- Позиции ---------- */
.thumb { width: 46px; height: 46px; border-radius: 12px; background: var(--fill); flex: none; display: flex; align-items: center; justify-content: center; color: var(--label-3); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 24px; height: 24px; }
.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; vertical-align: 1px; white-space: nowrap; }
.cat-summer { color: var(--c-summer); background: color-mix(in srgb, var(--c-summer) 14%, transparent); }
.cat-winter { color: var(--c-winter); background: color-mix(in srgb, var(--c-winter) 14%, transparent); }
.cat-aseason { color: var(--c-aseason); background: color-mix(in srgb, var(--c-aseason) 14%, transparent); }
.cat-disk { color: var(--c-disk); background: color-mix(in srgb, var(--c-disk) 16%, transparent); }
.cat-other { color: var(--c-other); background: color-mix(in srgb, var(--c-other) 14%, transparent); }
.pill-in { color: var(--label-2); background: var(--fill); }
.pill-out { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.pill-cancel { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.qty { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.zero .qty, .zero .name { color: var(--label-3); }
.struck { text-decoration: line-through; color: var(--label-3); }

/* ---------- Пустые состояния ---------- */
.empty { background: var(--card); border-radius: 22px; padding: 28px 20px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty svg { width: 40px; height: 40px; color: var(--label-3); }
.empty b { font-size: 18px; }

/* ---------- Кнопки ---------- */
.btn-p { background: var(--blue); color: var(--on-blue); border-radius: 999px; height: 52px; font-size: 17px; font-weight: 600; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-p:active { filter: brightness(.92); transform: scale(.99); }
.btn-p[aria-busy="true"] { opacity: .7; pointer-events: none; }
.btn-s { background: var(--fill); color: var(--blue); border-radius: 999px; height: 46px; padding: 0 18px; font-size: 16px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-s.danger { color: var(--red); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link-btn { color: var(--blue); font-size: 17px; }
.link-btn.danger { color: var(--red); }

/* ---------- Нижняя панель ---------- */
.dock {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.dock-in { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; align-items: center; pointer-events: auto; }
.tabs { flex: 1; height: 62px; border-radius: 999px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; }
.tab { border-radius: 999px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; font-weight: 500; color: var(--label); }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--blue); background: var(--fill); }
.fab { width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--blue); }
.fab svg { width: 28px; height: 28px; stroke-width: 2.2; }

/* ---------- Шторка ---------- */
#sheet-wrap { position: fixed; inset: 0; z-index: 40; }
#sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); animation: fade .2s ease; }
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: calc(100% - env(safe-area-inset-top, 0px) - 16px);
  background: var(--bg); border-radius: 30px 30px 0 0; overflow-y: auto; overscroll-behavior: contain;
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 -10px 40px var(--shadow);
}
#sheet-body {
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 20px) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 0 auto; }
.sh-head { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 8px; position: sticky; top: 0; }
.sh-title { text-align: center; font-size: 17px; font-weight: 600; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #sheet, #sheet-backdrop { animation: none; } }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 4px; padding: 10px 16px; position: relative; }
.field + .field::before, .cell + .field::before, .field + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.field label { font-size: 13px; color: var(--label-2); }
.field input, .field select { border: 0; background: none; outline: none; font-size: 17px; padding: 2px 0; width: 100%; color: var(--label); }
.field input::placeholder { color: var(--label-3); }
.inline-input { border: 0; background: none; outline: none; font-size: 17px; text-align: right; width: 110px; color: var(--label); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper input { width: 64px; text-align: center; font-size: 19px; font-weight: 600; border: 0; background: none; outline: none; color: var(--label); }
.step { width: 40px; height: 34px; border-radius: 999px; background: var(--fill); display: flex; align-items: center; justify-content: center; }
.step svg { width: 18px; height: 18px; }
.sugg .cell { padding-top: 9px; padding-bottom: 9px; }
.err { color: var(--red); font-size: 15px; margin: -6px 16px 0; }

/* ---------- Фото ---------- */
.gallery { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.gallery::-webkit-scrollbar { display: none; }
.ph { flex: none; width: 112px; height: 112px; border-radius: 18px; overflow: hidden; background: var(--fill); position: relative; display: flex; align-items: center; justify-content: center; color: var(--blue); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.add { flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.ph.add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ph .del { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; color: var(--label); }
.ph .del svg { width: 15px; height: 15px; }
#viewer { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; align-items: center; justify-content: center; }
#viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
#viewer button { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: max(16px, env(safe-area-inset-right, 0px)); }

/* ---------- Уведомление ---------- */
#toast {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 500; text-align: center;
  background: var(--glass); -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
  border: .5px solid var(--glass-edge); box-shadow: inset 0 1px 0 var(--glass-hi), 0 8px 28px var(--shadow);
  animation: fade .2s ease;
}
#toast.bad { color: var(--red); }

/* ---------- Вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 18px; max-width: 400px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) max(20px, env(safe-area-inset-left, 0px)); }
.logo { width: 76px; height: 76px; border-radius: 20px; background: var(--blue); color: var(--on-blue); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.logo svg { width: 44px; height: 44px; }
.logo-img { width: 88px; height: 88px; border-radius: 20px; margin: 0 auto; display: block; box-shadow: 0 8px 24px var(--shadow); }
.login h1 { text-align: center; font-size: 28px; margin: 0; }

/* ---------- Таблица отчёта ---------- */
.bar-line { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-top: 6px; }
.bar-line i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.loading { text-align: center; color: var(--label-2); padding: 40px 0; }
