:root {
  --bg: #f9f6f0;
  --bg-soft: #f3ede2;
  --card: #ffffff;
  --ink: #2c231a;
  --ink-soft: #5f554a;
  --ink-mute: #8a7d6d;
  --line: #e6dfd2;

  /* Single accent hue = the «ДЯ» logo brown (design.json brand_color #6b4c35).
     Every interactive color is DERIVED from this one hue via color-mix — there
     is no second hand-picked brand color, so the page reads as one warm wood
     tone with a darker hover/price state rather than two colors. */
  --accent: #6b4c35;
  --accent-hover: color-mix(in oklch, var(--accent) 80%, black);
  --accent-soft: color-mix(in oklch, var(--accent) 8%, transparent);
  --focus: var(--accent);

  --status-new: #a06b43;
  --status-measurement: #8a6d3b;
  --status-in_work: #5f7d5a;
  --status-done: #4f7d6b;
  --status-refused: #8a5549;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(44, 35, 26, .06), 0 4px 12px rgba(44, 35, 26, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Brand ---------- */
.logo {
  display: block; flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
}
.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-row-sm { gap: 12px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 20px; font-weight: 700; color: var(--ink); }
.brand-sub { font-size: 12px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Login ---------- */
.login-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 20px; gap: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-card .brand-row { margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-foot { font-size: 13px; color: var(--ink-mute); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-link {
  display: inline-flex; align-items: center;
  padding: 8px 14px; border-radius: 8px;
  color: var(--ink-soft); text-decoration: none;
  font-size: 15px; font-weight: 500;
  border: none; background: none; cursor: pointer;
  font-family: inherit;
}
.nav-link:hover { background: var(--bg-soft); color: var(--ink); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.btn-ghost { border: none; background: none; }
.btn-ghost:hover { background: var(--bg-soft); }

/* ---------- Layout ---------- */
.main {
  flex: 1; width: 100%; max-width: 900px;
  margin: 0 auto; padding: 24px 20px 48px;
  display: flex; flex-direction: column; gap: 20px;
}
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.h1 { font-size: 24px; font-weight: 700; margin: 0 0 18px; }
.panel .h1 + *, .panel .h2 { }
.h2 { font-size: 18px; font-weight: 600; margin: 0 0 16px; }
.muted { color: var(--ink-mute); font-weight: 400; }
.note { font-size: 13px; text-align: center; }

/* ---------- Search ---------- */
.search { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 420px; }
.search input {
  flex: 1; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font-size: 15px; font-family: inherit;
}

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select {
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink);
  font-size: 15px; font-family: inherit;
  width: 100%;
}
.field input:focus, .field select:focus, .search input:focus {
  outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus);
}

/* ---------- New lead ---------- */
.new-lead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.new-lead .field-grow { grid-column: 1 / -1; }
.form-error { color: #a04b3a; font-size: 14px; margin: 8px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border-radius: 8px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-soft { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }
.btn-soft:hover { background: var(--line); }
.btn-block { width: 100%; }
.btn-danger-ghost { background: none; border: 1px solid var(--line); color: #a04b3a; }
.btn-danger-ghost:hover { background: #f8eae6; border-color: #d8b0a6; }

/* ---------- Lead list ---------- */
.lead-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.lead-card {
  position: relative;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 18px 18px 14px;
  border-top: 4px solid var(--status-new);
}
.lead-card.status-measurement { border-top-color: var(--status-measurement); }
.lead-card.status-in_work { border-top-color: var(--status-in_work); }
.lead-card.status-done { border-top-color: var(--status-done); }
.lead-card.status-refused { border-top-color: var(--status-refused); }
.lead-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.lead-date { font-size: 13px; color: var(--ink-mute); }
.lead-name { font-size: 17px; font-weight: 600; margin: 0 0 2px; }
.lead-phone { margin: 0 0 4px; font-size: 15px; color: var(--ink-soft); }
.lead-phone a { color: inherit; text-decoration: none; }
.lead-phone a:hover { text-decoration: underline; color: var(--accent); }
.lead-request { margin: 0 0 4px; color: var(--ink-soft); }
.lead-source { margin: 0 0 4px; font-size: 13px; color: var(--ink-mute); }
.lead-comment { margin: 0 0 4px; font-size: 14px; color: var(--ink-soft); font-style: italic; }
.lead-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.lead-actions .field-inline select { width: auto; min-width: 150px; }

.status-chip {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: #fff;
  background: var(--status-new);
}
.status-chip-measurement { background: var(--status-measurement); }
.status-chip-in_work { background: var(--status-in_work); }
.status-chip-done { background: var(--status-done); }
.status-chip-refused { background: var(--status-refused); }

.empty-state { color: var(--ink-mute); font-size: 15px; padding: 12px 0; }

/* ---------- Calculator ---------- */
.calc-panel { max-width: 560px; }
.lead-intro { color: var(--ink-soft); margin: -8px 0 20px; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.calc-result {
  margin-top: 22px; padding: 20px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; border-left: 4px solid var(--accent);
  display: flex; flex-direction: column; gap: 6px;
}
.calc-result-area { margin: 0; font-size: 15px; color: var(--ink-soft); }
.calc-result-price { margin: 0; font-size: 22px; font-weight: 700; color: var(--accent-hover); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .main { padding: 16px 12px 40px; }
  .panel { padding: 18px 14px; }
  .new-lead-grid, .calc-grid { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .topbar { padding: 12px 14px; }
  .lead-actions .field-inline select { width: 100%; min-width: 0; flex: 1; }
}
