:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --border: #e2e5eb;
  --primary: #2f5bea;
  --primary-hover: #2449c4;
  --danger: #d23b3b;
  --success: #1f9d55;
  --warning: #c98a00;
  --sidebar: #161b29;
  --sidebar-text: #c7cbd6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 24px 0 12px; }
h3 { font-size: 16px; margin: 0 0 12px; }
code { background: #eef0f4; padding: 1px 6px; border-radius: 4px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font-size: 20px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reject { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f0f2f6; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #f0c6c6; }
.btn-danger:hover { background: #fdf0f0; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 17px; }
.btn-block { width: 100%; }
.link-button { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.inline-form { display: inline; }

/* Формы */
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 91, 234, .25); border-color: var(--primary); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
legend { padding: 0 6px; color: var(--muted); font-size: 14px; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-form input, .row-form select { width: auto; flex: 1 1 160px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-main > aside { display: flex; flex-direction: column; gap: 16px; }

/* Карточки, таблицы */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.warn { border-color: #f1d48a; background: #fffaf0; }
.card-link { display: block; color: inherit; }
.card-link:hover { border-color: var(--primary); text-decoration: none; }
.narrow-card { max-width: 520px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table th.num { white-space: normal; min-width: 64px; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.table.compact td:first-child { min-width: 180px; }
.table tr.inactive { opacity: .55; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-word; }
.props + .actions { margin-top: 14px; }
.list-item { display: block; color: inherit; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { text-decoration: none; background: #fafbfc; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef0f4; color: var(--muted); margin-right: 4px; }
.badge-hot { background: #fdecea; color: var(--danger); }
.badge.stage-hired { background: #e3f6ec; color: var(--success); }
.badge.stage-rejected { background: #fdecea; color: var(--danger); }
.status { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef0f4; color: var(--muted); vertical-align: middle; font-weight: 500; }
.status-open, .status-approved { background: #e3f6ec; color: var(--success); }
.status-paused, .status-pending { background: #fff4d6; color: var(--warning); }
.status-closed, .status-rejected { background: #eef0f4; color: var(--muted); }

.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.flash-success { border-color: #b7e4c7; background: #effaf3; }
.flash-error { border-color: #f3c0c0; background: #fdf1f1; }
.flash-info { border-color: #c6d4fa; background: #f0f4ff; margin-bottom: 16px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input[type="search"] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }
.filters label { flex-direction: row; align-items: center; gap: 6px; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #e9ecf1; padding: 3px; border-radius: 9px; }
.tabs a { padding: 5px 12px; border-radius: 7px; color: var(--muted); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.settings-tabs { margin-bottom: 16px; }
.pager { display: flex; gap: 16px; justify-content: center; padding: 12px; }

/* Приложение: боковое меню */
body.app { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--sidebar) 230px, var(--bg) 230px); }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { color: #fff; font-weight: 700; font-size: 19px; padding: 0 10px; }
.org-name { font-size: 13px; padding: 0 10px 12px; color: #8b92a5; }
.business-switch { padding: 0 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.business-switch label { color: #8b92a5; font-size: 12px; }
.business-switch select { background: #232a3d; color: #fff; border-color: #343c52; padding: 6px 8px; }
.account { border-top: 1px solid var(--border); padding: 16px 0 8px; }
.account-title { margin: 0; font-size: 15px; }
.inline-details { display: inline-block; }
.inline-details[open] { display: block; width: 100%; margin-top: 8px; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.badge-business { background: #e8eefc; color: var(--primary); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--sidebar-text); padding: 8px 10px; border-radius: 7px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.sidebar nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-link { color: #fff; display: flex; flex-direction: column; }
.user-link small { color: #8b92a5; }
.sidebar-footer .link-button { color: var(--sidebar-text); text-align: left; }
.content { padding: 24px 28px; min-width: 0; }

/* Канбан */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 16px; align-items: flex-start; }
.column { flex: 0 0 240px; background: #eceff4; border-radius: var(--radius); padding: 10px; min-height: 200px; transition: background .15s; }
.column.over { background: #dfe6fb; }
.column header { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; margin-bottom: 8px; }
.column-hired header { color: var(--success); }
.column-rejected header { color: var(--danger); }
.count { color: var(--muted); font-weight: 500; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; box-shadow: var(--shadow); }
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .5; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 300px; }
dialog::backdrop { background: rgba(16, 24, 40, .4); }

/* Карточка кандидата */
.application { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.application:last-of-type { border-bottom: 0; }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.event { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.event-comment { border-left-color: var(--primary); }
.event-stage { border-left-color: var(--warning); }
.event-interview, .event-feedback { border-left-color: var(--success); }
.event .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.file-row { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.file-row a { flex: 1; word-break: break-all; }
.feedback { padding: 8px 0; border-bottom: 1px solid var(--border); }
.verdict-strong_yes, .verdict-yes { color: var(--success); }
.verdict-no, .verdict-strong_no { color: var(--danger); }
.dict-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.dict-row .row-form { flex: 1; }
.grow { flex: 1; min-width: 200px; }
.hh-actions summary { cursor: pointer; color: var(--primary); }
.hh-actions .form { margin-top: 8px; }
.qr svg { width: 200px; height: 200px; background: #fff; }

/* Аналитика */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr) auto; gap: 10px; align-items: center; padding: 4px 0; }
.bar-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-size: 13px; color: var(--muted); text-align: right; }
progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 6px; background: #eceff4; overflow: hidden; }
progress::-webkit-progress-bar { background: #eceff4; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 6px; }

/* Публичный сайт */
body.site { display: flex; flex-direction: column; min-height: 100vh; }
.site-header { padding: 16px 32px; background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .logo { font-weight: 700; font-size: 20px; color: var(--text); }
.site-main { flex: 1; width: 100%; max-width: 1140px; margin: 0 auto; padding: 32px 24px; }
.narrow { max-width: 760px; }
.auth-card { max-width: 420px; margin: 24px auto; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .content { padding: 16px; }
  .grid-main, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .site-header { padding: 12px 16px; }
  .site-main { padding: 20px 16px; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
}
