@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/jetbrains-mono-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/jetbrains-mono-semibold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
}

:root {
  --p-ink: oklch(0.17 0.025 255);
  --p-panel: oklch(0.215 0.032 255);
  --p-panel-high: oklch(0.255 0.038 255);
  --p-line: oklch(0.34 0.045 250);
  --p-text: oklch(0.93 0.018 240);
  --p-muted: oklch(0.73 0.032 245);
  --p-cyan: oklch(0.84 0.14 215);
  --p-mint: oklch(0.82 0.17 155);
  --p-amber: oklch(0.84 0.15 85);
  --p-red: oklch(0.75 0.17 25);

  --surface: var(--p-ink);
  --surface-raised: var(--p-panel);
  --surface-high: var(--p-panel-high);
  --border: var(--p-line);
  --text: var(--p-text);
  --text-muted: var(--p-muted);
  --accent: var(--p-cyan);
  --success: var(--p-mint);
  --warning: var(--p-amber);
  --danger: var(--p-red);
  --font-mono: "JetBrains Mono", "Cascadia Mono", "Noto Sans Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--surface); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 4%, oklch(0.3 0.06 230 / 0.3), transparent 34rem),
    var(--surface);
  font: 400 16px/1.65 var(--font-mono);
  -webkit-font-smoothing: antialiased;
}
button, a, summary { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }
code { font: inherit; overflow-wrap: anywhere; }
::selection { color: var(--surface); background: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.13;
  background: repeating-linear-gradient(0deg, transparent 0 3px, oklch(0.8 0.04 230 / 0.05) 3px 4px);
}
.topbar, .shell { position: relative; z-index: 1; }
.topbar {
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: oklch(0.17 0.025 255 / 0.88);
  backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: 0.08em; }
.brand small { display: block; color: var(--text-muted); font-size: 10px; font-weight: 400; letter-spacing: 0.18em; }
.brand-mark { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 1.2; }
.brand-mark .brand-dot { fill: var(--success); stroke: none; }
.node-state { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 11px; letter-spacing: 0.12em; }
.led { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); animation: pulse 1.6s ease-in-out infinite; }
.led-wait { background: var(--warning); box-shadow: 0 0 12px var(--warning); }
.led-off { background: var(--danger); box-shadow: 0 0 12px var(--danger); animation: none; }

.shell { width: min(1240px, 100%); margin: 0 auto; padding: 0 clamp(16px, 3vw, 40px) 32px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr); gap: clamp(32px, 6vw, 80px); align-items: center; padding: clamp(48px, 8vw, 96px) 0 56px; }
.overline, .panel-label { margin: 0 0 12px; color: var(--accent); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 24px; font-size: clamp(34px, 4.6vw, 62px); line-height: 1.08; letter-spacing: -0.055em; font-weight: 600; }
h2 { margin-bottom: 0; font-size: clamp(20px, 2vw, 26px); line-height: 1.2; letter-spacing: -0.035em; }
.lede { max-width: 65ch; margin-bottom: 28px; color: var(--text-muted); font-size: 16px; line-height: 1.75; }
.trust-line { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--text-muted); font-size: 10px; letter-spacing: 0.08em; }
.trust-line span::before { content: "/"; margin-right: 8px; color: var(--accent); }

.access-panel { padding: clamp(24px, 4vw, 40px); border: 1px solid var(--border); background: oklch(0.215 0.032 255 / 0.82); box-shadow: 0 24px 70px oklch(0.08 0.02 255 / 0.32); }
.current-ip { margin: 4px 0 16px; font-size: clamp(28px, 4vw, 48px); line-height: 1.15; letter-spacing: -0.055em; overflow-wrap: anywhere; }
.access-state { display: flex; align-items: center; gap: 10px; min-height: 28px; margin-bottom: 24px; color: var(--text-muted); font-size: 13px; }
.access-state.allowed { color: var(--success); }
.access-state.denied { color: var(--warning); }
.primary-action {
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--surface);
  background: var(--accent);
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease-out, background 150ms ease-out, color 150ms ease-out, opacity 150ms ease-out;
}
.primary-action:hover:not(:disabled) { color: var(--accent); background: transparent; transform: scale(0.985); }
.primary-action:active:not(:disabled) { transform: scale(0.97); }
.primary-action:disabled { opacity: 0.48; cursor: not-allowed; }
.action-message { min-height: 26px; margin: 14px 0 0; color: var(--success); font-size: 13px; }
.action-message.error { color: var(--danger); }
.hint { margin: 18px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.7; }

