/* Malbi ID - веб-кабинет. Цвета знака: #1D3B8F -> #0B7A80. Светлая и тёмная тема по системе. */
:root {
  --brand-1: #1D3B8F;
  --brand-2: #0B7A80;
  --accent: #1f5fd1;
  --accent-ink: #ffffff;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --ink: #141a28;
  --muted: #5d6679;
  --line: #dde2ec;
  --ok: #12805c;
  --ok-bg: #e3f5ee;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 26, 40, .06), 0 4px 16px rgba(20, 26, 40, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #6c9cff;
    --accent-ink: #0b1220;
    --bg: #0f131c;
    --surface: #171c27;
    --surface-2: #1f2633;
    --ink: #e8ecf4;
    --muted: #9aa3b5;
    --line: #2a3242;
    --ok: #4fd1a1;
    --ok-bg: #12332a;
    --warn: #f5b84a;
    --warn-bg: #3a2c12;
    --danger: #ff8a80;
    --danger-bg: #3b1b1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/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; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* Раскладка */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; align-self: start; display: flex; flex-direction: column; gap: .5rem;
  padding: 1.1rem .9rem; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; color: var(--ink); padding: .2rem .4rem; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 9px; }
.company { color: var(--muted); font-size: .85rem; padding: 0 .45rem .6rem; border-bottom: 1px solid var(--line); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: .4rem; }
.sidebar nav a { display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: var(--radius-sm); color: var(--ink); }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .7rem .4rem 0; border-top: 1px solid var(--line); }
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: .8rem; color: var(--muted); }
.content { padding: 2rem clamp(1rem, 4vw, 3rem); max-width: 1100px; width: 100%; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand-1) 18%, transparent), transparent),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent), var(--bg); }
.page-head { margin-bottom: 1.4rem; }
.page-head p { margin: 0; max-width: 70ch; }

