/* ===== Дизайн-токены «Линия CRM» =====
   Бриф: тёплая бумага, тонкие линии чертежа, латунные акценты.
   Палитра: акцент #8c6428 (латунь, контраст с белым ≥ 4.5:1), тёмный #2e3638, бумага #f5f2ec. */

:root {
  --color-accent: #8c6428;
  --color-accent-hover: #7a5720;
  --color-accent-soft: #f3e9d9;
  --color-accent-ink: #ffffff;
  --color-brand: #2e3638;
  --color-bg: #f5f2ec;
  --color-surface: #ffffff;
  --color-ink: #212526;
  --color-muted: #636a6b;
  --color-border: #e3ddd2;
  --color-danger: #a3322b;
  --color-danger-soft: #f7e7e5;
  --color-success: #2f6b4f;
  --color-success-soft: #e4efe8;

  --radius: 0.8rem;
  --shadow: 0 1px 2px rgba(46, 54, 56, 0.06), 0 4px 16px rgba(46, 54, 56, 0.05);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-ink);
  background: var(--color-bg);
  text-align: left;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: 1.2;
  text-wrap: balance;
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--color-brand);
}

h1 { font-size: 1.9rem; letter-spacing: 0.01em; }
h2 { font-size: 1.25rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }

.muted { color: var(--color-muted); }
.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;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}

.page { padding-top: 2rem; padding-bottom: 4rem; }
.page-narrow { max-width: 760px; }

/* ===== Шапка ===== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 60px; flex-wrap: wrap; padding-top: 0.5rem; padding-bottom: 0.5rem;
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-heading); font-weight: 600; font-size: 1.2rem;
  color: var(--color-brand);
}
.brand em { font-style: normal; color: var(--color-accent); }
.logo-mark { width: 30px; height: 30px; color: var(--color-accent); flex: 0 0 auto; }
.main-nav {
  display: flex; gap: 0.25rem; flex-wrap: wrap;
}
.main-nav a {
  color: var(--color-brand); padding: 0.4rem 0.7rem; border-radius: 6px;
  font-weight: 500; position: relative;
}
.main-nav a:hover { background: var(--color-accent-soft); color: var(--color-accent-hover); }
.main-nav a.active { color: var(--color-accent-hover); }
.main-nav a.active::after {
  content: ""; position: absolute; left: 0.7rem; right: 0.7rem; bottom: 2px;
  height: 2px; background: var(--color-accent); border-radius: 2px;
}
.badge {
  display: inline-block; min-width: 1.3rem; text-align: center;
  background: var(--color-accent); color: var(--color-accent-ink);
  border-radius: 999px; font-size: 0.72rem; font-weight: 700; padding: 0.05rem 0.4rem;
}
.header-user { display: flex; align-items: center; gap: 0.8rem; margin-left: auto; }
.user-name { color: var(--color-muted); font-size: 0.9rem; }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.6rem 1.1rem; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; min-height: 44px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}
.btn-primary { background: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary:hover { background: var(--color-accent-hover); color: var(--color-accent-ink); }
.btn-secondary {
  background: var(--color-surface); color: var(--color-brand);
  border-color: var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-accent); color: var(--color-accent-hover); }
.btn-block { width: 100%; }
.btn-link {
  background: none; border: none; cursor: pointer; padding: 0.4rem 0.5rem;
  color: var(--color-accent); font-family: var(--font-body); font-size: 0.95rem; font-weight: 500;
}
.btn-link:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* ===== Фокус ===== */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===== Заголовок страницы ===== */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}

