:root {
  color-scheme: dark;
  --bg: #08090d;
  --panel: #161920;
  --panel-soft: #1f242d;
  --panel-strong: #2a303b;
  --text: #f7f3ff;
  --muted: #aab0bd;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #a855f7;
  --accent-2: #20d6b5;
  --accent-soft: rgba(168, 85, 247, 0.16);
  --cyan: #5de8cf;
  --success: #4ade80;
  --danger: #ff6b6b;
  --warning: #facc15;
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--tg-theme-bg-color, var(--bg));
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(168, 85, 247, 0.18), transparent 260px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 260px),
    var(--tg-theme-bg-color, var(--bg));
  color: var(--tg-theme-text-color, var(--text));
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-busy {
  cursor: progress;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 8px 10px 94px;
}

.banner {
  overflow: hidden;
  border-radius: 8px;
  background: #070811;
  box-shadow: var(--shadow);
}

.banner img {
  display: block;
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
}

.status-card,
.quick-card,
.action,
.list-card,
.plan-card,
.info-card,
.admin-card,
.sheet-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tg-theme-secondary-bg-color, var(--panel));
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 13px;
  box-shadow: var(--shadow);
}

.profile {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.avatar {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(135deg, rgba(168, 85, 247, 0.95), rgba(32, 214, 181, 0.82)),
    #1a1d25;
  background-position: center;
  background-size: cover;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.avatar.has-photo {
  background-color: #10131a;
}

.profile-text {
  min-width: 0;
}

.profile-text p {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overline,
.quick-card span,
.list-card span,
.plan-card span,
.info-card span,
.admin-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.overline {
  display: block;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  overflow: hidden;
  font-size: 19px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.status-pill {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(93, 232, 207, 0.22);
  background: rgba(93, 232, 207, 0.11);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
}

.status-pill.inactive {
  background: rgba(255, 107, 107, 0.14);
  color: var(--danger);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.quick-card {
  min-width: 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.quick-card strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen {
  display: none;
  margin-top: 12px;
}

.screen.active {
  display: block;
}

.actions {
  display: grid;
  gap: 8px;
}

.action {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 13px;
  text-align: left;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
}

.action strong,
.action small {
  display: block;
}

.action small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.primary-action {
  border-color: rgba(168, 85, 247, 0.42);
  background:
    linear-gradient(135deg, rgba(168, 85, 247, 0.82), rgba(92, 60, 178, 0.78)),
    var(--panel);
}

.primary-action small {
  color: rgba(255, 255, 255, 0.72);
}

.action-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-size: 21px;
  font-weight: 900;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 2px 9px;
}

.section-head.compact {
  margin-top: 12px;
}

.link-button,
.small-button {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
}

.stack,
.plans-grid,
.admin-grid {
  display: grid;
  gap: 8px;
}

.plans-grid,
.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  padding: 12px;
  text-align: left;
}

.list-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.list-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: rgba(93, 232, 207, 0.11);
  color: var(--cyan);
  font-weight: 900;
}

.list-copy {
  min-width: 0;
}

.list-copy strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-copy span {
  display: block;
  margin-top: 4px;
}

.chevron,
.state-dot {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 900;
}

.state-dot.ok {
  color: var(--success);
}

.plan-card {
  display: grid;
  gap: 14px;
  min-height: 148px;
  padding: 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent),
    var(--panel);
}

.plan-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.plan-name {
  font-size: 16px;
  font-weight: 900;
}

.plan-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(93, 232, 207, 0.11);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
}

.price {
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
}

.wide-button,
.plan-button {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 900;
}

.danger-button {
  background: rgba(255, 107, 107, 0.14);
  color: #ffd8d8;
}

.plan-button {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
}

.info-card,
.admin-card {
  padding: 13px;
}

.info-card {
  text-align: left;
}

.info-card p,
.admin-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.info-button {
  display: grid;
  min-height: 126px;
  align-content: start;
  gap: 7px;
}

.info-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 18px;
}

.info-panel {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.info-panel span {
  color: var(--muted);
  font-size: 12px;
}

.info-panel strong {
  font-size: 18px;
}

.info-panel p,
.info-lead {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

.info-back {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.info-back span {
  color: var(--cyan);
  font-size: 24px;
  line-height: 1;
}

.info-lead {
  padding: 0 2px 4px;
}

.admin-card strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.server-card {
  display: grid;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tg-theme-secondary-bg-color, var(--panel));
}

.server-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.server-head .list-copy {
  flex: 1 1 auto;
}

.server-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.server-meta span {
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.empty {
  padding: 22px 13px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty .wide-button {
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  width: min(720px, 100%);
  padding: 7px 8px max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 9, 13, 0.92);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.bottom-nav.has-admin {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.nav-item {
  display: grid;
  min-height: 54px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nav-item span {
  display: block;
  margin-bottom: 2px;
  font-size: 18px;
  line-height: 1;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.sheet.open {
  display: block;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
}

.sheet-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(720px, 100%);
  max-height: 82vh;
  padding: 10px 12px max(14px, env(safe-area-inset-bottom));
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  overflow: auto;
  transform: translateX(-50%);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

#sheet-content {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
}

.field input:focus {
  border-color: rgba(139, 92, 246, 0.82);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.field span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.server-picker,
.device-actions {
  display: grid;
  gap: 8px;
}

.server-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: left;
}

.server-option.selected {
  border-color: rgba(82, 220, 199, 0.72);
  background: rgba(82, 220, 199, 0.1);
}

.server-option strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-option span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.config-preview {
  max-height: 138px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0e17;
  color: #c8b8ff;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.qr-card {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  color: #111827;
}

.qr-card img {
  display: block;
  width: min(100%, 420px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.qr-card p {
  font-weight: 900;
}

@media (max-width: 430px) {
  .plans-grid,
  .admin-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    padding-right: 6px;
    padding-left: 6px;
  }
}

@media (max-width: 350px) {
  .quick-grid {
    grid-template-columns: 1fr;
  }
}