/* Иконки навигации - маски SVG */
.ico { width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ico-home { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='15' r='4'/%3E%3Cpath d='M11 12l9-9M17 6l3 3M15 8l2 2'/%3E%3C/svg%3E"); }
.ico-model { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='5' width='14' height='14' rx='3'/%3E%3Cpath d='M9 1v4M15 1v4M9 19v4M15 19v4M1 9h4M1 15h4M19 9h4M19 15h4'/%3E%3C/svg%3E"); }
.ico-users { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='4'/%3E%3Cpath d='M1 21c0-4 4-6 8-6s8 2 8 6M17 4a4 4 0 0 1 0 8M23 21c0-3-2-5-5-6'/%3E%3C/svg%3E"); }
.ico-settings { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0'/%3E%3Ccircle cx='16' cy='6' r='2'/%3E%3Ccircle cx='10' cy='12' r='2'/%3E%3Ccircle cx='18' cy='18' r='2'/%3E%3C/svg%3E"); }
.ico-audit { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M8 13h8M8 17h5'/%3E%3C/svg%3E"); }
.ico-profile { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4 4-7 8-7s8 3 8 7'/%3E%3C/svg%3E"); }
.dot-warn { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-left: auto; }

/* Карточки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem; margin-bottom: 1.1rem; }
.card.narrow { max-width: 680px; }
.card .row + .row { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.table-card { padding: .3rem .4rem; }
.auth-card { width: min(420px, 100%); padding: 2rem 1.8rem; }
.auth-card.wide { width: min(560px, 100%); }
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-head img { border-radius: 14px; box-shadow: 0 6px 20px color-mix(in srgb, var(--brand-1) 30%, transparent); }
.auth-head h1 { margin-top: .7rem; }
.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty img { opacity: .9; border-radius: 16px; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius-sm); padding: .75rem 1rem; margin-bottom: 1rem; }

/* Формы */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field > span { font-weight: 600; font-size: .9rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .62rem .75rem; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { font-family: var(--mono); font-size: .88rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .4rem 0 1rem; cursor: pointer; }
.check input { margin-top: .25rem; width: 18px; height: 18px; accent-color: var(--accent); }
.check small { display: block; }
.form-error { color: var(--danger); background: var(--danger-bg); border-radius: var(--radius-sm); padding: .55rem .75rem; margin: 0 0 1rem; }
.profiles { border: 0; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.profiles legend { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.profile-option { display: flex; gap: .7rem; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .75rem .85rem; cursor: pointer; }
.profile-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.profile-option input { margin-top: .3rem; accent-color: var(--accent); }
.profile-option span { display: flex; flex-direction: column; }
details.manual { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
details.manual summary { cursor: pointer; color: var(--muted); margin-bottom: .8rem; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  border-radius: 999px; border: 1px solid transparent; padding: .6rem 1.15rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: .35rem .8rem; font-size: .86rem; }
.btn-block { width: 100%; padding: .75rem; }
.row { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
.row.end { justify-content: flex-end; margin-top: .6rem; }
.page-head.row.between { align-items: flex-start; }

/* Значки, таблицы, чипы */
.badge { display: inline-block; font-size: .76rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); margin-left: .35rem; vertical-align: middle; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem .8rem; }
.table td { padding: .75rem .8rem; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr.disabled td { opacity: .6; }
.table .actions { text-align: right; width: 1%; white-space: nowrap; }
.chips { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chips li { background: var(--surface-2); border-radius: 999px; padding: .2rem .7rem; }

/* Меню действий */
details.menu { position: relative; display: inline-block; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 270px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0, 0, 0, .15); padding: .3rem; }
.menu-body button { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; color: var(--ink);
  padding: .55rem .7rem; border-radius: 7px; cursor: pointer; }
.menu-body button:hover { background: var(--surface-2); }
.menu-body button.danger { color: var(--danger); }

/* Секрет (пароль показывается один раз) */
.secret-box { display: flex; align-items: center; gap: .6rem; background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: var(--radius-sm); padding: .7rem .8rem; margin: .4rem 0 1rem; }
.secret { flex: 1; font-size: 1.02rem; word-break: break-all; user-select: all; }
.step p { margin-top: 0; }

/* Переключатель */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* Шаги начала работы */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; max-width: 760px; counter-reset: step; }
.checklist li { counter-increment: step; display: flex; align-items: center; gap: 1rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.checklist li::before { content: counter(step); flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; background: var(--surface-2); color: var(--muted); }
.checklist li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.checklist li.current { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.checklist li.current::before { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; }
.checklist li.locked { opacity: .65; }
.checklist li > div { flex: 1; display: flex; flex-direction: column; }

/* Проверка подключения */
.check-result { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; padding: .75rem .9rem; border-radius: var(--radius-sm);
  background: var(--surface-2); }
.check-result.ok { background: var(--ok-bg); color: var(--ok); }
.check-result.fail { background: var(--danger-bg); color: var(--danger); }
.check-icon { width: 22px; height: 22px; border-radius: 50%; flex: none; background: currentColor; opacity: .9;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11'/%3E%3C/svg%3E") center / contain no-repeat; }
.check-result.ok .check-icon { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm-1.6 15.6-4.3-4.3 1.6-1.6 2.7 2.7 6.1-6.1 1.6 1.6z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm-1.6 15.6-4.3-4.3 1.6-1.6 2.7 2.7 6.1-6.1 1.6 1.6z'/%3E%3C/svg%3E"); }

/* Диалоги и уведомления */
.dialog { border: 0; border-radius: var(--radius); padding: 1.5rem; width: min(480px, calc(100vw - 2rem)); background: var(--surface);
  color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog::backdrop { background: rgba(10, 14, 24, .45); }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg);
  padding: .7rem 1.1rem; border-radius: 999px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 2rem); }
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

/* Телефон: навигация сверху */
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0;
    border-bottom: 1px solid var(--line); padding: .7rem; }
  .company { display: none; }
  .sidebar nav { flex-direction: row; overflow-x: auto; width: 100%; min-width: 0; order: 3; margin: 0; scrollbar-width: thin; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .who { display: none; }
  .content { padding: 1.2rem 1rem; }
  .row.between { flex-wrap: wrap; }
  /* Таблицы на телефоне - карточками: без горизонтальной прокрутки, меню действий не обрезается */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-top: 1px solid var(--line); padding: .6rem 0; }
  .table tr:first-child { border-top: 0; }
  .table td { border: 0; padding: .2rem .8rem; }
  .table .actions { text-align: left; width: 100%; }
  .menu-body { left: 0; right: auto; }
}
