:root {
  color-scheme: dark;
  --bg: #070b0a;
  --sidebar: #0b1110;
  --panel: #101815;
  --panel-strong: #17211d;
  --text: #fbf7ee;
  --muted: #aebcb3;
  --line: rgba(251, 247, 238, 0.12);
  --green: #2de0b5;
  --cyan: #86caff;
  --coral: #ff7f70;
  --gold: #d8b76b;
  --danger: #ff8275;
  --shadow: rgba(0, 0, 0, 0.38);
  --brand-glow: rgba(45, 224, 181, 0.2);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #070b0a 0%, #0a1110 48%, #070b0a 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a,
button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  width: 252px;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(251, 247, 238, 0.035), rgba(251, 247, 238, 0)),
    var(--sidebar);
}

.brand,
.nav,
.bot-link,
.topbar,
.card-head,
.panel-heading,
.progress-meta,
.device-row,
.plan-item,
.node-item,
.support-panel {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 900;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(251, 247, 238, 0.16);
  border-radius: 8px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(45, 224, 181, 0.96), rgba(134, 202, 255, 0.72) 58%, rgba(216, 183, 107, 0.82));
  box-shadow: 0 14px 34px var(--brand-glow);
}

.nav {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.nav a,
.bot-link {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover,
.bot-link:hover {
  background: rgba(251, 247, 238, 0.08);
  color: var(--text);
}

.bot-link {
  justify-content: center;
  margin-top: auto;
  border: 1px solid var(--line);
}

.workspace {
  min-height: 100vh;
  margin-left: 252px;
  padding: 32px clamp(22px, 4vw, 56px) 56px;
}

.topbar {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p,
span,
strong {
  overflow-wrap: anywhere;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

.account-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: rgba(251, 247, 238, 0.04);
}

.account-controls label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.account-controls input {
  width: 140px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(7, 11, 10, 0.74);
}

#inviteCodeInput {
  text-transform: uppercase;
}

.panel-note {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
}

.panel-note.error {
  color: var(--danger);
}

.panel-note.success {
  color: var(--green);
}

.compact-button {
  min-height: 34px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(251, 247, 238, 0.04);
}

.plan-actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(40, 209, 165, 0.14);
}

.summary-grid,
.content-grid {
  display: grid;
  gap: 18px;
}

.summary-grid {
  grid-template-columns: 1.4fr 1fr 1fr;
}

.content-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  margin-top: 18px;
}

.summary-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(251, 247, 238, 0.035), rgba(251, 247, 238, 0)),
    var(--panel);
  box-shadow: 0 20px 54px var(--shadow);
}

.summary-card {
  min-height: 210px;
  padding: 24px;
}

.subscription-card {
  background:
    linear-gradient(135deg, rgba(45, 224, 181, 0.18) 0%, rgba(16, 24, 21, 0.92) 54%, rgba(134, 202, 255, 0.1) 100%),
    var(--panel);
}

.card-head,
.panel-heading,
.progress-meta {
  justify-content: space-between;
  gap: 18px;
}

.card-head {
  margin-bottom: 36px;
  color: var(--muted);
}

.card-head strong {
  color: var(--green);
}

.progress-wrap {
  margin-top: 28px;
}

.progress-meta {
  margin-bottom: 10px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.1);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width 180ms ease;
}

.panel {
  margin-top: 18px;
  padding: 24px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.device-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-actions select {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  opacity: 0;
  pointer-events: none;
  color: var(--text);
  background: rgba(7, 11, 10, 0.74);
}

.access-flow {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.flow-step {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: rgba(251, 247, 238, 0.035);
}

.flow-step span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 8px;
  color: #06100e;
  background: rgba(251, 247, 238, 0.28);
  font-weight: 900;
}

.flow-step.active {
  border-color: rgba(45, 224, 181, 0.44);
  color: var(--text);
  background: rgba(45, 224, 181, 0.07);
}

.flow-step.active span {
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

.flow-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
}

.flow-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.node-choice {
  display: grid;
  min-height: 96px;
  gap: 5px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  text-align: left;
  background: rgba(251, 247, 238, 0.04);
}

.node-choice:hover,
.node-choice.active {
  border-color: rgba(45, 224, 181, 0.48);
  background: rgba(45, 224, 181, 0.08);
}

.node-choice span {
  color: var(--muted);
  font-size: 13px;
}

.node-choice em {
  color: var(--gold);
  font-style: normal;
  font-weight: 900;
}

.access-compose {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(251, 247, 238, 0.04), rgba(251, 247, 238, 0)),
    rgba(251, 247, 238, 0.035);
}

.device-name-field {
  display: grid;
  gap: 8px;
}

.device-name-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.device-name-field input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(7, 11, 10, 0.74);
}

.access-summary {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(251, 247, 238, 0.1);
  border-radius: 8px;
  padding: 12px;
  background: rgba(7, 11, 10, 0.42);
}

.access-summary span {
  color: var(--muted);
}

.access-summary strong {
  color: var(--gold);
}

.access-result {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(45, 224, 181, 0.34);
  border-radius: 8px;
  padding: 18px;
  background: rgba(45, 224, 181, 0.08);
}

.access-result.hidden {
  display: none;
}

.access-hint {
  margin: 8px 0 0;
}

.access-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 16px;
  align-items: start;
}

.access-content textarea {
  min-height: 220px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: rgba(7, 11, 10, 0.74);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.access-content img {
  width: 180px;
  height: 180px;
  border-radius: 8px;
  background: #fff;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #06100e;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 14px 34px var(--brand-glow);
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(251, 247, 238, 0.055);
}

.danger-button {
  color: #230806;
  background: var(--danger);
}

.primary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.device-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.device-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) minmax(120px, 0.7fr) minmax(130px, 0.7fr);
  gap: 14px;
  min-height: 66px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.device-row:first-child {
  border-top: 0;
}

.table-head {
  min-height: 44px;
  color: var(--muted);
  background: rgba(251, 247, 238, 0.04);
  font-size: 13px;
  font-weight: 900;
}

.device-name {
  font-weight: 900;
}

.device-meta,
.muted {
  color: var(--muted);
}

.device-meta {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  border-radius: 8px;
  padding: 4px 9px;
  color: #06100e;
  background: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.plan-list,
.node-list {
  display: grid;
  gap: 10px;
}

.plan-item,
.node-item {
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(251, 247, 238, 0.04);
}

.plan-item.active {
  border-color: rgba(45, 224, 181, 0.45);
  background: rgba(45, 224, 181, 0.07);
}

.plan-price,
.node-code {
  color: var(--gold);
  font-weight: 900;
}

.support-panel {
  justify-content: space-between;
  gap: 24px;
}

.support-panel p {
  max-width: 780px;
  margin-bottom: 0;
}

@media (max-width: 1080px) {
  .summary-grid,
  .content-grid,
  .flow-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .bot-link {
    margin-top: 0;
  }

  .workspace {
    margin-left: 0;
    padding: 24px 16px 42px;
  }

  .topbar,
  .account-controls,
  .support-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .device-table {
    overflow-x: auto;
  }

  .device-row {
    min-width: 760px;
  }

  .account-controls input {
    width: 100%;
  }

  .flow-steps,
  .node-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 21px;
  }

  .panel,
  .summary-card {
    padding: 18px;
  }

  .panel-heading,
  .device-actions,
  .access-content {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .device-actions select,
  .access-content img {
    width: 100%;
  }

  .access-content img {
    height: auto;
    max-width: 220px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .flow-steps,
  .node-choice-grid {
    grid-template-columns: 1fr;
  }
}