.endpoint-strip { display: grid; grid-template-columns: 0.72fr 1.65fr 1.15fr; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.endpoint { min-width: 0; padding: 24px 24px 24px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.endpoint + .endpoint { padding-left: 24px; border-left: 1px solid var(--border); }
.endpoint .panel-label { margin-bottom: 0; }
.endpoint code { color: var(--text); font-size: 13px; }
.text-action { min-height: 44px; padding: 8px 0; border: 0; color: var(--accent); background: transparent; font-size: 12px; cursor: pointer; transition: color 150ms ease-out, transform 150ms ease-out; }
.text-action:hover { color: var(--text); transform: translateY(-1px); }
.text-action:disabled { color: var(--text-muted); cursor: wait; }

.status-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr); gap: 1px; margin-top: 56px; border: 1px solid var(--border); background: var(--border); }
.status-section { min-width: 0; padding: clamp(24px, 4vw, 36px); background: var(--surface-raised); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading .overline, .certificate-section .overline { margin-bottom: 8px; }
.service-list { margin: 0; padding: 0; list-style: none; }
.service-list li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 48px; border-top: 1px solid var(--border); font-size: 13px; }
.service-list li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); }
.service-list li.service-down::before { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.service-list .service-status { color: var(--success); font-size: 11px; letter-spacing: 0.1em; }
.service-list .service-down .service-status { color: var(--danger); }
.service-list .loading-row { display: block; color: var(--text-muted); }
.service-list .loading-row::before { display: none; }
.certificate-value { margin-top: 32px; font-size: clamp(40px, 5vw, 64px); line-height: 1; letter-spacing: -0.06em; }
.certificate-caption { min-height: 48px; margin: 12px 0 20px; color: var(--text-muted); font-size: 12px; }
.certificate-track { height: 3px; background: var(--border); overflow: hidden; }
.certificate-track span { display: block; width: 0; height: 100%; background: var(--success); transition: width 240ms ease-out; }

.clients-section { padding-top: 56px; }
.count-badge { display: grid; place-items: center; min-width: 36px; height: 36px; border: 1px solid var(--border); color: var(--accent); font-size: 13px; }
.client-table { border-top: 1px solid var(--border); }
.client-head, .client-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 120px; align-items: center; gap: 16px; min-height: 58px; border-bottom: 1px solid var(--border); }
.client-head { color: var(--text-muted); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.client-row { font-size: 13px; }
.client-access { color: var(--success); }
.client-access::before { content: "●"; margin-right: 10px; }
.remove-action { min-height: 44px; padding: 8px 0; border: 0; color: var(--text-muted); background: transparent; text-align: left; cursor: pointer; }
.remove-action:hover { color: var(--danger); }
.empty-row { margin: 0; padding: 24px 0; color: var(--text-muted); border-bottom: 1px dashed var(--border); font-size: 13px; }

.domain-section { margin-top: 56px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.domain-section summary { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style: none; }
.domain-section summary::-webkit-details-marker { display: none; }
.domain-section summary .overline { display: block; margin-bottom: 4px; }
.domain-section summary strong { font-size: 18px; }
.summary-action { color: var(--accent); font-size: 12px; }
.domain-section[open] .summary-action { color: var(--text-muted); }
.domain-content { padding: 0 0 28px; color: var(--text-muted); font-size: 13px; }
.domain-content p { max-width: 75ch; }
.domain-list { display: flex; flex-wrap: wrap; gap: 8px; }
.domain-list code { padding: 6px 10px; border: 1px solid var(--border); color: var(--text); background: var(--surface-raised); font-size: 12px; }
.footer { display: flex; justify-content: space-between; gap: 16px; padding-top: 32px; color: var(--text-muted); font-size: 10px; letter-spacing: 0.05em; }

.topbar-actions { display: flex; align-items: center; gap: 20px; }
.topbar-actions form { margin: 0; }
.logout-action { padding-inline: 12px; }
.management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 56px; border: 1px solid var(--border); background: var(--border); }
.management-section { min-width: 0; padding: clamp(24px, 4vw, 36px); background: var(--surface-raised); }
.management-section h2 { margin-bottom: 18px; }
.config-input, .inline-form input, .password-form input, .auth-form input {
  width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 4px;
  padding: 12px 14px; color: var(--text); background: var(--surface); font: inherit;
}
.config-input { display: block; min-height: 260px; margin-top: 20px; resize: vertical; line-height: 1.75; }
.compact-input { min-height: 132px; }
.config-input:focus, .inline-form input:focus, .password-form input:focus, .auth-form input:focus { border-color: var(--accent); outline: 1px solid var(--accent); outline-offset: 1px; }
.secondary-action {
  min-height: 46px; padding: 10px 18px; border: 1px solid var(--accent); border-radius: 5px;
  color: var(--accent); background: transparent; font: 600 13px/1.4 var(--font-mono); cursor: pointer;
  transition: color 150ms ease-out, background 150ms ease-out, opacity 150ms ease-out;
}
.secondary-action:hover:not(:disabled) { color: var(--surface); background: var(--accent); }
.secondary-action:disabled { opacity: 0.5; cursor: wait; }
.section-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.inline-form { display: flex; align-items: stretch; gap: 12px; margin: 0 0 12px; }
.inline-form input { flex: 1; min-width: 0; }
.password-form, .auth-form { display: grid; gap: 12px; }
.password-form label, .auth-form label { color: var(--text-muted); font-size: 12px; }
.password-form .secondary-action { margin-top: 8px; }
.security-state { color: var(--success); font-size: 13px; }
.backup-section, .audit-section { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--border); }
.backup-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; min-height: 76px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.backup-meta { display: grid; gap: 5px; min-width: 0; }
.backup-meta code { font-size: 13px; overflow-wrap: anywhere; }
.backup-meta span { color: var(--text-muted); font-size: 11px; }
.backup-actions { display: flex; align-items: center; gap: 18px; }
.audit-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.audit-row time { color: var(--text-muted); }
.audit-row code { overflow-wrap: anywhere; }
.error { color: var(--danger); }
.auth-body { display: grid; place-items: center; padding: 40px 20px; }
.auth-shell { width: min(460px, 100%); }
.auth-shell-wide { width: min(780px, 100%); }
.auth-brand { margin-bottom: 24px; }
.auth-panel { padding: clamp(26px, 5vw, 44px); border: 1px solid var(--border); background: var(--surface-raised); box-shadow: 0 24px 70px oklch(0.08 0.02 255 / 0.32); }
.auth-panel h1 { margin-bottom: 20px; font-size: clamp(30px, 5vw, 44px); }
.auth-panel .lede { font-size: 14px; }
.auth-form { margin-top: 20px; }
.form-error { min-height: 24px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.totp-input { font-size: 26px !important; letter-spacing: 0.22em; text-align: center; }
.setup-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 28px; }
.totp-qr { display: block; max-width: 100%; height: auto; background: white; }
.totp-secret { display: block; color: var(--accent); font-size: 16px; line-height: 1.8; overflow-wrap: anywhere; user-select: all; }

