@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap');

:root {
  --bg: #0a0d14;
  --bg-elevated: #121722;
  --bg-card: #141a26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f6fb;
  --text-muted: #8b95a8;
  --accent: #3dd6c6;
  --accent-dim: rgba(61, 214, 198, 0.14);
  --accent-strong: #1aa897;
  --success: #3ecf8e;
  --danger: #ff6b7a;
  --warning: #f0b429;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  --nav-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

html, body {
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 0% -5%, rgba(61, 214, 198, 0.10), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(90, 120, 255, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: Manrope, ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 22px 16px calc(var(--nav-h) + var(--safe-bottom) + 28px);
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-header p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 12px; }
.card-body { padding: 16px; }

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.chip {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  color: var(--text);
  border-color: rgba(61, 214, 198, 0.4);
  background: var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #041512;
}

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-block { width: 100%; }

.input, select.input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.input:focus {
  border-color: rgba(61, 214, 198, 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.state-icon { font-size: 2rem; margin-bottom: 10px; }
.state h3 { color: var(--text); margin-bottom: 8px; font-size: 1.1rem; }
.state p { line-height: 1.45; max-width: 28ch; margin: 0 auto; }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8px + var(--safe-bottom));
  width: min(460px, calc(100% - 20px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(10, 13, 20, 0.92);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  z-index: 40;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 4px;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.nav-item.active {
  color: var(--text);
  background: var(--accent-dim);
}

.add-device-inline {
  margin-top: 16px;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.device-card {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.device-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.device-name {
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.device-code {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.device-code strong {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.type-tag {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.type-tag.youtube {
  background: rgba(255, 107, 122, 0.12);
  color: #ff9aa4;
}

.type-tag.internet {
  background: rgba(96, 165, 250, 0.12);
  color: #93c5fd;
}

.type-tag.none {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}

.device-sub-row {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}

.device-sub-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.vpn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(61, 214, 198, 0.05);
  border: 1px solid rgba(61, 214, 198, 0.14);
}

.vpn-title {
  font-weight: 700;
  font-size: 0.92rem;
}

.vpn-status {
  margin-top: 3px;
  font-size: 0.8rem;
  font-weight: 600;
}

.vpn-status.on { color: var(--success); }
.vpn-status.off { color: var(--text-muted); }
.vpn-status.busy { color: var(--warning); }
.vpn-status.err { color: var(--danger); }

.vpn-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px;
}

.vpn-switch:disabled { opacity: 0.55; cursor: wait; }

.vpn-switch-track {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  position: relative;
  transition: background 0.18s ease;
}

.vpn-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.vpn-switch.is-on .vpn-switch-track {
  background: var(--accent);
}

.vpn-switch.is-on .vpn-switch-knob {
  transform: translateX(20px);
}

.device-btns {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
}

.device-btn {
  min-height: 44px;
  padding-left: 10px;
  padding-right: 10px;
}

.sub-card {
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.sub-card:active { transform: scale(0.99); }
.sub-card:hover { border-color: rgba(61, 214, 198, 0.35); }

.sub-title { font-weight: 800; font-size: 1rem; }
.sub-price { font-size: 1.4rem; font-weight: 800; margin: 10px 0 4px; color: var(--accent); }
.sub-meta { color: var(--text-muted); font-size: 0.85rem; }

.type-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.type-pill.youtube { background: rgba(255,107,122,0.12); color: #ff9aa4; }
.type-pill.internet { background: rgba(96,165,250,0.12); color: #93c5fd; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.72);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal.open { display: flex; }

.modal-panel {
  width: min(480px, 100%);
  max-height: 88dvh;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px 20px 16px 16px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h2 { font-size: 1.15rem; font-weight: 800; }

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-muted); }

.notice {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,107,122,0.1);
  border: 1px solid rgba(255,107,122,0.25);
  color: #fecaca;
  font-size: 0.82rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 24px);
  background: rgba(15, 20, 32, 0.96);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 200;
  max-width: min(92vw, 420px);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast[data-type="error"] { border-color: rgba(255,107,122,0.45); }

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px 22px;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  background: var(--accent-dim);
  border: 1px solid rgba(61,214,198,0.25);
}

.auth-card h1 {
  font-size: 1.45rem;
  margin-bottom: 8px;
  font-weight: 800;
}

.auth-card p {
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.faq-item + .faq-item { margin-top: 10px; }

.faq-q {
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
}

.faq-a {
  display: none;
  padding: 10px 4px 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.faq-item.open .faq-a { display: block; }

.profile-hero {
  text-align: center;
}

.profile-name {
  font-weight: 800;
  font-size: 1.2rem;
}

.profile-id {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  word-break: break-all;
}

.profile-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.orders-list {
  display: grid;
  gap: 10px;
}

.order-row {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.order-row-top,
.order-row-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.order-row-meta {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.order-status {
  font-size: 0.8rem;
  font-weight: 700;
}

.order-status.ok { color: #6ee7b7; }
.order-status.err { color: #fca5a5; }
.order-status.muted { color: var(--text-muted); }

.support-link {
  display: block;
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(61,214,198,0.25);
  background: var(--accent-dim);
  font-weight: 700;
}

body.modal-open { overflow: hidden; }

@media (min-width: 520px) {
  .modal { align-items: center; }
  .modal-panel { border-radius: 18px; }
}
