/* Konveer Hub — админка. Без внешних шрифтов и CDN: CSP разрешает только свои файлы. */
:root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --ink: #111418;
    --ink-2: #3b424c;
    --muted: #6b7280;
    --line: #e2e5e9;
    --line-strong: #cfd4da;
    --accent: #0b6e4f;
    --accent-ink: #ffffff;
    --accent-soft: #e6f2ed;
    --ok: #15803d;   --ok-soft: #e7f5ec;
    --warn: #a15c07; --warn-soft: #fdf3e2;
    --bad: #b42318;  --bad-soft: #fdecea;
    --side: #15181d;
    --side-ink: #c9ced6;
    --side-muted: #7d8592;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 600; letter-spacing: .01em; }
.side .brand .mark { width: 26px; height: 26px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.side nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.side .group { margin: 14px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); }
.side nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 5px; color: var(--side-ink); }
.side nav a:hover { background: #1f242b; text-decoration: none; color: #fff; }
.side nav a.active { background: #252b33; color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.side nav a .count { font-size: 11px; background: #3a414b; color: #fff; padding: 0 6px; border-radius: 9px; }
.side nav a .count.alert { background: var(--bad); }
.side .me { border-top: 1px solid #262b33; padding: 12px 18px 16px; font-size: 13px; }
.side .me .who { color: #fff; font-weight: 500; }
.side .me .links { display: flex; gap: 12px; margin-top: 6px; }
.side .me a, .side .me button { color: var(--side-muted); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.side .me a:hover, .side .me button:hover { color: #fff; text-decoration: none; }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; padding: 24px 28px 64px; }

/* ---------- Заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; line-height: 1.3; margin: 0; font-weight: 600; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); max-width: 720px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- Панели ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.panel-head .hint { color: var(--muted); font-size: 13px; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }

/* ---------- Цифры ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat.alert .value { color: var(--bad); }
.stat a { color: inherit; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 600; }
table.data .sub { color: var(--muted); font-size: 12.5px; }
.plate { font-family: var(--mono); font-weight: 600; letter-spacing: .03em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; }

/* ---------- Статусы ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 10px; background: #eef0f3; color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.note { font-size: 12.5px; margin-top: 4px; }
.note.bad { color: var(--bad); }
.note.warn { color: var(--warn); }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn:disabled, .btn.is-loading { opacity: .65; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); filter: none; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.ghost:hover { background: #eceef1; filter: none; }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #f0c4bf; }
.btn.danger:hover { background: var(--bad-soft); filter: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn .spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Формы ---------- */
.form-section { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 20px 16px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section > header h3 { font-size: 14px; margin: 0 0 4px; font-weight: 600; }
.form-section > header p { margin: 0; color: var(--muted); font-size: 13px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields .wide { grid-column: 1 / -1; }
.field label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
.field label .opt { font-weight: 400; color: var(--muted); }
.field .help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.field .error-text { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=url], input[type=email], input[type=search], input[type=datetime-local], select, textarea {
    width: 100%; height: 34px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit;
}
textarea { height: auto; min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.field.invalid input:focus { box-shadow: 0 0 0 3px var(--bad-soft); }
input[type=file] { font: inherit; font-size: 13px; }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; height: 34px; border-left: 0; }

.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 2px 0; }
.switch input { appearance: none; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; cursor: pointer; margin: 1px 0 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch .text strong { display: block; font-weight: 500; }
.switch .text span { color: var(--muted); font-size: 12.5px; }

.form-actions { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.form-actions .status { margin-left: auto; color: var(--muted); font-size: 13px; }

.alert-box { border: 1px solid; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
.alert-box.bad { background: var(--bad-soft); border-color: #f3c7c1; color: #7a1a12; }
.alert-box.warn { background: var(--warn-soft); border-color: #f1d9b0; color: #6b3f05; }
.alert-box.info { background: var(--accent-soft); border-color: #bcdccf; color: #0b4a36; }

/* ---------- Фильтры ---------- */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 170px; }
.filters .field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.filters .switch { align-self: center; margin-top: 18px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---------- Связь объекта ---------- */
.conn { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.conn dl { display: flex; gap: 24px; margin: 0; flex-wrap: wrap; }
.conn dt { font-size: 12px; color: var(--muted); }
.conn dd { margin: 0; font-weight: 500; }
.conn .btn { margin-left: auto; }

/* ---------- Сторис ---------- */
.thumb { width: 54px; height: 96px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); display: block; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); display: block; }
.order-input { width: 76px !important; }

/* ---------- Уведомления и диалоги ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 380px; font-size: 13.5px; animation: toast-in .18s ease-out; }
.toast.bad { background: var(--bad); }
.toast.ok { background: #13402f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
dialog.confirm { border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.2); }
dialog.confirm::backdrop { background: rgba(17, 20, 24, .4); }
dialog.confirm .body { padding: 18px 20px 6px; }
dialog.confirm h3 { margin: 0 0 6px; font-size: 16px; }
dialog.confirm p { margin: 0; color: var(--ink-2); }
dialog.confirm .buttons { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; }

/* ---------- Вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 28px; }
.auth-card .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.auth-card .brand .mark { width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.auth-card .lead { color: var(--muted); margin: 0 0 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; height: 38px; }
.pw { position: relative; }
.pw input { padding-right: 70px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; padding: 4px 6px; }
.pw button:hover { color: var(--ink); }
.strength { height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s, background .2s; }

/* ---------- Телефон ---------- */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    .app.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
    .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
    .topbar button { background: none; border: 1px solid #39404a; color: #fff; border-radius: 5px; height: 32px; padding: 0 10px; font: inherit; cursor: pointer; }
    .content { padding: 18px 16px 48px; }
    .form-section { grid-template-columns: 1fr; gap: 12px; }
    .fields { grid-template-columns: 1fr; }
}
.conn .full { flex-basis: 100%; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.resolve { display: flex; gap: 6px; margin-top: 6px; }
.resolve input { height: 28px; font-size: 13px; min-width: 160px; }
.note:not(.bad):not(.warn) { color: var(--ink-2); }
