:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --line: #e2e5ea;
  --text: #1c2430;
  --muted: #6b7683;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b42318;
  --warn: #b54708;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен перебивать display из классов ниже,
   иначе скрытые блоки остаются на экране */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ---------- вход ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; }

/* ---------- поля ---------- */
label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .35);
  border-color: var(--accent);
}

textarea { resize: vertical; }

/* ---------- кнопки ---------- */
button {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover { background: var(--accent-dark); }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; }

.topbar #search {
  width: 280px;
  margin: 0;
}

.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
}

.chk input { width: auto; margin: 0; }

/* ---------- две колонки ---------- */
.split {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 53px);
}

.left {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.left-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.badge {
  background: #eef1f5;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  color: var(--muted);
}

.cust-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.cust {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}

.cust:hover { background: #f8fafc; }
.cust.active { background: #eaf1ff; box-shadow: inset 3px 0 0 var(--accent); }

.cust-name {
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cust-meta {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.cust-callback {
  color: var(--warn);
  font-weight: 500;
}

.right {
  overflow-y: auto;
  padding: 20px 24px 60px;
}

.placeholder {
  display: grid;
  place-items: center;
  height: 60vh;
  color: var(--muted);
}

/* ---------- карточка ---------- */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.3; }

.totals { display: flex; gap: 24px; text-align: right; white-space: nowrap; }
.totals b { font-size: 16px; }

.section {
  margin: 24px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  background: #fafbfc;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: 8px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

td input {
  margin: 0;
  padding: 4px 6px;
  font-size: 13px;
  text-align: right;
  min-width: 110px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px 14px 2px;
  margin: 0;
}

legend { font-size: 12px; color: var(--muted); padding: 0 4px; }

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.ok { color: #067647; }

/* ---------- модальное окно ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 420px;
}

.modal-card h2 { margin: 0 0 16px; font-size: 17px; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; height: auto; }
  .left { max-height: 40vh; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar #search { width: 100%; }
}

.modal { overflow-y: auto; }
.modal-card.wide { max-width: 860px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#emp-table select { width: auto; margin: 0; padding: 4px 6px; }
.emp-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.emp-form input, .emp-form select { width: auto; flex: 1; min-width: 150px; margin: 0; }
.pass-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #f5d88a;
  border-radius: var(--radius);
}

/* --- круглая кнопка добавления заказчика --- */
.left-title { display: flex; align-items: center; gap: 8px; }
.fab {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .2);
}
.fab:hover { background: var(--accent-dark); }
.fab:active { transform: scale(.94); }

/* --- заголовок раздела с кнопкой --- */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 10px;
}
.section-row .section { margin: 0; }

/* --- подсказки DaData --- */
.dadata-status { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }
.dadata-status.warn { color: var(--warn); }

.dadata-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.dadata-row { margin-bottom: 4px; }
.dadata-row:last-child { margin-bottom: 0; }
