:root {
  color-scheme: light;
  --admin-max: 52rem;
  --admin-gutter: 1.5rem;
  --admin-width: min(var(--admin-max), calc(100% - var(--admin-gutter)));
  --nav-gap: 0.4rem;
  --nav-pad-y: 0.4rem;
  --nav-pad-x: 0.9rem;
  --nav-radius: 12px;
  --nav-height: 44px;
  --nav-border: 2px solid #c5ddd2;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1a1f1c;
  background: #e7f5ee;
  overflow-x: hidden;
}
.bar, .login, .detail, .nav, .panel, .subnav, .head, .order-row, .empty {
  width: var(--admin-width);
  margin-left: auto;
  margin-right: auto;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 0 0.5rem;
  min-height: calc(var(--nav-height) + 1.5rem);
}
.bar form { margin: 0; display: flex; align-items: center; }
h1 { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.order-tools { display: flex; gap: 0.4rem; }
a.icon-btn, button.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 2px solid #0a5c43;
  background: #0a5c43;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  cursor: pointer;
}
a.icon-btn svg, button.icon-btn svg { width: 22px; height: 22px; display: block; }
.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
  gap: 0.45rem;
  align-items: end;
}
.link-field { min-width: 0; }
.link-field input { width: 100%; }
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(22rem, calc(100% - 1.5rem));
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: #0a5c43;
  color: #fff;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 24px rgba(26, 31, 28, 0.18);
}
.copy-toast--error { background: #8d2618; }
.link-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
button.danger { color: #8d2618; border-color: #d7a39b; }
.notice {
  background: #edf4ef;
  border: 2px solid #9ec5b4;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-weight: 700;
}
.product-search {
  display: grid;
  gap: 0.35rem;
  margin: 0.2rem 0 0.8rem;
}
.product-search__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
}
.product-search input[type="search"] {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}
.product-search__clear {
  min-height: 48px;
  white-space: nowrap;
}
.product-list {
  display: grid;
  gap: 0.7rem;
}
button, .bar a {
  min-height: var(--nav-height);
  border-radius: var(--nav-radius);
  border: var(--nav-border);
  background: #fff;
  padding: var(--nav-pad-y) var(--nav-pad-x);
  font: inherit;
  font-weight: 700;
  color: #1a1f1c;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.login, .detail {
  background: #fff;
  border-radius: 18px;
  padding: 1rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}
label { display: grid; gap: 0.35rem; font-weight: 700; }
input {
  min-height: 48px;
  font-size: 16px;
  border: 2px solid #c5ddd2;
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
}
.login button { margin-top: 0.8rem; background: #0a5c43; color: #fff; border-color: #0a5c43; }
.bar button[type="submit"] {
  margin: 0;
  background: #0a5c43;
  color: #fff;
  border-color: #0a5c43;
  flex: 0 0 auto;
}
.error { color: #8d2618; font-weight: 700; }
.head, .order-row {
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
  display: grid;
  grid-template-columns: 4.2rem 1.4fr 1.1fr 4.5rem 6rem;
  gap: 0.4rem;
  align-items: center;
}
.head { color: #3e4a44; font-size: 0.8rem; font-weight: 700; padding: 0.4rem 0.7rem; }
.order-row {
  background: #fff;
  border-radius: 14px;
  padding: 0.75rem 0.7rem;
  text-decoration: none;
  color: inherit;
  min-height: 48px;
}
.line {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.7rem;
  padding: 0.7rem 0;
  border-top: 1px solid #c5ddd2;
}
.line img { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: 10px; }
.line h3 { margin: 0 0 0.25rem; }
.line p { margin: 0.1rem 0; }
.total { font-size: 1.15rem; font-weight: 800; }
.empty { margin-top: 1rem; margin-bottom: 1rem; }
.nav, .subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--nav-gap);
}
.nav { margin-top: 0.35rem; margin-bottom: 0; }
.subnav { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.panel > .subnav {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
}
.nav a, .subnav a, a.button {
  min-height: var(--nav-height);
  box-sizing: border-box;
  border-radius: var(--nav-radius);
  border: var(--nav-border);
  background: #fff;
  padding: var(--nav-pad-y) var(--nav-pad-x);
  font-weight: 700;
  color: #1a1f1c;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  line-height: 1.2;
}
.nav a.current, .subnav a.current, a.button { background: #0a5c43; color: #fff; border-color: #0a5c43; }
.card > a.button,
.panel > a.button,
.panel > p > a.button,
.card > p > a.button {
  justify-self: start;
}
.panel { margin-top: 0.7rem; margin-bottom: 2rem; display: grid; gap: 0.7rem; align-content: start; }
.card, .prow {
  background: #fff;
  border-radius: 16px;
  padding: 0.8rem;
  display: grid;
  gap: 0.55rem;
}
.prow {
  grid-template-columns: 4.5rem minmax(0, 1fr);
  align-items: center;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
}
.prow img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: contain;
  border-radius: 10px;
  background: #edf4ef;
}
.shot img { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: 10px; }
.prow small, .card p { margin: 0.15rem 0 0; color: #3e4a44; }
.prow strong { display: block; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; }
fieldset.stack { display: grid; gap: 0.55rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.money { width: 100%; border-collapse: collapse; }
table.money th, table.money td { padding: 0.45rem 0.35rem; border-bottom: 1px solid #c5ddd2; vertical-align: middle; text-align: left; }
table.money th:nth-child(n+2), table.money td:nth-child(n+2) { text-align: right; white-space: nowrap; }
table.money img { width: 2.5rem; height: 2.5rem; object-fit: cover; border-radius: 8px; vertical-align: middle; margin-right: 0.4rem; }
/* Остатки: не сжимать «Товар» из-за nowrap у длинных категорий. */
table.money.stock-balances,
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money {
  width: max(100%, 44rem);
  min-width: 44rem;
  table-layout: fixed;
}
table.money.stock-balances th,
table.money.stock-balances td,
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money th,
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money td {
  vertical-align: top;
}
table.money.stock-balances th:nth-child(1),
table.money.stock-balances td:nth-child(1),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money th:nth-child(1),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money td:nth-child(1) {
  width: 40%;
  min-width: 16rem;
  text-align: left;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}
table.money.stock-balances th:nth-child(2),
table.money.stock-balances td:nth-child(2),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money th:nth-child(2),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money td:nth-child(2) {
  width: 12%;
  min-width: 5.5rem;
  text-align: left;
  white-space: nowrap;
}
table.money.stock-balances th:nth-child(3),
table.money.stock-balances td:nth-child(3),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money th:nth-child(3),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money td:nth-child(3) {
  width: 30%;
  min-width: 12rem;
  text-align: left;
  white-space: normal;
  overflow-wrap: break-word;
}
table.money.stock-balances th:nth-child(4),
table.money.stock-balances td:nth-child(4),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money th:nth-child(4),
form.filters[action="/admin/warehouse"] ~ .table-wrap > table.money td:nth-child(4) {
  width: 18%;
  min-width: 7rem;
  text-align: right;
  white-space: nowrap;
}
legend { font-weight: 800; width: 100%; margin-bottom: 0.2rem; }
label.check { display: flex; align-items: center; gap: 0.45rem; min-height: 44px; font-weight: 700; }
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; min-height: 0; }
textarea, select { width: 100%; min-height: 48px; font-size: 16px; border: 2px solid #c5ddd2; border-radius: 12px; padding: 0.5rem 0.7rem; }
textarea { min-height: 7rem; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.6rem; }
.shot { display: grid; gap: 0.35rem; }
.shot form, .card + form { margin: 0; }
.ok { color: #0a5c43; font-weight: 700; }
h2 { margin: 0; font-size: 1.1rem; }
table.subs { width: 100%; border-collapse: collapse; }
table.subs th, table.subs td { padding: 0.5rem 0.35rem; border-bottom: 1px solid #c5ddd2; text-align: left; vertical-align: middle; }
table.subs td:nth-child(2), table.subs th:nth-child(2) { text-align: right; white-space: nowrap; }
.card ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.subnav a.alert { background: #b42318; color: #fff; border-color: #b42318; }
.subnav a.current.alert {
  background: #0a5c43;
  color: #fff;
  border-color: #b42318;
  box-shadow: 0 0 0 3px #b42318;
}
.filters {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  align-items: end;
}
.filters > button {
  justify-self: start;
  width: fit-content;
}
.doc-row {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #c5ddd2;
}
table.money input { width: 5.5rem; min-height: 44px; }
table.money input.price { width: 7.5rem; }
table.order-lines th:nth-child(2), table.order-lines td:nth-child(2) { text-align: left; }
.deficit { color: #8d2618; font-weight: 800; }
.warn-box {
  background: #fff6e8;
  border: 2px solid #c47b12;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0.8rem 0;
}
.warn-box p { margin: 0.28rem 0; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.confirm-actions button { background: #0a5c43; color: #fff; border-color: #0a5c43; }
@media (min-width: 720px) {
  .filters { grid-template-columns: 1.4fr 1fr 1fr auto; align-items: end; }
  .doc-row { grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); align-items: end; }
}
@media (max-width: 720px) {
  .head { display: none; }
  .order-row { grid-template-columns: 1fr 1fr; }
}
