/* public/style.css — мобильный первым, десктоп через @media */
:root {
    --bg: #f6f4ef; --card: #fff; --text: #1e1e1e; --muted: #6b6b6b; --line: #e3e0d8;
    --accent: #b5485d; --accent-text: #fff; --ok: #2e7d4f; --warn: #b26a00; --danger: #b3261e;
    --radius: 12px; --nav-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--nav-h) + 16px); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 18px; }
#header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#header .brand { font-weight: 700; color: var(--accent); }
#header .shop-name, #header .user { color: var(--muted); font-size: 14px; }
#header .user { margin-left: auto; }
#header .shop-select { font-size: 15px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); }
main { padding: 16px; max-width: 1100px; margin: 0 auto; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 5; }
/* 7 пунктов у владельца не влезают в 375px — нижнее меню прокручивается вбок, а не сжимает подписи */
#nav { overflow-x: auto; scrollbar-width: none; }
#nav a { flex: 1 0 auto; padding: 0 8px; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: 13px; white-space: nowrap; }
#nav a.active { color: var(--accent); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
/* в переносимых рядах растущие поля не сжимаются уже 140px — на телефоне уходят на новую строку */
.wrap > .grow { flex: 1 1 140px; }
.muted { color: var(--muted); font-size: 14px; }
.right { text-align: right; }
.hidden { display: none !important; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input[type="number"] { -moz-appearance: textfield; }
input[type="checkbox"] { width: auto; }
label.row { margin: 0; white-space: nowrap; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.btn { padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { padding: 6px 10px; font-size: 14px; }
.btn-block { width: 100%; padding: 14px; font-size: 18px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .title { flex: 1; }
.list .sub, td .sub { display: block; color: var(--muted); font-size: 13px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { width: 36px; height: 36px; border: 0; background: #fff; font-size: 18px; cursor: pointer; }
.stepper span { min-width: 32px; text-align: center; }
.price-input { width: 96px; text-align: right; padding: 8px; }
.pay { display: flex; gap: 8px; margin: 12px 0; }
.pay button { flex: 1; }
.pay button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.total { display: flex; justify-content: space-between; font-size: 22px; font-weight: 700; margin: 12px 0; }
/* Продажа: теги партии и блок итога */
.tag { display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 6px; background: #eee; margin-right: 4px; }
.tag-warn { background: #fde8e6; color: var(--danger); }
.tag-sale { background: #e6f4ea; color: var(--ok); }
/* Прогноз: «скоро закончится» — жёлтый, в отличие от красного tag-warn */
.tag-soon { background: #fff4e5; color: var(--warn); }
.old-price { text-decoration: line-through; color: var(--muted); margin-right: 4px; }
.totals { margin: 12px 0; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 22px; font-weight: 700; }
.totals h3 { margin: 16px 0 6px; font-size: 16px; }
.totals h3:first-child { margin-top: 0; }
.totals div { gap: 8px; }
.totals div b { text-align: right; }
.totals .grand b { white-space: nowrap; }
.currency-select { width: auto; }
.bouquet { border: 1px dashed var(--accent); border-radius: 8px; padding: 8px; margin: 6px 0; }
.bouquet.active { background: #fbeff2; }
.bouquet .items { padding-left: 12px; font-size: 14px; color: var(--muted); }
.bouquet-info { font-size: 13px; color: var(--muted); margin: 4px 0 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.bouquet-info b { color: var(--text); font-weight: 600; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
/* широкие таблицы на телефоне прокручиваются внутри себя, а не всей страницей */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
tr.expiring td { background: #fff4e5; }
tr.expired td { background: #fde8e6; }
td .row { flex-wrap: wrap; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
.list li.voided .title { color: var(--muted); text-decoration: line-through; }
tr.inactive td { color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 0 1 auto; padding-left: 10px; padding-right: 10px; }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.toast { width: max-content; position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translate(-50%, 20px); opacity: 0; background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; transition: .25s; z-index: 20; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }
dialog.confirm { border: 0; border-radius: var(--radius); padding: 20px; max-width: 360px; }
dialog.confirm::backdrop { background: rgba(0,0,0,.4); }
dialog.confirm .row { justify-content: flex-end; margin-top: 12px; }
.login { max-width: 360px; margin: 60px auto; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.supply-line { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.supply-line .full { grid-column: 1 / -1; }
.search-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 6; margin: 2px 0 0; padding: 0; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 260px; overflow: auto; }
.suggest li { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest li:last-child { border-bottom: 0; }
.suggest li.create { color: var(--accent); font-weight: 600; }
.suggest li:hover, .suggest li.hover { background: #fbeff2; }
.new-product { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 6px 0 0; }
.new-product label { margin-top: 0; }
.margin-note { color: var(--muted); font-size: 13px; }
/* Остатки: кнопка раскрытия партий и вложенная таблица */
.btn-link { display: block; margin-top: 4px; padding: 2px 0; border: 0; background: none; color: var(--accent); font-size: 13px; }
/* на телефоне у таблицы остатков поуже поля, чтобы 4 столбца влезали в 375px */
.stock-table > thead > tr > th, .stock-table > tbody > tr > td { padding-left: 4px; padding-right: 4px; }
.stock-table > tbody > tr.batches-row > td { padding: 0 0 8px; background: #faf9f6; }
table.batches { border-radius: 0; background: transparent; font-size: 13px; }
table.batches th, table.batches td { padding: 6px 4px; }
table.batches .old-price { display: block; margin: 0; }
table.batches .price-input { width: 80px; }
table.batches td.price-cell { white-space: normal; }
table.batches .nowrap, table.batches .tag { white-space: nowrap; }
table.batches .tag { margin-right: 0; }
table.batches tr:last-child td { border-bottom: 0; }
.mode-select { width: auto; padding: 8px 6px; }
.settings-form .row > div { flex: 1 1 140px; }
.settings-form .settings-sub { margin-top: 16px; }
.settings-form .error + .btn { margin-top: 4px; }
/* Панель периода (Расходы, Дашборд): пресеты + две даты для «Период» */
.period-bar { margin-bottom: 8px; }
.period-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.period-presets .btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.period-dates { margin-top: 8px; }
.period-dates input { flex: 1 1 0; min-width: 0; }
/* Расходы */
.expense-shop-name { padding: 10px 0; }
label.check-row { margin: 12px 0 4px; font-size: 15px; color: var(--text); }
.expenses-head { margin-bottom: 8px; }
.expenses-head h2 { margin: 0; }
.scope-select { width: auto; padding: 6px 8px; font-size: 14px; }
.expense-amount { white-space: nowrap; font-weight: 600; }
.tag-register { background: #fff4e5; color: var(--warn); margin-left: 6px; margin-right: 0; }
#expenses-total { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 18px; }
textarea { resize: vertical; }
/* Дашборд */
.dash-filters { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.dash-filters #period { flex: 1 1 auto; }
.dash-filters .period-bar { margin-bottom: 0; }
.kpi-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.kpi-grid .kpi-card { margin-bottom: 0; }
.kpi-title { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 8px; }
.kpi-total { border-color: var(--accent); }
.kpi-line { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 15px; }
.kpi-line > span:first-child { color: var(--muted); }
.kpi-line .num { text-align: right; white-space: nowrap; }
.kpi-line .sub { display: block; color: var(--muted); font-size: 12px; }
.kpi-profit { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 8px 0 4px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 22px; font-weight: 700; }
.kpi-profit > span:first-child { font-size: 15px; font-weight: 600; color: var(--text); }
.kpi-profit.neg { color: var(--danger); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; margin-right: 6px; vertical-align: -1px; }
.kpi-title .swatch { margin-right: 0; }
.chart-box { position: relative; height: 280px; }
.chart-box canvas { width: 100%; }
.chart-empty { margin: 0; padding: 40px 0; text-align: center; }
.dash-sub { margin-top: 18px; }
tfoot .total-row td { font-weight: 700; border-bottom: 0; }
tfoot .muted-row td { color: var(--muted); font-size: 14px; border-bottom: 0; }
.cash-row { flex-wrap: wrap; }
.cash-row .title { flex: 1 1 160px; }
.cash-form { flex: 1 1 100%; padding-top: 4px; }
.cash-form input { padding: 8px 10px; }
.cash-form-title { font-size: 14px; font-weight: 600; }
@media (min-width: 900px) {
    body { padding-bottom: 16px; padding-left: 200px; }
    #nav { top: 0; bottom: 0; right: auto; width: 200px; height: auto; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding-top: 60px; }
    #nav a { flex: 0 0 auto; justify-content: flex-start; padding: 12px 20px; font-size: 15px; }
    #header { padding-left: 216px; margin-left: -200px; }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .chart-box { height: 320px; }
    th, td { padding: 10px; }
    .stock-table > thead > tr > th, .stock-table > tbody > tr > td { padding-left: 10px; padding-right: 10px; }
    .stock-table > tbody > tr.batches-row > td { padding-left: 16px; }
    table.batches { font-size: 14px; }
    table.batches th, table.batches td { padding: 6px 8px; }
    table.batches .old-price { display: inline; margin-right: 4px; }
    .supply-line { grid-template-columns: minmax(0, 2fr) repeat(5, minmax(0, 1fr)) auto; align-items: end; }
}
/* Прогноз */
.forecast .tag { white-space: nowrap; }
.forecast-peaks { margin-top: 6px; }
.forecast th.num { white-space: normal; }
/* на телефоне таблицы прогноза помещаются без прокрутки — поля ячеек уже, как в «Остатках» */
.forecast th, .forecast td { padding-left: 4px; padding-right: 4px; }
@media (min-width: 900px) { .forecast th, .forecast td { padding-left: 10px; padding-right: 10px; } }
.stock-table > tbody > tr > td > .tag { white-space: nowrap; }
/* ---- Журнал психолога ---- */
.tag-info { background: #e8f0fe; color: #1a56b0; }
.tag-ok { background: #e6f4ea; color: var(--ok); }
/* Заявка ждёт решения — жёлтый, а не красный tag-warn (это не ошибка) */
.tag-pending { background: #fff4e5; color: var(--warn); }
.tag-danger { background: #fde8e6; color: var(--danger); }
.picker { position: relative; }
.picker-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; max-height: 240px; overflow-y: auto; z-index: 20; }
.picker-item { padding: 8px 12px; cursor: pointer; }
.picker-item:hover { background: var(--bg); }
.picker-new { color: var(--accent); }
.appt-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.appt-row .time { font-weight: 600; min-width: 48px; }
.appt-row .body { flex: 1; }
.appt-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.3); }
/* календарь: неделя */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.cal-head h1 { margin: 0; font-size: 20px; min-width: 0; }
.cal-head select { width: auto; }
.cal-grid { display: grid; grid-template-columns: 48px repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cal-col { position: relative; border-left: 1px solid var(--line); }
.cal-col .cell { height: 24px; border-bottom: 1px dashed #eee; cursor: pointer; }
.cal-col .cell.off { background: #f3f1ec; cursor: default; }
.cal-col .cell.now { border-top: 2px solid var(--accent); }
.cal-day-head { text-align: center; font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-day-head.today { color: var(--accent); font-weight: 700; }
.cal-time { font-size: 11px; color: var(--muted); height: 24px; padding-right: 4px; text-align: right; }
.cal-appt { position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 2px 4px; font-size: 12px; overflow: hidden; cursor: pointer; background: #e8f0fe; border-left: 3px solid #1a56b0; }
.cal-appt.requested { background: #fff4e5; border-left-color: var(--warn); }
.cal-appt.done { background: #e6f4ea; border-left-color: var(--ok); }
.cal-appt.no_show, .cal-appt.late_cancel { background: #fde8e6; border-left-color: var(--danger); }
.cal-appt.cancelled_by_client, .cal-appt.cancelled_by_owner, .cal-appt.rejected { background: #eee; border-left-color: #999; text-decoration: line-through; }
@media (max-width: 700px) { .cal-grid { grid-template-columns: 40px repeat(7, minmax(64px, 1fr)); } .cal-wrap { overflow-x: auto; } }
/* месяц */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-cell { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 64px; padding: 4px; font-size: 13px; cursor: pointer; }
.month-cell.other { opacity: .4; }
.month-cell.today { border-color: var(--accent); }
.month-cell .count { color: var(--muted); font-size: 12px; }

/* Анкета клиента: темы чипсами, галочки тем в форме, кликабельное имя в заявках */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: #f6e9ec; color: var(--accent); }
label.chip-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--text); cursor: pointer; }
label.chip-check input { margin: 0; }
h3.form-sub { margin: 16px 0 0; font-size: 16px; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
a.client-link { font-weight: 600; text-decoration: none; }
a.client-link:hover, a.client-link:focus-visible { text-decoration: underline; }

/* Материалы в настройках: форма столбиком, длинные названия и ссылки переносятся. */
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.material-row .title { min-width: 0; overflow-wrap: anywhere; }
.small-link { font-size: 13px; }
.chip.chip-platform { background: #eef1f5; color: var(--text); }
