:root {
  --bg: #0E141B;
  --surface: #151D27;
  --raised: #1C2632;
  --line: #2A3644;
  --line-strong: #3A4859;
  --text: #E4EAF1;
  --muted: #93A1B1;
  --accent: #7DB3FF;
  --accent-hover: #9CC5FF;
  --accent-ink: #0A1A30;
  --ok: #5FCB8F;
  --warn: #E8B75A;
  --danger: #F2777A;
  --radius: 10px;
  --radius-s: 6px;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: #2F4A6E; }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--accent); color: var(--accent-ink);
  padding: 8px 12px; border-radius: var(--radius-s); z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- шапка ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(14, 20, 27, .88);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1040px; margin: 0 auto; padding: 0 20px; height: 60px;
  display: flex; align-items: center; gap: 28px; }
.brand { color: var(--text); text-decoration: none; font-weight: 600; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: var(--radius-s);
  font-size: .95rem; display: flex; align-items: center; gap: 6px; }
.nav a:hover { color: var(--text); background: var(--raised); }
.nav a[aria-current="page"] { color: var(--text); background: var(--raised); }
.nav .off-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.topbar-end { display: flex; gap: 8px; align-items: center; }
.topbar .menu-btn { display: none; }

@media (max-width: 760px) {
  .topbar-inner { gap: 12px; }
  .topbar .menu-btn { display: inline-flex; margin-left: auto; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 60px; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px 14px; }
  .nav.open { display: flex; }
  .nav a { padding: 12px; font-size: 1rem; }
  .topbar-end { order: 3; }
}

/* ---------- кнопки ---------- */
.btn { font: inherit; font-size: .95rem; font-weight: 500; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-s);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--text); background: var(--raised); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

