/* solkeyservice — дизайн-система дашборда.
   Тёмная тема по умолчанию, светлая — отдельный набор шагов (не инверсия).
   Шрифт интерфейса — системный sans; моноширинный только для адресов и сумм. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px;
  --maxw: 1180px;
  --t-fast: .14s ease; --t: .22s cubic-bezier(.4,0,.2,1);
}

:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --plane:   #0b0d10;
  --plane-2: #0f1216;
  --surface: #151a20;
  --surface-2: #1b212a;
  --raise:   #202834;
  --control: #202730;
  --hover:   #232c38;
  --line:    rgba(255,255,255,.09);
  --line-2:  rgba(255,255,255,.05);
  --ink:     #f3f6fa;
  --ink-2:   #aeb8c4;
  --muted:   #6f7c8c;
  --accent:  #4c8dff;
  --accent-2:#6aa4ff;
  --accent-fade: rgba(76,141,255,.14);
  --good:    #35c977;
  --good-fade: rgba(53,201,119,.14);
  --warn:    #f2b336;
  --warn-fade: rgba(242,179,54,.14);
  --bad:     #f0555f;
  --bad-fade: rgba(240,85,95,.14);
  --shadow:  0 8px 30px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.3);
}

:root[data-theme="light"] {
  color-scheme: light;
  --plane:   #eef1f5;
  --plane-2: #e7ebf1;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --raise:   #ffffff;
  --control: #f1f4f8;
  --hover:   #eef2f7;
  --line:    rgba(15,25,40,.12);
  --line-2:  rgba(15,25,40,.06);
  --ink:     #101722;
  --ink-2:   #48566a;
  --muted:   #7d8a9c;
  --accent:  #2f6bdc;
  --accent-2:#2f6bdc;
  --accent-fade: rgba(47,107,220,.1);
  --good:    #17a55a;
  --good-fade: rgba(23,165,90,.12);
  --warn:    #c6870e;
  --warn-fade: rgba(198,135,14,.14);
  --bad:     #d83b45;
  --bad-fade: rgba(216,59,69,.12);
  --shadow:  0 10px 30px rgba(20,35,60,.12);
  --shadow-sm: 0 2px 10px rgba(20,35,60,.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink-2);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { color: var(--ink); margin: 0; font-weight: 650; letter-spacing: -.01em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* --- загрузка --- */