@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding-top: 48px; }
  .access-panel { max-width: 640px; }
  .endpoint-strip { grid-template-columns: 1fr; }
  .endpoint, .endpoint + .endpoint { padding: 20px 0; border-left: 0; }
  .endpoint + .endpoint { border-top: 1px solid var(--border); }
  .status-grid { grid-template-columns: 1fr; }
  .management-grid { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
  .totp-qr { width: 252px; }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  .topbar { min-height: 64px; }
  .brand { font-size: 12px; }
  .brand small { font-size: 8px; }
  .brand-mark { width: 34px; height: 34px; }
  .node-state { font-size: 9px; letter-spacing: 0.06em; }
  .hero { padding-bottom: 40px; }
  h1 { font-size: clamp(30px, 9vw, 42px); }
  .current-ip { font-size: clamp(25px, 8vw, 36px); }
  .access-panel { padding: 24px 20px; }
  .client-head { display: none; }
  .client-row { grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; }
  .client-row code { grid-column: 1 / -1; }
  .client-access { font-size: 11px; }
  .remove-action { text-align: right; }
  .domain-section summary { align-items: flex-start; padding: 20px 0; }
  .summary-action { max-width: 90px; text-align: right; }
  .footer { flex-direction: column; }
  .topbar-actions { gap: 6px; }
  .logout-action { padding-inline: 8px; }
  .inline-form { flex-direction: column; }
  .backup-row { grid-template-columns: 1fr; gap: 4px; }
  .backup-actions { justify-content: space-between; }
  .audit-row { grid-template-columns: 1fr; gap: 3px; }
  .auth-body { padding: 24px 16px; }
  .auth-panel { padding: 26px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* Персональные DoH-ссылки */
.link-label { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-state { font-size: 11px; letter-spacing: 0.08em; padding: 2px 8px; border: 1px solid var(--border); border-radius: 3px; }
.link-state.on { color: var(--success); }
.link-state.off { color: var(--danger); }
.link-url { display: block; font-family: var(--font-mono); font-size: 12px; color: var(--accent); overflow-wrap: anywhere; }
.link-stats { color: var(--text-muted); font-size: 12px; }
.link-history { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.history-head, .history-row { display: grid; grid-template-columns: 165px 125px minmax(0, 1fr) 55px 120px 55px; gap: 12px; padding: 9px 0; font-family: var(--font-mono); font-size: 12px; border-bottom: 1px solid var(--border); }
.history-head { color: var(--text-muted); }
.history-row .qname { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .history-head { display: none; }
  .history-row { grid-template-columns: 1fr 1fr; row-gap: 4px; }
  .link-row .backup-actions { flex-wrap: wrap; gap: 12px; }
}


/* Managed SSH proxy users */
.ssh-user-row { align-items: flex-start; }
.ssh-user-row .backup-meta { min-width: 0; }
.ssh-user-row .ssh-pac-url { font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere; }
.ssh-user-actions { max-width: 460px; flex-wrap: wrap; justify-content: flex-end; }
.download-action { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
@media (max-width: 900px) {
  .ssh-user-actions { max-width: none; justify-content: flex-start; }
}