/* ---------- каркас страницы ---------- */
main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 48px 20px 72px; }
.narrow { max-width: 680px; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.25rem); line-height: 1.15; font-weight: 600;
  letter-spacing: -.02em; margin: 0 0 10px; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 0 0 14px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 36px; max-width: 38em; font-size: 1.05rem; }
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.footer-inner { max-width: 1040px; margin: 0 auto; padding: 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid; margin-bottom: 28px; font-size: .95rem; }
.notice-warn { background: rgba(232, 183, 90, .08); border-color: rgba(232, 183, 90, .35); color: #F1D29A; }
.notice-ok { background: rgba(95, 203, 143, .08); border-color: rgba(95, 203, 143, .35); color: #A9E5C4; }
.notice-err { background: rgba(242, 119, 122, .08); border-color: rgba(242, 119, 122, .4); color: #F7B2B4; }

/* ---------- главная ---------- */
.tools { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.tools li { border-bottom: 1px solid var(--line); }
.tool { display: grid; grid-template-columns: 44px 1fr auto; gap: 18px; align-items: center;
  padding: 22px 8px; color: var(--text); text-decoration: none; border-radius: var(--radius-s); }
.tool:hover { background: var(--surface); color: var(--text); }
.tool-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--raised);
  display: grid; place-items: center; color: var(--accent); }
.tool-icon svg { width: 22px; height: 22px; }
.tool-title { font-weight: 600; font-size: 1.1rem; display: flex; gap: 10px; align-items: center; }
.tool-desc { color: var(--muted); font-size: .95rem; }
.tool-chev { color: var(--muted); width: 20px; height: 20px; }
.tool:hover .tool-chev { color: var(--text); }
.badge { font-size: .75rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; }
.badge-off { background: rgba(232, 183, 90, .14); color: var(--warn); }
.badge-on { background: rgba(95, 203, 143, .14); color: var(--ok); }
.empty { color: var(--muted); padding: 32px 0; }

/* ---------- формы ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 500; font-size: .95rem; }
.input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius-s); padding: 10px 12px; min-height: 44px; width: 100%; }
.input:hover { border-color: #4A5A6D; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125, 179, 255, .2); }
.help { color: var(--muted); font-size: .85rem; margin: 0; }

.group { border: 0; padding: 0; margin: 0 0 22px; }
.group legend { font-weight: 500; margin-bottom: 10px; padding: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface); padding: 4px;
  border-radius: var(--radius); border: 1px solid var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 14px; border-radius: var(--radius-s); cursor: pointer;
  font-size: .93rem; color: var(--muted); }
.seg span:hover { color: var(--text); }
.seg input:checked + span { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.check { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* переключатель */
.switch { position: relative; display: inline-flex; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); background: #0E2A1B; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- конвертер ---------- */
.drop { position: relative; display: grid; place-items: center; text-align: center; gap: 6px;
  padding: 52px 24px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 28px; }
.drop:hover, .drop.over { border-color: var(--accent); background: #17243A; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { width: 44px; height: 44px; color: var(--accent); margin-bottom: 6px; }
.drop strong { font-size: 1.1rem; font-weight: 600; }
.drop span { color: var(--muted); font-size: .93rem; }
.drop .pick { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.jobs { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; }
.job-name { font-weight: 500; overflow-wrap: anywhere; }
.job-state { color: var(--muted); font-size: .9rem; }
.job-state.err { color: var(--danger); }
.job-state.ok { color: var(--ok); }
.job-bar { grid-column: 1 / -1; height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.job-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.job-bar.indet i { width: 30%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.job .btn { grid-row: 1 / 3; grid-column: 2; }

/* ---------- генератор паролей ---------- */
.pw-out { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 28px; }
.pw-row { display: flex; gap: 10px; align-items: center; }
.pw-value { flex: 1; min-width: 0; font: 500 clamp(1.1rem, 2.6vw, 1.5rem)/1.4 var(--mono);
  letter-spacing: .02em; overflow-wrap: anywhere; word-break: break-all; }
.pw-value .d { color: #F2C572; }
.pw-value .s { color: #8FD7C4; }
.pw-value .u { color: var(--text); }
.pw-value .l { color: #C6D3E1; }
.strength { margin-top: 16px; display: grid; gap: 6px; }
.strength-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength-bar i { height: 4px; border-radius: 2px; background: var(--raised); }
.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: #A8D46F; }
.strength[data-level="4"] i:nth-child(-n+4) { background: var(--ok); }
.strength-text { font-size: .88rem; color: var(--muted); }
.pw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; }
@media (max-width: 640px) { .pw-grid { grid-template-columns: 1fr; } }
.range-row { display: flex; gap: 14px; align-items: center; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; }
.range-row .input { width: 84px; text-align: center; }
.pw-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 6px; }
.pw-list li { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 8px 8px 8px 14px; }
.pw-list code { flex: 1; font: 500 1rem var(--mono); overflow-wrap: anywhere; }
.privacy { display: flex; gap: 10px; color: var(--muted); font-size: .9rem; margin-top: 28px; }
.privacy svg { flex: none; width: 18px; height: 18px; color: var(--ok); margin-top: 2px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-s); font-weight: 500;
  font-size: .93rem; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- админка ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 28px; }
.panel-head { padding: 18px 20px 4px; }
.panel-head p { color: var(--muted); margin: -8px 0 8px; font-size: .93rem; }
.panel-body { padding: 8px 20px 20px; }
.page-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--line); }
.page-row .t { font-weight: 500; }
.page-row .p { color: var(--muted); font-size: .88rem; }
.page-row .p a { color: var(--muted); }
.admin-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.admin-head .lead { margin: 0; }
.stat { color: var(--muted); font-size: .93rem; }

.login-wrap { max-width: 400px; margin: 24px auto 0; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login-card .btn { width: 100%; margin-top: 8px; min-height: 46px; }
.pw-field { position: relative; }
.pw-field .input { padding-right: 48px; }
.pw-field button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

.error-page { text-align: center; padding: 64px 0; }
.error-code { font-size: 4rem; font-weight: 600; color: var(--line-strong); line-height: 1; margin-bottom: 12px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (max-width: 520px) {
  .pw-row { flex-wrap: wrap; }
  .pw-value { flex-basis: 100%; margin-bottom: 8px; }
  .pw-row .btn-primary { flex: 1; }
  .page-row { grid-template-columns: 1fr auto; }
  .page-row .badge { display: none; }
}
.group .help { margin-top: 8px; }