.boot { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- каркас --- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--plane) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; font-size: 15px; }
.brand .mark { color: var(--accent); font-size: 18px; }
.tabs { display: flex; gap: 4px; margin-left: 6px; }
.tab { padding: 7px 14px; border-radius: 999px; color: var(--ink-2); font-weight: 550;
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast); border: 0; background: none; font-size: 13.5px; }
.tab:hover { background: var(--hover); }
.tab.active { background: var(--accent-fade); color: var(--accent); }
.appbar .spacer { flex: 1; }
.live { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.live.on .dot { animation: pulse 2s infinite; }
.live.stale .dot { background: var(--warn); }
.live.off .dot { background: var(--bad); }
@keyframes pulse { 0%{box-shadow:0 0 0 0 var(--good-fade);} 70%{box-shadow:0 0 0 7px transparent;} 100%{box-shadow:0 0 0 0 transparent;} }
.icon-btn { width: 36px; height: 36px; display: grid; place-content: center; border-radius: 10px;
  background: var(--control); border: 1px solid var(--line); color: var(--ink-2); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast); font-size: 15px; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

main.wrap { max-width: var(--maxw); margin: 0 auto; padding: 22px 20px 60px; }

/* --- карточки --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-sm); }
.stack > * + * { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h2 { font-size: 15px; }

/* --- сетка обзора --- */
.overview { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
@media (max-width: 860px) { .overview { grid-template-columns: 1fr; } }

.epoch-card { display: grid; gap: 16px; justify-items: center; text-align: center; }
.ring { width: 168px; height: 168px; position: relative; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1); }
.ring .val { position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; }
.ring .val b { font-size: 30px; color: var(--ink); font-family: var(--mono); letter-spacing: -.02em; }
.ring .val span { color: var(--muted); font-size: 12px; }
.epoch-meta { display: grid; gap: 6px; width: 100%; }
.epoch-meta .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.epoch-meta .row span:first-child { color: var(--muted); }
.epoch-meta .row span:last-child { color: var(--ink); font-family: var(--mono); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.tile .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tile .v { color: var(--ink); font-size: 24px; font-family: var(--mono); letter-spacing: -.02em; }
.tile .v small { font-size: 13px; color: var(--muted); font-family: var(--font); }
.tile.good .v { color: var(--good); } .tile.warn .v { color: var(--warn); } .tile.bad .v { color: var(--bad); }

/* --- таблица нод --- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search { flex: 1; min-width: 180px; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 34px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.seg { display: inline-flex; background: var(--control); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--ink-2); padding: 6px 12px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; color: var(--muted); font-weight: 550; font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
thead th.num { text-align: right; }
thead th .arw { color: var(--accent); }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
tbody tr { cursor: pointer; transition: background var(--t-fast); }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
.node-name { display: flex; align-items: center; gap: 9px; }
.node-name b { color: var(--ink); font-weight: 600; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.ok { background: var(--good); } .status-dot.skip { background: var(--muted); }
.status-dot.warn { background: var(--warn); } .status-dot.bad { background: var(--bad); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.chip.n { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.chip.ok { background: var(--good-fade); color: var(--good); }
.chip.warn { background: var(--warn-fade); color: var(--warn); }
.chip.bad { background: var(--bad-fade); color: var(--bad); }
.chip.acc { background: var(--accent-fade); color: var(--accent); }
.plan-cell { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.plan-arrow { color: var(--muted); }

/* --- кнопки, поля --- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--control); color: var(--ink); font: inherit; font-weight: 550;
  cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: none; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select { background: var(--control); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font: inherit; outline: none; transition: border-color var(--t-fast); }
input:focus, select:focus { border-color: var(--accent); }

/* --- drawer детали ноды --- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; opacity: 0; pointer-events: none; transition: opacity var(--t); }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); z-index: 70;
  background: var(--plane-2); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform var(--t); overflow-y: auto; }
.drawer.open { transform: none; }
.drawer-h { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 20px; background: var(--plane-2); border-bottom: 1px solid var(--line); z-index: 1; }
.drawer-h h2 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.drawer-body { padding: 20px; display: grid; gap: 16px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; color: var(--ink); }
.kv dd .mono { word-break: break-all; }
.sub { color: var(--muted); font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.flow .amt { font-family: var(--mono); color: var(--ink); font-size: 15px; }
.flow .to { color: var(--muted); }

.alert { padding: 10px 13px; border-radius: 10px; font-size: 13px; }
.alert-bad { background: var(--bad-fade); color: var(--bad); }
.alert-warn { background: var(--warn-fade); color: var(--warn); }
.banner { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--r-md);
  background: var(--warn-fade); color: var(--warn); margin-bottom: 16px; }
.banner.bad { background: var(--bad-fade); color: var(--bad); }

/* --- логи --- */
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 70vh; overflow: auto; }
.log-list .grp { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 12px 12px 6px; }
.log-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer; transition: background var(--t-fast); }
.log-list li:hover { background: var(--hover); }
.log-list li.active { background: var(--accent-fade); color: var(--accent); }
.log-view { background: var(--plane); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all;
  max-height: 70vh; overflow: auto; color: var(--ink-2); }
