:root {
  --bg: #080d0b;
  --bg-2: #111916;
  --card: #151f1b;
  --card-hover: #1a2621;
  --line: rgba(180, 220, 200, 0.1);
  --line-strong: rgba(61, 207, 154, 0.28);
  --text: #eef6f1;
  --muted: #8fa59a;
  --accent: #3dcf9a;
  --accent-2: #1a9d6e;
  --accent-glow: rgba(61, 207, 154, 0.35);
  --danger: #ff6b6b;
  --warn: #f0c14a;
  --ok: #3dcf9a;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --shadow-btn: 0 8px 24px rgba(26, 157, 110, 0.25);
  font-family: "Sora", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(61, 207, 154, 0.14), transparent 55%),
    radial-gradient(600px 400px at 100% 20%, rgba(40, 120, 100, 0.12), transparent 60%),
    radial-gradient(500px 350px at 0% 80%, rgba(30, 90, 70, 0.1), transparent 55%),
    var(--bg);
  pointer-events: none;
}

body {
  padding: max(16px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

#app {
  max-width: 560px;
  margin: 0 auto;
}

/* ——— Header ——— */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.header-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: linear-gradient(145deg, rgba(61, 207, 154, 0.22), rgba(61, 207, 154, 0.06));
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

.balance-pill {
  background: linear-gradient(135deg, rgba(61, 207, 154, 0.22), rgba(61, 207, 154, 0.06));
  border: 1px solid var(--line-strong);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.link-accent {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.link-accent:hover {
  text-decoration: underline;
}

/* ——— Guest banner ——— */
.guest-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, rgba(61, 207, 154, 0.1), rgba(61, 207, 154, 0.03));
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.guest-banner-icon {
  font-size: 18px;
  line-height: 1.2;
}

/* ——— Auth ——— */
.auth-panel {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.auth-panel-glow {
  position: absolute;
  top: -60px;
  right: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.auth-welcome {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}

.auth-sub {
  margin: 0 0 16px;
}

.auth-foot {
  margin: 16px 0 0;
  text-align: center;
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg-2);
  padding: 5px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px;
  border-radius: 11px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.auth-tab:hover:not(.active) {
  color: var(--text);
}

.auth-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.auth-form input {
  border: 1px solid var(--line);
  background: #0c1411;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form input::placeholder {
  color: rgba(143, 165, 154, 0.45);
}

.auth-form input:focus {
  outline: none;
  border-color: rgba(61, 207, 154, 0.5);
  box-shadow: 0 0 0 3px rgba(61, 207, 154, 0.12);
}

.input-mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  letter-spacing: 0.04em;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.telegram-login-wrap {
  text-align: center;
}

.telegram-login-wrap iframe {
  margin: 8px auto 0;
}

/* ——— Tabs ——— */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  background: var(--bg-2);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.tabs--scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs--scroll::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1 0 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 8px;
  border-radius: 12px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.tab-icon {
  font-size: 16px;
  line-height: 1;
}

.tab-label {
  line-height: 1.1;
}

.tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  background: linear-gradient(180deg, var(--card) 0%, #121a17 100%);
  color: var(--text);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tab:active {
  transform: scale(0.97);
}

.panel { display: none; }
.panel.active {
  display: block;
  animation: panel-in 0.28s ease;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.main-panels {
  display: grid;
  gap: 14px;
}

.section-lead {
  margin: 0 0 12px;
}

/* ——— Cards ——— */
.card, .tariff, .client, .server {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-hero {
  border-color: rgba(61, 207, 154, 0.15);
  background: linear-gradient(165deg, #182420 0%, var(--card) 45%);
}

.card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 4px;
}

.card-head.compact {
  margin-bottom: 12px;
}

.card-head.compact h2 {
  margin: 0;
}

.card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.card h2, .tariff h3, .client h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.sub-status {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.sub-status.status-ok {
  color: var(--accent);
}

.sub-status.status-warn {
  color: var(--warn);
}

.sub-status.status-off {
  color: var(--danger);
}

.muted { color: var(--muted); }
.small { font-size: 12px; margin: 0 0 10px; }

.tip + .tip,
.card + .card {
  margin-top: 14px;
}

#tab-home .card + .card {
  margin-top: 14px;
}

.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.steps-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tx-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tx-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  font-size: 13px;
}

.tx-list .tx-amount {
  font-weight: 700;
  white-space: nowrap;
}

.tx-list .tx-amount.plus {
  color: var(--accent);
}

.tx-list .tx-amount.minus {
  color: var(--muted);
}

.tx-list .tx-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.pay-methods-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.pay-methods-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  align-items: start;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
}

.pay-methods-list strong {
  color: var(--text);
  font-weight: 600;
}

.pay-badge {
  grid-row: span 2;
  align-self: start;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.pay-badge--crypto {
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.pay-badge--code {
  color: var(--accent);
  background: rgba(61, 207, 154, 0.12);
  border: 1px solid var(--line-strong);
}

.steps-list li span {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(61, 207, 154, 0.12);
  border-radius: 8px;
  border: 1px solid var(--line-strong);
}

.stack {
  display: grid;
  gap: 12px;
}

.stack-tight {
  gap: 8px;
}

.sub-url-wrap {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.url-label {
  margin: 0;
}

.sub-url-wrap code {
  display: block;
  word-break: break-all;
  background: #0a110e;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 11px;
  line-height: 1.5;
  color: #b8e8d0;
}

.extras-billing-box.suspended {
  border-color: rgba(240, 193, 74, 0.35);
  background: rgba(240, 193, 74, 0.08);
}

.extras-billing-box.suspended #extras-billing-text {
  color: var(--warn);
}

.traffic-box {
  margin: 14px 0 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}

.traffic-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.traffic-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.traffic-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3dcf9a, #229e72);
  transition: width 0.4s ease;
  box-shadow: 0 0 12px rgba(61, 207, 154, 0.4);
}

.traffic-fill.warn {
  background: linear-gradient(90deg, #f0c14a, #d97706);
  box-shadow: 0 0 12px rgba(240, 193, 74, 0.35);
}

.traffic-fill.danger {
  background: linear-gradient(90deg, #ff8a7a, #ff6b6b);
  box-shadow: 0 0 12px rgba(255, 107, 107, 0.35);
}

.alert-inline {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--warn);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(240, 193, 74, 0.1);
  border: 1px solid rgba(240, 193, 74, 0.25);
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(135deg, #45e0a8 0%, #1a9d6e 100%);
  color: #04110c;
  box-shadow: var(--shadow-btn);
}

.btn.primary:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(26, 157, 110, 0.35);
  filter: brightness(1.05);
}

.btn.secondary {
  background: rgba(61, 207, 154, 0.12);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.btn.secondary:hover:not(:disabled) {
  background: rgba(61, 207, 154, 0.18);
  border-color: rgba(61, 207, 154, 0.45);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn.full { width: 100%; }
.btn-lg { padding: 14px 18px; font-size: 15px; }

.btn-stack {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.btn-stack .btn.full {
  margin-top: 0;
}

.btn.full:not(.btn-stack .btn) {
  margin-top: 12px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.small-btn {
  padding: 9px 14px;
  font-size: 12px;
  border-radius: 12px;
}

.btn-icon {
  min-width: 40px;
  padding: 10px;
}

.tariff-meta, .client-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted);
}

.chip.accent {
  color: var(--accent);
  border-color: var(--line-strong);
  background: rgba(61, 207, 154, 0.08);
}

.price {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 14px;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tariff {
  transition: border-color 0.2s, transform 0.2s;
}

.tariff:hover {
  border-color: rgba(61, 207, 154, 0.2);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions .btn.full-span {
  grid-column: 1 / -1;
}

.client-links {
  display: grid;
  gap: 8px;
}

.client-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(61, 207, 154, 0.08);
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.client-links a:hover {
  background: rgba(61, 207, 154, 0.14);
  border-color: var(--line-strong);
}

.client-links a::after {
  content: "↗";
  margin-left: auto;
  opacity: 0.6;
  font-size: 12px;
}

.faq-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s;
}

.faq-item[open] {
  border-color: rgba(61, 207, 154, 0.2);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  padding-right: 24px;
  position: relative;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item .faq-answer {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.tickets-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tickets-toolbar .section-lead {
  margin: 0;
}

.ticket-create {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.ticket-create label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.ticket-create input,
.ticket-create textarea,
.ticket-reply textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

.ticket-create-actions,
.ticket-reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ticket-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.ticket-item:hover {
  border-color: rgba(61, 207, 154, 0.35);
}

.ticket-item-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ticket-item-main strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.ticket-badge--open {
  color: var(--accent);
  border-color: rgba(61, 207, 154, 0.35);
}

.ticket-badge--answered {
  color: #7db7ff;
  border-color: rgba(125, 183, 255, 0.35);
}

.ticket-badge--closed {
  color: var(--muted);
}

.ticket-thread {
  padding: 14px 16px;
  display: grid;
  gap: 12px;
}

.ticket-thread-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ticket-thread-head h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.ticket-messages {
  display: grid;
  gap: 10px;
  max-height: 42vh;
  overflow: auto;
  padding-right: 4px;
}

.ticket-msg {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.ticket-msg--admin {
  border-color: rgba(61, 207, 154, 0.28);
  background: rgba(61, 207, 154, 0.08);
}

.ticket-msg--ai {
  border-color: rgba(125, 183, 255, 0.35);
  background: rgba(125, 183, 255, 0.1);
}

.ticket-msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.ticket-msg-body {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ticket-reply {
  display: grid;
  gap: 10px;
}

.servers-head,
.card-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.server {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

.dot.on {
  background: var(--ok);
  box-shadow: 0 0 12px rgba(61, 207, 154, 0.7);
}

.dot.off { background: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #0f1a16;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 14px;
  max-width: min(90vw, 420px);
  z-index: 100;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden { display: none !important; }

@media (max-width: 420px) {
  h1 { font-size: 20px; }
  .tab { padding: 8px 6px; font-size: 10px; }
  .tab-icon { font-size: 15px; }
  .actions { grid-template-columns: 1fr; }
  .balance-pill { padding: 8px 12px; font-size: 13px; }
}

@media (min-width: 421px) {
  .tab {
    flex-direction: row;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    padding: 11px 10px;
  }
}
