/* Учёт фермы — мобильная вёрстка: крупно, контрастно, без лишнего. */

:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #6b716c;
  --line: #ddd8cc;
  --green: #2f6b3a;
  --green-soft: #e3efe4;
  --red: #b3392f;
  --red-soft: #f8e4e1;
  --amber: #9a6a12;
  --amber-soft: #f7ecd5;
  --blue: #2b5c8a;
  --radius: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

a { color: var(--blue); }

h1 { font-size: 26px; margin: 8px 0 16px; }
h2 { font-size: 20px; margin: 0 0 12px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--green);
  color: #fff;
}
.top a { color: #fff; text-decoration: none; font-weight: 700; font-size: 20px; }
.top .who { opacity: .9; }

.page { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.muted { color: var(--muted); font-size: 16px; }

/* --- Сообщения --- */
.msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 600;
}
.msg-error { background: var(--red-soft); color: var(--red); }
.msg-warning { background: var(--amber-soft); color: var(--amber); }

/* --- Кнопки --- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
  width: 100%;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-big { min-height: 72px; font-size: 22px; }
.btn-expense { background: var(--red); color: #fff; }
.btn-income { background: var(--green); color: #fff; }
.btn-stock { background: var(--amber); color: #fff; }
.btn-danger { background: var(--red-soft); color: var(--red); box-shadow: none; }
.btn-link { background: none; box-shadow: none; color: var(--blue); min-height: 44px; }

.actions { display: grid; gap: 12px; margin-bottom: 16px; }

/* --- Главная: баланс --- */
.family-balance li { font-size: 22px; font-weight: 700; }
.balance p { margin: 12px 0 0; }
.balance-even { color: var(--green); font-size: 22px; font-weight: 700; text-align: center; }
.balance .btn { margin-top: 12px; }
.balance .common { margin-top: 12px; text-align: center; }

/* --- Таблички «название — сумма» --- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rows li:last-child { border-bottom: 0; }
.rows .total { font-weight: 700; }
.plus { color: var(--green); }
.minus { color: var(--red); }

/* --- Плитки выбора (новая запись, категории, семьи) --- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.grid .btn { min-height: 88px; text-align: center; flex-direction: column; }
.grid .btn small { font-weight: 400; color: inherit; opacity: .8; font-size: 14px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.tiles input { position: absolute; opacity: 0; pointer-events: none; }
.tiles label {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: var(--tap);
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
}
.tiles input:checked + label {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.tiles input:focus-visible + label { outline: 3px solid var(--blue); }
.tiles + .group-title { margin-top: 12px; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.group-title { font-weight: 700; color: var(--muted); font-size: 16px; margin: 4px 0 6px; }
h2.group-title { margin: 12px 0 0; }
.rows li.empty { color: var(--muted); }
.rows li.weights { font-size: 15px; padding-top: 0; }
.ingredient { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; align-items: start; }
.ingredient .field { margin-bottom: 12px; }
.ingredient .help { display: none; }

/* --- Формы --- */
.field { margin-bottom: 18px; }
.label { display: block; font-weight: 600; margin-bottom: 6px; }
.help { color: var(--muted); font-size: 15px; margin-top: 4px; }
.error { color: var(--red); font-weight: 600; margin-top: 6px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }

input[type=text], input[type=date], input[type=time], input[type=month], input[type=password],
input[type=number], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); }
.big-input { font-size: 32px; font-weight: 700; text-align: center; }

details.more { margin-bottom: 18px; }
details.more summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
  padding: 10px 0;
  min-height: 44px;
}

.preview {
  background: var(--amber-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
}
.preview .sum { font-size: 28px; font-weight: 700; }
.preview .warn { color: var(--red); font-weight: 600; }

/* --- Журнал --- */
.filters { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.filters .field { margin-bottom: 0; }
.filters .wide { grid-column: 1 / -1; }

.op {
  display: block;
  color: inherit;
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.op:last-child { border-bottom: 0; }
.op-main { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.op-sub { color: var(--muted); font-size: 15px; margin-top: 2px; }
.op-comment { font-size: 15px; margin-top: 4px; }
.op .edit { color: var(--blue); font-size: 15px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pager .btn { width: auto; }

/* --- Нижнее меню --- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}
.tabbar a .icon { font-size: 24px; line-height: 1.1; }
.tabbar a.on { color: var(--green); }

.footer-links { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.footer-links form { margin: 0; }

.login { max-width: 420px; margin: 24px auto; }

/* --- Доставки --- */
.switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.switch .btn { min-height: 48px; }
.switch .btn.on { background: var(--green-soft); color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.day-title { margin: 20px 0 10px; }
.day-title.alarm { color: var(--red); }
.delivery-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.delivery-when { font-weight: 700; color: var(--muted); }
.delivery-address { display: block; font-size: 22px; font-weight: 700; color: var(--text); text-decoration: none; margin: 6px 0 2px; }
.delivery-client { font-weight: 600; margin-bottom: 6px; }
.delivery-items { margin: 6px 0; padding-left: 20px; }
.delivery-sum { font-size: 20px; margin: 6px 0 2px; }
.delivery-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn-call { background: var(--green); color: #fff; }
.delivery > .btn-call { margin: 8px 0; }
.warn-line { color: var(--amber); font-weight: 600; font-size: 15px; margin-top: 6px; }
.badge { display: inline-block; font-size: 14px; font-weight: 700; padding: 2px 10px; border-radius: 999px; vertical-align: middle; }
.badge-new { background: var(--amber-soft); color: var(--amber); }
.badge-assembled { background: #e2ebf4; color: var(--blue); }
.badge-delivered { background: var(--green-soft); color: var(--green); }
.badge-cancelled { background: var(--line); color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions form { margin: 0; }
.home-deliveries { display: block; font-weight: 700; text-decoration: none; }

/* --- Без связи и значок на телефоне --- */
#offline-bar ul { margin: 6px 0 0; padding-left: 20px; font-weight: 400; }
#offline-bar .btn-link { min-height: 40px; padding: 4px 0; justify-content: flex-start; }
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 20;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.install p { margin: 6px 0 10px; }
/* В приложении на iPhone — отступ под «чёлку» */
.top { padding-top: calc(12px + env(safe-area-inset-top)); }
