/* Мобильная ширина 360 px — основная: без горизонтальной прокрутки, кнопки от 40 px. */
:root {
  --text: #1d2330;
  --bg: #f4f5f7;
  --accent: #1f5fbf;
  --soft: #eef0f3;
  --line: #dde1e7;
  --muted: #5d6675;
  --danger: #b3261e;
  --input-line: #c4cad4;
  --surface: #fff;
  --ok: #1e7d45;
  --ok-bg: #e7f3ec;
  --error-bg: #fbe9e7;
  --error: #8c1d13;
  --warn-bg: #fdecc8;
  --panel: #f6f7f9;
  --highlight: #eef4ff;
  --faint: #8a93a2;
  --accent-strong: #1d4ed8;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); overflow-wrap: anywhere;
}
img, video, table, input, select, textarea { max-width: 100%; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
code { background: var(--soft); padding: 0 4px; border-radius: 4px; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: inherit; min-height: 40px; display: flex; align-items: center; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 100%; order: 3; }
.nav a {
  min-height: 40px; display: inline-flex; align-items: center; padding: 0 10px;
  border-radius: 8px; text-decoration: none; color: inherit; background: var(--soft);
}
.nav a.active { background: var(--accent); color: var(--surface); }
.logout { margin-left: auto; }

.page { width: 100%; max-width: 960px; margin: 0 auto; padding: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.narrow { max-width: 420px; margin: 24px auto; }
.muted { color: var(--muted); font-size: 0.92rem; }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-weight: 600; }
.field-hint { color: var(--muted); font-size: 0.9rem; }
.field-error { color: var(--danger); font-size: 0.9rem; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; font: inherit;
  border: 1px solid var(--input-line); border-radius: 8px; background: var(--surface);
}
textarea { min-height: 96px; }

.btn, button {
  min-height: 40px; padding: 8px 14px; font: inherit; border-radius: 8px; border: 0;
  background: var(--accent); color: var(--surface); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; max-width: 100%;
}
.btn-link { background: transparent; color: var(--accent); padding: 8px 6px; }
.btn-on { background: var(--ok); }
.btn-off { background: var(--soft); color: var(--text); }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--ok-bg); }
.flash-error { background: var(--error-bg); color: var(--error); }
.copy { margin-top: 6px; }

.rows { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--soft); }
.row-main { display: flex; flex-direction: column; flex: 1 1 200px; min-width: 0; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { background: var(--soft); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile {
  min-height: 64px; display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: inherit; font-weight: 600;
}
.empty { background: var(--surface); border: 1px dashed var(--input-line); border-radius: 12px; padding: 20px 14px; text-align: center; }
.counters { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.counters a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit; }

/* --- общие классы страниц CRM (были в crm/_styles.html) --- */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.head h1 { margin: 0; }
.feed { list-style: none; margin: 12px 0 0; padding: 0; }
.feed li { padding: 8px 0; border-top: 1px solid var(--soft); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 100px), 1fr)); gap: 8px; margin: 12px 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
details.step { border-top: 1px solid var(--soft); padding: 6px 0; }
details.step summary { cursor: pointer; min-height: 40px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.state-done { color: var(--ok); }
.state-skipped { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check input { width: auto; min-height: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
fieldset[hidden] { display: none; }
.btn-danger { background: var(--danger); }
.badge-warn { background: var(--warn-bg); }
.back { display: inline-block; margin-bottom: 8px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.placeholder { color: var(--error); font-weight: 600; }

/* Пары «название — значение»: две колонки; .facts-stack — название над значением. */
.facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 4px 12px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-stack { grid-template-columns: 1fr; gap: 2px; margin: 0; }
.facts-stack dt { font-size: 0.9rem; }
.facts-stack dd { margin: 0 0 6px; }

/* --- покупатели и подбор --- */
.match-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.score { font-weight: 700; }
.miss { color: var(--error); font-size: 0.92rem; margin: 2px 0; overflow-wrap: anywhere; }
.unk { color: var(--muted); font-size: 0.92rem; margin: 2px 0; }
.match-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.match-actions form { margin: 0; }
.crit { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.crit .check { min-height: 36px; }
.pick { max-height: 240px; overflow-y: auto; }
details.group { border-top: 1px solid var(--soft); padding: 4px 0; }
details.group summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; }
.niches { display: flex; flex-wrap: wrap; gap: 0 14px; padding-bottom: 6px; }

/* --- сделки, деньги, показатели --- */
.board { display: none; }
.board-col { background: var(--panel); border-radius: 12px; padding: 8px; min-width: 0; }
.board-col h3 { font-size: 0.95rem; margin: 0 0 8px; }
.board-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 6px; text-decoration: none; color: inherit; overflow-wrap: anywhere; }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; margin: 8px 0; }
.sum-grid div { background: var(--panel); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; min-width: 0; }
.counter { font-size: 1.6rem; font-weight: 700; }

/* --- фин. модель --- */
.fm-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 8px; margin: 0 0 8px; }
.fm-totals dt { color: var(--muted); font-size: 0.9rem; }
.fm-totals dd { margin: 0; font-weight: 700; font-size: 1.1rem; }
.fm-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.fm-table th, .fm-table td { padding: 6px 4px; border-top: 1px solid var(--soft); text-align: right; }
.fm-table th:first-child, .fm-table td:first-child { text-align: left; }
.fm-table tr.cur td, .fm-table tr.cur th { background: var(--highlight); }
.fm-table .empty { color: var(--faint); }
.fm-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 88px), 1fr)); gap: 6px; margin: 8px 0 12px; }
.fm-months a { display: block; text-align: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; min-height: 40px; font-size: 0.85rem; text-decoration: none; }
.fm-months a.on { background: var(--accent-strong); color: var(--surface); border-color: var(--accent-strong); }
.fm-months a.has { font-weight: 700; }
.fm-row { border-top: 1px solid var(--soft); padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.fm-nav { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; }

@media (min-width: 760px) {
  .nav { flex: 1 1 auto; order: 0; }
  .page { padding: 20px; }
}

@media (min-width: 900px) {
  .board.on { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 8px; }
  .deal-list.with-board { display: none; }
}
