:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1a2027;
  --muted: #6b7683;
  --line: #e2e7ec;
  --accent: #0d6b4f;
  --accent-ink: #ffffff;
  --alert: #b23b3b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}

h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 12px; }

button, .link {
  font: inherit;
  cursor: pointer;
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
}

button.link, .link {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

textarea { width: 100%; resize: vertical; }

/* --- Вход --- */
.login { max-width: 360px; margin: 60px auto; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login input { font-size: 16px; }

.alert { color: var(--alert); font-size: 14px; }

/* --- Сводка --- */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--muted);
}
.chip b { color: var(--ink); }
.chip-total b { color: var(--accent); }

/* --- Фильтры --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.filters input[type="search"] { flex: 1; min-width: 180px; }

/* --- Таблица --- */
.table-scroll { overflow-x: auto; }
table.leads {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
table.leads th, table.leads td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
table.leads th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.leads tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.inline-status { display: flex; gap: 6px; }
.inline-status button { padding: 6px 10px; font-size: 13px; }
.no-js-hide { display: none; }

/* --- Карточка заявки --- */
.detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th {
  text-align: left;
  width: 190px;
  padding: 8px 12px 8px 0;
  color: var(--muted);
  font-weight: 500;
  vertical-align: top;
}
table.kv td { padding: 8px 0; border-bottom: 1px solid var(--line); }
table.kv tr:last-child td { border-bottom: 0; }
.pre { white-space: pre-wrap; }

.card form { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.card form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); width: 100%; max-width: 520px; }

.history { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.history li { margin-bottom: 4px; }

/* --- Бейджи статусов --- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-new { background: #e5efff; color: #1c4fa1; }
.badge-in_progress { background: #fff2d9; color: #8a5b00; }
.badge-callback { background: #e4f7ec; color: #1d7a4c; }
.badge-rejected { background: #f1f1f3; color: #5c5c66; }
.badge-client { background: #d9f2e6; color: #0d6b4f; }

@media (max-width: 600px) {
  .wrap { padding: 14px; }
  .card { padding: 16px; }
  table.kv th { width: 130px; }
}
