:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel2: #0f141c;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #34d399;
  --accent2: #10b981;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #10231c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

section {
  width: 100%;
  max-width: 100%;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0 18px;
}

.logo {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.3px;
}

.logo span {
  color: var(--accent);
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel2);
}

.badge.ok {
  color: var(--accent);
  border-color: #14532d;
  background: #052e1a;
}

.badge.bad {
  color: var(--danger);
  border-color: #7f1d1d;
  background: #2a0f0f;
}

.spacer {
  flex: 1;
}

/* Language Switcher */
.lang-switch {
  display: inline-flex;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 7px;
  transition: 0.15s;
}

.lang-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.lang-btn.active {
  background: var(--accent);
  color: #04120c;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: 0.15s;
}

button:hover {
  border-color: #334155;
  background: #17202b;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  color: #04120c;
  border: none;
}

button.primary:hover {
  filter: brightness(1.08);
}

button.ghost {
  background: transparent;
}

button.danger {
  color: var(--danger);
  border-color: #4c1d1d;
}

button.sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 6px 0 20px;
  flex-wrap: wrap;
}

.tabs button {
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 600;
}

.tabs button.active {
  background: var(--accent);
  color: #04120c;
  border-color: transparent;
}

.card {
  width: 100%;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-h1,
.card-h2 {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  line-height: 1.4;
}

.field {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
}

input[type="text"],
input[type="number"],
select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 0%;
}

/* Remove mobile browser spinner width inflation on number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

select {
  cursor: pointer;
  display: block;
  width: 100%;
  max-width: 100%;
  text-overflow: ellipsis;
}

select.w-full {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  text-overflow: ellipsis;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

/* Use CSS Grid with minmax(0, 1fr) so mobile browsers never let input[type="number"] overflow */
.input-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding-right: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.input-suffix input {
  border: none;
  background: transparent;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  grid-column: 1;
}

.input-suffix button {
  justify-self: end;
  flex-shrink: 0;
}

.input-suffix .suffix {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  justify-self: end;
}

.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.grid2 > div {
  min-width: 0;
  max-width: 100%;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

.kv:last-child {
  border-bottom: none;
}

.kv .k {
  color: var(--muted);
}

.kv .v {
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.kv .v.good {
  color: var(--accent);
}

.kv .v.bad {
  color: var(--danger);
}

.kv .v.warn {
  color: var(--warn);
}

.kv .v.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.warn-banner {
  padding: 10px 12px;
  border-radius: 10px;
  background: #2a2208;
  border: 1px solid #78350f;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
}

.section-divider {
  margin-top: 18px;
  border-top: 1px dashed var(--border);
  padding-top: 16px;
}

.section-subtitle {
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--text);
}

.resolve-box {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.add-token-box {
  background: var(--panel2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.pending-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--panel2);
}

.pending-item .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--warn);
}

.countdown.ready {
  color: var(--accent);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.toast-box {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  max-width: 380px;
}

.toast {
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f1720;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  line-height: 1.5;
  animation: slide 0.2s ease;
}

.toast.error {
  border-color: #7f1d1d;
  background: #1e0d0d;
  color: #fecaca;
}

.toast.success {
  border-color: #14532d;
  background: #082016;
  color: #bbf7d0;
}

.toast.info {
  border-color: #1e3a5f;
  background: #0b1622;
  color: #bfdbfe;
}

@keyframes slide {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.hidden {
  display: none !important;
}

.domain-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--panel2);
  flex-wrap: wrap;
}

.domain-row > div {
  min-width: 0;
  max-width: 100%;
}

.domain-row .name {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  overflow-wrap: anywhere;
  word-break: break-all;
}

.tag {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #0b2a1c;
  color: var(--accent);
  border: 1px solid #14532d;
}

.tag.expired {
  background: #2a0f0f;
  color: var(--danger);
  border-color: #7f1d1d;
}

.tag.grace {
  background: #2a2208;
  color: var(--warn);
  border-color: #78350f;
}

.tag.sub {
  background: #1e3a5f;
  color: #93c5fd;
  border-color: #1e40af;
}

.tag.primary {
  background: #2e1065;
  color: #d8b4fe;
  border-color: #6b21a8;
  font-weight: 700;
}

.token-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--panel2);
  flex-wrap: wrap;
  transition: 0.15s;
  width: 100%;
  max-width: 100%;
}

.token-item > div {
  min-width: 0;
  max-width: 100%;
}

.token-item .mono,
.token-item a {
  overflow-wrap: anywhere;
  word-break: break-all;
}

.token-item.selected {
  border-color: var(--accent);
  background: #0b1f18;
}

.token-item .sym {
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
}

.token-item .bal {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #334155;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}

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

a {
  color: var(--accent);
  cursor: pointer;
}

/* Modal Confirm Dialog (Replaces native confirm()) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.modal-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-all;
}

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

/* Footer */
.site-footer {
  margin-top: 24px;
  padding: 18px 20px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s;
}

.footer-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #0b1f18;
}

.footer-note {
  color: var(--muted);
  font-size: 12px;
}

/* Utility Classes */
.m-0 { margin: 0 !important; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mr-4 { margin-right: 4px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.w-full { width: 100%; }
.w-140 { width: 140px; flex: 0 0 140px; }
.min-w-120 { min-width: 120px; }
.min-w-160 { min-width: 160px; }
.min-w-220 { min-width: 220px; }
.col-span-full { grid-column: 1 / -1; }
.space-between { justify-content: space-between; }
.text-right { text-align: right; }
.hidden-init { display: none; }

@media (max-width: 640px) {
  .wrap {
    padding: 16px 12px 48px;
  }

  .grid2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .card {
    padding: 16px 14px;
  }

  .input-suffix {
    padding-right: 10px;
  }

  .input-suffix button.sm {
    padding: 5px 8px;
    font-size: 12px;
  }

  .token-item {
    align-items: flex-start;
  }

  .token-item .row:last-child {
    width: 100%;
    justify-content: flex-end;
  }
}
