:root {
  color-scheme: dark;
  --bg: #0b141a;
  --bg-2: #0e1a22;
  --surface: #17212b;
  --surface-2: #1e2c38;
  --border: rgba(255,255,255,.08);
  --border-2: rgba(255,255,255,.14);
  --text: #e9edef;
  --muted: #8696a0;
  --accent: #25D366;
  --accent-dark: #1da851;
  --accent-glow: rgba(37,211,102,.18);
  --red: #ff5c5c;
  --red-bg: rgba(255,92,92,.14);
  --orange: #ffb020;
  --orange-bg: rgba(255,176,32,.14);
  --green-bg: rgba(37,211,102,.15);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #123 0%, var(--bg) 45%) fixed, var(--bg);
  color: var(--text);
  font-size: 16.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: none; }
.link-accent { color: var(--accent); }
.link-accent:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.center { text-align: center; }
code { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: .88em; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand.center { justify-content: center; margin-bottom: 8px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow);
}
.brand-name { line-height: 1.05; }
.brand-name b { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: .15s ease; background: var(--surface-2); color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #04140a; }
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 6px 18px var(--accent-glow); }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: rgba(255,92,92,.4); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-lg { padding: 15px 26px; font-size: 17px; }
.btn-block { width: 100%; }
.is-disabled, .btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ---------- Layout (app) ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 270px; flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--border); padding: 24px 18px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 6px 20px; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  display: flex; align-items: center; gap: 13px; padding: 12px 14px;
  border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
  font-size: 15px;
  transition: .12s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--green-bg); color: var(--accent); }
.nav-ic { width: 18px; height: 18px; border-radius: 5px; background: currentColor; opacity: .8;
  -webkit-mask-size: cover; mask-size: cover; }
.ic-grid { -webkit-mask: none; }
.sidebar-foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.plan-chip {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border); padding: 10px 12px; border-radius: var(--radius-sm);
}
.plan-chip-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.plan-chip-name { color: var(--accent); font-weight: 700; }
.user-mini { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #04140a; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-mini-info { overflow: hidden; }
.user-mini-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini-mail { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; padding: 34px 42px; max-width: 1240px; margin: 0 auto; width: 100%; }

/* ---------- Topbar / titles ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; }
.page-title { font-size: 27px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0; font-size: 15px; }
.section-title { font-size: 17px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 15px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-label { color: var(--muted); font-size: 13.5px; text-transform: uppercase; letter-spacing: .05em; }
.cards-row { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-big { font-size: 44px; font-weight: 800; color: var(--accent); line-height: 1; margin: 8px 0 2px; }

/* ---------- Quota / progress ---------- */
.quota-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.quota-count { font-size: 19px; } .quota-count b { color: var(--accent); font-size: 24px; }
.progress { height: 13px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #4ce383); border-radius: 20px; transition: width .4s ease; }
.progress-bar.is-full { background: linear-gradient(90deg, var(--orange), var(--red)); }
.quota-foot { margin-top: 10px; font-size: 13px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 20px; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-bg); color: var(--accent); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }

/* ---------- Sessions grid ---------- */
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.session-card { display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }
.session-top { display: flex; justify-content: space-between; align-items: center; }
.session-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--green-bg);
  position: relative; }
