:root {
  --bg: #0b0f14;
  --surface: #111827;
  --surface-weak: rgba(255,255,255,.05);
  --border: rgba(255,255,255,.06);
  --text: #e5e7eb;
  --muted: #a3a3a3;
  --pri: #60a5fa;
  --pri-600: #3b82f6;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --input-bg: #0f172a;
  --input-text: var(--text);
  --input-border: rgba(255,255,255,.10);
  --chip-bg: rgba(255,255,255,.06);
  --grad1: rgba(96,165,250,.08);
  --grad2: rgba(52,211,153,.08);
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,.25);
}

html[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-weak: rgba(0,0,0,.04);
  --border: rgba(0,0,0,.08);
  --text: #0b1220;
  --muted: #6b7280;
  --pri: #2563eb;
  --pri-600: #1d4ed8;
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --input-bg: #ffffff;
  --input-text: #0b1220;
  --input-border: rgba(0,0,0,.12);
  --chip-bg: rgba(0,0,0,.06);
  --grad1: rgba(59,130,246,.18);
  --grad2: rgba(16,185,129,.12);
  --shadow: 0 8px 24px rgba(0,0,0,.08);
}

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 80% -20%, var(--grad1), transparent 60%),
    radial-gradient(1200px 800px at -20% 120%, var(--grad2), transparent 60%),
    var(--bg);
  font: 14px system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--pri) 0%, #8b5cf6 60%, #f472b6 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.logo img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 70%;
  height: 70%;
  object-fit: contain;
  filter: invert(1) brightness(1.15) drop-shadow(0 1px 1px rgba(0,0,0,.25));
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .2px;
}

.env {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-weak);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  box-sizing: border-box;
}

.pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--chip-bg);
}

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.small { font-size: 12px; opacity: .8; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.card h2 { margin: 0 0 6px; font-size: 16px; }
.h3 { margin: 0; font-size: 14px; }
.muted { color: var(--muted); }

.hr {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 10px 0 6px;
  border: 0;
}

.grid-main {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, auto);
}

.grid-main .wide { grid-column: 1 / -1; }

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px;
  align-items: center;
}

.break { word-break: break-all; }

.log {
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  opacity: .95;
}

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

.tx-table th,
.tx-table td {
  padding: 2px 4px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-table th:last-child,
.tx-table td:last-child {
  text-align: right;
}

.tx-table tbody tr:last-child td {
  border-bottom: 0;
}

.footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

select,
input[type="text"],
input[type="password"],
input[type="file"] {
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

input::file-selector-button {
  background: var(--chip-bg);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  margin-right: 10px;
  cursor: pointer;
}

button {
  background: linear-gradient(180deg, var(--pri), var(--pri-600));
  border: 0;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .2px;
  box-shadow: 0 6px 16px color-mix(in oklab, var(--pri) 40%, transparent);
  transition: transform .02s ease, filter .15s ease;
}

button:hover { filter: brightness(1.02); }
button:active { transform: translateY(1px); }

button.ghost {
  background: transparent;
  border: 1px solid var(--input-border);
  color: var(--text);
  box-shadow: none;
}

button:disabled { opacity: .5; cursor: not-allowed; }

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

.row > * { flex: 1; }

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

.ml8 { margin-left: 8px; }
.mt10 { margin-top: 10px; }

@media (max-width: 980px) {
  .grid-main { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .header {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    align-items: start;
  }
  .env {
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
  }
  h1 { font-size: 18px; line-height: 1.2; }
  .row { flex-direction: column; align-items: stretch; }
  .row > * { width: 100%; }
  button { min-height: 44px; }
  select,
  input[type="text"],
  input[type="password"],
  input[type="file"] { min-height: 44px; }
  #createBtn,
  #registerBtn,
  #downloadBtn { width: 100%; }
  #openPassword,
  #openBtn { width: 100%; }
  #amount,
  #sendBtn { width: 100%; }
  #otherWallet,
  #checkBtn { width: 100%; }
  #refreshBalanceBtn {
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    display: inline-block;
  }
  .pill { margin-top: 4px; max-width: 100%; white-space: normal; }
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  min-width: 38px;
  min-height: 38px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-header h2 { margin: 0; }