:root {
  color-scheme: dark;
  --bg: #0a0e12;
  --surface: #10161c;
  --surface-raised: #151c23;
  --surface-soft: #0d1318;
  --line: #27323b;
  --line-strong: #3a4853;
  --text: #edf3ef;
  --muted: #9aa9a6;
  --faint: #788986;
  --cyan: #78d7ff;
  --green: #9ce676;
  --amber: #ffc56a;
  --red: #ff8580;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --overlay-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

html {
  min-height: 100%;
  background: var(--bg);
  scrollbar-gutter: stable;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(120, 215, 255, 0.055), transparent 27rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--cyan); }
::selection { color: var(--text); background: rgba(120, 215, 255, 0.28); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.7rem 0.95rem;
  border-radius: 0.55rem;
  background: var(--text);
  color: var(--bg);
  font-weight: 750;
  text-decoration: none;
  transform: translateY(calc(-100% - 2rem));
  transition: transform 140ms var(--ease-out);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: relative;
  z-index: 10;
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.7rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.7rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 18, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.brand-mark {
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 auto;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.3rem var(--bg), inset 0 0 0 0.46rem var(--green);
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav a {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border-radius: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 120ms ease, background-color 120ms ease;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  padding: max(0.65rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.65rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 18, 0.94);
  backdrop-filter: blur(16px);
}

.admin-brand-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-nav.admin-nav-desktop,
.admin-logout-desktop { display: none; }

.admin-menu { position: relative; }
.admin-menu summary {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  transition: transform 140ms var(--ease-out), border-color 140ms ease, background-color 140ms ease;
}

.admin-menu summary::-webkit-details-marker { display: none; }
.menu-chevron { color: var(--muted); transition: transform 180ms var(--ease-out); }
.admin-menu[open] .menu-chevron { transform: rotate(180deg); }

.admin-menu-panel {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  width: min(22rem, calc(100vw - 2rem));
  max-height: calc(100vh - 5.5rem - env(safe-area-inset-bottom));
  max-height: calc(100dvh - 5.5rem - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.8rem;
  background: var(--surface-raised);
  box-shadow: var(--overlay-shadow);
  transform-origin: top right;
  opacity: 1;
  transform: scale(1);
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out), display 160ms allow-discrete;
}

@starting-style {
  .admin-menu[open] .admin-menu-panel {
    opacity: 0;
    transform: scale(0.98);
  }
}

.admin-nav { display: grid; gap: 0.25rem; }
.nav-section { display: grid; gap: 0.15rem; }
.nav-section + .nav-section {
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.nav-section-label {
  padding: 0 0.65rem 0.25rem;
  color: var(--faint);
  font: 700 0.67rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.admin-nav a {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding: 0.58rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.52rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.89rem;
  font-weight: 620;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.admin-nav a[aria-current="page"] {
  border-color: rgba(156, 230, 118, 0.18);
  background: rgba(156, 230, 118, 0.1);
  color: var(--text);
}

.logout-form { margin: 0.65rem 0 0; padding-top: 0.65rem; border-top: 1px solid var(--line); }
.link-button {
  width: 100%;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 0.52rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
  text-align: left;
  transition: color 120ms ease, background-color 120ms ease, transform 140ms var(--ease-out);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--cyan);
  font: 700 0.7rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shell {
  width: min(calc(100% - 2rem - env(safe-area-inset-left) - env(safe-area-inset-right)), 76rem);
  margin: 0 auto;
  padding: 2.25rem 0 4rem;
}

.narrow { width: min(calc(100% - 2rem - env(safe-area-inset-left) - env(safe-area-inset-right)), 34rem); }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 18ch;
  margin-bottom: 0.45rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
h2 { margin-bottom: 0.75rem; font-size: 1.15rem; line-height: 1.25; letter-spacing: -0.018em; }
h3 { font-size: 1rem; line-height: 1.3; }
.lede { max-width: 43rem; margin-bottom: 1.35rem; color: var(--muted); line-height: 1.58; }
.page-heading .lede { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.panel {
  padding: clamp(1.1rem, 2.4vw, 1.55rem);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--surface);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.015);
}

.narrow > .panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head h2 { margin-bottom: 0.22rem; }
.panel-head p:last-child { margin-bottom: 0; }

.app-download p { line-height: 1.55; }
.release-details { margin-top: 1rem; color: var(--muted); }
.release-details summary,
.config-details summary {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  width: fit-content;
  cursor: pointer;
  color: var(--cyan);
  font-weight: 680;
}
.release-details dl { display: grid; gap: 0.35rem; margin: 0.8rem 0 0; }
.release-details dt { font-size: 0.78rem; font-weight: 700; }
.release-details dd { margin: 0 0 0.45rem; }
.release-details code { color: var(--text); font-size: 0.72rem; overflow-wrap: anywhere; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.metric {
  min-height: 9.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--text);
  text-decoration: none;
  transition: transform 160ms var(--ease-out), border-color 160ms ease, background-color 160ms ease;
}
.metric-value { font: 750 clamp(2rem, 5vw, 2.8rem)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -0.07em; }
.metric-label { margin-top: auto; padding-top: 1rem; color: var(--muted); }
.metric-link { margin-top: 0.35rem; color: var(--cyan); font-size: 0.78rem; font-weight: 680; }

.route-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 0 0 1rem;
  color: var(--muted);
  font: 0.77rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.route-node { white-space: nowrap; padding: 0.45rem 0.62rem; border: 1px solid var(--line); border-radius: 0.45rem; background: var(--surface-soft); color: var(--text); }
.route-arrow { color: var(--green); }

.field { display: grid; gap: 0.42rem; margin-bottom: 1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
label { font-size: 0.88rem; font-weight: 670; }

input, select, textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.68rem 0.78rem;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 0.52rem;
  background: #090e12;
  transition: border-color 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}

input::placeholder, textarea::placeholder { color: #70807f; }
textarea { min-height: 18rem; resize: vertical; font: 0.78rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.compact-textarea { min-height: 10rem; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 0 3px rgba(120, 215, 255, 0.17); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(120, 215, 255, 0.42); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 0.79rem; line-height: 1.45; }

.checkbox-list { padding: 0; border: 0; }
.checkbox-list legend { margin-bottom: 0.55rem; font-size: 0.88rem; font-weight: 670; }
.checkbox-list label { min-height: 2.75rem; display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.checkbox-list input { width: 1.2rem; min-height: 1.2rem; margin: 0; accent-color: var(--green); }
.checkbox-list small { color: var(--muted); }

.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.actions form { margin: 0; }
.button {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.66rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  background: var(--green);
  color: #071007;
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), color 140ms ease, background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.button.secondary { border-color: var(--line-strong); background: var(--surface-raised); color: var(--text); }
.button.tertiary { border-color: transparent; background: transparent; color: var(--muted); }
.button.danger { border-color: rgba(255, 133, 128, 0.42); background: transparent; color: var(--red); }
.button.small-button { min-height: 2.25rem; padding: 0.38rem 0.62rem; font-size: 0.78rem; }
.button:active, .link-button:active, .admin-menu summary:active { transform: scale(0.97); }
.button[aria-disabled="true"], .link-button[aria-disabled="true"] { pointer-events: none; opacity: 0.68; }

.button[data-busy="true"]::before,
.link-button[data-busy="true"]::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 650ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  margin-bottom: 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(255, 197, 106, 0.26);
  border-left: 3px solid var(--amber);
  border-radius: 0.55rem;
  background: rgba(255, 197, 106, 0.065);
  line-height: 1.5;
}
.notice > strong + span { display: block; margin-top: 0.2rem; }
.notice.error { border-color: rgba(255, 133, 128, 0.28); border-left-color: var(--red); background: rgba(255, 133, 128, 0.065); }
.notice.success { border-color: rgba(156, 230, 118, 0.25); border-left-color: var(--green); background: rgba(156, 230, 118, 0.065); }
.one-time-notice { padding-block: 1rem; }
.secret { margin: 0.55rem 0; color: var(--green); font: 700 clamp(1rem, 4vw, 1.32rem)/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.secret-actions { align-items: center; }
.secret-actions .small { color: var(--muted); }

.result-panel .panel-head { margin-bottom: 0.8rem; }
.result-actions { margin-bottom: 1rem; }
.config-details { margin-top: 0.9rem; border-top: 1px solid var(--line); }
.config-details textarea { margin-top: 0.4rem; min-height: 16rem; }
.qr-figure { margin: 1rem 0 0; }
.qr-figure figcaption { margin-top: 0.65rem; color: var(--muted); font-size: 0.82rem; line-height: 1.45; text-align: center; }
.config-qr {
  display: block;
  width: min(100%, 22rem);
  height: auto;
  margin: 0 auto;
  padding: 0.55rem;
  border-radius: 0.7rem;
  background: #fff;
}

.telegram-webapp { min-height: 100dvh; }
.webapp-shell {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  padding-top: calc(1.5rem + env(safe-area-inset-top));
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  text-align: center;
}
.webapp-shell .lede { margin-inline: auto; }
.webapp-mark { display: flex; justify-content: center; margin-bottom: 1.1rem; }
.webapp-mark .brand-mark { width: 3.25rem; height: 3.25rem; }
.telegram-state { display: flex; align-items: center; justify-content: center; gap: 0.65rem; }
.state-spinner { width: 1rem; height: 1rem; flex: 0 0 auto; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin 650ms linear infinite; }
#telegram-close { width: fit-content; margin: 0 auto; }

.revision-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
}
.revision-error { color: var(--red); overflow-wrap: anywhere; }

.source-list { display: grid; gap: 0.75rem; }
.source-card { padding: 1rem; border: 1px solid var(--line); border-radius: 0.68rem; background: var(--surface-soft); }
.source-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.source-main h3 { margin-bottom: 0.22rem; }
.origin { max-width: 38rem; margin-bottom: 0.65rem; color: var(--muted); font-size: 0.74rem; overflow-wrap: anywhere; }
.diagnostic { margin-bottom: 0.7rem; color: var(--red); font-size: 0.8rem; line-height: 1.45; }
.row-actions { padding-top: 0.2rem; }

.simulation-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 0.7rem; }
.simulation-form .field { margin-bottom: 0; }
.simulation-result { display: flex; flex-direction: column; gap: 0.2rem; margin: 1rem 0 0; }

.table-wrap { overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th, td { padding: 0.76rem 0.62rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.075em; }
tbody tr:last-child td { border-bottom: 0; }
.table-actions { width: 1%; }
.table-actions .actions { flex-wrap: nowrap; justify-content: flex-end; }

.status { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.status::before { content: ""; width: 0.48rem; height: 0.48rem; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.status.active::before, .status.ready::before { background: var(--green); box-shadow: 0 0 0 0.22rem rgba(156, 230, 118, 0.1); }
.status.pending::before, .status.revoking::before { background: var(--amber); }
.status.failed::before { background: var(--red); box-shadow: 0 0 0 0.22rem rgba(255, 133, 128, 0.08); }
.status.revoked::before, .status.disabled::before { background: var(--faint); }

.empty {
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.35rem;
  padding: 1rem 0;
  color: var(--muted);
  line-height: 1.5;
}
.empty strong { color: var(--text); }
.empty .actions { margin-top: 0.6rem; }

.footer { color: var(--muted); font-size: 0.77rem; line-height: 1.5; }
.footer-inner {
  width: min(calc(100% - 2rem - env(safe-area-inset-left) - env(safe-area-inset-right)), 76rem);
  margin: 0 auto;
  padding: 0 0 calc(2rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

@media (hover: hover) and (pointer: fine) {
  a:hover { color: #b5edff; }
  .nav a:hover, .admin-nav a:hover, .link-button:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
  .admin-menu summary:hover { border-color: var(--line-strong); background: var(--surface-raised); }
  .button:hover { background: #b8f396; color: #071007; }
  .button.secondary:hover { border-color: #53636f; background: #1a232b; color: var(--text); }
  .button.tertiary:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
  .button.danger:hover { border-color: var(--red); background: rgba(255, 133, 128, 0.08); color: #ffaaa6; }
  .metric:hover { transform: translateY(-1px); border-color: var(--line-strong); background: var(--surface-raised); color: var(--text); }
  tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
  .release-details summary:hover, .config-details summary:hover { color: #b5edff; }
}

@media (pointer: coarse) {
  .button.small-button { min-height: 2.75rem; padding: 0.58rem 0.75rem; }
}

@media (min-width: 961px) {
  .admin-topbar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 15.5rem;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 1.15rem 0.9rem max(1rem, env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    border-bottom: 0;
    overflow-y: auto;
    background: #0c1116;
    backdrop-filter: none;
  }

  .admin-brand-row { width: auto; padding: 0 0.35rem 1rem; }
  .admin-menu { display: none; }
  .admin-nav.admin-nav-desktop { display: grid; }
  .admin-logout-desktop { display: block; margin-top: auto; }

  .admin-topbar + .shell {
    width: min(calc(100% - 18.5rem), 76rem);
    margin-left: max(17rem, calc(15.5rem + (100vw - 15.5rem - 76rem) / 2));
    margin-right: auto;
  }

  .admin-topbar + .shell.narrow {
    width: min(calc(100% - 18.5rem), 34rem);
    margin-left: max(17rem, calc(15.5rem + (100vw - 15.5rem - 34rem) / 2));
  }

  .admin-topbar ~ .footer .footer-inner {
    width: min(calc(100% - 18.5rem), 76rem);
    margin-left: max(17rem, calc(15.5rem + (100vw - 15.5rem - 76rem) / 2));
    margin-right: auto;
  }
}

@media (max-width: 760px) {
  .shell { padding-top: 1.35rem; padding-bottom: 3rem; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 0.9rem; }
  .page-heading > .actions { width: 100%; }
  .span-4, .span-6, .span-8 { grid-column: span 12; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .simulation-form { grid-template-columns: 1fr; }
  .source-main, .revision-bar { align-items: flex-start; flex-direction: column; }
  .metric { min-height: 8.5rem; }
  .result-actions .button { flex: 1 1 10rem; }
  .button.small-button { min-height: 2.75rem; padding: 0.58rem 0.75rem; }

  .table-wrap { overflow: visible; }
  .responsive-table { display: block; min-width: 0; }
  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .responsive-table tbody { display: grid; gap: 0.75rem; }
  .responsive-table tr {
    display: block;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
    background: var(--surface-soft);
  }
  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 0.72fr) minmax(0, 1.28fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .responsive-table td.table-actions {
    width: auto;
    display: block;
    padding-top: 0.75rem;
    border-bottom: 0;
  }
  .responsive-table td.table-actions:empty { display: none; }
  .table-actions .actions { flex-wrap: wrap; justify-content: flex-start; }
  .table-actions form { flex: 1 1 auto; }
  .table-actions .button { width: 100%; }
  .responsive-table td:last-child:not(.table-actions) { border-bottom: 0; }
}

@media (max-width: 430px) {
  .topbar, .admin-topbar { padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
  .shell, .narrow, .footer-inner { width: calc(100% - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right)); }
  h1 { font-size: clamp(1.9rem, 10vw, 2.45rem); }
  .panel { padding: 1rem; }
  .actions.result-actions { display: grid; grid-template-columns: 1fr; }
  .result-actions .button { width: 100%; }
  .admin-menu-panel { width: calc(100vw - 1.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .skip-link,
  .metric,
  .button,
  .link-button,
  .admin-menu summary,
  .menu-chevron,
  .admin-menu-panel {
    transition-property: color, background-color, border-color, opacity;
    transition-duration: 100ms;
  }
  .skip-link:focus, .metric:hover, .button:active, .link-button:active, .admin-menu summary:active, .admin-menu-panel, .admin-menu[open] .menu-chevron { transform: none; }
  .state-spinner, .button[data-busy="true"]::before, .link-button[data-busy="true"]::before { animation: none; border-right-color: currentColor; opacity: 0.6; }
}

/* Quiet infrastructure theme: content first, restrained surfaces, one accent. */
:root {
  color-scheme: light dark;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #eceee9;
  --line: #d9ddd6;
  --line-strong: #bcc4ba;
  --control-border: #7c877d;
  --text: #1b211c;
  --muted: #657066;
  --faint: #7c877d;
  --cyan: #356844;
  --green: #3f6f4a;
  --on-primary: #ffffff;
  --focus-ring: #245833;
  --amber: #8a641d;
  --red: #a33c36;
  --overlay-shadow: 0 16px 42px rgba(24, 35, 26, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151916;
    --surface: #1b201c;
    --surface-raised: #222823;
    --surface-soft: #191e1a;
    --line: #323a33;
    --line-strong: #4b574d;
    --control-border: #647166;
    --text: #edf1ec;
    --muted: #a4afa5;
    --faint: #879287;
    --cyan: #8ab596;
    --green: #7cac88;
    --on-primary: #111713;
    --focus-ring: #b7e3bd;
    --amber: #d1aa62;
    --red: #df837c;
    --overlay-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  }
}

html, body { background: var(--bg); }
body { background-image: none; }
.brand-mark, .webapp-mark, .eyebrow, .route-strip { display: none; }

.topbar,
.admin-topbar {
  border-color: var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.brand { letter-spacing: -0.02em; }
.nav a { color: var(--muted); }

.admin-menu summary,
.admin-menu-panel {
  border-color: var(--control-border);
  background: var(--surface-raised);
}

.admin-nav { gap: 0.18rem; }
.admin-nav > a,
.nav-group > summary {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.42rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 620;
  text-decoration: none;
  cursor: pointer;
}

.admin-nav .admin-primary-action {
  margin-bottom: 0.75rem;
  border-color: var(--control-border);
  background: var(--surface);
  color: var(--text);
  justify-content: center;
}

.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary span:last-child { transition: transform 160ms var(--ease-out); }
.nav-group[open] summary span:last-child { transform: rotate(180deg); }
.nav-subitems { display: grid; gap: 0.12rem; margin: 0.12rem 0 0.4rem; padding-left: 0.7rem; border-left: 1px solid var(--line); }
.nav-subitems a { min-height: 2.75rem; display: flex; align-items: center; padding: 0.42rem 0.65rem; font-size: 0.84rem; }
.admin-nav a[aria-current="page"],
.nav-group summary[aria-current="page"] {
  border-color: transparent;
  background: color-mix(in srgb, var(--green) 12%, transparent);
  color: var(--text);
}

.shell { padding-top: 2rem; }
.page-heading { margin-bottom: 1.5rem; align-items: center; }
h1 {
  max-width: 24ch;
  margin-bottom: 0.38rem;
  font-size: clamp(1.85rem, 3vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}
h2 { font-size: 1.08rem; }
.lede { margin-bottom: 0; line-height: 1.52; }

.panel {
  padding: 1.15rem 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.narrow > .panel,
.form-panel,
.result-panel {
  padding: clamp(1rem, 2.4vw, 1.4rem);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
}

.download-section {
  margin-top: 1.25rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
  line-height: 1.55;
}

.grid > .span-4,
.grid > .span-8 { grid-column: span 12; }
.grid > .span-4 { max-width: 42rem; }

input, select, textarea {
  color: var(--text);
  border-color: var(--control-border);
  border-radius: 0.45rem;
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--focus-ring); outline: 3px solid var(--focus-ring); outline-offset: 1px; box-shadow: none; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline-color: var(--focus-ring); }

.button {
  border-radius: 0.46rem;
  background: var(--green);
  color: var(--on-primary);
  box-shadow: none;
}
.button.secondary { border-color: var(--control-border); background: var(--surface); color: var(--text); }
.button.tertiary { color: var(--muted); }
.button.danger { border-color: color-mix(in srgb, var(--red) 42%, transparent); color: var(--red); }
.row-actions .button {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}
.row-actions .button.danger { border-color: transparent; color: var(--red); }

.notice {
  border-color: color-mix(in srgb, var(--amber) 28%, var(--line));
  border-left-color: var(--amber);
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--amber) 7%, var(--surface));
}
.notice.error { border-color: color-mix(in srgb, var(--red) 28%, var(--line)); border-left-color: var(--red); background: color-mix(in srgb, var(--red) 7%, var(--surface)); }
.notice.success { border-color: color-mix(in srgb, var(--green) 28%, var(--line)); border-left-color: var(--green); background: color-mix(in srgb, var(--green) 7%, var(--surface)); }

.revision-bar {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0.9rem 1rem;
  border-color: var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}
.revision-bar > div { display: grid; gap: 0.22rem; }
.revision-bar strong { color: var(--text); }
.revision-bar span { color: var(--muted); }
.revision-bar.active { border-left: 3px solid var(--green); }
.revision-bar.failed { border-left: 3px solid var(--red); }

.overview-list { margin-top: 1rem; border-top: 1px solid var(--line); }
.overview-list a {
  min-height: 4.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.2rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.overview-list strong { display: inline-block; min-width: 2.6rem; font-size: 1.55rem; letter-spacing: -0.04em; }
.overview-list a > span:last-child { color: var(--muted); font-size: 0.86rem; }
.service-details {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.25rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.service-details p { margin-bottom: 0; }
.service-details > div:last-child { display: grid; gap: 0.25rem; text-align: right; }

.choice-links { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 1rem 0 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
.choice-links a, .choice-links span { min-height: 2.75rem; display: flex; align-items: center; padding: 0.45rem 0.65rem; border-radius: 0.4rem; color: var(--muted); text-decoration: none; }
.choice-links [aria-current="page"] { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--text); font-weight: 680; }
.device-methods .device-method-primary { background: var(--green); color: var(--on-primary); font-weight: 680; }
.direct-config-path { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.direct-config-path > div { display: grid; gap: 0.18rem; }

.source-card { border-color: var(--line); border-width: 0 0 1px; border-radius: 0; background: transparent; }
.responsive-table tr, th, td { border-color: var(--line); }
.status::before,
.status.active::before,
.status.ready::before,
.status.failed::before { box-shadow: none; }
.release-details summary,
.config-details summary { color: var(--green); }
.footer-inner { border-color: var(--line); }

.wordmark { margin-bottom: 1rem; color: var(--muted); font-weight: 720; letter-spacing: -0.02em; }
.webapp-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; }
.telegram-state { min-height: 2.75rem; display: flex; align-items: center; justify-content: center; gap: 0.65rem; margin-bottom: 1rem; color: var(--muted); }
.telegram-state.error { color: var(--red); }

@media (hover: hover) and (pointer: fine) {
  a:hover { color: var(--text); }
  .button:hover { background: color-mix(in srgb, var(--green) 88%, #000); color: var(--on-primary); }
  .button.secondary:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--text); }
  .row-actions .button:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--text); }
  .row-actions .button.danger:hover { border-color: color-mix(in srgb, var(--red) 35%, transparent); color: var(--red); }
  .release-details summary:hover, .config-details summary:hover { color: var(--text); }
  .overview-list a:hover { color: var(--green); }
}

@media (min-width: 961px) {
  .admin-topbar { background: var(--surface-soft); }
}

@media (max-width: 760px) {
  .service-details { flex-direction: column; }
  .service-details > div:last-child { text-align: left; }
  .direct-config-path { align-items: stretch; flex-direction: column; }
  .grid > .span-4 { max-width: none; }
}

.telegram-close {
  min-height: 2.75rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--control-border);
  border-radius: 0.42rem;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.telegram-bottom-nav { display: none; }
.telegram-shell .button { color: var(--button-text, var(--on-primary)); }
.telegram-webapp .button { color: var(--button-text, var(--on-primary)); }
.telegram-shell .button.secondary,
.telegram-shell .button.tertiary,
.telegram-webapp .button.secondary,
.telegram-webapp .button.tertiary { color: var(--text); }
.telegram-shell .button.danger,
.telegram-webapp .button.danger { color: var(--red); }
.telegram-shell .footer { display: none; }

@media (max-width: 760px) {
  .telegram-shell .admin-menu { display: none; }
  .telegram-shell .admin-topbar {
    position: sticky;
    padding-top: max(0.65rem, env(safe-area-inset-top));
    background: var(--bg);
  }
  .telegram-shell .shell {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }
  .telegram-bottom-nav {
    position: fixed;
    z-index: 40;
    inset: auto 0 0;
    min-height: calc(4.2rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0.4rem max(0.35rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(0.35rem, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(16px);
  }
  .telegram-bottom-nav a {
    min-height: 3.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.2rem;
    border-radius: 0.42rem;
    color: var(--muted);
    font-size: clamp(0.64rem, 2.8vw, 0.74rem);
    font-weight: 650;
    text-align: center;
    text-decoration: none;
  }
  .telegram-bottom-nav a[aria-current="page"] {
    background: color-mix(in srgb, var(--green) 13%, transparent);
    color: var(--text);
  }
}
