/* Палитра и шрифты сервиса «По следам» */
:root {
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --border: #E8E4DF;
  --text: #1A1816;
  --text-muted: #7A756E;
  --accent: #E07B2A;
  --accent-light: #FFF0E0;
  --accent-dark: #C46820;
  --tag-bg: #EDEAE6;
  --green: #2E8B57;
  --red: #C0392B;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Onest', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

h1, h2, h3, .logo { font-family: 'Unbounded', sans-serif; letter-spacing: -0.02em; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-light); border-color: var(--accent); }
/* Чекбоксы/радио не должны растягиваться на всю ширину (иначе ломается вёрстка строк) */
input[type="checkbox"], input[type="radio"] { width: auto; flex: none; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 360px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 18px; margin-bottom: 8px; }
.login-card .hint { color: var(--text-muted); font-size: 12px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- Layout ---------- */
.app { display: none; min-height: 100vh; }
.app.visible { display: grid; grid-template-columns: 220px 1fr; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 24px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.logo { font-size: 16px; font-weight: 700; padding: 0 10px 20px; }
.logo em { font-style: normal; color: var(--accent); }
.nav-item {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--tag-bg); }
.nav-item.active { background: var(--accent-light); color: var(--accent-dark); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.admin-name { padding: 0 12px; font-size: 12px; color: var(--text-muted); }

.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px;
  background: rgba(247, 245, 242, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 18px; margin-right: auto; }
.topbar .search-box { width: 260px; }
/* Кнопки действий в шапке (например, фильтры «Все/Заблокированные/Активные») с отступами */
#top-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  padding: 9px 18px; border-radius: 8px; border: none;
  font-size: 14px; font-weight: 500;
  background: var(--accent); color: #fff;
  transition: background 0.2s;
}
.btn:hover { background: var(--accent-dark); }
.btn.ghost {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:hover { border-color: var(--text); background: var(--surface); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #96281B; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---------- Content + detail panel ---------- */
.content-wrap { display: flex; flex: 1; min-width: 0; }
.content { flex: 1; padding: 24px; min-width: 0; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { border-style: hidden; box-shadow: 0 0 0 1px var(--border); border-radius: 12px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
th {
  background: var(--tag-bg); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover { color: var(--text); }
th .arrow { color: var(--accent); margin-left: 4px; }
tbody tr:hover { background: var(--bg); }
td { font-size: 14px; }
.empty-row { text-align: center; color: var(--text-muted); padding: 32px; }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--text-muted); }
.dot-orange { background: var(--accent); }

.tag {
  display: inline-block; background: var(--tag-bg); border-radius: 6px;
  padding: 2px 8px; font-size: 12px; color: var(--text-muted);
}
.link { color: var(--accent-dark); cursor: pointer; text-decoration: underline; background: none; border: none; font-size: inherit; padding: 0; }

/* Detail panel */
.detail {
  width: 0; overflow: hidden; transition: width 0.2s ease;
  border-left: 1px solid transparent; background: var(--surface);
}
.detail.open { width: 360px; border-left-color: var(--border); }
.detail-inner { width: 360px; padding: 24px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 70px); overflow-y: auto; position: sticky; top: 70px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; }
.detail-head h3 { font-size: 14px; }
.detail-close { background: none; border: none; font-size: 18px; color: var(--text-muted); }
.detail-field { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.detail-field .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 2px; }
.detail-field .value { font-size: 14px; word-break: break-word; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-images { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-images img { width: 96px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26, 24, 22, 0.45);
  display: none; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 48px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; padding: 28px;
  width: 480px; max-width: 100%;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 16px; }
.form-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
.checkbox-field label { margin: 0; font-size: 14px; color: var(--text); }

.point-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.point-row .point-num { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); }
/* Кнопка «выберите файл» не должна вылезать за пределы ячейки/модального окна */
.point-row input { min-width: 0; }
input[type="file"] { max-width: 100%; min-width: 0; font-size: 12px; overflow: hidden; }
input[type="file"]::file-selector-button {
  font-family: inherit; font-size: 12px;
  padding: 5px 10px; margin-right: 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--tag-bg); color: var(--text); cursor: pointer;
}

/* Профиль пользователя */
.profile-head { margin-bottom: 20px; }
.profile-head h2 { font-size: 20px; margin-bottom: 4px; }
.profile-sub { font-size: 13px; color: var(--text-muted); }
.profile-block { margin-top: 28px; }
.profile-block h3 { font-size: 14px; margin-bottom: 10px; }
.profile-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; }
.dash-grid { margin-top: 16px; }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.dash-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 24px;
}
.dash-num {
  font-family: 'Unbounded', sans-serif; font-size: 30px; font-weight: 700;
  letter-spacing: -0.03em; color: var(--accent); line-height: 1.1;
}
.dash-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.dash-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.dash-card-clickable { cursor: pointer; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
.dash-card-clickable:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(224, 123, 42, 0.12); }

