:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #161616;
    --bg-card: #1c1c1c;
    --bg-input: #232323;
    --bg-hover: #2a2a2a;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    --accent: #e8820c;
    --accent-hover: #d4750a;
    --accent-glow: rgba(232, 130, 12, 0.15);
    --accent-border: rgba(232, 130, 12, 0.4);
    --green: #a3c424;
    --green-hover: #8fb01e;
    --green-bg: rgba(163, 196, 36, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --border: #2a2a2a;
    --border-light: #383838;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --sidebar-w: 240px;
    --telegram: #2AABEE;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Screens ──────────────────────────────── */

.screen { display: none; }
.screen.active { display: flex; }

/* ── Auth ─────────────────────────────────── */

#auth-screen {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 0%, rgba(232, 130, 12, 0.06) 0%, transparent 60%),
                var(--bg-primary);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 40px 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 20px;
}

.auth-logo { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; margin-bottom: 12px; }
.auth-logo h1 { font-size: 24px; font-weight: 700; color: var(--accent); }
.auth-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.auth-tabs {
    display: flex; gap: 2px; margin-bottom: 24px;
    background: var(--bg-input); border-radius: var(--radius-sm); padding: 3px;
}
.auth-tab {
    flex: 1; padding: 10px 8px; border: none; background: none;
    color: var(--text-secondary); cursor: pointer; border-radius: 6px;
    font-size: 13px; font-weight: 500; transition: all 0.2s;
    white-space: nowrap;
}
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-tab:hover:not(.active) { color: var(--text-primary); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-divider { text-align: center; margin: 20px 0; position: relative; }
.auth-divider::before { content: ''; position: absolute; left: 0; top: 50%; width: 100%; height: 1px; background: var(--border); }
.auth-divider span { position: relative; background: var(--bg-secondary); padding: 0 16px; color: var(--text-muted); font-size: 13px; }

.otp-input-row {
    display: flex; gap: 8px; align-items: flex-end;
}
.otp-input-row .form-group { flex: 1; margin-bottom: 0; }
.otp-input-row .btn { height: 42px; flex-shrink: 0; }

/* ── Forms ─────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px;
    outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ───────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-green { background: var(--green); color: #111; font-weight: 600; }
.btn-green:hover { background: var(--green-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-light); background: var(--bg-hover); }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-telegram { background: var(--telegram); color: #fff; }
.btn-telegram:hover { opacity: 0.9; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-link-tg {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 12px 16px;
    background: linear-gradient(135deg, #a0642a 0%, #8b5522 100%);
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
    position: relative; overflow: hidden;
}
.btn-link-tg:hover { filter: brightness(1.1); }
.btn-link-tg .arrows {
    font-weight: 700; letter-spacing: 2px;
    animation: arrowPulse 1.5s ease-in-out infinite;
}
@keyframes arrowPulse {
    0%, 100% { opacity: 0.5; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(4px); }
}

/* ── Layout ────────────────────────────────── */

#main-screen { min-height: 100vh; }

.sidebar {
    position: fixed; left: 0; top: 0; width: var(--sidebar-w); height: 100vh;
    background: var(--bg-secondary); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 16px 12px; z-index: 100;
    transition: transform 0.3s;
}
.sidebar-top { padding: 0 4px 16px; }

.sidebar-logo {
    display: none;
}

.nav-list { list-style: none; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    color: var(--text-secondary); text-decoration: none; border-radius: var(--radius-sm);
    font-size: 14px; transition: all 0.15s; border: 1px solid transparent;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active {
    color: var(--accent); background: var(--accent-glow);
    border-color: var(--accent-border);
}

.nav-separator {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); padding: 16px 12px 8px; letter-spacing: 0.5px;
}

.sidebar-footer {
    margin-top: auto; padding-top: 12px;
    border-top: 1px solid var(--border);
}

.content {
	margin-left: var(--sidebar-w);
	padding: 32px;
	min-height: 100vh;
	width: calc(100% - 240px);
}
.mobile-header { display: none; }

/* ── Page Header ──────────────────────────── */

.page-header {
    margin-bottom: 24px;
}
.page-greeting {
    font-size: 28px; font-weight: 700; margin-bottom: 4px;
}
.page-user-id {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--text-secondary); font-size: 14px;
}
.page-user-id .copy-id {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 2px; transition: color 0.2s;
}
.page-user-id .copy-id:hover { color: var(--text-primary); }

/* ── Cards ─────────────────────────────────── */

.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
}
.card-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; }
.card-brand {
    font-size: 13px; color: var(--accent); font-weight: 500;
}

.sub-status-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
}
.sub-status-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.sub-status-value {
    font-size: 22px; font-weight: 700; margin-bottom: 16px;
}
.sub-status-value.active { color: var(--green); }
.sub-status-value.inactive { color: var(--text-muted); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
}
.stat-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* ── Info Box ──────────────────────────────── */

