/* ── Telegram theme variables ── */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #007aff);
  --btn-bg: var(--tg-theme-button-color, #007aff);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-green: #34c759;
  --accent-red: #ff3b30;
  --accent-orange: #ff9500;
  --radius: 12px;
  --gap: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  padding: 12px;
}

#app {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ── Cards ── */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 4px 0;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.label {
  color: var(--hint);
  font-size: 14px;
}

.value {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--hint);
  margin-bottom: 4px;
}

/* ── Badges ── */
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--accent-green);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.expired { background: var(--accent-red); }
.badge.pending { background: var(--accent-orange); }
.badge.cancelled { background: var(--hint); }

.days-badge {
  font-size: 16px;
  font-weight: 700;
}
.days-badge.urgent { color: var(--accent-red); }
.days-badge.ok { color: var(--accent-green); }

.unlimited-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: rgba(52, 199, 89, 0.1);
  border: 1px solid rgba(52, 199, 89, 0.3);
  border-radius: 8px;
  color: var(--accent-green);
  font-weight: 600;
  font-size: 14px;
  margin-top: 4px;
}

.unlimited-icon {
  font-size: 20px;
}

/* ── Progress bar ── */
.progress-wrap {
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--accent-green);
  transition: width 0.4s ease, background 0.3s;
  width: 0%;
}

.progress-bar.critical { background: var(--accent-red); }
.progress-bar.warning  { background: var(--accent-orange); }

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--hint);
  margin-top: 4px;
}

/* ── Cache notice ── */
.cache-notice {
  font-size: 11px;
  color: var(--hint);
  text-align: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  margin-top: 4px;
}

/* ── Config / QR ── */
#qr-container {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

#qr-container canvas {
  border-radius: 8px;
}

.copy-notice {
  text-align: center;
  font-size: 13px;
  color: var(--accent-green);
  font-weight: 600;
  padding: 6px;
}

/* ── Collapsible History ── */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.collapsible-header:active {
  opacity: 0.7;
}

.toggle-icon {
  font-size: 10px;
  color: var(--hint);
  transition: transform 0.3s ease;
  margin-left: 8px;
}

.collapsible-header.expanded .toggle-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
  max-height: 0;
}

.collapsible-content.expanded {
  max-height: 2000px;
}

/* ── History ── */
.history-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.history-item:last-child { border-bottom: none; }

.history-item .plan { 
  font-weight: 600; 
  font-size: 14px;
}

.history-item .dates { 
  font-size: 12px; 
  color: var(--hint);
}

.history-item .status-row { 
  display: flex; 
  align-items: center; 
  gap: 6px;
  font-size: 13px;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:active { 
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-secondary {
  background: transparent;
  color: var(--link);
  border: 1.5px solid var(--link);
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  transition: opacity 0.2s, transform 0.1s, background 0.2s;
}

.btn-secondary:active { 
  opacity: 0.8;
  transform: scale(0.98);
  background: rgba(0, 122, 255, 0.05);
}

.btn-admin {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 12px;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-admin:active {
  opacity: 0.9;
  transform: scale(0.98);
}

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.top-bar .btn-admin {
  width: auto;
  margin-bottom: 0;
  padding: 8px 14px;
  font-size: 13px;
}

.top-bar-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Burger button ── */
.btn-burger {
  background: var(--bg-secondary);
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  margin-left: auto;
  transition: opacity 0.2s;
}
.btn-burger:active { opacity: 0.7; }
.btn-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s;
}

/* ── Side menu overlay ── */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 3000;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

/* ── Side menu drawer ── */
.side-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--bg);
  z-index: 3100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-menu.open { right: 0; }

.side-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
}

.side-menu-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.side-menu-user { flex: 1; min-width: 0; }
.side-menu-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-menu-sub { font-size: 12px; color: var(--hint); margin-top: 2px; }

.side-menu-divider { height: 1px; background: rgba(0,0,0,0.08); margin: 0 16px; }

.side-menu-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 0.15s;
  width: 100%;
}
.menu-item:active { background: var(--bg-secondary); }
.menu-item-icon { font-size: 20px; width: 28px; text-align: center; }

