@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/manrope/manrope-cyrillic-400-normal.woff2') format('woff2'),
       url('/fonts/manrope/manrope-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/manrope/manrope-cyrillic-500-normal.woff2') format('woff2'),
       url('/fonts/manrope/manrope-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/manrope/manrope-cyrillic-700-normal.woff2') format('woff2'),
       url('/fonts/manrope/manrope-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/manrope/manrope-cyrillic-800-normal.woff2') format('woff2'),
       url('/fonts/manrope/manrope-latin-800-normal.woff2') format('woff2');
}

:root {
  --c-ink: #0F1115;
  --c-ink-soft: #2A2D33;
  --c-muted: #6E7079;
  --c-muted-soft: #9498A0;
  --c-line: #E6E7EA;
  --c-line-soft: #F0F1F3;
  --c-paper: #FFFFFF;
  --c-bg: #F4F5F7;
  --c-accent: #ED5A52;
  --c-accent-soft: #FCE9E7;
  --c-green: #2E9F5C;
  --c-green-soft: #E6F4EC;
  --c-yellow: #E89B1E;
  --c-yellow-soft: #FBEFD8;
  --c-red: #D7443D;
  --c-red-soft: #FBE5E3;
  --r: 8px;
  --r-sm: 6px;
  color-scheme: light;
}

/* Dark theme is applied via [data-theme="dark"] on <html> by /js/theme.js
   (so we control "auto/light/dark" from the toggle, not from prefers only). */
[data-theme="dark"] {
  --c-ink: #F0F1F3;
  --c-ink-soft: #C8CCD2;
  --c-muted: #8E929A;
  --c-muted-soft: #6E7079;
  --c-line: #2A2D33;
  --c-line-soft: #1F222A;
  --c-paper: #1A1D24;
  --c-bg: #0F1115;
  --c-accent: #F47974;
  --c-accent-soft: #3D1F1D;
  --c-green: #4FB57A;
  --c-green-soft: #1A2B22;
  --c-yellow: #F0B040;
  --c-yellow-soft: #2D2515;
  --c-red: #E2625B;
  --c-red-soft: #2D1815;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', -apple-system, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-ink);
  background: var(--c-bg);
}
a { color: inherit; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; color: var(--c-ink); }

/* Layout */
.app-header {
  background: var(--c-paper);
  border-bottom: 1px solid var(--c-line);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header__brand { font-weight: 800; font-size: 15px; }
.app-header__right { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--c-muted); }
.app-header__right a, .app-header__right button {
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--c-ink); text-decoration: none;
  font-size: 13px; font-weight: 600;
}
.app-header__right a:hover, .app-header__right button:hover { color: var(--c-accent); }
.app-header__user { color: var(--c-muted); font-weight: 500; }

/* Theme switcher: cycles auto → light → dark → auto. */
.theme-btn {
  background: transparent;
  border: 0;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1.4;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--r-sm);
  color: var(--c-ink);
}
.theme-btn:hover { background: var(--c-bg); color: var(--c-ink); }
.theme-btn::before { content: '🖥'; line-height: 1; }
.theme-btn[data-mode="light"]::before { content: '☀️'; }
.theme-btn[data-mode="dark"]::before { content: '🌙'; }
.theme-btn[data-mode="auto"]::before { content: '🖥'; }

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.burger {
  display: none;
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  color: var(--c-ink);
  cursor: pointer;
  user-select: none;
  border-radius: var(--r-sm);
}
.burger:hover { background: var(--c-bg); }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

