:root {
  --concrete: #e8eaea;
  --card:     #ffffff;
  --ink:      #15171a;
  --ink-2:    #5a6167;
  --line:     #c7ccce;
  --line-2:   #e0e4e5;
  --mark:     #ffd400;
  --need:     #b8332a;
  --ok:       #17673f;
  --radius:   10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font-family: 'Golos Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 14px 96px;
}

a { color: inherit; }

h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 4px 0 14px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 26px 0 8px;
}

/* ---------- Шапка страницы ---------- */

.topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.backlink {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  display: inline-block;
  padding: 6px 0;
}

/* ---------- Карточки и списки ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.row {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
  text-decoration: none;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.row-title { font-weight: 600; }
.row-sub { font-size: 14px; color: var(--ink-2); margin-top: 2px; }

.tag {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--concrete);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.tag.work  { background: var(--mark); border-color: #d9b400; }
.tag.need  { background: var(--need); border-color: var(--need); color: #fff; }
.tag.ok    { background: var(--ok);   border-color: var(--ok);   color: #fff; }

.empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}

/* ---------- Формы ---------- */

label { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); margin: 12px 0 4px; }

input[type=text], input[type=tel], input[type=number], input[type=date],
input[type=time], input[type=password], input[type=file], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

textarea { min-height: 76px; resize: vertical; }

input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 3px solid #2b6cb0;
  outline-offset: 1px;
}

.pair { display: flex; gap: 10px; }
.pair > div { flex: 1; min-width: 0; }

.btn {
  display: inline-block;
  width: 100%;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  padding: 13px 16px;
  margin-top: 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--mark);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.btn.ghost { background: var(--card); border-color: var(--line); font-weight: 500; }
.btn.danger { background: var(--card); border-color: var(--need); color: var(--need); font-weight: 500; }
.btn.slim { padding: 9px 12px; font-size: 15px; margin-top: 8px; }

details.adder > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  padding: 13px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink-2);
  margin-top: 10px;
}

details.adder > summary::-webkit-details-marker { display: none; }
details.adder[open] > summary { border-style: solid; border-color: var(--ink); color: var(--ink); margin-bottom: 4px; }

/* ---------- Таблица сметы ---------- */

.sum {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-variant-numeric: tabular-nums;
}

.sum:last-child { border-bottom: none; }
.sum-total { font-weight: 700; font-size: 19px; padding-top: 12px; border-top: 2px solid var(--ink); border-bottom: none; }
.sum small { display: block; font-size: 13px; color: var(--ink-2); font-weight: 400; }

/* ---------- Нижняя навигация ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar-item {
  flex: 1;
  text-align: center;
  padding: 15px 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
}

.tabbar-item.is-on {
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 3px 0 var(--mark);
}

/* ---------- Прочее ---------- */

.receipt { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; }

.hint { font-size: 14px; color: var(--ink-2); margin: 6px 0 0; }

.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filters a {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.filters a.is-on { background: var(--ink); color: var(--card); border-color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Покупки ---------- */

.row-sum {
  flex: 0 0 auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.card.alert,
.row.alert {
  border-color: var(--need);
  border-width: 2px;
}

.row.alert .row-sum { color: var(--need); }

.receipt {
  max-height: 150px;
  width: auto;
}

details.adder .btn.danger { margin-top: 10px; }


/* ---------- Стадии воронки ---------- */

h2.stage {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 24px 0 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--ink);
}

h2.stage span {
  font-weight: 500;
  color: var(--ink-2);
}

.row-link { display: block; text-decoration: none; }

/* ---------- Кнопки-инструменты в карточке ---------- */

.task-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.task-tools form { display: contents; }

.task-tools button,
.task-tools select {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  width: auto;
  color: var(--ink-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  cursor: pointer;
}

.task-tools button.accent {
  background: var(--mark);
  border-color: #d9b400;
  color: var(--ink);
  font-weight: 600;
}

.stage-tools { margin: 0 0 16px; }

.row > details.adder > summary { display: none; }
.row > details.adder[open] { margin-top: 8px; }

/* ---------- Строки сумм ---------- */

.line-end { display: flex; align-items: center; gap: 10px; }
.line-end form { display: contents; }

button.x {
  border: none;
  background: none;
  color: var(--ink-2);
  font-size: 21px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  width: auto;
}

/* ---------- Поиск по справочнику ---------- */

.rate-hits { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }

.rate-hits button {
  font: inherit;
  font-size: 15px;
  text-align: left;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--concrete);
  cursor: pointer;
  width: 100%;
}

.rate-hits:empty { display: none; }

input[type=checkbox].cb { width: auto; margin-right: 6px; vertical-align: -2px; }

/* ---------- Галерея ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.gallery figure {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.gallery img { display: block; width: 100%; height: 120px; object-fit: cover; }

.gallery figcaption {
  font-size: 12px;
  color: var(--ink-2);
  padding: 6px 8px;
  line-height: 1.3;
}

.gallery form { position: absolute; top: 4px; right: 4px; }

.gallery button.x {
  background: rgba(255,255,255,.9);
  border-radius: 5px;
  width: 28px;
  height: 28px;
  color: var(--ink);
}

/* ---------- Переключатель статуса ---------- */

.statusbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--mark);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  margin-bottom: 16px;
}

.statusbar.is-lost { border-left-color: var(--need); }

.statusbar > label {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.statusbar select {
  font-size: 18px;
  font-weight: 600;
  padding: 12px;
}

.statusbar-hint {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

#lost-wrap { margin-top: 10px; }
#lost-wrap[hidden] { display: none; }

/* ---------- Деньги на карточке ---------- */

.money-card .price-line strong { font-size: 20px; }
.money-card .pay-line strong { color: var(--ok); }
.money-card .sum-total.is-debt strong { color: var(--need); }

.card.alert h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--need);
  border: none;
  margin-bottom: 4px;
  padding: 0;
}

.card.alert .sum:last-child { border-bottom: none; }

#pause-wrap { margin-top: 10px; }
#pause-wrap[hidden] { display: none; }

/* ---------- Публичная страница отчёта ---------- */

.wrap-public { padding-bottom: 40px; }

.card.day { padding-bottom: 10px; }

.day-head {
  font-size: 13px;
  font-weight: 700;
  padding-bottom: 6px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}

.day-text { margin: 0 0 10px; }

a.chek {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: underline;
  white-space: nowrap;
}

/* ---------- Публикация фото ---------- */

.gallery figure.is-pub { border-color: var(--ok); border-width: 2px; }

.pub-btn { padding: 0 8px 8px; }

.pub-btn button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--concrete);
  color: var(--ink-2);
  cursor: pointer;
}

.gallery figure.is-pub .pub-btn button {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.gallery figure > details.adder > summary {
  display: block;
  font-size: 12px;
  margin: 0 8px 8px;
  padding: 6px;
  border-radius: 6px;
}

.gallery figure > details.adder[open] { padding: 0 8px 8px; }

.task-tools a.wa {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
}

#lnk { font-size: 13px; }

/* ---------- Закупка пачкой ---------- */

.batch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-2);
}

.batch-line label {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
}

.batch-line label span {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-2);
}

.batch-line input {
  flex: 0 0 110px;
  text-align: right;
  font-weight: 600;
}

/* ---------- Период на экране денег ---------- */

.filters-wrap { flex-wrap: wrap; }
.filters-wrap a { flex: 1 1 28%; }