.session-ic::after { content: ""; position: absolute; inset: 10px; border-radius: 50%;
  background: var(--accent); mask: radial-gradient(circle at 50% 45%, transparent 32%, #000 33%); }
.session-label { font-size: 18px; font-weight: 700; margin-top: 4px; }
.session-jid { font-size: 14px; font-family: ui-monospace, monospace; }
.session-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline { display: inline; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 50px 20px; background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--radius); }
.empty-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--green-bg); margin: 0 auto 14px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid transparent; font-size: 14px; }
.alert-success { background: var(--green-bg); color: var(--accent); border-color: rgba(37,211,102,.3); }
.alert-error { background: var(--red-bg); color: #ff9a9a; border-color: rgba(255,92,92,.3); }
.alert-info { background: var(--orange-bg); color: #ffd27a; border-color: rgba(255,176,32,.3); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 15px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.form input, .form select, .form textarea {
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--text); font-size: 15px; width: 100%;
  font-family: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.modal-box .form { padding: 20px; }
.qr-area { padding: 20px; text-align: center; }
.qr-status { color: var(--muted); margin-bottom: 12px; }
.qr-image-wrap { min-height: 240px; display: flex; align-items: center; justify-content: center; }
.qr-image-wrap img { width: 256px; height: 256px; background: #fff; padding: 10px; border-radius: 12px; }
.qr-steps { text-align: left; margin: 18px auto 0; max-width: 300px; font-size: 13px; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tables / code ---------- */
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv th { color: var(--muted); font-weight: 600; width: 130px; white-space: nowrap; }
.table-list th { width: auto; }
.table-list td, .table-list th { font-size: 14px; }
.nowrap { white-space: nowrap; }
.code { background: #0a0f14; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; overflow-x: auto; font-family: ui-monospace, monospace; font-size: 13px; color: #d6e2dc; white-space: pre; }
.code-head { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.method-post { background: var(--green-bg); color: var(--accent); padding: 3px 10px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.method-get { background: rgba(90,160,255,.16); color: #7ab6ff; padding: 3px 10px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.apikey-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.apikey { background: #0a0f14; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; flex: 1; overflow-x: auto; white-space: nowrap; color: var(--accent); }
.logs-table .log-tag { font-family: ui-monospace, monospace; font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.log-ok { background: var(--green-bg); color: var(--accent); }
.log-err { background: var(--red-bg); color: var(--red); }
.log-info { background: var(--surface-2); color: var(--muted); }

/* ---------- Plan management ---------- */
.plan-manage, .plan-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.plan-manage-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.plan-manage-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.pm-name { font-weight: 700; font-size: 17px; }
.pm-price { font-size: 23px; font-weight: 800; color: var(--accent); }
.pm-price span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.pm-sessions { color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
.pm-warn { font-size: 11.5px; }
.plan-manage-card form { width: 100%; }
.billing-toggle-mini { display: inline-flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 18px; }
.billing-toggle-mini button { border: none; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 600; padding: 8px 16px; border-radius: 7px; cursor: pointer; transition: .12s; }
.billing-toggle-mini button.is-active { background: var(--green-bg); color: var(--accent); }

/* ---------- Test send widget ---------- */
.test-send-result { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-family: ui-monospace, monospace; white-space: pre-wrap; word-break: break-word; display: none; }
.test-send-result.is-visible { display: block; }
.test-send-result.ok { background: var(--green-bg); color: var(--accent); border: 1px solid rgba(37,211,102,.3); }
.test-send-result.err { background: var(--red-bg); color: #ff9a9a; border: 1px solid rgba(255,92,92,.3); }
.char-count { text-align: right; font-size: 12px; color: var(--muted); margin-top: -8px; }

/* ---------- Public / landing ---------- */
body.public { background: radial-gradient(900px 500px at 50% -10%, #0f2a1c 0%, var(--bg) 50%) fixed, var(--bg); }
.landing { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.lp-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 0; }
.lp-actions { display: flex; gap: 12px; }
.hero { text-align: center; padding: 74px 0 54px; }
.hero h1 { font-size: 50px; line-height: 1.12; margin: 0 0 20px; }
.hero .accent { color: var(--accent); }
.hero-sub { color: var(--muted); font-size: 19px; max-width: 660px; margin: 0 auto 30px; }
.hero .lp-actions { justify-content: center; }
.pricing { padding: 44px 0 64px; }
.pricing h2 { text-align: center; font-size: 32px; margin-bottom: 8px; }
.billing-toggle { display: flex; align-items: center; justify-content: center; margin: 26px 0 8px; }
.billing-toggle-track {
  position: relative; display: inline-flex; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 999px; padding: 5px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.25);
}
.billing-toggle-thumb {
  position: absolute; top: 5px; left: 5px; height: calc(100% - 10px); width: calc(50% - 5px);
  background: linear-gradient(135deg, var(--accent), #1fbd5a);
  border-radius: 999px; box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform .32s cubic-bezier(.65,0,.35,1);
  z-index: 0;
}
.billing-toggle-track.is-annual .billing-toggle-thumb { transform: translateX(100%); }
.billing-opt {
  position: relative; z-index: 1; flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  border: none; background: transparent; padding: 10px 22px; border-radius: 999px;
  font-size: 14.5px; font-weight: 700; color: var(--muted); cursor: pointer;
  transition: color .28s ease; white-space: nowrap;
}
.billing-toggle-track:not(.is-annual) .billing-opt[data-cycle="monthly"],
.billing-toggle-track.is-annual .billing-opt[data-cycle="annual"] { color: #04140a; }
.billing-save-badge {
  background: rgba(4,20,10,.16); color: inherit; font-size: 11px; font-weight: 800;
  padding: 2px 8px; border-radius: 20px; letter-spacing: .02em;
}
.billing-toggle-track:not(.is-annual) .billing-opt[data-cycle="annual"] .billing-save-badge,
.billing-toggle-track.is-annual .billing-opt[data-cycle="monthly"] .billing-save-badge { background: var(--green-bg); color: var(--accent); }

/* Instant, lively price update feedback */
.price-amount [data-price-value] { display: inline-block; will-change: transform, opacity; }
.price-amount.price-pop [data-price-value] { animation: priceHop .38s cubic-bezier(.34,1.56,.64,1); }
.price-annual-note { transition: opacity .2s ease; }
@keyframes priceHop {
  0%   { transform: translateY(6px) scale(.85); opacity: 0; }
  55%  { transform: translateY(-2px) scale(1.08); opacity: 1; }
  100% { transform: translateY(0) scale(1); }
}
.price-card { transition: transform .2s ease, box-shadow .2s ease; }
.price-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 28px; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 22px; position: relative; display: flex; flex-direction: column; gap: 9px; }
.price-card.featured { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); transform: translateY(-6px); }
.ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #04140a; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px; }
.price-name { font-size: 19px; font-weight: 700; }
.price-amount { font-size: 38px; font-weight: 800; color: var(--accent); }
.price-amount span { font-size: 14px; color: var(--muted); font-weight: 500; }
.price-annual-note { font-size: 12.5px; color: var(--muted); min-height: 1.4em; }
.price-sessions { color: var(--text); font-size: 15px; }
.price-feats { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 9px; }
.price-feats li { color: var(--muted); font-size: 14.5px; padding-left: 24px; position: relative; }
.price-feats li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.price-card .btn { margin-top: auto; }
.lp-footer { text-align: center; padding: 30px 0; border-top: 1px solid var(--border); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-card-wide { max-width: 560px; }
.auth-title { text-align: center; font-size: 26px; margin: 6px 0 20px; }
.auth-alt { text-align: center; color: var(--muted); margin-top: 18px; font-size: 14.5px; }
.auth-alt a { color: var(--accent); }
.hp-field { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; left: -9999px; }
.plan-pick-label { font-size: 14px; color: var(--muted); font-weight: 600; }
.plan-opt input { position: absolute; opacity: 0; }
.plan-opt-box { display: flex; flex-direction: column; gap: 4px; text-align: center; padding: 14px 9px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); cursor: pointer; transition: .12s; }
.plan-opt-box:hover { border-color: var(--muted); }
.plan-opt input:checked + .plan-opt-box { border-color: var(--accent); background: var(--green-bg); box-shadow: 0 0 0 2px var(--accent-glow); }
.plan-opt-name { font-weight: 700; font-size: 15px; }
.plan-opt-price { color: var(--accent); font-size: 14px; }
.plan-opt-sessions { color: var(--muted); font-size: 12.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: .2s; }
  .main { padding: 20px; }
  .cards-row, .price-grid, .plan-manage, .plan-pick { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 32px; }
}
@media (max-width: 560px) {
  .cards-row, .price-grid, .plan-manage, .plan-pick { grid-template-columns: 1fr; }
}
