/* NeoSSH Sync — тема «Graphite», те же токены, что и в приложении (ui/theme/Theme.kt). */
@font-face { font-family: Onest; src: url(fonts/onest_regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Onest; src: url(fonts/onest_medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Onest; src: url(fonts/onest_semibold.ttf) format("truetype"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: Unbounded; src: url(fonts/unbounded_medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }

:root, [data-theme="dark"] {
  --bg: #0B0B0C; --surface: #131315; --surface2: #1A1A1D; --surface3: #242428;
  --line: #222225; --line-strong: #303034;
  --text: #EDEDEF; --muted: #9B9BA1; --faint: #68686F;
  --accent: #3D73F5; --ink: #DADADF; --soft: rgba(255,255,255,.08);
  --danger: #EF6B6B; --danger-soft: rgba(239,107,107,.1); --warn: #DDAA55; --ok: #5CC489;
  --scrim: rgba(0,0,0,.62);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F7F7F8; --surface: #FFFFFF; --surface2: #F1F1F3; --surface3: #E6E6E9;
  --line: #E6E6E9; --line-strong: #D4D4D8;
  --text: #18181B; --muted: #63636B; --faint: #9A9AA2;
  --accent: #2F66EB; --ink: #27272A; --soft: rgba(0,0,0,.06);
  --danger: #D03434; --danger-soft: rgba(208,52,52,.07); --warn: #A86A00; --ok: #23864C;
  --scrim: rgba(0,0,0,.35);
  color-scheme: light;
}
:root {
  --r-s: 8px; --r: 10px; --r-l: 14px;
  --hover: 260ms cubic-bezier(.4,0,.2,1);
  --ui: Onest, system-ui, sans-serif;
  --display: Unbounded, var(--ui);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 400 14px/20px var(--ui);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color var(--hover), color var(--hover);
}
a { color: inherit; text-decoration: none; }
b { font-weight: 600; }
h1 { font: 600 24px/30px var(--ui); letter-spacing: -.3px; margin: 0; }
h2, h3 { margin: 0; }
p { margin: 0; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i .fill { fill: currentColor; stroke: none; }

/* ---------- Каркас: навигационная колонка как в приложении ---------- */
.shell {
  display: flex; min-height: calc(100vh - 27px);
  background: linear-gradient(to right, var(--surface) 84px, var(--line) 84px, var(--line) 85px, transparent 85px);
}
.rail {
  position: sticky; top: 0; height: calc(100vh - 27px);
  width: 85px; flex: none; display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; background: var(--surface); border-right: 1px solid var(--line);
}
.rail-logo { display: block; margin-bottom: 18px; border-radius: 9px; transition: transform var(--hover); }
.rail-logo:hover { transform: scale(1.04); }
.appicon { width: 34px; height: 34px; display: block; }
.rail-item {
  width: 74px; margin: 4px 0; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; border-radius: var(--r); background: transparent; color: var(--muted); cursor: pointer; font: inherit;
  transition: background-color var(--hover), color var(--hover);
}
.rail-item span { font: 500 11px/14px var(--ui); color: var(--faint); transition: color var(--hover); white-space: nowrap; }
.rail-item:hover { background: var(--surface2); color: var(--text); }
.rail-item:hover span { color: var(--muted); }
.rail-item.active { background: var(--surface3); color: var(--text); }
.rail-item.active span { color: var(--text); }
.rail-item:active { transform: scale(.96); }
.rail-spacer { flex: 1; }
.rail-form { margin: 0; }

.main { flex: 1; min-width: 0; }
.content { max-width: 940px; padding: 28px 40px 48px; display: flex; flex-direction: column; gap: 32px; }

.statusbar {
  height: 27px; display: flex; align-items: center; gap: 16px; padding: 0 12px;
  border-top: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 10.5px;
  position: sticky; bottom: 0;
}
.sb-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sb-item b { font-weight: 500; color: var(--text); }
.sb-item svg.i { width: 13px; height: 13px; }
.sb-spacer { flex: 1; }
.faint { color: var(--faint); }

/* ---------- Заголовки и группы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { display: block; font: 500 12.5px/16px var(--ui); color: var(--muted); }
.eyebrow.accent { color: var(--ink); }
.page-head .eyebrow { margin-bottom: 4px; }
.back { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 4px -4px; color: var(--muted); font: 500 12.5px/16px var(--ui); transition: color var(--hover); }
.back:hover { color: var(--text); }
.back svg.i { width: 16px; height: 16px; }

.group { display: flex; flex-direction: column; min-width: 0; }
.group-title { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 10px; font: 500 15px/20px var(--ui); color: var(--muted); }
.group-link { font: 500 12.5px var(--ui); color: var(--faint); transition: color var(--hover); }
.group-link:hover { color: var(--text); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; margin: 0; }
.card.pad { padding: 18px; }

.row {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 18px;
  transition: background-color var(--hover);
}
.row + .row, .card > form + .row, .card > .row + form, .card > form + form { border-top: 1px solid var(--line); }
.row.tight { min-height: 0; padding: 10px 18px; align-items: flex-start; }
.row.hover:hover { background: var(--surface2); }
.row.end { justify-content: flex-end; min-height: 0; }
.row.dim { opacity: .55; }
.row-icon {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: var(--r); background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
}
.row-icon svg.i { width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font: 500 15px/20px var(--ui); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.row-text { font: 400 13.5px/18px var(--ui); }
.row-desc { font: 400 12.5px/17px var(--ui); color: var(--muted); overflow-wrap: anywhere; }
.row-trail { display: flex; align-items: center; gap: 8px; flex: none; }
.row-trail form { margin: 0; }
.meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.form-row { align-items: flex-end; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.grow { flex: 1; min-width: 200px; }
.footnote { font-size: 12.5px; color: var(--faint); padding: 0 4px; margin-top: -18px; }

/* ---------- Плитки статистики ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  transition: border-color var(--hover), background-color var(--hover);
}
.tile:hover { border-color: var(--line-strong); }
.tile b { font: 600 26px/32px var(--ui); letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.tile-sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.meter { height: 3px; border-radius: 3px; background: var(--surface3); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 600ms cubic-bezier(.4,0,.2,1); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

/* ---------- Метки, точки, события ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: var(--r-s);
  background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
  font: 500 11px/14px var(--ui); white-space: nowrap;
}
.tag.ok { color: var(--ok); } .tag.warn { color: var(--warn); } .tag.danger { color: var(--danger); } .tag.faint { color: var(--faint); }
.dot { position: relative; width: 8px; height: 8px; flex: none; display: inline-block; }
.dot::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; opacity: .35; animation: glow 1.6s ease-in-out infinite alternate; }
.dot::after { content: ""; position: absolute; inset: 1.5px; border-radius: 50%; background: currentColor; }
.dot.ok { color: var(--ok); } .dot.warn { color: var(--warn); }
.tag .dot { width: 6px; height: 6px; }
@keyframes glow { from { opacity: .2; } to { opacity: .6; } }
.ev { width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--faint); }
.ev.ok { background: var(--ok); } .ev.warn { background: var(--warn); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  font: 500 14px/18px var(--ui); background: var(--text); color: var(--bg);
  transition: background-color var(--hover), color var(--hover), border-color var(--hover), transform 120ms ease-out, opacity var(--hover);
}
.btn svg.i { width: 17px; height: 17px; }
.btn:hover { background: color-mix(in srgb, var(--text) 88%, transparent); }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--surface2); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface3); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.compact { min-height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn.compact svg.i { width: 15px; height: 15px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn.busy { opacity: .6; pointer-events: none; }
.btn.busy::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 900ms linear infinite;
}
.btn.busy svg.i { display: none; }
.icon-btn {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; padding: 0; border: 0; cursor: pointer;
  border-radius: var(--r-s); background: transparent; color: var(--muted);
  transition: background-color var(--hover), color var(--hover), transform 120ms ease-out;
}
.icon-btn svg.i { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn:active { transform: scale(.86); }
.icon-btn.on { color: var(--ink); }
.actions-row { display: flex; gap: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field:focus-within > .eyebrow { color: var(--text); }
input, select {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r);
  background: var(--bg); color: var(--text); border: 1px solid var(--line-strong);
  font: 400 14px/20px var(--ui); outline: none; caret-color: var(--accent);
  transition: border-color 180ms ease, background-color var(--hover);
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: color-mix(in srgb, var(--accent) 80%, transparent); }
input[readonly] { color: var(--muted); }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-right: 42px; }
.input-wrap .icon-btn { position: absolute; right: 5px; }
input.otp { font-variant-numeric: tabular-nums; letter-spacing: 4px; font-size: 18px; text-align: center; max-width: 180px; }
.field input.otp { max-width: none; }
input.spaced { letter-spacing: 1.5px; }
.form-inline { display: flex; gap: 10px; align-items: center; }
.form-inline .otp { width: 180px; }
.form-error { color: var(--danger); font-size: 12.5px; }
.form-ok { color: var(--ok); font-size: 12.5px; }
.strength { display: flex; align-items: center; gap: 4px; }
.strength i { flex: 1; height: 3px; border-radius: 3px; background: var(--line); transition: background-color var(--hover); }
.strength span { width: 64px; margin-left: 6px; font: 500 11px var(--ui); color: var(--muted); }
.strength[data-level="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] i:nth-child(-n+2) { background: var(--warn); }
.strength[data-level="3"] i:nth-child(-n+3) { background: var(--ok); }
.strength[data-level="4"] i { background: var(--ink); }
.strength[data-level="1"] span { color: var(--danger); } .strength[data-level="2"] span { color: var(--warn); }
.strength[data-level="3"] span { color: var(--ok); } .strength[data-level="4"] span { color: var(--ink); }

.note { padding: 12px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.note.warn { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.lead { color: var(--muted); font-size: 13.5px; line-height: 19px; }
.lead b { color: var(--text); font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: 14px; width: 100%; }

/* ---------- QR ---------- */
.qr-tile { flex: none; width: 196px; padding: 12px; border-radius: var(--r-l); background: #fff; border: 1px solid var(--line); }
.qr { display: block; width: 100%; height: auto; }
.invite-new, .totp-setup { display: flex; gap: 22px; align-items: flex-start; }
.totp-setup { padding: 18px; }

/* ---------- Пустые состояния ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 32px 24px; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 10px; border-radius: var(--r-l); background: var(--surface2); border: 1px solid var(--line); color: var(--muted); }
.empty-icon svg.i { width: 24px; height: 24px; }
.empty b { font: 600 16px/22px var(--ui); }
.empty span:not(.empty-icon) { color: var(--muted); max-width: 360px; }
.empty .btn { margin-top: 12px; }

/* ---------- Экран входа ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; }
.auth-hero { margin-bottom: 18px; }
.auth-sub { margin: 6px 0 28px; color: var(--muted); text-align: center; }
.auth-foot { margin-top: 18px; text-align: center; font: 500 12.5px var(--ui); color: var(--faint); }
.auth-foot a { color: var(--muted); transition: color var(--hover); }
.auth-foot a:hover { color: var(--text); }
.auth-foot b { color: var(--muted); font-weight: 500; }
.wordmark { display: flex; align-items: center; gap: 12px; font: 500 26px/1 var(--display); letter-spacing: -.5px; }
.wordmark em { font-style: normal; color: var(--accent); }
.wordmark .appicon { width: 40px; height: 40px; }
.wordmark .tag { font-family: var(--ui); letter-spacing: 0; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.steps b { color: var(--text); font-weight: 500; }

.dial { width: 168px; height: 168px; display: block; overflow: visible; }
.dial line { stroke: var(--line-strong); stroke-width: 1; }
.dial line.long { stroke: var(--muted); stroke-width: 2; }
.dial circle { fill: none; }
.dial .arc-accent { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; animation: pulse 1.8s ease-in-out infinite alternate; }
.dial .arc-line { stroke: var(--line-strong); stroke-width: 1; }
.dial .arc-thick { stroke: var(--line); stroke-width: 6; }
.dial .arc-faint { stroke: var(--faint); stroke-width: 6; }
.dial .dial-core { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.dial .dial-shield { fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linejoin: round; }
.dial-ticks, .dial-a, .dial-b { transform-origin: 84px 84px; transition: animation-duration 400ms; }
.dial-ticks { animation: spin 96s linear infinite; }
.dial-a { animation: spin 24s linear infinite reverse; }
.dial-b { animation: spin 40s linear infinite; }
.busy-dial .dial-ticks { animation-duration: 5.6s; }
.busy-dial .dial-a { animation-duration: 1.4s; }
.busy-dial .dial-b { animation-duration: 2.3s; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }

/* ---------- Уведомления и модальные окна ---------- */
.toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: var(--r-l); background: var(--surface2); border: 1px solid var(--line-strong);
  box-shadow: 0 12px 40px rgba(0,0,0,.35); font-size: 13.5px;
  animation: toast-in 260ms cubic-bezier(.4,0,.2,1);
}
.toast svg.i { color: var(--ok); width: 18px; height: 18px; }
.toast.err { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--text); }
.toast.err::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); flex: none; }
.toast.hide { opacity: 0; transform: translate(-50%, 8px); transition: opacity 260ms, transform 260ms; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

.modal {
  width: min(460px, calc(100vw - 40px)); padding: 22px; border-radius: var(--r-l);
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
}
.modal[open] { animation: modal-in 260ms cubic-bezier(.4,0,.2,1); }
.modal::backdrop { background: var(--scrim); animation: fade 260ms; }
.modal form { display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font: 600 16px/22px var(--ui); }
.modal-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r); background: var(--surface2); border: 1px solid var(--line); color: var(--danger); }
.modal-icon svg.i { width: 18px; height: 18px; }
.modal p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes modal-in { from { opacity: 0; transform: scale(.92); } }
@keyframes fade { from { opacity: 0; } }

:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; }

/* ---------- Телефон ---------- */
@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { flex-direction: column; min-height: 100vh; padding-bottom: 72px; background: none; }
  .rail {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: auto;
    flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .rail-logo, .rail-spacer { display: none; }
  .rail-item { width: 62px; margin: 0; }
  .rail-item span { font-size: 10px; }
  .content { padding: 20px 14px 32px; gap: 26px; }
  .statusbar { display: none; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .invite-new, .totp-setup { flex-direction: column; align-items: center; }
  .row { padding: 12px 14px; flex-wrap: wrap; }
  .row-trail { margin-left: 46px; }
  .row-icon + .row-main + .row-trail.meta { margin-left: 0; }
  .toast { bottom: 88px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
