/* ==== Дуб и Ясень — CRM. Тёплое дерево, строгие тонкие разделители. ==== */

:root {
  --bg: #f9f6f0;
  --surface: #ffffff;
  --ink: #2c1e11;
  --ink-soft: #6b5949;
  --ink-faint: #7c6c5a;
  --line: #e6ded2;
  --line-strong: #d8ccbb;

  /* Brand brown #8b5a2b — safe for white text on fills (5.8:1). */
  --accent: #8b5a2b;
  --accent-hover: #74491f;
  --accent-ink: #3a2c22;
  --accent-soft: #f0e6d8;

  --ok: #3f7d4e;
  --warn: #9a6a1e;
  --danger: #b23b34;

  --r: 10px;
  --shadow: 0 1px 2px rgba(44,30,17,.06), 0 6px 20px rgba(44,30,17,.05);
  --topbar-h: 64px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==== Topbar ==== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .5px;
}
.brand-mark-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14.5px;
  padding: 8px 14px;
  border-radius: 8px;
}
.nav a:hover { background: var(--accent-soft); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.user-name { font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.logout {
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-faint);
  border: 1px solid var(--line-strong);
  padding: 7px 12px;
  border-radius: 8px;
}
.logout:hover { border-color: var(--accent); color: var(--accent-hover); }

/* ==== Main ==== */
.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.page-title {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -.01em;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ==== Buttons ==== */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: 9px;
  padding: 11px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink-faint); color: var(--ink); }
.btn-block { width: 100%; justify-content: center; }
.ic { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ==== Flash ==== */
.flash {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
}
.flash-error {
  background: #fbeceb;
  color: var(--danger);
  border-color: #f0d3d0;
}

/* ==== Login ==== */
.login-wrap {
  min-height: calc(100vh - 2 * 28px);
  display: grid;
  place-items: center;
  padding: 12px 0;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  text-align: center;
}
.login-brand { margin-bottom: 18px; display: flex; justify-content: center; }
.login-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.login-sub {
  margin: 6px 0 24px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.login-form { text-align: left; }
.form-error {
  color: var(--danger);
  background: #fbeceb;
  border: 1px solid #f0d3d0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  margin: 0 0 16px;
  text-align: left;
}

/* ==== Fields ==== */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ==== Dashboard ==== */
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.new-card { padding: 22px 22px 20px; margin-bottom: 18px; }
.card-title { font-size: 18px; font-weight: 800; margin: 0 0 18px; }
.form-actions { display: flex; gap: 12px; margin-top: 4px; }

.search-bar { padding: 16px 20px; margin-bottom: 20px; }
.search-label { font-size: 14px; font-weight: 700; color: var(--ink-soft); display: block; margin-bottom: 10px; }
.search-row { display: flex; align-items: center; gap: 12px; }
.search-row input { flex: 1; }
.search-clear { font-size: 13px; color: var(--ink-faint); text-decoration: none; white-space: nowrap; }
.search-clear:hover { color: var(--accent-hover); }

/* ==== Application list ==== */
.app-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.app-card { padding: 18px 20px; }
.app-main { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.app-row1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.app-name { font-size: 17px; font-weight: 800; }
.app-row2 { display: flex; align-items: center; gap: 12px; margin-top: 4px; color: var(--ink-soft); font-size: 14px; }
.app-phone { font-variant-numeric: tabular-nums; }
.app-source {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 9px;
  font-weight: 600;
}
.app-req { margin: 10px 0 0; color: var(--ink); font-size: 14.5px; }
.app-comment { margin: 6px 0 0; color: var(--ink-faint); font-size: 13.5px; font-style: italic; }

.app-status {
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 10px;
  text-transform: capitalize;
}
.st-new { background: #fdf3e3; color: #96660f; }
.st-measure { background: #eef3fb; color: #33557e; }
.st-work { background: #eaf4ee; color: #356b46; }
.st-done { background: #efe9fb; color: #5b3f96; }
.st-refused { background: #fbeceb; color: var(--danger); }

.app-statuses { display: flex; flex-direction: column; gap: 8px; }
.statuses-label { font-size: 12px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.status-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.status-btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all .12s ease;
}
.status-btn:hover { border-color: var(--accent); color: var(--accent-hover); }
.status-btn.status-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.status-btn:disabled { opacity: .5; cursor: wait; }

/* ==== Empty state ==== */
.empty { text-align: center; padding: 48px 20px; }
.empty-title { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.empty-sub { color: var(--ink-faint); margin: 0; font-size: 14.5px; }

/* ==== Calculator ==== */
.calc-lead { color: var(--ink-soft); margin: 0 0 20px; max-width: 60ch; }
.calc-card { padding: 24px; max-width: 720px; }
.field-wide { grid-column: 1 / -1; }
.seg { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.seg-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-soft);
  background: var(--surface);
}
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.calc-result { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 20px; }
.calc-result-line { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.calc-result-sub { color: var(--ink-soft); font-size: 15px; }
.calc-result-price {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent-ink);
  margin: 4px 0 10px;
  letter-spacing: -.01em;
}
.calc-result-note { color: var(--ink-faint); font-size: 13.5px; margin: 0; max-width: 62ch; }
.calc-note { color: var(--danger); font-size: 14px; font-weight: 600; margin: 12px 0 0; }
.calc-foot { color: var(--ink-faint); font-size: 13.5px; margin-top: 16px; max-width: 62ch; }

/* ==== Responsive ==== */
@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 15px; }
  .nav a { padding: 8px 10px; font-size: 13.5px; }
  .user-name { display: none; }
  .main { padding: 20px 14px 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 0; }
  .grid-2 .field, .grid-3 .field { margin-bottom: 16px; }
  .page-title { font-size: 22px; }
  .calc-result-price { font-size: 25px; }
  .dash-head .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .topbar-inner { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: space-between; margin-left: 0; }
  .nav { order: 3; width: 100%; margin-left: 0; margin-top: 4px; }
}
