/* Вакансии ishkop — интерфейс. Цвета и размеры — токены в :root. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f6;
  --border: #e4e7eb;
  --border-strong: #d3d8de;
  --text: #15181c;
  --text-2: #3d444d;
  --muted: #6b7380;
  --accent: #0e7c6b;
  --accent-hover: #0b6a5b;
  --accent-weak: #e3f3ef;
  --blue: #1f5fbf;
  --blue-weak: #e8f0fc;
  --green: #137a4b;
  --green-weak: #e5f5ec;
  --red: #b42318;
  --red-weak: #fdecea;
  --amber: #a15c07;
  --amber-weak: #fef3e2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013;
    --surface: #16191d;
    --surface-2: #1d2126;
    --border: #272c33;
    --border-strong: #353b44;
    --text: #e8eaed;
    --text-2: #c3c8cf;
    --muted: #8d96a3;
    --accent: #2fb39c;
    --accent-hover: #3cc5ad;
    --accent-weak: rgba(47, 179, 156, .14);
    --blue: #6aa2f2;
    --blue-weak: rgba(106, 162, 242, .14);
    --green: #4cc38a;
    --green-weak: rgba(76, 195, 138, .14);
    --red: #f07167;
    --red-weak: rgba(240, 113, 103, .14);
    --amber: #e9a23b;
    --amber-weak: rgba(233, 162, 59, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-blue { color: var(--blue); }
.text-red { color: var(--red); }
.icon { flex: none; }
[hidden] { display: none !important; }

/* --- Каркас -------------------------------------------------------------- */

.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { padding: 4px 10px; font-size: 15px; font-weight: 650; white-space: nowrap; }
.brand:hover { color: inherit; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-weak); color: var(--accent); }

.sync-indicator {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--blue-weak); color: var(--blue);
}
.logout { margin-top: auto; }
.sync-indicator:not([hidden]) + .logout { margin-top: 0; }
.nav-button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer;
}
.nav-button:hover { background: var(--surface-2); color: var(--text); }

/* Страница входа */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .form-grid { margin-top: 18px; }
.login-card .btn { width: 100%; justify-content: center; }
.sync-indicator span:last-child { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sync-indicator small { color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.pulse {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--blue);
  box-shadow: 0 0 0 0 var(--blue);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 95, 191, .45); }
  70% { box-shadow: 0 0 0 8px rgba(31, 95, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 95, 191, 0); }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.main { padding: 28px 32px 48px; max-width: 1320px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.page-head p { margin-top: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 14px; }

/* --- Элементы ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head a { color: var(--muted); font-size: 13px; }
.card-head a:hover { color: var(--accent); }
.card-intro { margin: -4px 0 14px; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible, .switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

input, select {
  height: 36px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; min-width: 0;
}
select { padding-right: 28px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7380' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
input[type="number"] { width: 76px; }
input[type="file"] { height: auto; padding: 4px 8px 4px 4px; max-width: 100%; color: var(--text-2); }
input[type="file"]::file-selector-button {
  margin-right: 10px; height: 26px; padding: 0 10px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: inherit;
}

.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Вкладки внутри страницы (настройки) */
.tabs { display: flex; gap: 4px; margin: -4px 0 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a {
  padding: 9px 14px; margin-bottom: -1px; white-space: nowrap;
  color: var(--text-2); font-weight: 550; text-decoration: none; border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.field-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; line-height: 18px; white-space: nowrap;
}
.badge-green { background: var(--green-weak); color: var(--green); }
.badge-blue { background: var(--blue-weak); color: var(--blue); }
.badge-red { background: var(--red-weak); color: var(--red); }
.badge-amber { background: var(--amber-weak); color: var(--amber); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-outline { border: 1px solid var(--border-strong); color: var(--text-2); padding: 1px 8px; }
.badge-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.toast {
  margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius-sm);
  font-weight: 500;
}
.toast-ok { background: var(--green-weak); color: var(--green); }
.toast-err { background: var(--red-weak); color: var(--red); }
.notice { margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm); }
.notice-muted { background: var(--surface-2); color: var(--text-2); }
.notice-err { background: var(--red-weak); color: var(--red); }
.notice-amber { background: var(--amber-weak); color: var(--text-2); }
.notice-amber b { color: var(--amber); }

/* --- Обзор --------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
a.stat:hover { color: inherit; border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-small { font-size: 17px; display: flex; align-items: center; gap: 8px; min-height: 34px; letter-spacing: 0; }
.stat-blue { color: var(--blue); }
.stat-red { color: var(--red); }
.stat-green { color: var(--green); }
.stat-amber { color: var(--amber); }

.meter { display: block; height: 6px; margin: 4px 0 2px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter .meter-amber { background: var(--amber); }
.meter .meter-red { background: var(--red); }
.stat-sub { color: var(--muted); font-size: 12px; }

.live-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 12px 16px;
  border-radius: var(--radius); background: var(--blue-weak); color: var(--blue);
}
.live-banner:hover { color: var(--blue); }
.live-text { display: flex; flex-direction: column; line-height: 1.35; }
.live-text small { color: var(--text-2); }
.live-counters { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 40px 24px; }
.empty h2 { font-size: 17px; margin-bottom: 8px; }
.empty p { max-width: 560px; margin: 0 auto; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.list li:first-child { border-top: 0; padding-top: 2px; }
.list-main { display: flex; flex-direction: column; min-width: 0; }
.list-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-title { font-weight: 550; }
.list-main .muted { font-size: 13px; }
.list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.list-compact li { padding: 7px 0; }

/* --- Таблицы ------------------------------------------------------------- */

.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 550; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th.num { text-align: right; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-2); }
.table-compact th, .table-compact td { padding: 8px 6px; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 0; }
.table-compact th:last-child, .table-compact td:last-child { padding-right: 0; }
.table-compact .row-link:hover td { background: transparent; }
.table-compact .row-link:hover a { color: var(--accent); }
.cell-title { min-width: 280px; max-width: 460px; }
.cell-title a { display: block; font-weight: 550; }
.cell-title .muted { display: block; font-size: 13px; margin-top: 2px; }
.cell-income { min-width: 130px; max-width: 200px; }
.empty-row { text-align: center; color: var(--muted); padding: 36px 14px !important; }
.actions { text-align: right; width: 1%; }

