:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f242d;
  --border: #2a303c;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius: 14px;
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Layout */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand-icon {
  border-radius: 12px;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

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

.topbar-icon {
  border-radius: 7px;
}

.title-text {
  font-weight: 700;
  font-size: 1rem;
  display: block;
}

.domain-badge {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
}

.content {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-top-gap {
  margin-top: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.section-header h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* Inputs */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.field > span {
  color: var(--muted);
  font-weight: 500;
}

input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  flex: 1;
  min-width: 0;
}

.input-suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: none;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

/* Buttons */
.btn {
  min-height: 48px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-sm {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.85rem;
}

.btn-lg {
  min-height: 50px;
}

.btn-xl {
  min-height: 56px;
  font-size: 1.05rem;
}

/* Segmented controls */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--bg);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  gap: 4px;
}

.seg-btn {
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

/* Result & Lists */
.result-card {
  border-color: var(--accent);
  gap: 8px;
  display: flex;
  flex-direction: column;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mono-address {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  word-break: break-all;
  color: var(--text);
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.item-title {
  font-weight: 600;
  word-break: break-all;
}

.item-meta {
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-word;
}

.item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.quota-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: none;
  background: var(--bg);
  appearance: none;
}

.quota-bar::-webkit-progress-bar {
  background: var(--bg);
  border-radius: 999px;
}

.quota-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.quota-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.collapsible-summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 36px;
  display: flex;
  align-items: center;
  list-style: none;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(23, 26, 33, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  min-height: var(--nav-height);
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Toast & Dialog */
.toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  max-width: 90vw;
  text-align: center;
}

.toast.toast-error {
  border-color: var(--danger);
  color: #fecaca;
}

.toast.toast-success {
  border-color: var(--success);
  color: #bbf7d0;
}

.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: min(92vw, 400px);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.dialog h3 {
  margin: 0;
}

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

.muted {
  color: var(--muted);
  margin: 0;
}

.small-label {
  font-size: 0.82rem;
}

.error-text {
  color: #fca5a5;
  margin: 0;
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}