/* Steps (sections) */
.step {
  background: var(--c-paper);
  border-radius: var(--r);
  padding: 22px 22px 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.step__title {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step__num {
  width: 26px; height: 26px;
  background: var(--c-ink);
  color: var(--c-paper);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.step__hint { color: var(--c-muted); font-size: 12px; margin: 0 0 16px 36px; }

/* Fields */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 14px;
}
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field > label { font-size: 11.5px; color: var(--c-muted); letter-spacing: 0.02em; font-weight: 600; }
.field > input,
.field > select,
.field > textarea {
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
.field > input:focus,
.field > select:focus,
.field > textarea:focus { border-color: var(--c-ink); }
.field > textarea { min-height: 80px; resize: vertical; line-height: 1.45; }

/* Inline tools */
.row { display: flex; align-items: stretch; gap: 8px; }
.row > input { flex: 1; }
.row__remove {
  background: transparent; border: 1px solid var(--c-line); color: var(--c-muted);
  border-radius: var(--r-sm); padding: 0 10px; cursor: pointer; font-size: 16px;
}
.row__remove:hover { background: var(--c-red-soft); color: var(--c-red); border-color: var(--c-red-soft); }

.list { display: flex; flex-direction: column; gap: 6px; }
.list:empty + .add-btn { margin-top: 0; }

.add-btn {
  margin-top: 10px;
  background: transparent;
  border: 1px dashed var(--c-line);
  color: var(--c-muted);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}
.add-btn:hover { border-color: var(--c-ink); color: var(--c-ink); }

/* Cars */
.car {
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 12px;
}
.car__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-line);
}
.car__title { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.car__num {
  width: 26px; height: 26px;
  background: var(--c-ink); color: var(--c-paper);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800;
}
.car__remove {
  background: transparent; border: 1px solid var(--c-line); color: var(--c-muted);
  border-radius: var(--r-sm); padding: 6px 12px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.car__remove:hover { color: var(--c-red); border-color: var(--c-red-soft); background: var(--c-red-soft); }

.subgroup { margin-top: 16px; }
.subgroup__title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-muted); margin-bottom: 8px; }

/* Light radio */
.lights { display: flex; gap: 8px; }
.lights label {
  flex: 1;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  cursor: pointer;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.lights label .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lights label.green .dot { background: var(--c-green); }
.lights label.yellow .dot { background: var(--c-yellow); }
.lights label.red .dot { background: var(--c-red); }
.lights input { display: none; }
.lights label:has(input:checked) { border-color: var(--c-ink); background: var(--c-bg); }

/* Legal-fact row */
.legal-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; }
.legal-row select { padding: 9px 11px; border: 1px solid var(--c-line); border-radius: var(--r-sm); background: #fff; }
.legal-row select.positive { color: var(--c-green); border-color: var(--c-green-soft); }
.legal-row select.negative { color: var(--c-red); border-color: var(--c-red-soft); }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo {
  background: var(--c-bg); border-radius: var(--r-sm); padding: 8px; display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.photo__img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: #2A2D33; border-radius: 4px;
}
.photo__caption { font-size: 12px; padding: 6px 8px; border: 1px solid var(--c-line); border-radius: 4px; background: #fff; }
.photo__remove {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 22px; padding: 0;
}
.photos-empty {
  border: 1px dashed var(--c-line); border-radius: var(--r-sm); padding: 16px;
  text-align: center; color: var(--c-muted); font-size: 12.5px;
}

.file-btn {
  display: inline-block;
  margin-top: 8px;
  cursor: pointer;
  background: transparent; border: 1px dashed var(--c-line); color: var(--c-muted);
  border-radius: var(--r-sm); padding: 8px 14px;
  font-size: 12.5px; font-weight: 600;
}
.file-btn:hover { border-color: var(--c-ink); color: var(--c-ink); }
.file-btn input { display: none; }

/* Final block */
.toggle { display: flex; gap: 10px; margin-bottom: 12px; }
.toggle label {
  border: 1px solid var(--c-line); border-radius: var(--r-sm); padding: 8px 14px;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.toggle input { display: none; }
.toggle label:has(input:checked) { border-color: var(--c-ink); background: var(--c-bg); }

/* Top recommendation row */
.top-row { display: grid; grid-template-columns: 60px 1fr 1fr 60px; gap: 8px; align-items: stretch; }
.top-row__inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; grid-column: 2 / -2; }
.top-row__reason { grid-column: 1 / -1; margin-top: 6px; }
.top-row textarea { min-height: 50px; }

/* Submit bar */
.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--c-paper); border-top: 1px solid var(--c-line);
  padding: 12px 20px;
  display: flex; gap: 12px;
  justify-content: center; align-items: stretch;
  z-index: 10;
}
.submit-bar__btn {
  background: var(--c-ink); color: var(--c-paper);
  border: 0; border-radius: var(--r-sm);
  padding: 12px 24px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 200px;
}
.submit-bar__btn:hover { background: var(--c-accent); }
.submit-bar__btn:disabled { opacity: .5; cursor: wait; }
.submit-bar__btn--ghost {
  background: var(--c-paper); color: var(--c-ink);
  border: 1px solid var(--c-line);
}
.submit-bar__btn--ghost:hover { background: var(--c-bg); color: var(--c-ink); }

/* Save indicator embedded in the Save button */
.save-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--c-muted-soft);
  flex-shrink: 0;
  transition: background-color .2s;
}
#save[data-save-state="saved"]  .save-dot { background: var(--c-green); }
#save[data-save-state="dirty"]  .save-dot { background: var(--c-yellow); }
#save[data-save-state="saving"] .save-dot { background: var(--c-yellow); animation: save-pulse 1s ease-in-out infinite; }
#save[data-save-state="error"]  .save-dot { background: var(--c-red); }
@keyframes save-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  background: var(--c-ink); color: var(--c-paper);
  padding: 10px 18px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  z-index: 100;
  animation: toast-in .25s ease-out;
}
.toast.error { background: var(--c-red); }
@keyframes toast-in {
  from { transform: translate(-50%, -10px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

/* Mobile */
@media (max-width: 720px) {
  main { padding: 12px 10px 90px; }
  .step { padding: 16px 14px 18px; }
  .grid, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .legal-row { grid-template-columns: 1fr; }
  .top-row { grid-template-columns: 1fr; }
  .top-row__inputs { grid-template-columns: 1fr; grid-column: auto; }
  .submit-bar { padding: 8px 10px; gap: 8px; }
  .submit-bar__btn { flex: 1; min-width: 0; padding: 12px 14px; font-size: 14px; }

  /* Bigger tap targets on phones (≈44 px is the iOS guideline). */
  .lights { flex-direction: column; gap: 6px; }
  .lights label { padding: 14px 14px; font-size: 14px; }
  .add-btn { padding: 12px 16px; font-size: 13px; }
  .row__remove { min-width: 44px; padding: 0 14px; font-size: 18px; }
  .photo__remove { width: 28px; height: 28px; line-height: 28px; font-size: 16px; top: 8px; right: 8px; }
  .field > input,
  .field > select,
  .field > textarea { padding: 12px 12px; font-size: 15px; }
  .car__remove { padding: 10px 16px; font-size: 13px; }
  .file-btn { padding: 12px 16px; font-size: 13px; }

  .app-header { position: relative; flex-wrap: wrap; padding: 10px 16px; }
  .burger { display: inline-flex; align-items: center; margin-left: auto; }
  .app-header__right {
    display: none !important;
    flex-direction: column;
    align-items: stretch;
    width: calc(100% + 32px);
    margin: 10px -16px -10px;
    padding: 0;
    background: var(--c-paper);
    border-top: 1px solid var(--c-line);
    box-shadow: 0 6px 16px rgba(0,0,0,.06);
    gap: 0;
  }
  .nav-toggle:checked ~ .app-header__right {
    display: flex !important;
  }
  .app-header__right > * {
    padding: 14px 20px;
    border-bottom: 1px solid var(--c-line-soft);
    text-align: left;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
  }
  .app-header__right > *:last-child { border-bottom: 0; }
  .app-header__user { color: var(--c-muted); background: var(--c-bg); }
  .app-header__right button {
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
  }

  /* Theme button on mobile: full-width row with label after the icon */
  .app-header__right .theme-btn {
    justify-content: flex-start;
    font-size: 14px;
    font-weight: 600;
    min-height: auto;
  }
  .theme-btn::after { font-size: 14px; font-weight: 600; }
  .theme-btn[data-mode="auto"]::after { content: 'Системная тема'; }
  .theme-btn[data-mode="light"]::after { content: 'Светлая тема'; }
  .theme-btn[data-mode="dark"]::after { content: 'Тёмная тема'; }

}
