/* Sneak n Fresh CRM. Сначала телефон, потом широкий экран. */

:root {
  --bg: #f5f6f4;
  --card: #ffffff;
  --ink: #1b1f1d;
  --muted: #5d6863;
  --line: #e1e5e2;
  --field: #cdd4d0;
  --accent: #0b7a63;
  --accent-hover: #09654f;
  --accent-soft: #e2f2ed;
  --accent-ink: #0a5546;
  --danger: #b42318;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* hidden всегда прячет, даже если у блока свой display */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 28px 0 10px; }
p { margin: 0 0 8px; }

/* Шапка */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; }
.brand-big { font-size: 15px; color: var(--accent); margin-bottom: 14px; }
.who { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); }
.who form { margin: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
@media (max-width: 520px) {
  .who-name { display: none; }
}

/* Страница */
.page { max-width: 960px; margin: 0 auto; padding: 20px 16px 56px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.crumbs { margin: 0 0 8px; font-size: 14px; }
.crumbs a { text-decoration: none; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.head .sub { margin-bottom: 16px; }
.head .btn { margin-bottom: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.grid > .card + .card { margin-top: 0; }  /* в сетке отступы дает сама сетка */
.narrow { max-width: 440px; }

/* Главная: плитки разделов */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; min-height: 96px; }
a.tile { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
a.tile:hover { border-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
a.tile strong { color: var(--accent-ink); }
.tile.soon { background: transparent; border-style: dashed; }
.tile.soon strong { color: var(--muted); }
.tile .tag { align-self: flex-start; margin-top: auto; }

/* Формы */
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input[type="text"], input[type="password"], input[type="search"], input[type="tel"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit; font-weight: 400;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--field);
  border-radius: 10px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, .link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
select:disabled { background: var(--bg); color: var(--muted); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check .hint { display: block; margin-top: 2px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 600;
  color: #fff; background: var(--accent);
  border: 1px solid transparent; border-radius: 10px;
  text-decoration: none; cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn.secondary { color: var(--ink); background: #fff; border-color: var(--field); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { color: var(--danger); background: #fff; border-color: #efb7b1; }
.btn.danger:hover { background: #fdf1ef; }
.btn.is-loading { opacity: 0.75; cursor: progress; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn, a.tile { transition: none; }
  .btn.is-loading::before { animation: none; }
}
.link {
  padding: 0; font: inherit; color: var(--accent);
  background: none; border: 0; text-decoration: underline; cursor: pointer;
}

/* Сообщения */
.alert, .flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; }
.alert { color: var(--danger); background: #fdecea; border: 1px solid #f4c4be; }
.flash { color: var(--accent-ink); background: var(--accent-soft); border: 1px solid #bfe2d7; }

/* Списки */
.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.list > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; color: inherit; text-decoration: none;
}
a.row:hover { background: #fafbfa; }
a.row strong { color: var(--accent-ink); }
.tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.tag {
  font-size: 12px; line-height: 1.6; padding: 1px 9px;
  color: var(--muted); background: #edf0ee; border-radius: 999px; white-space: nowrap;
}
.tag.accent { color: var(--accent-ink); background: var(--accent-soft); }
.tag.off { color: #8a2d20; background: #f6e5e2; }
.log-item { padding: 12px 16px; display: grid; gap: 2px; }
.row-form { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.row-form p { margin: 2px 0 0; }
.pager { display: flex; gap: 8px; justify-content: space-between; margin-top: 12px; }

/* Пустые экраны и ошибки */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty h1 { color: var(--ink); }
.empty .btn { margin-top: 8px; }

/* Вход */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 24px; }
.login-card .btn { width: 100%; }

/* --- Шаг 2: меню, поиск, клиенты, прайс --- */
textarea { min-height: 0; resize: vertical; line-height: 1.4; }
.mainnav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 6px 12px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 4;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  flex: none; padding: 8px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
}
.mainnav a:hover { background: var(--bg); color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }

.searchbar { display: flex; gap: 8px; margin: 0 0 16px; }
.searchbar input { flex: 1; min-width: 0; }
.caption { margin: 0 0 6px; }
.grow { flex: 1; min-width: 0; }
.two { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.head .actions { margin-bottom: 16px; }
.alert-actions { margin-top: 6px; font-weight: 600; }
.problem-line { color: var(--danger); font-size: 13px; margin-top: 2px; }
.note-card { white-space: pre-line; margin-bottom: 12px; }
.price { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted) !important; font-weight: 600; }
.list + h2 { margin-top: 28px; }
h2 + .list, .caption + .list { margin-top: 0; }
.card + .list, .alert + .card { margin-top: 12px; }

/* --- Шаг 3: приемка, заказ, фото --- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.center { text-align: center; }
.pre { white-space: pre-line; margin: 0; }
.hint.good { color: var(--accent-ink); font-weight: 600; }
.btn.big { min-height: 52px; font-size: 17px; padding: 12px 22px; }
.section-title { font-size: 17px; margin: 0; }
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 8px; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 600; font-size: 14px; }
.client-strip { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

/* Чипы-переключатели: радиокнопка внутри, видна подпись */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; position: relative; font-weight: 600; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--field); border-radius: 999px; background: #fff; font-size: 15px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Услуги */
.svc-group { border: 1px solid var(--line); border-radius: 10px; }
.svc-group > summary {
  cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.svc-group > summary::-webkit-details-marker { display: none; }
.svc-group > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s ease; }
.svc-group[open] > summary::before { transform: rotate(90deg); }
.svc {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 8px 14px; border-top: 1px solid var(--line);
}
.svc-name { display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: 15px; cursor: pointer; }
.svc-name input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.svc-price { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.svc-input { grid-column: 1 / -1; max-width: 200px; margin-left: 32px; }
.svc:has(input:checked) { background: var(--accent-soft); }
.urgent-check { padding: 10px 12px; border: 1px dashed #e0b25a; border-radius: 10px; background: #fff8ea; }

/* Итог прилипает к низу экрана */
.summary {
  position: sticky; bottom: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 10px 16px; margin: 0 -16px;
  background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}
.sum-rows { display: flex; flex-wrap: wrap; gap: 0 12px; margin: 0; font-size: 13px; line-height: 1.35; }
.sum-rows > div { display: flex; gap: 6px; }
.sum-rows dt { color: var(--muted); }
.sum-rows dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.sum-rows .sum-total { font-size: 17px; flex-basis: 100%; }
.summary .btn.big { padding: 12px 16px; }
.sum-rows .sum-total dd { font-weight: 800; }
@media (min-width: 700px) { .summary { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); } }

/* Фото */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.photo-pick { display: grid; gap: 10px; }
.file-btn { display: inline-flex; justify-self: start; position: relative; font-size: 15px; }
.photo-block + .photo-block { margin-top: 12px; }
.photo-block .photo-pick { margin-top: 12px; }

/* Карточка заказа */
.card-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 12px; }
.card-grid > .card + .card { margin-top: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.note-master { background: #fff8ea; border-color: #f0dcae; }
.total-row { background: #fafbfa; }
.list > li.row { padding: 12px 16px; }
.tags-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag.urgent { color: #fff; background: #c2410c; }
.overdue-text { color: var(--danger); font-weight: 700; }
.tag.status-accepted, .tag.status-to_workshop { color: #1e4b8f; background: #e3edfb; }
.tag.status-in_work { color: #7a4a00; background: #fdf0d5; }
.tag.status-qc { color: #5b2a86; background: #efe5fa; }
.tag.status-ready, .tag.status-to_pvz { color: var(--accent-ink); background: var(--accent-soft); }
.tag.status-notified { color: #0f5d75; background: #dff2f8; }
.tag.status-issued { color: var(--muted); background: #edf0ee; }
.tag.status-cancelled { color: #8a2d20; background: #f6e5e2; }

/* Заказ принят */
.done-card { text-align: center; padding: 28px 16px; }
.done-mark {
  width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center; font-size: 28px; color: #fff; background: var(--accent);
}
.done-actions { display: grid; gap: 10px; margin: 16px 0 8px; }
@media (min-width: 700px) { .done-actions { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.home-block { margin-bottom: 16px; }
.home-block .row-form { margin-bottom: 6px; }

/* --- Шаг 4: доска --- */
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.warn-text { color: #b45309; font-weight: 600; }
.board-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.board-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.board-filters select { width: auto; min-width: 150px; }
.board-search { flex: 1; min-width: 240px; margin: 0; }
.board-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 0 12px; }
.board-tabs a {
  flex: none; padding: 6px 10px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px;
}
.board-tabs b { color: var(--accent-ink); }
.board { display: grid; gap: 16px; }
.board-col { min-width: 0; scroll-margin-top: 64px; }
.col-title { font-size: 15px; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.col-title .count { font-size: 12px; color: var(--muted); background: #e7ebe8; border-radius: 999px; padding: 0 8px; }
.col-empty { padding: 8px 2px; }
.bcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; overflow: hidden;
}
.bcard.is-urgent { border-left: 4px solid #c2410c; }
.bcard.is-overdue { border-color: #f1a9a0; background: #fff6f5; }
.bcard-link { display: grid; gap: 2px; padding: 10px 12px; color: inherit; text-decoration: none; }
.bcard-link:hover { background: #fafbfa; }
.bcard-top { display: flex; justify-content: space-between; gap: 8px; }
.bcard-due { font-size: 13px; color: var(--muted); white-space: nowrap; }
.bcard-item { font-weight: 600; color: var(--accent-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard .tags-line { margin-top: 4px; }
.bcard-action { padding: 0 12px 10px; }
.bcard-action .btn { width: 100%; }
.board-foot { margin-top: 16px; }
.queue { display: grid; gap: 0; }
@media (min-width: 900px) {
  .page:has(.board) { max-width: none; }
  .board-tabs { display: none; }
  .board { grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); overflow-x: auto; align-items: start; padding-bottom: 8px; }
  .board-col { background: #eceeed; border-radius: 12px; padding: 10px; }
  .queue { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
}

/* Статус в карточке заказа */
.status-card { display: grid; gap: 12px; margin-bottom: 12px; }
.status-moves { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.status-moves form { margin: 0; }
.move-note > summary { list-style: none; }
.move-note > summary::-webkit-details-marker { display: none; }
.move-note[open] { flex-basis: 100%; }
.note-form { margin-top: 10px; padding: 12px; background: var(--bg); border-radius: 10px; }
.master-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.master-form label { display: inline; }
.master-form select { width: auto; min-width: 180px; }
.fix-status summary { font-size: 14px; color: var(--muted); }

/* --- Шаг 5: деньги --- */
.minus { color: var(--danger); }
.money-card { display: grid; gap: 14px; }
.money-sums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.money-sums > div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.money-sums strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.money-sums .debt { background: #fdecea; }
.money-sums .debt strong { color: var(--danger); }
.money-sums .paid-ok { background: var(--accent-soft); }
.ops { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.ops li { display: flex; gap: 12px; align-items: baseline; }
.pay-form { padding-top: 12px; border-top: 1px solid var(--line); }
.refund summary, .fix-status summary { cursor: pointer; }
.refund-on-cancel { padding: 10px; border: 1px dashed var(--field); border-radius: 10px; }
.cash-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 12px; }
.cash-grid > .card + .card { margin-top: 0; }
.stat { display: grid; gap: 2px; }
.stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.stat.total { background: var(--accent-soft); border-color: #bfe2d7; }
.cash-drawer { margin-bottom: 12px; }
.cash-forms { margin-bottom: 12px; }
.cash-forms > .card + .card { margin-top: 0; }
.cash-forms summary { cursor: pointer; }
.report-filters { display: grid; gap: 12px; margin-bottom: 16px; }
.report-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.report-row label { min-width: 140px; flex: 1; }
.master-line > summary { list-style: none; cursor: pointer; }
.master-line > summary::-webkit-details-marker { display: none; }
.master-line .ops { padding: 0 16px 12px; }
.issue .note-form { min-width: min(100%, 360px); }

/* --- Шаг 6: WhatsApp --- */
.wa-btn { background: #1f9d55; color: #fff; border-color: transparent; }
.wa-btn:hover { background: #17834a; }
.btn.secondary.wa-btn { background: #1f9d55; color: #fff; }
.wa-card { display: grid; gap: 8px; margin-bottom: 12px; }
.wa-card .card-title { margin: 0; }
.wa-form { margin: 0; display: grid; }
.home-block .ops li { align-items: center; }
.home-block .ops form { margin: 0; }

/* --- Шаг 7: копии и перенос --- */
.steps { padding-left: 36px; display: grid; gap: 8px; margin: 0 0 12px; }
.error-list { margin: 8px 0 0; padding-left: 20px; }
