/* === TOKENS === */
:root {
  color-scheme: light;
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-hover: #f0f3f9;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.07);
  --accent: #4f7fff;
  --accent-dim: rgba(79, 127, 255, 0.1);
  --accent-hover: rgba(79, 127, 255, 0.16);
  --active: #16a34a;
  --active-dim: rgba(22, 163, 74, 0.1);
  --warn: #d97706;
  --warn-dim: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.1);
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #b0b8c8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

/* === BASE === */
body {
  margin: 0;
  min-height: 100svh;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(79, 127, 255, 0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* === LAYOUT === */
#app {
  position: relative;
  width: min(100%, 540px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 16px 106px;
  z-index: 1;
}

.splash {
  display: grid;
  place-items: center;
  min-height: 100svh;
  color: var(--text-muted);
  font-size: 15px;
}

/* === SCREEN WRAPPER === */
.screen {
  display: grid;
  gap: 12px;
  padding-top: 22px;
}

/* === SCREEN TITLE === */
.screen-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  padding: 0 2px;
}

/* === SECTION LABEL === */
.section-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0 2px;
  margin-top: 4px;
}

/* === HERO CARD === */
.hero-card {
  border-radius: 22px;
  padding: 28px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(22, 163, 74, 0.14) 0%, transparent 70%);
  pointer-events: none;
}

.hero-card.inactive::before {
  background: radial-gradient(circle, rgba(217, 119, 6, 0.12) 0%, transparent 70%);
}

.hero-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  margin-bottom: 14px;
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.22);
  color: var(--active);
}

.hero-icon-wrap.inactive {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.22);
  color: var(--warn);
}

.hero-icon-wrap svg {
  width: 38px;
  height: 38px;
}