/* ===== Карточки ===== */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* ===== Формы ===== */
.form .field, .field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; color: var(--color-brand); }
.req { color: var(--color-muted); font-weight: 400; font-size: 0.85rem; }
.field input, .field select, .field textarea,
.filters input, .filters select {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--color-border);
  border-radius: var(--radius); font-family: var(--font-body); font-size: 1rem;
  color: var(--color-ink); background: var(--color-surface);
  min-height: 44px;
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus {
  border-color: var(--color-accent); outline: none;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.field-error { color: var(--color-danger); font-size: 0.88rem; margin-top: 0.35rem; }
[aria-invalid="true"] { border-color: var(--color-danger) !important; }

/* ===== Алерты ===== */
.alert {
  padding: 0.8rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.alert-error { background: var(--color-danger-soft); color: var(--color-danger); }
.alert-success { background: var(--color-success-soft); color: var(--color-success); }

/* ===== Сводка ===== */
.summary {
  display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.summary-item {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 0.6rem 1rem; text-align: center;
  min-width: 76px;
}
.summary-num { display: block; font-family: var(--font-heading); font-size: 1.4rem; font-weight: 600; color: var(--color-brand); }
.summary-label { font-size: 0.78rem; color: var(--color-muted); }

/* ===== Фильтры ===== */
.filters {
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.filters .search-field { flex: 1 1 240px; min-width: 200px; }
.filters .select-field { flex: 0 1 200px; min-width: 160px; }

/* ===== Список заявок ===== */
.lead-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.lead-list li { margin: 0; }
.lead-card {
  display: block; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem 1.25rem; color: var(--color-ink);
  box-shadow: var(--shadow); transition: border-color 0.15s ease;
}
.lead-card:hover { border-color: var(--color-accent); color: var(--color-ink); }
.lead-card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.lead-name { font-weight: 600; font-size: 1.05rem; color: var(--color-brand); }
.lead-card-meta { display: flex; gap: 0.5rem; color: var(--color-muted); font-size: 0.92rem; margin-top: 0.25rem; flex-wrap: wrap; }
.lead-card-foot { display: flex; gap: 1rem; margin-top: 0.6rem; font-size: 0.9rem; color: var(--color-brand); }
.dot { color: var(--color-border); }

/* ===== Статусы ===== */
.status {
  font-size: 0.8rem; font-weight: 600; padding: 0.15rem 0.6rem;
  border-radius: 999px; border: 1px solid var(--color-border); color: var(--color-muted);
  white-space: nowrap;
}
.status-new { background: var(--color-accent-soft); color: var(--color-accent-hover); border-color: var(--color-accent); }
.status-closed { background: var(--color-success-soft); color: var(--color-success); border-color: var(--color-success); }
.status-rejected { background: var(--color-danger-soft); color: var(--color-danger); border-color: var(--color-danger); }

/* ===== Статусная линия (карточка) ===== */
.status-track { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.status-step {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0;
  position: relative;
}
.status-step:not(:last-child)::before {
  content: ""; position: absolute; left: 6px; top: 1.5rem; bottom: -0.35rem;
  width: 2px; background: var(--color-border);
}
.status-dot {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--color-border);
  background: var(--color-surface); flex: 0 0 auto; position: relative; z-index: 1;
}
.status-step.done .status-dot { background: var(--color-accent); border-color: var(--color-accent); }
.status-step.done:not(:last-child)::before { background: var(--color-accent); }
.status-step.current .status-dot {
  background: var(--color-accent); border-color: var(--color-accent-hover);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}
.status-step.current .status-step-label { color: var(--color-brand); font-weight: 600; }
.status-step-label { color: var(--color-muted); font-size: 0.92rem; }
.status-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.status-actions select { min-width: 160px; padding: 0.55rem 0.7rem; border: 1px solid var(--color-border); border-radius: var(--radius); min-height: 44px; }

/* ===== Сетка карточки заявки ===== */
.lead-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 768px) {
  .lead-grid { grid-template-columns: 1fr 1fr; }
  .lead-grid > .card:last-child { grid-column: 1 / -1; }
}

/* ===== Заметки ===== */
.note-list { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.note { padding: 0.75rem 0; border-bottom: 1px solid var(--color-border); }
.note:last-child { border-bottom: none; }
.note-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.85rem; }
.note-author { font-weight: 600; color: var(--color-brand); }
.note-body { margin: 0.3rem 0 0; color: var(--color-ink); }

/* ===== Отчёт ===== */
.report-total { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 1.25rem; }
.report-total-num { font-family: var(--font-heading); font-size: 2.4rem; font-weight: 600; color: var(--color-brand); }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.report-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 1rem; align-items: center; }
.report-label { color: var(--color-brand); font-size: 0.9rem; }
.report-bar { height: 10px; background: var(--color-accent-soft); border-radius: 6px; overflow: hidden; }
.report-bar-fill { height: 100%; background: var(--color-accent); border-radius: 6px; transition: width 0.3s ease; }
.report-num { text-align: right; font-weight: 600; color: var(--color-brand); }

/* ===== Менеджеры ===== */
.manager-list { list-style: none; margin: 0; padding: 0; }
.manager-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--color-border); }
.manager-row:last-child { border-bottom: none; }
.manager-info { display: flex; flex-direction: column; }
.manager-name { font-weight: 600; color: var(--color-brand); }
.role-badge { font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid var(--color-border); color: var(--color-muted); }
.role-admin { background: var(--color-accent-soft); color: var(--color-accent-hover); border-color: var(--color-accent); }

/* ===== Уведомления ===== */
.notification-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.notification { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.notification.unread { border-left: 3px solid var(--color-accent); }
.notification-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.notification-title { font-weight: 600; color: var(--color-brand); }
.notification-title:hover { color: var(--color-accent-hover); }
.notification-meta { display: flex; gap: 0.5rem; color: var(--color-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ===== Пустые состояния ===== */
.empty { text-align: center; padding: 3rem 1rem; }
.empty h2 { margin-bottom: 0.5rem; }
.empty .btn { margin-top: 1rem; }

/* ===== Вход ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 400px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 2.5rem 2rem; box-shadow: var(--shadow); }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .logo-mark { width: 44px; height: 44px; margin: 0 auto 1rem; display: block; }
.login-brand h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.login-form .field { margin-bottom: 1.1rem; }

/* ===== Подвал ===== */
.site-footer { border-top: 1px solid var(--color-border); padding: 1.5rem 0; margin-top: 2rem; }
.footer-inner { color: var(--color-muted); font-size: 0.85rem; }

/* ===== Адаптив ===== */
@media (max-width: 640px) {
  .header-inner { gap: 0.75rem; }
  .header-user .user-name { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .report-row { grid-template-columns: 90px 1fr 32px; gap: 0.5rem; }
  h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .report-bar-fill { transition: width 0.3s ease; }
}
