/* CRM «Фото-плед» — общие стили всех экранов.
   Сначала телефон (от 360 px), шире 720 px — раскладка для компьютера.
   Правила: никаких фиксированных ширин больше 360 px; кнопки и поля не ниже 44 px.
   Классы: .page .card .card-muted .list .row-between .narrow .grid
           .btn .btn-primary .btn-danger .btn-ghost .btn-block .btn-row
           .form .field .notice(-ok|-error|-info) .badge(-off|-ok|-warn) .muted .small
           .table-wrap > table.table  .kanban > .kanban-col  .tabs > a(.active)  .empty */

:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7078;
  --line: #e2e0db;
  --accent: #b5532f;
  --accent-text: #ffffff;
  --accent-soft: #f6e6df;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --error: #b42318;
  --error-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --radius: 10px;
  --gap: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}

img, svg { max-width: 100%; height: auto; }

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

h1 { font-size: 1.4rem; margin: 0 0 var(--gap); }
h2 { font-size: 1.15rem; margin: 24px 0 var(--gap); }
h3 { font-size: 1rem; margin: 16px 0 8px; }

/* --- шапка и меню --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }

.menu-toggle { position: absolute; opacity: 0; pointer-events: none; }

.menu {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 8px;
}

.menu-toggle:checked ~ .menu { display: flex; }
.menu-toggle:focus-visible ~ .menu-button { outline: 2px solid var(--accent); }

.menu a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.menu a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.menu-logout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px 12px 0;
  border-top: 1px solid var(--line);
}

@media (min-width: 720px) {
  .topbar { flex-wrap: nowrap; }
  .menu-button { display: none; }
  .menu {
    display: flex;
    flex-basis: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 0;
  }
  .menu a { min-height: 40px; padding: 0 10px; }
  .menu-logout { margin: 0 0 0 8px; padding: 0 0 0 12px; border-top: 0; border-left: 1px solid var(--line); }
}

/* --- страница --- */
.page { max-width: 1200px; margin: 0 auto; padding: 16px; }

.narrow { max-width: 360px; margin: 24px auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 var(--gap);
}

.card-muted { opacity: .7; }

.list { display: flex; flex-direction: column; gap: var(--gap); }
.list > .card { margin: 0; }

.grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* --- кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(.95); border-color: var(--accent); }
.btn-danger { background: var(--surface); border-color: var(--error); color: var(--error); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- формы --- */
.form { display: flex; flex-direction: column; gap: var(--gap); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-weight: 600; font-size: .9rem; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
textarea { min-height: 88px; resize: vertical; }

details > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

/* --- сообщения и метки --- */
.notice {
  padding: 12px 16px;
  margin: 0 0 var(--gap);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-error { background: var(--error-soft); color: var(--error); }
.notice-info { background: var(--warn-soft); color: var(--warn); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-off { background: var(--line); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* --- таблицы: на телефоне листаются внутри блока, страница не уезжает --- */
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .95rem; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }

/* --- вкладки (дашборд) --- */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 var(--gap); padding-bottom: 4px; }
.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --- канбан: на телефоне колонки листаются по одной --- */
.kanban {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}
.kanban-col {
  flex: 0 0 85%;
  max-width: 340px;
  scroll-snap-align: start;
  background: var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
@media (min-width: 720px) {
  .kanban-col { flex-basis: 260px; }
}

/* T05 */
.order-card { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); margin: 0 0 8px; }
details.card > summary.btn { display: flex; align-items: center; justify-content: center; list-style: none; cursor: pointer; }
details.card[open] > summary.btn { margin-bottom: var(--gap); }
.field-error input, .field-error select { border-color: var(--error); }
.field-msg { color: var(--error); font-weight: 600; }

/* T09 */
.list-plain { list-style: none; margin: 4px 0 0; padding: 0; }
.list-plain li { padding: 2px 0; }
.list-plain .ok { color: var(--ok); }
.list-plain .muted { color: var(--muted); }
.dash-dates { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.dash-cards .card { margin: 0; }
.stat { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat:last-of-type { border-bottom: 0; }
.stat-label { color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-empty .stat-value { font-size: 1rem; font-weight: 400; color: var(--muted); }
.dash-big { font-size: 1.25rem; font-weight: 700; margin: 12px 0 0; }
.num-neg { color: var(--error); font-weight: 600; }
.num-pos { color: var(--ok); font-weight: 600; }
.weakest { padding: 12px 16px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); }
.table tr.total th, .table tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.chart-card svg { width: 100%; }
.chart { display: block; font: 12px/1 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.chart-down { fill: var(--line); opacity: .7; }
.chart-down-text { fill: var(--muted); font-size: 11px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); }
.chart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.chart-s0 { stroke: var(--accent); fill: var(--accent); }
.chart-s1 { stroke: var(--ok); fill: var(--ok); }
.chart-s2 { stroke: var(--warn); fill: var(--warn); }
.chart-s3 { stroke: var(--muted); fill: var(--muted); }
.chart-line.chart-s0, .chart-line.chart-s1, .chart-line.chart-s2, .chart-line.chart-s3 { fill: none; }
.chart-bar { fill: var(--accent); }
