:root {
  --accent: #2f5d62;        /* тёмно-зелёный; вместе с серым и чёрным: три основных цвета */
  --accent-ink: #2f5d62;
  --accent-soft: #e7efef;
  --ink: #1f2933;
  --muted: #6b7680;
  --line: #d9dee2;
  --bg: #f4f6f7;
  --card: #ffffff;
  --bad: #b3261e;
  --warn: #9a5b00;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
[hidden] { display: none !important; }

.app { max-width: 960px; margin: 0 auto; padding: 16px; }
.top { padding: 8px 0 16px; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-name { font-weight: 800; letter-spacing: .12em; color: var(--accent-ink); font-size: 22px; }
.brand-sub { color: var(--muted); font-size: 13px; }
h1 { margin: 6px 0 0; font-size: 24px; }

.hint { color: var(--muted); margin: 0 0 12px; }
.hint.bad { color: var(--bad); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #b9c2c8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, .btn:focus-visible {
  outline: 3px solid rgba(47, 93, 98, .3);
  border-color: var(--accent);
}
input.invalid { border-color: var(--bad); }
input.changed { border-color: var(--warn); background: #fff9ee; }
.error { display: block; color: var(--bad); font-size: 14px; margin-top: 4px; min-height: 0; }
.error:empty { display: none; }
.note { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.price-note { color: var(--warn); }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent-ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #244a4e; }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.danger { border-color: var(--line); color: var(--muted); }
.btn.danger:hover:not(:disabled) { border-color: #e2b4b0; background: #fff5f4; color: var(--bad); }
.btn.wide { width: 100%; margin-top: 4px; }

.summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.summary-name { font-weight: 700; font-size: 18px; }
.summary-meta { color: var(--muted); font-size: 14px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) 120px 200px;
  grid-template-areas:
    "proc price date"
    "comment comment comment"
    "tools tools tools";
  gap: 12px;
  align-items: start;
}
.row .field { margin: 0; }
.row .proc { grid-area: proc; }
.row .price { grid-area: price; }
.row .date { grid-area: date; }
.row .comment { grid-area: comment; }
.row-tools { grid-area: tools; display: flex; gap: 8px; justify-content: flex-end; }

.combo { position: relative; }
.suggest {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid #b9c2c8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 41, 51, .15);
  max-height: 320px;
  overflow: auto;
}
.suggest li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.suggest li.active, .suggest li:hover { background: var(--accent-soft); }
.suggest { max-height: 380px; scrollbar-width: auto; }
.suggest::-webkit-scrollbar { width: 10px; }
.suggest::-webkit-scrollbar-thumb { background: #b9c2c8; border-radius: 6px; border: 2px solid #fff; }
.suggest::-webkit-scrollbar-track { background: #f1f3f4; border-radius: 6px; }
.suggest li.count { position: sticky; top: -4px; z-index: 1; background: #fff; color: var(--muted); font-size: 13px; padding: 6px 10px; cursor: default; border-bottom: 1px solid var(--line); margin: -4px -4px 4px; border-radius: 8px 8px 0 0; }
.suggest li.count:hover { background: #fff; }
.suggest li.none { color: var(--muted); cursor: default; }
.suggest li.none:hover { background: none; }
/* Плашка «Нет в списке» не перехватывает клики: под ней окошко цены, до него должно быть можно дотянуться */
.suggest li.none { pointer-events: none; }
.suggest:has(> li.none:only-child) { pointer-events: none; }
.sg-price { color: var(--muted); white-space: nowrap; }

.add-row { margin: 4px 0 16px; display: flex; align-items: center; gap: 12px; }
.total {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 18px;
}
.total strong { font-size: 24px; color: var(--accent-ink); }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 32px; }
.actions .error { margin: 0; }

@media (max-width: 720px) {
  .app { padding: 12px 16px; }
  .row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "proc proc" "price date" "comment comment" "tools tools";
  }
  .row-tools { justify-content: stretch; }
  .row-tools .btn { flex: 1; }
  .btn.primary { width: 100%; }
}

/* ---------- печатная форма (для печати и для PDF) ----------
   Все размеры в px: 1px = 1/96 дюйма, поэтому на бумаге и в PDF выглядит одинаково. */
.sheet { display: none; font-family: 'Montserrat', -apple-system, 'Segoe UI', Arial, sans-serif; color: #1f1f1f; }
.sheet, .sheet * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Режим создания PDF: форма рисуется за пределами экрана, ширина A4 */
.sheet.capture {
  display: block; position: absolute; left: -10000px; top: 0;
  width: 794px; padding: 45px; background: #fff;
}
.sheet .sh-label {
  display: block; font-size: 9px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: #6f7378; line-height: 1.35;
}
.sh-head { padding-bottom: 16px; margin-bottom: 22px; border-bottom: 2px solid #2f5d62; }
.sh-top { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 20px; }
.sh-logo { height: 46px; width: auto; display: block; }
.sh-req { text-align: right; font-size: 8px; line-height: 1.6; color: #4d5358; }
.sh-req-name { font-weight: 600; color: #1f1f1f; }
.sh-title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; text-align: center; }

.sh-meta { display: grid; grid-template-columns: 2fr 1.2fr 1fr; gap: 18px; margin-bottom: 30px; }
.sh-field .sh-value { display: block; margin-top: 5px; font-size: 13px; font-weight: 500; padding-bottom: 6px; border-bottom: 1px solid #d9dcde; min-height: 22px; }

.sh-section { margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid #1f1f1f; }
.sh-section.spaced { margin-top: 28px; }
.sh-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; table-layout: fixed; }
.sheet td, .sheet th, .sh-hi, .sh-value, .sh-care { overflow-wrap: anywhere; }
.sh-table th { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid #d9dcde; vertical-align: bottom; }
.sh-table td { padding: 10px 8px 10px 0; border-bottom: 1px solid #e8eaeb; vertical-align: top; font-size: 11px; font-weight: 400; line-height: 1.4; }
.sh-table tr { break-inside: avoid; }
.sh-table .c-n { width: 28px; color: #8a8f94; }
.sh-table .c-d { width: 112px; }
.sh-table .c-p { width: 70px; text-align: right; white-space: nowrap; padding-right: 14px; }
.sh-table .c-c { width: 160px; padding-right: 0; }
.sh-table td.c-t { font-weight: 500; }

.sh-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0 14px; margin-bottom: 26px; break-inside: avoid; }
.sh-total strong { font-size: 18px; font-weight: 600; color: #2f5d62; }

.sh-care { margin-bottom: 26px; min-height: 80px; font-size: 11px; line-height: 1.55; white-space: pre-wrap; break-inside: avoid; padding-top: 4px; }
.sh-line { border-bottom: 1px solid #d9dcde; height: 30px; }
.sh-foot { margin-top: 30px; text-align: center; font-size: 7px; line-height: 1.7; letter-spacing: 0; word-spacing: 0; font-weight: 400; color: #6f7378; break-inside: avoid; }

.sh-home { width: 100%; table-layout: fixed; border-collapse: collapse; margin-bottom: 4px; break-inside: avoid; }
.sh-home th { text-align: left; padding: 8px 14px 8px 0; border-bottom: 1px solid #d9dcde; width: 33.33%; }
.sh-home td { padding: 8px 14px 0 0; vertical-align: top; font-size: 11px; line-height: 1.4; }
.sh-hi { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 0 8px; }
.sh-hi-price { flex: none; font-size: 9px; white-space: nowrap; font-weight: 500; color: #4d5358; }

.sh-deposit { margin-top: 48px; padding: 10px 14px 9px; background: #eef3f3; border-left: 3px solid #2f5d62; border-radius: 0 6px 6px 0; font-size: 7px; line-height: 1.5; break-inside: avoid; }
.sh-deposit-title { font-size: 7px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #2f5d62; margin-bottom: 5px; }
.sh-deposit-lead { font-size: 7px; font-weight: 600; color: #1f1f1f; margin-bottom: 2px; }
.sh-deposit-text { font-size: 7px; font-weight: 400; color: #4d5358; margin-bottom: 7px; }
.sh-deposit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sh-dep-main { display: block; font-size: 7px; font-weight: 600; color: #1f1f1f; }
.sh-dep-bonus { display: block; font-size: 7px; font-weight: 500; color: #2f5d62; }
.sh-deposit-note { margin-top: 6px; padding-top: 5px; border-top: 1px solid #d3e0e0; font-size: 7px; font-weight: 400; color: #4d5358; }
.sh-deposit + .sh-foot { margin-top: 14px; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .app { display: none !important; }
  .sheet { display: block; }
}

.actions .btn.ghost { border-color: var(--accent); color: var(--accent-ink); }
.actions .btn[disabled] { opacity: .6; cursor: progress; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.top h1 { margin: 6px 0 0; }
.top-link { color: var(--accent-ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--accent); }
.summary-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.save-note { margin: 0; color: var(--accent-ink); }
.save-note.bad { color: var(--bad); }

/* ---------- журнал ---------- */
.wide-app { max-width: 1180px; }
.h2 { margin: 0 0 10px; font-size: 18px; }
select { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #b9c2c8; border-radius: 8px; background: #fff; color: var(--ink); }
.filters { display: grid; grid-template-columns: 200px 160px 160px minmax(180px, 1fr) auto; gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filter-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.as-link { text-decoration: none; display: inline-block; text-align: center; }
.count { color: var(--muted); margin-bottom: 8px; }
.table-wrap { overflow-x: auto; }
.jtable { width: 100%; border-collapse: collapse; font-size: 15px; }
.jtable th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.jtable td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.jtable td.num { text-align: right; white-space: nowrap; }
.jtable .main-row:hover { background: #fafbfb; }
.detail-row td { background: var(--accent-soft); }
.items { margin: 0; padding-left: 22px; }
.care { margin: 8px 0 0; color: var(--muted); }
@media (max-width: 900px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .grow, .filter-tools { grid-column: 1 / -1; }
}

/* ---------- домашний уход на экране ---------- */
.home-note { margin: -6px 0 12px; }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.home-col .label { margin-bottom: 8px; }
.home-item { margin-bottom: 12px; }
.home-item .combo { width: 100%; }
.home-item-sub { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.home-price { display: inline-flex; align-items: center; gap: 5px; }
.home-price-input { width: 92px; padding: 6px 8px; font-size: 14px; -moz-appearance: textfield; }
.home-price-input::-webkit-outer-spin-button, .home-price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.home-price-cur { color: var(--muted); font-size: 14px; }
.btn.icon { padding: 9px 12px; line-height: 1; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }

/* ---------- выбор филиала ---------- */
.branch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.branch-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  font: inherit; font-size: 18px; font-weight: 600; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 18px; cursor: pointer;
}
.branch-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.branch-btn:focus-visible { outline: 3px solid rgba(47, 93, 98, .3); border-color: var(--accent); }
.branch-num {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 16px;
}
.branch-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.cat-title { margin: 18px 0 10px; }
.cat-title:first-child { margin-top: 0; }
.bar-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.journal-link { font-size: 13px; }
.journal-link span { font-weight: 400; color: var(--muted); }