.hero-status {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.hero-sub {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

/* === STATUS BADGE === */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-top: 14px;
}

.status-badge.active {
  background: rgba(22, 163, 74, 0.1);
  color: var(--active);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.status-badge.inactive {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warn);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* === STATS ROW === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  border-radius: 16px;
  padding: 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin-top: 7px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

/* === GENERIC CARD === */
.card {
  border-radius: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

/* === URL CARD === */
.url-card {
  border-radius: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.url-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 10px;
}

.url-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.6;
  max-height: 72px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* === LIST CARD === */
.list-card {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
}

.list-row:last-child { border-bottom: 0; }

button.list-row:active,
button.list-row:hover { background: var(--surface-hover); }

.list-row.static { pointer-events: none; }

.row-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}

.row-icon svg { width: 17px; height: 17px; }

.row-content { flex: 1; min-width: 0; }

.row-title { font-size: 15px; font-weight: 600; color: var(--text); }

.row-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.row-value {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.row-chevron { color: var(--text-faint); flex-shrink: 0; }
.row-chevron svg { width: 15px; height: 15px; }

/* === BUTTONS === */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(79, 127, 255, 0.3);
  transition: opacity 0.12s, transform 0.1s;
}

.btn-primary:active { opacity: 0.82; transform: scale(0.98); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 0 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.12s;
}

.btn-secondary:active { background: var(--surface-hover); }
.btn-secondary svg { width: 18px; height: 18px; }

/* === ICON BUTTON === */
.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.icon-btn:active { background: var(--accent-dim); color: var(--accent); }
.icon-btn svg { width: 15px; height: 15px; }

/* === PROFILE HEADER === */
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid rgba(79, 127, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }

.profile-handle { color: var(--text-muted); font-size: 14px; margin-top: 3px; }

/* === ID ROW === */
.id-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.id-label { color: var(--text-muted); font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.id-value { font-weight: 700; font-size: 15px; color: var(--text); }

/* === PLANS === */
.plans-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.plan-card {
  border-radius: 16px;
  padding: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s;
}

.plan-card.selected {
  border-color: var(--accent);
  background: rgba(79, 127, 255, 0.04);
}

.plan-period { font-size: 15px; font-weight: 700; color: var(--text); }
.plan-price { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.plan-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

/* === PRICE SUMMARY === */
.price-summary {
  border-radius: 18px;
  padding: 22px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.price-amount {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.price-currency { font-size: 26px; font-weight: 400; color: var(--text-muted); }

.price-tags { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

.price-tag {
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

/* === CHIPS === */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* === STEP CARDS === */
.step-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.step-num {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
}

.step-body h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.step-body p { color: var(--text-muted); font-size: 14px; margin-top: 5px; line-height: 1.5; }

/* === TEXTAREA === */
textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 10px;
  outline: none;
  transition: border-color 0.12s;
}

textarea:focus { border-color: var(--accent); }

/* === STATE === */
.state {
  min-height: 60vh;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
}

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

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed;
  left: max(12px, calc((100vw - 540px) / 2 + 12px));
  right: max(12px, calc((100vw - 540px) / 2 + 12px));
  bottom: 14px;
  z-index: 100;
  display: flex;
  gap: 3px;
  padding: 5px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -2px 20px rgba(0,0,0,0.06), 0 8px 32px rgba(0,0,0,0.1);
}

.bottom-nav.single { gap: 0; }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--text-faint);
  transition: color 0.15s, background 0.15s;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 9.5px; font-weight: 700; letter-spacing: 0.02em; }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

/* === ADMIN (in-app) === */
.admin-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.admin-tab {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  color: var(--text-muted);
  background: transparent;
  font-weight: 700;
  font-size: 14px;
  transition: color 0.15s, background 0.15s;
}

.admin-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.admin-section { display: grid; gap: 12px; }
.admin-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-section-head h2 { font-size: 18px; font-weight: 700; color: var(--text); }
.admin-section-head span { color: var(--text-muted); font-size: 14px; }
.admin-list { display: grid; gap: 10px; }

.admin-user, .admin-node, .admin-create {
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.admin-user-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-user-head h2 { font-size: 16px; font-weight: 700; color: var(--text); }
.admin-user-head p, .device-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.admin-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(22, 163, 74, 0.1);
  color: var(--active);
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid rgba(22, 163, 74, 0.18);
}

.admin-badge.ok { background: rgba(22, 163, 74, 0.1); color: var(--active); border-color: rgba(22, 163, 74, 0.18); }
.admin-badge.warn { background: rgba(217, 119, 6, 0.1); color: var(--warn); border-color: rgba(217, 119, 6, 0.18); }

.admin-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.admin-meta span {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.small-button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s;
}

.small-button:active { background: var(--accent-hover); }
.small-button.danger { background: var(--danger-dim); color: var(--danger); }

.admin-device {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.device-title { font-size: 14px; font-weight: 700; color: var(--text); }

.node-health-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }

.node-health-grid div {
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.node-health-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 3px;
}

.node-health-grid strong { display: block; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }

.node-error {
  border-radius: 10px;
  padding: 10px;
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 12px;
  overflow-wrap: anywhere;
  margin: 6px 0;
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.node-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-create .node-form { margin-top: 12px; }

.node-form label { display: grid; gap: 5px; }

.node-form label span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.node-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.12s;
}

.node-form input:focus { border-color: var(--accent); }

.node-form .admin-user-head, .node-form .node-health-grid,
.node-form .node-error, .node-form .admin-meta,
.node-form .admin-actions, .node-form .btn-primary { grid-column: 1 / -1; }

.check-row { display: flex !important; grid-template-columns: none; align-items: center; gap: 8px !important; min-height: 38px; }
.check-row input { width: 18px; min-height: 18px; }
.admin-create summary { color: var(--accent); font-weight: 700; cursor: pointer; padding: 4px 0; }

/* === MEDIA === */
@media (max-width: 420px) {
  #app { padding: 0 12px 100px; }
  .screen-title { font-size: 26px; }
  .hero-card { padding: 22px 18px 20px; }
  .plans-grid, .node-health-grid, .node-form { grid-template-columns: 1fr; }
  .bottom-nav { left: 10px; right: 10px; bottom: 10px; }
  .stats-row { gap: 8px; }
  .stat-value { font-size: 15px; }
}