.table-scroll { overflow-x: auto; }
.fields-table th[scope="row"] { width: 150px; color: var(--muted); font-weight: 500; font-size: 13px; white-space: normal; }
.fields-table td { width: 42%; }
.field-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.run-card { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.run-card a { color: var(--accent); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form-grid { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field small { font-weight: 400; margin-left: 6px; }
.field input, .field select { width: 100%; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); }
.check input { height: auto; margin-top: 3px; accent-color: var(--accent); }
.card-note { margin-top: 14px; font-size: 12.5px; }
.key-delete { margin-top: 8px; }
.access-line { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.code-area {
  width: 100%; min-height: 220px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 12.5px/1.55 var(--mono);
}
.code-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.form-actions { margin-top: 10px; }
.code-area-sm { min-height: 150px; }
.inline-edit { margin-top: 6px; }
.inline-edit summary { color: var(--accent); font-size: 13px; }
.inline-edit summary::after { content: none; }
.inline-edit form { margin-top: 10px; max-width: 420px; }
.api-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.guard-notice { margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
code { font: 12.5px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

/* --- Фильтры ------------------------------------------------------------- */

.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; padding: 14px 16px; }
.filters .search {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--muted); background: var(--surface);
}
.filters .search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.filters .search input { border: 0; height: 38px; padding: 0; flex: 1; box-shadow: none; background: transparent; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-row select { max-width: 240px; }

.segmented {
  display: inline-flex; align-self: flex-start;
  padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 10px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; padding: 5px 14px; border-radius: 7px;
  color: var(--text-2); font-weight: 500; cursor: pointer;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* --- Вакансия ------------------------------------------------------------ */

.vacancy-head h1 { max-width: 820px; }
.vacancy-org { display: flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--text-2); font-size: 15px; }
.vacancy-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.vacancy-main, .vacancy-side { display: flex; flex-direction: column; gap: 16px; }

.bullets { margin: 0; padding-left: 20px; }
.bullets li { margin: 4px 0; }
.bullets li::marker { color: var(--accent); }
.bullets-muted { color: var(--text-2); font-size: 13.5px; }

details summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "Показать"; margin-left: auto; color: var(--muted); font-size: 13px; }
details[open] summary::after { content: "Скрыть"; }
.fulltext { margin-top: 12px; color: var(--text-2); }
.fulltext p { margin: 0 0 6px; }

.facts { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-stacked { grid-template-columns: 1fr; gap: 2px; }
.facts-stacked dd { margin-bottom: 8px; }
.fact-line { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 10px; }
.fact-line:last-child { margin-bottom: 0; }
.fact-line .icon { margin-top: 2px; color: var(--muted); }
.fact-note { margin: -2px 0 10px 25px; color: var(--muted); font-size: 12.5px; }
.fact-note a { color: var(--accent); }

/* --- Прогон -------------------------------------------------------------- */

.run-stage { margin: -8px 0 16px; }
.log {
  margin: 0; max-height: 560px; overflow: auto;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-2);
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* --- Настройки ----------------------------------------------------------- */

.switch {
  position: relative; width: 38px; height: 22px; padding: 0;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--border-strong); transition: background .15s;
}
.switch span {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .15s;
}
.switch.on { background: var(--accent); }
.switch.on span { transform: translateX(16px); }
.add-city { margin-top: 14px; }
.proxy-stats { margin-bottom: 12px; font-size: 13.5px; color: var(--text-2); }
.add-city input { flex: 1; min-width: 220px; }

/* --- Узкие экраны -------------------------------------------------------- */

@media (max-width: 1100px) {
  .stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-7 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .vacancy-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; z-index: 10; height: auto;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .nav { flex-direction: row; }
  .nav a { padding: 8px 10px; }
  .sync-indicator { margin: 0 0 0 auto; padding: 6px 10px; }
  .sync-indicator small { display: none; }
  .main { padding: 20px 16px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
  .fields-table th[scope="row"] { width: 110px; }
}

@media (max-width: 560px) {
  .hide-sm { display: none; }
  .sync-indicator span:last-child { display: none; }
  .sync-indicator { padding: 10px; }
  .sidebar { gap: 6px; padding: 10px 12px; }
  .brand { padding: 4px 2px; font-size: 14px; }
  .nav a { padding: 8px; }
  .cell-title { min-width: 0; }
  .cell-income { min-width: 0; }
  .nav a span, .nav-button span { display: none; }
  .nav-button { padding: 8px; }
  .stats, .stats-6, .stats-7 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-value { font-size: 23px; }
  .filter-row select { max-width: none; flex: 1 1 140px; }
  .page-head .inline-form, .page-head .inline-form select { width: 100%; }
}
