/* DF Lead Finder — локальный интерфейс. Светлая спокойная тема, без внешних шрифтов и ресурсов. */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #5d6978;
  --border: #d8dde4;
  --border-strong: #b9c1cc;
  --accent: #1d5a85;
  --accent-hover: #164a6e;
  --accent-weak: #e7f0f7;
  --ok: #1d6f42;
  --ok-weak: #e6f4ec;
  --warn: #7f5200;
  --warn-weak: #fcf2dc;
  --err: #9d2626;
  --err-weak: #fbe9e9;
  --neutral-weak: #eef1f5;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 600; }
p { margin: 6px 0; }
code, pre, .mono { font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace; font-size: 12.5px; }

/* ---- каркас ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-sub { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 13px; }
.topbar-info { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; color: var(--muted); font-size: 13px; min-width: 0; }
.topbar-info > * { min-width: 0; overflow-wrap: anywhere; }
.layout { display: flex; min-height: calc(100vh - 46px); }
.sidebar {
  width: 168px; flex: 0 0 168px; padding: 16px 10px; border-right: 1px solid var(--border);
  background: var(--panel); display: flex; flex-direction: column; gap: 2px;
}
.sidebar a {
  display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.sidebar a:hover { background: var(--neutral-weak); }
.sidebar a.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
main { flex: 1; min-width: 0; padding: 18px 20px 60px; max-width: 1480px; }
main:focus { outline: none; }

/* ---- блоки ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); min-width: 0;
}
.panel > h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.wrap { overflow-wrap: anywhere; word-break: break-word; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.stack > * + * { margin-top: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 10px 0; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--panel); min-width: 0; }
.card .label { color: var(--muted); font-size: 12.5px; }
.card .value { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.card .note { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
button.stat-card { text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.stat-card:hover { border-color: var(--border-strong); }

/* ---- вкладки ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button, .tabs a {
  background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer;
  color: var(--muted); font: inherit; text-decoration: none; margin-bottom: -1px;
}
.tabs .active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 10px; background: var(--neutral-weak); color: var(--muted); font-size: 12px; font-weight: 400; }

/* ---- формы ---- */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
label.field > span.lbl { color: var(--text); font-weight: 500; }
label.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 4px; background: #fff;
  color: var(--text); min-width: 0; max-width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #8fb7d6; outline-offset: 1px; }
textarea { resize: vertical; min-height: 64px; }
input.w-xs { width: 70px; } input.w-s { width: 110px; } input.w-m { width: 220px; } input.w-l { width: 360px; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: flex-start; }
.checks .desc { color: var(--muted); font-size: 12.5px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px; min-width: 0; }
legend { padding: 0 6px; font-weight: 600; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: flex; gap: 6px; align-items: center; }

button.btn, a.btn {
  font: inherit; padding: 7px 14px; border-radius: 4px; border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
button.btn:hover, a.btn:hover { background: var(--neutral-weak); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.primary:hover { background: var(--accent-hover); }
button.btn.danger { color: var(--err); border-color: #d9a3a3; }
button.btn:disabled, button.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
button.link { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; overflow-wrap: anywhere; }
button.link:hover { text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* ---- сообщения ---- */
.alert { border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; border: 1px solid; overflow-wrap: anywhere; }
.alert.info { background: var(--accent-weak); border-color: #c4d8e8; }
.alert.warn { background: var(--warn-weak); border-color: #ecd3a0; color: #4d3500; }
.alert.error { background: var(--err-weak); border-color: #e8bcbc; color: #5f1717; }
.alert.ok { background: var(--ok-weak); border-color: #b9dcc7; color: #124a2b; }
.alert details { margin-top: 6px; }
.alert pre { white-space: pre-wrap; margin: 6px 0 0; }
.loading { color: var(--muted); padding: 18px 4px; }
.loading::before { content: "⏳ "; }
.empty { color: var(--muted); padding: 22px 12px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #fbfcfd; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.5;
}
.badge.ok { background: var(--ok-weak); color: var(--ok); border-color: #b9dcc7; }
.badge.warn { background: var(--warn-weak); color: var(--warn); border-color: #ecd3a0; }
.badge.err { background: var(--err-weak); color: var(--err); border-color: #e8bcbc; }
.badge.run { background: var(--accent-weak); color: var(--accent); border-color: #c4d8e8; }
.badge.neutral { background: var(--neutral-weak); color: var(--muted); border-color: var(--border); }

/* ---- таблицы ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 7px 9px; border-bottom: 1px solid #e9ecf0; text-align: left; vertical-align: top; }
table.data th { background: #f8f9fb; font-weight: 600; color: #3b4652; position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num { text-align: right; white-space: nowrap; }
table.data td.nowrap { white-space: nowrap; }
table.data td.trunc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.wide { min-width: 200px; max-width: 420px; overflow-wrap: anywhere; }
table.data td.mid { min-width: 120px; max-width: 230px; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
table.data td.check, table.data th.check { width: 30px; }
.pager { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.selection-bar {
  position: sticky; bottom: 0; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 10px 12px; margin-top: 10px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; box-shadow: 0 -2px 6px rgba(20,30,45,0.06);
}

/* ---- журнал ---- */
pre.log {
  background: #f8f9fb; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; max-height: 360px;
  overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
}
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 6px 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }

/* ---- карточка (боковая панель) ---- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); background: var(--panel); z-index: 40;
  border-left: 1px solid var(--border-strong); box-shadow: -4px 0 18px rgba(20,30,45,0.12); overflow-y: auto; padding: 18px 20px 40px;
}
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20, 30, 45, 0.25); z-index: 30; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.drawer-head h2 { overflow-wrap: anywhere; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #23303d; color: #fff; padding: 9px 16px;
  border-radius: var(--radius); z-index: 60; max-width: 90vw; overflow-wrap: anywhere; box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding: 8px; }
  main { padding: 14px; }
}

/* профиль компании (задание 6) */
.profile h3 { margin-top: 18px; }
ul.features { list-style: none; padding-left: 0; columns: 2; column-gap: 24px; }
ul.features li { margin: 3px 0; break-inside: avoid; }
@media (max-width: 900px) { ul.features { columns: 1; } }
button.btn.small { padding: 2px 8px; font-size: 12px; margin: 1px 2px; }

/* серверный режим: страница входа (задание 12) */
.login { max-width: 480px; margin: 48px auto; padding: 0 16px; }