.side-menu-footer {
  padding: 16px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

/* ── Instructions modal ── */
.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.instruction-item {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.instruction-platform {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.instruction-app {
  font-size: 12px;
  color: var(--hint);
  flex: 1;
}

.instruction-link {
  color: var(--link);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn-icon {
  background: var(--bg-secondary);
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-icon:active {
  opacity: 0.7;
  transform: scale(0.95);
}

.btn-icon-danger:hover {
  background: rgba(255, 59, 48, 0.12);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-danger:active { opacity: 0.8; }

/* ── Profile modal ── */
.profile-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-secondary);
}

.profile-label {
  color: var(--hint);
  font-size: 14px;
}

.profile-value {
  font-weight: 500;
  font-size: 14px;
  text-align: right;
  max-width: 60%;
  word-break: break-all;
}


/* ── Speed test ── */
.speedtest-modal-content {
  padding-bottom: 24px;
}

/* Gauge */
.st-gauge-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin: 4px 0 0;
}
.st-gauge-svg {
  width: 200px;
  height: 120px;
}
.st-gauge-track {
  stroke: var(--bg-secondary);
}
.st-gauge-fill {
  stroke: var(--link);
  transition: stroke-dashoffset 0.25s ease, stroke 0.3s ease;
}
.st-gauge-center {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.st-gauge-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  min-width: 80px;
  text-align: center;
}
.st-gauge-unit {
  font-size: 11px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Phase label */
.st-phase {
  text-align: center;
  font-size: 13px;
  color: var(--hint);
  margin: 8px 0 14px;
  min-height: 18px;
  transition: opacity 0.2s;
}

/* Steps */
.st-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.st-step {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px 14px;
  transition: background 0.2s, box-shadow 0.2s;
}
.st-step.active {
  background: color-mix(in srgb, var(--link) 10%, var(--bg-secondary));
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--link) 30%, transparent);
}
.st-step.done {
  background: color-mix(in srgb, var(--accent-green) 8%, var(--bg-secondary));
}
.st-step-icon { font-size: 22px; flex-shrink: 0; }
.st-step-info { flex: 1; }
.st-step-name { font-size: 13px; font-weight: 600; color: var(--text); }
.st-step-val { font-size: 12px; color: var(--hint); margin-top: 2px; }
.st-step-val span { color: var(--link); font-weight: 600; }
.st-step.done .st-step-val span { color: var(--accent-green); }
.st-step-state {
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.3s;
}
.st-step.active .st-step-state { animation: st-spin 1s linear infinite; }
.st-step.done .st-step-state { color: var(--accent-green); }

@keyframes st-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Verdict */
.speed-verdict {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-secondary);
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}

.st-run-btn {
  width: 100%;
  margin-top: 0;
}

/* Gauge color states */
.st-gauge-fill.gauge-green { stroke: var(--accent-green); }
.st-gauge-fill.gauge-orange { stroke: var(--accent-orange); }
.st-gauge-fill.gauge-red { stroke: var(--accent-red); }

.speed-status { display: none; }

/* ── Support chat ── */
.support-chat {
  min-height: 120px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px 0;
}

.support-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.support-msg-user { align-self: flex-end; align-items: flex-end; }
.support-msg-admin { align-self: flex-start; align-items: flex-start; }

.support-msg-text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.support-msg-user .support-msg-text {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-bottom-right-radius: 4px;
}

.support-msg-admin .support-msg-text {
  background: var(--bg-secondary);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* ── AI markdown rendering ── */
.ai-code-block {
  background: rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 6px 0;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
  display: block;
}
.ai-code-inline {
  background: rgba(0,0,0,0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 12.5px;
}
.ai-list {
  margin: 4px 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ai-li-num, .ai-li-dot {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 14px;
  line-height: 1.4;
}
.ai-li-n {
  font-weight: 700;
  color: var(--link);
  flex-shrink: 0;
  min-width: 18px;
}
.ai-li-bullet {
  color: var(--link);
  flex-shrink: 0;
}
.ai-link {
  color: var(--link);
  text-decoration: underline;
  word-break: break-all;
}

.support-msg-time {
  font-size: 11px;
  color: var(--hint);
  margin-top: 3px;
  padding: 0 4px;
}

.support-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.support-textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  transition: border-color 0.2s;
}
.support-textarea:focus { outline: none; border-color: var(--link); }

.support-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.support-send-btn:active { opacity: 0.7; }
.support-sent-notice { text-align: center; padding: 8px; color: var(--accent-green); font-weight: 600; font-size: 13px; }

.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.skeleton-card {
  height: 110px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-secondary) 25%, rgba(0, 0, 0, 0.04) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-card.short { height: 80px; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Error / Empty states ── */
.error-box, .empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 20px;
  text-align: center;
}

.error-icon, .empty-icon { font-size: 52px; }

.error-box p, .empty-box p {
  color: var(--hint);
  font-size: 14px;
  line-height: 1.5;
}

.empty-box h2 { 
  font-size: 20px; 
  font-weight: 600;
}

/* ── Utilities ── */
.hidden { display: none !important; }
.hint { 
  color: var(--hint); 
  font-size: 13px; 
  text-align: center; 
  padding: 12px 0;
}

/* ── Modal ── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-header h2 {
  font-size: 19px;
  font-weight: 600;
}

.close-btn {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--hint);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.close-btn:active { background: rgba(0, 0, 0, 0.12); }

#plans-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-item {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-item h3 {
  font-size: 16px;
  font-weight: 600;
}

.plan-item .plan-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--link);
}

.plan-item .plan-details {
  font-size: 13px;
  color: var(--hint);
}

/* ── VLESS input ── */
.vless-input {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.vless-input::placeholder {
  color: var(--hint);
}

.vless-input:focus {
  outline: none;
  border-color: var(--link);
}

/* ── Responsive ── */
@media (max-width: 360px) {
  body { padding: 10px; }
  .card { padding: 14px; }
  .card-header h2 { font-size: 17px; }
}

/* ── Admin Modal ── */
.admin-modal-content {
  max-width: 500px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.admin-stat-card {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.admin-stat-card:active {
  transform: scale(0.98);
}

.stat-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--hint);
  font-weight: 500;
}

@media (max-width: 360px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-value {
    font-size: 22px;
  }
}


/* ── Admin Panel (Full Screen) ── */
.admin-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: var(--bg);
  z-index: 2000;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.admin-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.admin-header h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.admin-header .back-btn,
.admin-header .refresh-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--link);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.admin-header .back-btn:active,
.admin-header .refresh-btn:active {
  background: rgba(0, 0, 0, 0.05);
}

.admin-content-wrapper {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 16px;
  margin-bottom: 8px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.admin-stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-tab {
  background: transparent;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--hint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.admin-tab.active {
  color: var(--link);
  border-bottom-color: var(--link);
}

.admin-tab:active {
  opacity: 0.7;
}

.admin-tab-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-tab-content.hidden {
  display: none;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--link));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-meta {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}

.admin-user-status {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
}

.admin-user-status.active {
  background: rgba(52, 199, 89, 0.15);
  color: var(--accent-green);
}

.admin-user-status.expired {
  background: rgba(255, 59, 48, 0.15);
  color: var(--accent-red);
}

.admin-user-status.none {
  background: rgba(142, 142, 147, 0.15);
  color: var(--hint);
}

.admin-payment-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-payment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-payment-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-green);
}

.admin-payment-status {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.admin-payment-status.confirmed {
  background: rgba(52, 199, 89, 0.15);
  color: var(--accent-green);
}

.admin-payment-status.pending {
  background: rgba(255, 149, 0, 0.15);
  color: var(--accent-orange);
}

.admin-payment-status.failed {
  background: rgba(255, 59, 48, 0.15);
  color: var(--accent-red);
}

.admin-payment-info {
  font-size: 13px;
  color: var(--text);
}

.admin-payment-meta {
  font-size: 12px;
  color: var(--hint);
}

.admin-server-status {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-server-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.admin-server-metric:last-child {
  border-bottom: none;
}

.admin-metric-label {
  font-size: 14px;
  color: var(--hint);
}

.admin-metric-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.admin-expiring-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 3px solid var(--accent-orange);
}

.admin-expiring-user {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.admin-expiring-date {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}

.admin-expiring-days {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-orange);
}

@media (min-width: 768px) {
  .admin-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 360px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Admin Search & Filters ── */
.admin-search-bar,
.admin-filter-bar {
  margin-bottom: 16px;
}

.admin-search-input,
.admin-filter-select,
.admin-input,
.admin-select {
  width: 100%;
  padding: 12px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.admin-search-input:focus,
.admin-filter-select:focus,
.admin-input:focus,
.admin-select:focus {
  outline: none;
  border-color: var(--link);
}

.admin-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
}

.admin-textarea:focus {
  outline: none;
  border-color: var(--link);
}

/* ── Admin Pagination ── */
.admin-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.admin-pagination .btn-secondary {
  flex: 1;
  margin-top: 0;
}

.page-info {
  font-size: 13px;
  color: var(--hint);
  white-space: nowrap;
}

/* ── Admin Action Cards ── */
.admin-action-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.action-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.action-icon {
  font-size: 24px;
}

.action-header h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.action-description {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 12px;
}

/* ── Analytics Cards ── */
.admin-analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.analytics-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.analytics-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.analytics-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--link);
  margin-bottom: 4px;
}

.analytics-label {
  font-size: 11px;
  color: var(--hint);
}

/* ── Modal Actions ── */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  margin-top: 0;
}

/* ── Activity Chart ── */
.activity-item {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-date {
  font-size: 13px;
  font-weight: 600;
}

.activity-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--link);
}

@media (max-width: 360px) {
  .admin-analytics-grid {
    grid-template-columns: 1fr;
  }
  
  .analytics-value {
    font-size: 24px;
  }
}

/* ── Grant user search dropdown ── */
.grant-user-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}
.grant-user-option {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.grant-user-option:last-child { border-bottom: none; }
.grant-user-option:hover { background: var(--bg-secondary); }
.grant-user-selected {
  font-size: 13px;
  color: var(--accent-green);
  padding: 4px 0 8px;
  font-weight: 500;
}

/* ── User action modal ── */
.user-action-info {
  margin-bottom: 16px;
}
.user-action-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-action-btns .btn-primary,
.user-action-btns .btn-secondary,
.user-action-btns .btn-danger {
  width: 100%;
}

/* ── Admin user card clickable ── */
.admin-user-card {
  transition: background 0.15s;
}
.admin-user-card:hover {
  background: color-mix(in srgb, var(--link) 8%, var(--bg-secondary));
}
