:root {
  --bg0: #0f1419;
  --bg1: #1a2332;
  --bg2: #243044;
  --line: #334155;
  --text: #e8eef7;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --card: #152033;
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #0f3d3a 0%, transparent 50%),
    var(--bg0);
  color: var(--text);
  min-height: 100vh;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 18px 60px; }
header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  justify-content: space-between; margin-bottom: 22px;
}
.header-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 12px;
  font-size: 0.82rem;
}
.logout-btn:hover { color: var(--text); border-color: var(--danger); }
h1 { margin: 0; font-size: 1.55rem; letter-spacing: 0.02em; }
.sub { color: var(--muted); font-size: 0.92rem; margin-top: 6px; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  padding: 6px 10px; border-radius: 999px; font-size: 0.8rem;
  border: 1px solid var(--line); background: rgba(255,255,255,0.03);
}
.badge.ok { border-color: #065f46; color: var(--accent2); }
.badge.warn { border-color: #854d0e; color: var(--warn); }
.badge.danger { border-color: #7f1d1d; color: var(--danger); }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
}
.panel h2 {
  margin: 0 0 12px; font-size: 1.05rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.panel h2 .step {
  display: inline-flex; width: 22px; height: 22px; border-radius: 50%;
  align-items: center; justify-content: center; font-size: 0.75rem;
  background: var(--bg2); color: var(--accent); border: 1px solid var(--line);
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 8px 0 4px; }
input, textarea, select, button {
  font: inherit; color: var(--text);
}
input, textarea, select {
  width: 100%;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg2);
  border-radius: 8px;
  padding: 9px 14px;
}
button.primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border-color: #0369a1;
}
button.success {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #047857;
}
button.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: #991b1b;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.meta { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 0.92rem; }
.kv b { color: var(--muted); font-weight: 500; }

.gifts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}
.gift {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg1);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.gift:hover { border-color: var(--accent); transform: translateY(-1px); }
.gift.selected { border-color: var(--accent2); box-shadow: 0 0 0 1px rgba(52,211,153,.35); }
.gift img {
  width: 64px; height: 64px; object-fit: contain; display: block; margin: 0 auto 8px;
  background: rgba(0,0,0,.2); border-radius: 8px;
}
.gift .t { font-size: 0.82rem; text-align: center; min-height: 2.4em; }
.gift .p { text-align: center; color: var(--warn); font-weight: 600; margin-top: 4px; }
.gift .tag {
  display: block; text-align: center; margin-top: 4px;
  font-size: 0.72rem; color: var(--danger);
}

.table-wrap { overflow: auto; max-height: 280px; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--card); }
.toast {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.25);
  color: var(--text); font-size: 0.88rem; white-space: pre-wrap;
}
.toast.err { background: rgba(248,113,113,.08); border-color: rgba(248,113,113,.3); }
.preview-box {
  margin-top: 10px; padding: 12px; border-radius: 8px;
  background: rgba(16,185,129,.08); border: 1px dashed rgba(52,211,153,.4);
}
footer { margin-top: 24px; color: var(--muted); font-size: 0.8rem; }

.api-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(56,189,248,.05);
}
.api-box a { color: var(--accent); }

.account-brief {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.98rem;
}
.account-brief .name {
  font-weight: 600;
  color: var(--accent2);
}
.account-brief .hint {
  color: var(--muted);
  font-size: 0.85rem;
}
.account-switch select,
#sendAccountSelect {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  font-size: 0.95rem;
}
.account-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,.15);
}
.account-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.92rem;
  cursor: pointer;
}
.account-checklist input {
  width: auto;
  margin: 0;
}

/* Telegram-like send gift panel */
.tg-send-layout {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 920px) {
  .tg-send-layout { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
}
.tg-modal {
  background: #1c1c1e;
  border-radius: 18px;
  border: 1px solid #2c2c2e;
  padding: 14px 14px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  color: #f2f2f7;
}
.tg-modal-head { text-align: center; margin-bottom: 10px; }
.tg-modal-title { font-size: 1.05rem; font-weight: 600; }
.tg-pill {
  margin: 0 auto 14px;
  max-width: 92%;
  text-align: center;
  background: #2c2c2e;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.86rem;
  line-height: 1.35;
  color: #d1d1d6;
}
.tg-card {
  background: linear-gradient(180deg, #2a2a2c, #1f1f21);
  border-radius: 16px;
  padding: 18px 14px 14px;
  text-align: center;
  margin-bottom: 14px;
}
.tg-gift-img {
  width: 120px; height: 120px; object-fit: contain; display: block; margin: 0 auto 12px;
}
.tg-gift-ph {
  width: 120px; height: 120px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; background: rgba(255,255,255,.04); border-radius: 16px;
}
.tg-from { font-size: 0.92rem; margin-bottom: 8px; }
.tg-from b { font-weight: 600; }
.tg-avatar {
  display: inline-flex; width: 18px; height: 18px; border-radius: 50%;
  align-items: center; justify-content: center; font-size: 0.7rem;
  background: #3a3a3c; vertical-align: middle;
}
.tg-desc { font-size: 0.8rem; color: #8e8e93; line-height: 1.4; margin-bottom: 12px; }
.tg-view-btn {
  width: 100%;
  background: #2c2c2e;
  border: none;
  border-radius: 12px;
  padding: 11px;
  color: #0a84ff;
  font-weight: 600;
  opacity: 0.85;
}
.tg-msg-box { margin-bottom: 12px; }
.tg-msg-label {
  display: block; font-size: 0.78rem; color: #8e8e93; margin-bottom: 6px;
}
.tg-msg-input-wrap {
  position: relative;
  background: #2c2c2e;
  border: 2px solid #0a84ff;
  border-radius: 14px;
  padding: 2px 36px 2px 2px;
}
.tg-msg-input-wrap textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: #f2f2f7;
  padding: 12px 12px;
  border-radius: 12px;
  resize: vertical;
  min-height: 52px;
  box-shadow: none;
}
.tg-msg-input-wrap textarea:focus { outline: none; border: none; }
.tg-emoji {
  position: absolute; right: 10px; top: 12px; opacity: 0.7; pointer-events: none;
}
.tg-msg-meta { text-align: right; color: #8e8e93; font-size: 0.75rem; margin-top: 4px; }
.tg-hide-row {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  margin: 8px 0 14px;
}
.tg-hide-title { font-size: 0.95rem; font-weight: 500; }
.tg-hide-desc { font-size: 0.75rem; color: #8e8e93; line-height: 1.4; margin-top: 4px; max-width: 280px; }
.tg-switch { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.tg-switch input { opacity: 0; width: 0; height: 0; }
.tg-slider {
  position: absolute; cursor: pointer; inset: 0; background: #3a3a3c; border-radius: 999px; transition: .2s;
}
.tg-slider:before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.tg-switch input:checked + .tg-slider { background: #34c759; }
.tg-switch input:checked + .tg-slider:before { transform: translateX(20px); }
.tg-send-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  background: #0a84ff;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}
.tg-send-btn:hover { filter: brightness(1.05); }
.tg-side h3 { margin: 0 0 8px; font-size: 1rem; }
.tg-side {
  background: rgba(255,255,255,.02);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px;
}