/* Графики сводки */
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; margin-top: 20px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--accent); transition: fill 0.15s; }
.chart-bar:hover { fill: var(--accent-dark); }
.chart-label { font-size: 10px; fill: var(--text-muted); font-family: 'Onest', sans-serif; }
.chart-value { font-size: 11px; font-weight: 600; fill: var(--text); font-family: 'Onest', sans-serif; }

.hbar-wrap { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: center; }
.hbar-clickable { cursor: pointer; border-radius: 8px; }
.hbar-clickable:hover .hbar-label { color: var(--accent-dark); }
.hbar-label { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-bars { display: flex; flex-direction: column; gap: 3px; }
.hbar-bar {
  background: var(--accent); border-radius: 4px; min-height: 16px;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 6px;
  min-width: 22px; transition: background 0.15s;
}
.hbar-bar-secondary { background: #8AAE8F; }
.hbar-num { font-size: 11px; color: #fff; font-weight: 600; }

/* Бейджи и переключатели фильтра */
.badge { display: inline-block; border-radius: 100px; padding: 3px 11px; font-size: 12px; font-weight: 500; vertical-align: 3px; }
.badge-green { background: #E4F0E6; color: var(--green); }
.badge-red { background: #F8E3E0; color: var(--red); }
.btn.seg-active { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-light); }

/* Контакты компании */
.contact-list { display: flex; flex-direction: column; gap: 4px; }
.contact-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; margin-bottom: 8px; }
.contacts-editor { margin-bottom: 8px; }
.tag-mr { margin-right: 6px; margin-bottom: 4px; }
.partnership-item { margin-bottom: 6px; display: block; }

/* Античит-время точек */
.time-row { font-size: 13px; color: var(--text); }
.time-total { font-size: 13px; font-weight: 600; margin-top: 4px; }

/* Пагинация */
.page-footer { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.page-info { font-size: 13px; color: var(--text-muted); }

/* Блок «Требуют внимания» на сводке */
.attention-card { grid-column: 1 / -1; }
.attention-row { cursor: pointer; }
.attention-row:hover { background: var(--bg); }

/* Индикатор загрузки (#11) */
#loading-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 500; opacity: 0;
  transition: width 0.3s ease, opacity 0.3s ease;
}
#loading-bar.active { width: 100%; opacity: 1; }

/* Настройки: раскрывающиеся блоки */
.collapse { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.collapse-head {
  width: 100%; text-align: left; border: none; background: transparent;
  padding: 16px 20px; font-family: 'Unbounded', sans-serif; font-size: 14px; font-weight: 600;
}
.collapse-head:hover { background: var(--bg); }
.collapse-arrow { color: var(--accent); }
.collapse-body { padding: 8px 20px 20px; }
.settings-form { max-width: 560px; }
.settings-form .btn { margin-top: 8px; }
.settings-label, .settings-hint { font-size: 13px; color: var(--text-muted); margin: 16px 0 8px; }
.screen-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.screen-name { flex: 1; font-weight: 500; }
.screen-add { display: flex; gap: 8px; margin-top: 10px; max-width: 400px; }
.version-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.version-head { display: flex; align-items: center; gap: 10px; }
.version-notes { font-size: 13px; color: var(--text); margin-top: 4px; white-space: pre-wrap; }
.version-notes.muted { color: var(--text-muted); font-style: italic; }
.template-area { width: 100%; font-family: 'Courier New', monospace; font-size: 13px; margin-bottom: 10px; }

/* Визуальный редактор договора */
.doc-palette { margin-bottom: 10px; }
.doc-palette .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.palette-chip {
  display: inline-block; cursor: grab; user-select: none;
  background: var(--accent-light); color: var(--accent-dark);
  border: 1px solid #F5C89A; border-radius: 100px; padding: 3px 12px; font-size: 12px;
}
.palette-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.doc-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.doc-editor {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 20px 24px; min-height: 360px; max-height: 600px; overflow-y: auto;
  font-family: 'Times New Roman', serif; font-size: 14px; line-height: 1.5;
  margin-bottom: 10px;
}
.doc-editor:focus { outline: 2px solid var(--accent-light); border-color: var(--accent); }
.doc-editor .ct {
  background: var(--accent-light); color: var(--accent-dark);
  border-radius: 4px; padding: 0 5px; font-size: 0.92em; white-space: nowrap;
}
.doc-editor .sec, .doc-editor .var { font-weight: 700; }
.doc-editor h1 { font-size: 16px; text-align: center; }
.doc-editor h2 { font-size: 14px; text-align: center; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; transform: translateY(8px); transition: all 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }
