:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fc;
  --ink: #10131f;
  --muted: #73798a;
  --line: #dfe4f3;
  --panel: #ffffff;
  --panel-soft: #eef2ff;
  --accent: #6f4de3;
  --accent-2: #2f3f73;
  --danger: #c84f4f;
  --shadow: 0 22px 60px rgba(64, 76, 130, 0.12);
  --topbar-bg: rgba(255, 255, 255, 0.96);
  --topbar-border: #eef1fb;
  --table-head-bg: #eaf0ff;
  --table-row-bg: rgba(255, 255, 255, 0.55);
  --badge-pending-bg: #fff0bb;
  --badge-pending-color: #6b4f00;
  --badge-processing-bg: #e4e8ff;
  --badge-processing-color: #3343a4;
  --badge-completed-bg: #eee9ff;
  --badge-completed-color: #4f34c7;
  --badge-failed-bg: #f7dddd;
  --badge-failed-color: #a33939;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1118;
  --ink: #e8eaf0;
  --muted: #8b90a0;
  --line: #2a2d3a;
  --panel: #1a1c28;
  --panel-soft: #22243a;
  --accent: #9b7df5;
  --accent-2: #7b8fcc;
  --danger: #e06666;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
  --topbar-bg: rgba(20, 22, 32, 0.96);
  --topbar-border: #2a2d3a;
  --table-head-bg: #1e2035;
  --table-row-bg: rgba(26, 28, 40, 0.7);
  --badge-pending-bg: #3d3520;
  --badge-pending-color: #f0d060;
  --badge-processing-bg: #252848;
  --badge-processing-color: #8b9aff;
  --badge-completed-bg: #2a2448;
  --badge-completed-color: #b49fff;
  --badge-failed-bg: #3d2020;
  --badge-failed-color: #ff8a8a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #c8d0ee;
  box-shadow: 0 10px 26px rgba(81, 70, 202, 0.12);
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  padding: 15px 17px;
  outline: none;
  font-weight: 700;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(111, 77, 227, 0.13);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 96px;
  padding: 0 clamp(28px, 6vw, 90px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 23px;
  font-weight: 950;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #7355e7, #5167e8);
  color: #fff;
  box-shadow: 0 14px 30px rgba(111, 77, 227, 0.28);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.toggle-btn:hover {
  border-color: var(--accent);
  transform: none;
  box-shadow: none;
}

[data-theme="light"] .theme-icon-dark,
:root .theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-icon-dark {
  display: inline;
}

main {
  padding: clamp(44px, 7vw, 96px) clamp(22px, 6vw, 96px);
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.hero-copy h1 {
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.98;
  max-width: 820px;
}

.subcopy {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
  max-width: 560px;
}

.login-card,
.dashboard {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.form-tip {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.form-tip.success {
  color: var(--accent);
}

.form-tip.error {
  color: var(--danger);
}

/* Step 1: Verify Code */
.step-verify {
  display: grid;
  place-items: center;
  min-height: calc(100svh - 200px);
}

.verify-center {
  width: min(520px, 100%);
  text-align: center;
}

.verify-icon {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 28px;
  border-radius: 24px;
  background: linear-gradient(135deg, #7355e7, #5167e8);
  color: #fff;
  box-shadow: 0 18px 40px rgba(111, 77, 227, 0.25);
}

.verify-title {
  font-size: clamp(36px, 5vw, 52px);
  line-height: 1.1;
  margin: 0 0 12px;
}

.verify-desc {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  margin: 0 0 32px;
}

.verify-form {
  display: grid;
  gap: 14px;
}

.verify-input {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 18px 20px;
}

.verify-btn {
  font-size: 17px;
  padding: 16px 28px;
}

.verify-query {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.verify-query p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
}

.query-inline {
  display: flex;
  gap: 10px;
}

.query-inline input {
  flex: 1;
}

/* Step 2: Redeem Layout */
.step-redeem {
  max-width: 1200px;
  margin: 0 auto;
}

.redeem-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}

.guide-sidebar {
  position: sticky;
  top: 120px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--panel-soft) 0%, var(--panel) 100%);
  padding: 28px 24px;
  box-shadow: 0 14px 34px rgba(64, 76, 130, 0.06);
}

.guide-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 900;
}

.guide-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.guide-steps {
  display: grid;
  gap: 20px;
}

.guide-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.guide-num {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
}

.guide-num.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(111, 77, 227, 0.3);
}

.guide-step strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 3px;
}

.guide-step p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.guide-link {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.guide-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(111, 77, 227, 0.3);
}

.session-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-help {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.session-help:hover {
  text-decoration: underline;
}

.session-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.copy-session-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
}

.session-parsed {
  border: 1px solid rgba(111, 77, 227, 0.15);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--panel-soft) 0%, var(--panel-soft) 100%);
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.session-parsed-item {
  display: grid;
  gap: 4px;
}

.session-parsed-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.session-parsed-item strong {
  font-size: 15px;
  color: var(--accent);
  word-break: break-all;
}

.redeem-main {
  min-width: 0;
}

.redeem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.redeem-header h2 {
  font-size: clamp(24px, 3vw, 34px);
  margin: 0;
}

.back-btn {
  font-size: 14px;
  padding: 10px 18px;
  color: var(--accent);
  border-color: var(--accent);
  background: #fff;
}

.back-btn:hover {
  background: var(--accent);
  color: #fff;
}

.product-banner {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, var(--panel-soft) 0%, var(--panel-soft) 100%);
  padding: 28px;
  margin-bottom: 28px;
}

.product-name {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 900;
  color: var(--ink);
}

.redeem-form {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  padding: clamp(22px, 4vw, 34px);
  box-shadow: var(--shadow);
}

.redeem-actions {
  display: grid;
  grid-template-columns: minmax(180px, 0.36fr) 1fr;
  gap: 14px;
}

.redeem-actions button {
  min-height: 54px;
}

.redeem-actions button:not(.primary) {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: none;
}

.redeem-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.redeem-result {
  margin-top: 18px;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 18px;
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 16px 36px rgba(64, 76, 130, 0.12);
}

.redeem-result h3 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 900;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 16px;
}

.result-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.result-item strong {
  font-size: 15px;
  word-break: break-all;
}

.result-item strong.completed {
  color: var(--accent);
}

.result-item strong.pending {
  color: #6b4f00;
}

.result-item strong.processing {
  color: #3343a4;
}

.result-item strong.failed {
  color: var(--danger);
}

.query-section {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 520px);
  gap: 18px;
  align-items: end;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.query-form,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.query-form input,
.inline-form input {
  min-width: 180px;
  flex: 1;
}

.result-box {
  grid-column: 1 / -1;
}

.status-line,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 16px;
}

.workspace {
  display: block;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

.login-card {
  max-width: 480px;
  padding: 38px;
  margin: 80px auto;
}

.login-card p {
  color: var(--muted);
  line-height: 1.6;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.dashboard {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hidden {
  display: none;
}

.trpay-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 19, 31, 0.42);
  backdrop-filter: blur(8px);
}

.trpay-modal-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(16, 19, 31, 0.28);
  padding: 28px;
}

.trpay-modal-card h3 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 900;
}

.trpay-modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.trpay-modal-card input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 0 16px;
  font-size: 18px;
  font-weight: 800;
  outline: none;
}

.trpay-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.trpay-success-card {
  text-align: center;
}

.trpay-success-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #24c277;
  color: #fff;
  font-size: 46px;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(36, 194, 119, 0.3);
}

.trpay-success-detail {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  padding: 14px;
  text-align: left;
}

.trpay-success-detail span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.trpay-success-detail strong {
  word-break: break-all;
}

.trpay-success-card .trpay-modal-actions {
  justify-content: center;
}

.trpay-confetti {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  pointer-events: none;
}

