:root {
  --bg: #f4f2ed;
  --panel: #ffffff;
  --ink: #1b1a17;
  --muted: #6e6960;
  --line: #e0dbd1;
  --accent: #1f6f4a;
  --accent-ink: #ffffff;
  --warn: #a8481c;
  --hot: #b8860b;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ---------- вход ---------- */

.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }

.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
}
.login-box h1 { font-size: 20px; margin: 0 0 20px; font-weight: 600; }
.login-box label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-box input {
  display: block; width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 4px; font: inherit; background: #fff; color: var(--ink);
}
.login-box button {
  width: 100%; padding: 10px; margin-top: 6px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 4px; font-weight: 600;
}
.error { color: var(--warn); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

.brand { font-weight: 700; letter-spacing: 0.06em; font-size: 14px; }
.brand span { font-weight: 400; color: var(--muted); letter-spacing: 0; }

/* ---------- шапка ---------- */

.top {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.progress { flex: 1; font-size: 13px; color: var(--muted); }
.progress b { color: var(--ink); }
.who { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ---------- две колонки ---------- */

.cols {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
  max-width: 1400px;
}

.side, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.side { overflow: hidden; position: sticky; top: 63px; }

.search {
  width: 100%; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line);
  font: inherit; background: transparent; color: var(--ink);
}
.search:focus { outline: 0; background: #fbfaf7; }

.filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.filters button {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 4px 8px; border-radius: 20px; font-size: 12.5px;
}
.filters button:hover { background: var(--bg); }
.filters button.on { background: var(--ink); color: #fff; }
.filters button i { font-style: normal; opacity: 0.6; margin-left: 4px; }

.list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 190px); overflow-y: auto; }
.list li {
  padding: 9px 14px; border-bottom: 1px solid #f0ece5; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
}
.list li:hover { background: #fbfaf7; }
.list li.on { background: #eef4f0; box-shadow: inset 3px 0 0 var(--accent); }
.list .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { grid-column: 1; font-size: 12px; color: var(--muted); }
.list .due { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 11px; color: var(--warn); }
.list li.waiting { background: #fdf6ec; }
.list li.waiting .due { color: var(--hot); font-weight: 600; }
.list li.waiting:hover { background: #fbf0dd; }

.private { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.private input { margin: 0; }

.wa-link {
  display: inline-flex; align-items: center; padding: 11px 20px;
  border: 1px solid var(--line); border-radius: 4px; text-decoration: none;
  color: var(--ink); font-weight: 600;
}

.hint { padding: 10px 14px; font-size: 12.5px; color: var(--muted); margin: 0; }

/* ---------- карточка ---------- */

.card { padding: 22px 24px 26px; min-height: 60vh; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.card h2 { margin: 0 0 2px; font-size: 21px; font-weight: 600; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.meta a { color: var(--accent); }

.phone { font-size: 22px; letter-spacing: 0.01em; margin: 0 0 4px; }
.phone small { font-size: 13px; color: var(--muted); letter-spacing: 0; margin-left: 8px; }

.actions { display: flex; gap: 10px; margin: 16px 0 22px; flex-wrap: wrap; }
.actions button {
  padding: 11px 20px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel); font-weight: 600;
}
.actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions .wa { border-color: #128c7e; color: #0d6b60; }
.wa-open { align-self: center; font-size: 12.5px; color: #0d6b60; max-width: 320px; line-height: 1.3; }

.row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.field { flex: 1 1 200px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 4px; font: inherit; background: #fff; color: var(--ink);
}
.field textarea { min-height: 74px; resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chips button {
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 13px;
}
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.save-row { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.save-row button {
  padding: 10px 24px; border: 0; border-radius: 4px;
  background: var(--accent); color: #fff; font-weight: 600;
}
.saved { color: var(--accent); font-size: 13px; opacity: 0; transition: opacity 0.2s; }
.saved.on { opacity: 1; }

h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }

.history { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.history li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f2eee7; }
.history time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.history .k { color: var(--muted); }

/* ---------- итог звонка ---------- */

.outcome { border: 1px solid var(--accent); background: #f2f7f4; border-radius: var(--radius); padding: 14px 16px; margin: 0 0 20px; }
.outcome p { margin: 0 0 10px; font-weight: 600; }
.outcome .chips button { background: #fff; }

/* ---------- отчёт ---------- */

.modal { position: fixed; inset: 0; background: rgba(20,18,15,0.45); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal-box { background: var(--panel); border-radius: var(--radius); padding: 26px 28px; width: min(720px, 100%); max-height: 85vh; overflow: auto; position: relative; }
.modal-box h2 { margin: 0 0 16px; font-size: 19px; }
.close { position: absolute; right: 16px; top: 12px; border: 0; background: none; font-size: 24px; color: var(--muted); line-height: 1; }

table { border-collapse: collapse; width: 100%; font-size: 14px; margin-bottom: 22px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .side { position: static; }
  .list { max-height: 40vh; }
}