.info-box {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px;
    display: flex; gap: 12px; align-items: flex-start;
    font-size: 14px; color: var(--text-secondary); line-height: 1.6;
}
.info-box .info-icon {
    flex-shrink: 0; width: 22px; height: 22px;
    border-radius: 50%; border: 2px solid var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--text-muted);
    margin-top: 2px;
}

/* ── Tariff Tabs ───────────────────────────── */

.tariff-tabs {
    display: flex; gap: 0; margin-bottom: 24px;
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
}
.tariff-tab {
    flex: 1; padding: 14px 16px; border: none;
    background: var(--bg-card); color: var(--text-secondary);
    cursor: pointer; font-size: 14px; font-weight: 500;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s;
}
.tariff-tab + .tariff-tab { border-left: 1px solid var(--border); }
.tariff-tab.active {
    background: var(--green); color: #111; font-weight: 600;
}
.tariff-tab:hover:not(.active) { background: var(--bg-hover); }
.tariff-tab svg { width: 16px; height: 16px; }

/* ── Status badges ─────────────────────────── */

.badge {
    display: inline-flex; align-items: center; padding: 4px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-cancelled { background: var(--yellow-bg); color: var(--yellow); }
.badge-expired { background: var(--red-bg); color: var(--red); }

/* ── Key display ───────────────────────────── */

.key-block {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; word-break: break-all; font-family: monospace; font-size: 13px;
    color: var(--text-secondary);
}
.key-block .key-text {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-btn {
    flex-shrink: 0; padding: 6px 10px; background: var(--accent); color: #fff;
    border: none; border-radius: 6px; cursor: pointer; font-size: 12px;
    transition: all 0.2s;
}
.copy-btn:hover { background: var(--accent-hover); }
.copy-btn.copied { background: var(--green); color: #111; }

/* ── QR ────────────────────────────────────── */

.qr-container { text-align: center; padding: 20px; }
.qr-container img {
    max-width: 256px; border-radius: var(--radius);
    background: #fff; padding: 12px;
}

/* ── Plans ─────────────────────────────────── */

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.plan-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    transition: border-color 0.2s; position: relative;
}
.plan-card:hover { border-color: var(--accent); }
.plan-card.best-value {
    border-color: var(--green);
}
.plan-card .plan-badge {
    position: absolute; top: -1px; right: 16px;
    background: var(--green); color: #111; font-size: 11px; font-weight: 700;
    padding: 4px 12px; border-radius: 0 0 8px 8px; text-transform: uppercase;
}
.plan-name {
    font-size: 16px; font-weight: 600; margin-bottom: 4px;
    display: flex; align-items: center; gap: 8px;
}
.plan-duration { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.plan-price-row { margin-bottom: 4px; }
.plan-price-label { font-size: 12px; color: var(--text-muted); }
.plan-price {
    font-size: 32px; font-weight: 700; color: var(--accent);
}
.plan-price-old {
    font-size: 16px; color: var(--text-muted);
    text-decoration: line-through; margin-left: 8px;
}

/* ── Table ─────────────────────────────────── */

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    text-align: left; padding: 12px 16px;
    border-bottom: 1px solid var(--border); font-size: 14px;
}
.data-table th {
    color: var(--text-muted); font-weight: 500;
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Referral Points Table ─────────────────── */

.points-table {
    width: 100%; border-collapse: collapse;
}
.points-table td {
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.points-table td:last-child {
    text-align: right; color: var(--accent); font-weight: 600;
}
.points-table tr:hover td { background: var(--bg-hover); }

/* ── FAQ Accordion ─────────────────────────── */

.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.faq-question {
    width: 100%; padding: 16px 20px; border: none; background: none;
    color: var(--text-primary); font-size: 15px; font-weight: 500;
    text-align: left; cursor: pointer; display: flex;
    justify-content: space-between; align-items: center;
    transition: background 0.2s;
}
.faq-question:hover { background: var(--bg-hover); }
.faq-question .faq-chevron {
    font-size: 18px; color: var(--text-muted);
    transition: transform 0.3s;
}
.faq-item.open .faq-chevron { transform: rotate(180deg); }
.faq-answer {
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
    padding: 0 20px;
}
.faq-item.open .faq-answer {
    max-height: 500px; padding: 0 20px 16px;
}
.faq-answer p {
    color: var(--text-secondary); font-size: 14px; line-height: 1.7;
}

/* ── Alerts ────────────────────────────────── */

.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 14px; margin-top: 12px;
}
.alert-error {
    background: var(--red-bg); color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
}
.alert-success {
    background: var(--green-bg); color: var(--green);
    border: 1px solid rgba(163,196,36,0.2);
}
.alert-info {
    background: var(--accent-glow); color: var(--accent);
    border: 1px solid rgba(232,130,12,0.2);
}

/* ── Toast ─────────────────────────────────── */

.logo-icon img {
  max-width: 135px;
}

.logo-icon {
  font-size: 47px;
  margin-bottom: 0;
}

.info-box a {
	color: #a3c424;
}

.container_pay a {
	text-decoration: underline;
	color: #a3c424;
	font-weight: bold;
	cursor: pointer;
}

.container_pay {
  display: flex;
  gap: 15px;
}

.container_pay a {
  color: #fff;
}

.container_pay .btn.btn-green.btn-full {
  color: #111;
  text-decoration: navajowhite;
}

.plan-card.best-value {
}

.plan-card.best-value p {
  text-align: center;
  font-size: 14px;
  line-height: 1.2em;
  margin-top: 15px;
}

.plan-card.best-value p a {
  color: #a3c424;
}

.plan-card {
  max-width: 519px;
}

#toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px;
    animation: slideIn 0.3s ease; min-width: 240px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast-success { background: #1a3d1a; color: #a3c424; border: 1px solid rgba(163,196,36,0.3); }
.toast-error { background: #3d1a1a; color: #fecaca; border: 1px solid rgba(239,68,68,0.3); }
.toast-info { background: #3d2a0a; color: #fbbf24; border: 1px solid rgba(232,130,12,0.3); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ── Loading ───────────────────────────────── */

.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 40px; }

/* ── Settings ──────────────────────────────── */

.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.link-status {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px; font-size: 14px;
}
.link-status .linked { color: var(--green); }
.link-status .not-linked { color: var(--text-muted); }

/* ── Modal ─────────────────────────────────── */

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px;
    max-width: 480px; width: 90%; position: relative;
}
.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; transition: color 0.2s;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal h2 {
    font-size: 20px; font-weight: 700; margin-bottom: 12px;
}
.modal p {
    color: var(--text-secondary); font-size: 14px;
    line-height: 1.6; margin-bottom: 20px;
}
.modal-actions {
    display: flex; gap: 12px;
}
.modal-actions .btn { flex: 1; }

/* ── Referral ──────────────────────────────── */

.referral-link-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px;
    margin-bottom: 16px;
}
.referral-link-box .ref-url {
    flex: 1; font-size: 13px; color: var(--accent);
    word-break: break-all;
}
.referral-balance {
    font-size: 14px; color: var(--accent); font-weight: 600;
}

/* ── Page title ────────────────────────────── */

.page-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; }

/* ── Empty state ───────────────────────────── */

.empty-state {
    text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ── Admin search ──────────────────────────── */

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }

/* ── Responsive ────────────────────────────── */

#sidebar-tg-link::before {
  content: '';
  display: block;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg id='Livello_1' data-name='Livello 1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 240 240'%3e%3cdefs%3e%3clinearGradient id='linear-gradient' x1='120' y1='240' x2='120' gradientUnits='userSpaceOnUse'%3e%3cstop offset='0' stop-color='%231d93d2'/%3e%3cstop offset='1' stop-color='%2338b0e3'/%3e%3c/linearGradient%3e%3c/defs%3e%3ctitle%3eTelegram_logo%3c/title%3e%3ccircle cx='120' cy='120' r='120' fill='url(%23linear-gradient)'/%3e%3cpath d='M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z' fill='%23c8daea'/%3e%3cpath d='M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763' fill='%23a9c6d8'/%3e%3cpath d='M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z' fill='%23fff'/%3e%3c/svg%3e");
  width: 51px;
  height: 30px;
  background-repeat: no-repeat;
}


.btn-link-tg {
  justify-content: flex-start;
  position: relative;
}
.card a {
	color: #e8820c;
} 
.card p {
	text-align: center;
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .content { margin-left: 0; padding: 16px; padding-top: 60px; }
    .mobile-header {
        display: flex; align-items: center; gap: 12px;
        position: fixed; top: 0; left: 0; right: 0; height: 56px;
        background: var(--bg-secondary); border-bottom: 1px solid var(--border);
        padding: 0 16px; z-index: 99;
    }
    .hamburger {
        background: none; border: none; color: var(--text-primary);
        font-size: 24px; cursor: pointer;
    }
    .mobile-title { font-weight: 600; font-size: 16px; color: var(--accent); }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .plans-grid { grid-template-columns: 1fr; }
    .auth-container { padding: 28px 20px; margin: 12px; }
    .tariff-tabs { flex-direction: column; }
    .tariff-tab + .tariff-tab { border-left: none; border-top: 1px solid var(--border); }
    .modal-actions { flex-direction: column; }
	

	.content {
	  width: 100%;
	}

}
@media (max-width: 570px) {
	.container_pay {
		flex-wrap: wrap;
	}
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 99;
}
.sidebar-overlay.active { display: block; }