.trpay-confetti i {
  position: absolute;
  top: -30px;
  width: var(--w);
  height: var(--h);
  border-radius: 3px;
  background: var(--color);
  opacity: 0.95;
  transform: rotate(var(--rotate));
  animation: trpay-confetti-fall var(--duration) ease-in var(--delay) forwards;
}

@keyframes trpay-confetti-fall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(var(--rotate));
  }
  100% {
    transform: translate3d(calc((50vw - 50%) * 0.35), 110vh, 0) rotate(calc(var(--rotate) + 720deg));
  }
}

@media (max-width: 560px) {
  .trpay-modal-card {
    padding: 22px;
  }

  .trpay-modal-actions {
    flex-direction: column-reverse;
  }

  .trpay-modal-actions button {
    width: 100%;
  }
}

.dash-head,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.dash-head {
  margin-bottom: 42px;
}

.dash-actions {
  display: flex;
  gap: 10px;
}

.dash-head h1 {
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.08;
}

.table-head h2,
.dashboard > h2 {
  font-size: clamp(28px, 3vw, 42px);
  white-space: nowrap;
}

.table-head select {
  max-width: 360px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 18px;
  margin-bottom: 40px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  padding: 22px 24px;
  box-shadow: 0 14px 34px rgba(64, 76, 130, 0.08);
}

.metric-link {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.metric-link:hover {
  border-color: var(--accent);
  box-shadow: 0 14px 34px rgba(111, 77, 227, 0.15);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}

.metrics strong {
  font-size: 42px;
  line-height: 1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  margin-bottom: 54px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  background: transparent;
}

th,
td {
  text-align: left;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
  background: var(--table-head-bg);
  white-space: nowrap;
}

td {
  font-size: 16px;
  background: var(--table-row-bg);
  word-break: break-word;
}

tr:last-child td {
  border-bottom: 0;
}

.code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  background: var(--panel-soft);
}

.badge.pending,
.badge.unused {
  color: var(--badge-pending-color);
  background: var(--badge-pending-bg);
}

.badge.processing {
  color: var(--badge-processing-color);
  background: var(--badge-processing-bg);
}

.badge.completed,
.badge.used {
  color: var(--badge-completed-color);
  background: var(--badge-completed-bg);
}

.badge.failed,
.badge.disabled {
  color: var(--badge-failed-color);
  background: var(--badge-failed-bg);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 132px;
}

.actions button {
  padding: 8px 12px;
  font-size: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 36px;
  align-items: start;
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.log-item strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.tracker-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(18, 22, 39, 0.46);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.18s ease-out;
}

.tracker-panel {
  width: min(520px, 100%);
  border: 1px solid rgba(223, 228, 243, 0.9);
  border-radius: 28px;
  background: var(--panel);
  padding: 34px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(31, 37, 74, 0.25);
  animation: riseIn 0.22s ease-out;
}

.tracker-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 22px;
}

.pulse-ring {
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  background: rgba(111, 77, 227, 0.12);
  animation: pulse 1.55s ease-in-out infinite;
}