.logs-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .logs-grid { grid-template-columns: 1fr; } }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* --- вход --- */
.login-page { display: grid; place-content: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-fade), transparent), var(--plane); }
.login-shell { display: grid; justify-items: center; gap: 14px; padding: 24px; }
.login-card { width: min(360px, 92vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 26px; box-shadow: var(--shadow); display: grid; gap: 14px; text-align: center; }
.field { display: grid; gap: 6px; text-align: left; }
.field span { color: var(--muted); font-size: 12px; }

/* --- всплывающие сообщения --- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 10px; max-width: 340px; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--raise); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink);
  animation: toast-in .25s ease; }
.toast .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--accent); }
.toast.good .bar { background: var(--good); } .toast.warn .bar { background: var(--warn); } .toast.bad .bar { background: var(--bad); }
.toast .msg { font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 560px) {
  .tabs .tab { padding: 7px 10px; }
  .brand span.name { display: none; }
  main.wrap { padding: 16px 14px 50px; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* --- журнал --- */
.journal-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .journal-grid { grid-template-columns: 1fr; } }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 70vh; overflow: auto; }
.log-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer; transition: background var(--t-fast); }
.log-list li:hover { background: var(--hover); }
.log-list li.active { background: var(--accent-fade); color: var(--accent); }
.log-view { background: var(--plane); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all;
  max-height: 40vh; overflow: auto; color: var(--ink-2); }
tr.op-row { cursor: pointer; }
ul.audit { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.audit li { padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
ul.notes { margin: 0; padding-left: 20px; display: grid; gap: 7px; color: var(--ink-2); }
h3.mt, h2.mt { margin-top: 20px; }
.nowrap { white-space: nowrap; }
.bad { color: var(--bad); }
.link-like { cursor: pointer; border-bottom: 1px dashed var(--line); }

/* --- формы --- */
.field.wide { width: 100%; }
.field.wide input { width: 100%; }
.check { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; cursor: pointer; color: var(--ink-2); }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--accent); }
.settings-form { display: grid; gap: 12px; max-width: 620px; }
.settings-form h2 { font-size: 15px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

/* --- операции в карточке ноды --- */
.action { border-top: 1px solid var(--line-2); padding-top: 14px; margin-top: 14px; display: grid; gap: 9px; }
.action:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.action-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.action-h b { color: var(--ink); }
.action-row { display: flex; gap: 8px; }
.action-row input { flex: 1; min-width: 0; }

/* --- модальное подтверждение --- */
.modal { position: fixed; z-index: 80; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(440px, 92vw); background: var(--raise); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 22px; display: grid; gap: 14px;
  animation: pop .18s ease; }
.modal h2 { font-size: 17px; }
.modal .kv { grid-template-columns: 110px 1fr; }
.modal .kv dd { word-break: break-all; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%); } }

/* --- второй фактор --- */
.steps { list-style: none; counter-reset: step; margin: 0 0 4px; padding: 0;
  display: flex; gap: 8px; }
.steps li { counter-increment: step; flex: 1; font-size: 12px; color: var(--muted);
  padding-top: 22px; position: relative; text-align: center; }
.steps li::before { content: counter(step); position: absolute; top: 0; left: 50%;
  transform: translateX(-50%); width: 18px; height: 18px; border-radius: 50%;
  background: var(--control); border: 1px solid var(--line); color: var(--muted);
  font-size: 11px; line-height: 17px; }
.steps li.on { color: var(--ink); }
.steps li.on::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li.done::before { content: "✓"; background: var(--good-fade); border-color: transparent; color: var(--good); }
.panel.step { display: grid; gap: 12px; }
.qr { display: flex; justify-content: center; }
.qr svg { width: 220px; height: 220px; border-radius: 10px; padding: 8px; background: #fff;
  box-shadow: var(--shadow-sm); }
.center { text-align: center; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.manual { border-top: 1px solid var(--line-2); padding-top: 10px; }
.manual .flow { justify-content: center; }
code.secret { font-family: var(--mono); font-size: 14px; letter-spacing: .08em;
  background: var(--control); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; color: var(--ink); word-break: break-all; }
.code-input { width: 100%; text-align: center; font-family: var(--mono);
  font-size: 30px; letter-spacing: .3em; padding: 12px; }
.code-input.small-code { font-size: 16px; letter-spacing: .12em; padding: 9px 12px; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.codes span { font-family: var(--mono); font-size: 14px; text-align: center; color: var(--ink);
  background: var(--control); border: 1px solid var(--line); border-radius: 8px; padding: 8px 4px; }

/* --- вход: шаг кода --- */
.login-card .code-input { font-size: 26px; }