.spinner {
  width: 58px;
  height: 58px;
  border: 7px solid #ece8ff;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.tracker-overlay[data-status="completed"] .spinner,
.tracker-overlay[data-status="failed"] .spinner {
  animation: none;
  border-color: var(--accent);
}

.tracker-overlay[data-status="failed"] .spinner {
  border-color: var(--danger);
}

.tracker-panel h2 {
  font-size: 36px;
  line-height: 1.1;
  margin-bottom: 12px;
}

.tracker-copy {
  margin: 0 auto 24px;
  color: var(--muted);
  line-height: 1.7;
}

.tracker-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.tracker-steps::before,
.tracker-steps::after {
  content: "";
  position: absolute;
  left: 13%;
  right: 13%;
  top: 50%;
  height: 10px;
  border-radius: 999px;
  transform: translateY(-50%);
}

.tracker-steps::before {
  background: #ece8ff;
}

.tracker-steps::after {
  width: 18%;
  right: auto;
  background: linear-gradient(90deg, #7355e7, #8d72ff, #5167e8, #7355e7);
  background-size: 220% 100%;
  box-shadow: 0 0 22px rgba(111, 77, 227, 0.38);
  animation: pipeFlow 1.2s linear infinite;
  transition: width 0.28s ease;
}

.tracker-overlay[data-status="processing"] .tracker-steps::after {
  width: 48%;
}

.tracker-overlay[data-status="completed"] .tracker-steps::after {
  width: 74%;
}

.tracker-overlay[data-status="failed"] .tracker-steps::after {
  width: 74%;
  background: linear-gradient(90deg, #c84f4f, #f08a8a, #c84f4f);
}

.tracker-steps span {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  background: var(--bg);
}

.tracker-steps span.active {
  border-color: rgba(111, 77, 227, 0.2);
  color: #fff;
  background: var(--accent);
}

.tracker-info {
  display: grid;
  gap: 7px;
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 16px;
  margin-bottom: 22px;
  text-align: left;
}

.tracker-info span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.tracker-actions {
  display: flex;
  justify-content: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.65;
    transform: scale(0.88);
  }

  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@keyframes pipeFlow {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 220% 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.pwd-form {
  display: grid;
  gap: 14px;
}

.generated-codes-list {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.generated-code-item {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  user-select: all;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.admin-tab {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.admin-tab:hover {
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-tab-panel {
  min-height: 200px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 40px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 40px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.page-btn.page-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-dots {
  padding: 0 4px;
  color: var(--muted);
  font-weight: 700;
}

.page-info {
  margin-left: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.admin-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(31, 37, 74, 0.18);
  font-size: 15px;
  font-weight: 700;
  animation: toastIn 0.3s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.admin-toast.toast-success {
  border-color: rgba(24, 180, 157, 0.42);
  box-shadow: 0 20px 50px rgba(24, 180, 157, 0.18);
}

.admin-toast.toast-hide {
  opacity: 0;
  transform: translateX(20px);
}

.toast-icon {
  font-size: 22px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Confetti & Success Celebration */
.canvas-shell {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

#confetti {
  width: 100%;
  height: 100%;
  display: block;
}

.success-layer {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(56px, 12vh, 120px) 24px 24px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 260ms ease, visibility 260ms ease;
  z-index: 201;
}

.success-layer.is-visible {
  opacity: 1;
  visibility: visible;
}

.success-layer.is-visible .success-card {
  animation: successCardIn 900ms cubic-bezier(0.2, 0.9, 0.18, 1.15) both;
}

.success-card {
  position: relative;
  padding: 0 clamp(80px, 14vw, 200px);
  text-align: center;
  opacity: 0;
  transform: translateY(22px) scale(0.88);
}

.success-card h2 {
  margin: 0;
  font-size: clamp(44px, 9vw, 100px);
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: #fff;
  text-shadow: 0 0 18px rgba(111, 77, 227, 0.4), 0 0 54px rgba(111, 77, 227, 0.2), 0 18px 48px rgba(0, 0, 0, 0.3);
}

.party-horn {
  position: absolute;
  top: 50%;
  width: clamp(100px, 10vw, 148px);
  height: clamp(40px, 4vw, 58px);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255,255,255,0.16) 20%, transparent 20%),
    linear-gradient(90deg, #fff 0 22%, #d4b4ff 22% 42%, #a78bfa 42% 68%, #7355e7 68% 100%);
  clip-path: polygon(0 50%, 18% 18%, 84% 6%, 100% 50%, 84% 94%, 18% 82%);
  box-shadow: 0 0 24px rgba(111, 77, 227, 0.24), 0 12px 32px rgba(0, 0, 0, 0.2);
}

.party-horn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.96), rgba(255,255,255,0.2) 46%, transparent 48%),
    linear-gradient(135deg, #fff, #a78bfa);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 0 16px rgba(111, 77, 227, 0.24);
}

.party-horn::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transform: translateY(-50%);
  border: 4px solid rgba(255,255,255,0.56);
  box-sizing: border-box;
}

.party-horn-left {
  left: 0;
  transform: translate(-78%, -50%) scaleX(-1) rotate(14deg);
}

.party-horn-right {
  right: 0;
  transform: translate(78%, -50%) rotate(-14deg);
}

.success-streamers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.streamer {
  position: absolute;
  height: clamp(10px, 1.2vw, 16px);
  border-radius: 999px;
  opacity: 0;
  transform-origin: center;
  box-shadow: 0 0 24px rgba(111, 77, 227, 0.18), 0 8px 20px rgba(0, 0, 0, 0.16);
}

.success-layer.is-visible .streamer {
  animation: streamerSweep 960ms cubic-bezier(0.2, 0.9, 0.18, 1.15) both;
}

.streamer-1 { top: 18%; left: -6%; width: 34vw; background: linear-gradient(90deg, #fff, #d4b4ff 45%, #a78bfa); transform: rotate(20deg) scaleX(0.2); animation-delay: 30ms; }
.streamer-2 { top: 28%; left: -2%; width: 28vw; background: linear-gradient(90deg, #c4b5fd, #7355e7); transform: rotate(34deg) scaleX(0.2); animation-delay: 110ms; }
.streamer-3 { top: 38%; left: 4%; width: 24vw; background: linear-gradient(90deg, #fff, #a78bfa); transform: rotate(52deg) scaleX(0.2); animation-delay: 180ms; }
.streamer-4 { top: 20%; right: -6%; width: 34vw; background: linear-gradient(90deg, #a78bfa, #d4b4ff, #fff); transform: rotate(-20deg) scaleX(0.2); animation-delay: 50ms; }
.streamer-5 { top: 30%; right: -2%; width: 28vw; background: linear-gradient(90deg, #7355e7, #c4b5fd); transform: rotate(-34deg) scaleX(0.2); animation-delay: 130ms; }
.streamer-6 { top: 40%; right: 4%; width: 24vw; background: linear-gradient(90deg, #a78bfa, #fff); transform: rotate(-52deg) scaleX(0.2); animation-delay: 210ms; }
.streamer-7 { top: 10%; left: 26%; width: 18vw; background: linear-gradient(90deg, #d4b4ff, #a78bfa); transform: rotate(74deg) scaleX(0.2); animation-delay: 260ms; }
.streamer-8 { top: 10%; right: 26%; width: 18vw; background: linear-gradient(90deg, #a78bfa, #d4b4ff); transform: rotate(-74deg) scaleX(0.2); animation-delay: 300ms; }

@keyframes successCardIn {
  0% { opacity: 0; transform: translateY(22px) scale(0.88); }
  55% { opacity: 1; transform: translateY(-10px) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes streamerSweep {
  0% { opacity: 0; filter: blur(10px); }
  35% { opacity: 1; filter: blur(0); }
  100% { opacity: 0.92; filter: blur(0); }
}

@media (max-width: 640px) {
  .success-card {
    padding: 0 40px;
  }
  .party-horn { width: 80px; height: 32px; }
  .party-horn-left { transform: translate(-58%, -110%) scaleX(-1) rotate(14deg); }
  .party-horn-right { transform: translate(58%, -110%) rotate(-14deg); }
}

@media (max-width: 980px) {
  .redeem-layout,
  .workspace,
  .query-section,
  .split {
    grid-template-columns: 1fr;
  }

  .guide-sidebar {
    position: static;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding: 20px 14px 40px;
  }

  .hero-copy h1 {
    font-size: 38px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .dash-head,
  .table-head,
  .query-form,
  .inline-form,
  .redeem-actions {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }
}

/* Telegram config */
.tg-desc {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.tg-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
}

.tg-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tg-form label span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.tg-form input,
.tg-form textarea {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--panel);
  color: var(--ink);
}

.tg-chat-table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.tg-chat-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.tg-chat-table thead {
  background: var(--table-head-bg);
}

.tg-chat-table th {
  padding: 10px 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: left;
}

.tg-chat-table th:nth-child(1) {
  width: 40%;
}

.tg-chat-table th:nth-child(2) {
  width: 26%;
}

.tg-chat-table th:nth-child(3) {
  width: 24%;
}

.tg-chat-table th:nth-child(4) {
  width: 10%;
}

.tg-chat-table td {
  padding: 14px 18px;
  vertical-align: middle;
  border-top: 1px solid var(--line);
}

.tg-chat-table tbody tr:first-child td {
  border-top: 0;
}

.tg-chat-table tbody tr {
  background: var(--panel);
}

.chat-id-cell {
  min-width: 0;
}

.chat-id-cell span,
.chat-quota-field span {
  display: none;
}

.chat-id-cell strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-form .chat-quota-field {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
}

.tg-form .chat-quota-field input {
  width: 104px;
  min-width: 88px;
  height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.92rem;
  text-align: center;
}

.tg-form .dispatch-switch {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.tg-form .dispatch-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  opacity: 0;
  pointer-events: none;
}

.dispatch-slider {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #c8cedd;
  transition: background 0.16s ease;
}

.dispatch-slider::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(16, 19, 31, 0.2);
  transition: transform 0.16s ease;
}

.dispatch-switch input:checked + .dispatch-slider {
  background: #18b49d;
}

.dispatch-switch input:checked + .dispatch-slider::after {
  transform: translateX(26px);
}

.dispatch-switch input:focus-visible + .dispatch-slider {
  box-shadow: 0 0 0 4px rgba(24, 180, 157, 0.2);
}

.dispatch-text {
  min-width: 34px;
  color: #11866f;
  font-size: 0.84rem;
  font-weight: 850;
}

.dispatch-switch input:not(:checked) ~ .dispatch-text {
  color: var(--muted);
}

.chat-remove-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
}

.chat-remove-btn:hover {
  background: var(--panel-soft);
  color: var(--danger);
  box-shadow: none;
  transform: none;
}

.tg-empty {
  padding: 22px 18px !important;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.bot-command-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 16px;
}

.bot-command-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bot-command-head h3 {
  margin: 0;
  font-size: 0.98rem;
}

.bot-command-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.bot-command-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.bot-command-grid code {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 850;
}

.bot-stats-list {
  display: grid;
  gap: 10px;
}

.bot-stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--table-row-bg);
}

.bot-stat-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.bot-stat-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-stat-title span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 850;
}

.bot-stat-title .is-on {
  background: rgba(24, 180, 157, 0.16);
  color: #11866f;
}

.bot-stat-title .is-off {
  background: rgba(115, 121, 138, 0.16);
  color: var(--muted);
}

.bot-stat-card dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
  margin: 0;
}

.bot-stat-card dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.bot-stat-card dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.bot-stat-empty {
  color: var(--muted);
  font-weight: 800;
}

.tg-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.detect-btn {
  font-size: 0.75rem;
  padding: 2px 8px;
  margin-left: 8px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.detect-btn:hover {
  background: var(--accent);
  color: #fff;
}

.chat-detect-result {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.chat-pick-btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.85rem;
}

.chat-pick-btn:hover {
  border-color: var(--accent);
  background: var(--panel-soft);
}

@media (max-width: 620px) {
  .tg-form {
    max-width: none;
  }

  .tg-chat-table,
  .tg-chat-table tbody,
  .tg-chat-table tr,
  .tg-chat-table td {
    display: block;
    width: 100%;
  }

  .tg-chat-table thead {
    display: none;
  }

  .tg-chat-table tr {
    position: relative;
    padding: 14px;
    border-top: 1px solid var(--line);
  }

  .tg-chat-table tbody tr:first-child {
    border-top: 0;
  }

  .tg-chat-table td {
    padding: 6px 0;
    border-top: 0;
  }

  .chat-id-cell span,
  .chat-quota-field span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
  }

  .tg-form .chat-quota-field input {
    width: 140px;
    text-align: left;
  }

  .chat-remove-btn {
    position: absolute;
    top: 12px;
    right: 12px;
  }
}
