:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0b0c0d;
  color: #f4eee2;
  --bg: #0b0c0d;
  --sidebar: #15181b;
  --panel: #1b1b1b;
  --border: #423726;
  --gold: #e6bc68;
  --gold-strong: #f0c675;
  --muted: #aa9f8b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 74% 0%, #292013 0, transparent 32%), var(--bg); }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 28px;
  background: #111315;
  border-bottom: 1px solid #393023;
  box-shadow: 0 2px 12px #0005;
}
.brand, .top-actions { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 18px; letter-spacing: .02em; }
.brand small { display: block; color: #9b8f7a; font-size: 11px; margin-top: 3px; }
.mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  background: linear-gradient(135deg, #f2ce82, #a87832);
  box-shadow: 0 5px 15px #b98a3833;
  color: #21190d;
  font-size: 14px;
  font-weight: 900;
}
.network {
  color: #efd095;
  background: #2b251b;
  border: 1px solid #6d5632;
  border-radius: 100px;
  padding: 8px 12px;
  white-space: nowrap;
  font: 600 11px ui-monospace, monospace;
}
.network-short { display: none; }
.top-actions button {
  color: #efdbb9;
  background: #24211b;
  border: 1px solid #6b5534;
  border-radius: 8px;
  padding: 8px 12px;
}
.top-actions button:hover { background: #352a1d; }

.shell { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar {
  position: sticky;
  top: 0;
  height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 12px;
  background: var(--sidebar);
  border-right: 1px solid #332a1d;
}
.sidebar button {
  color: #b7ae9f;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 13px 15px;
  text-align: left;
  font-size: 14px;
}
.sidebar button:hover { color: #f7e0b1; background: #29251f; }
.sidebar button.active {
  color: #21180c;
  background: linear-gradient(135deg, #f0c675, #c99a49);
  font-weight: 700;
  box-shadow: 0 5px 14px #0004;
}
main { width: 100%; max-width: 1320px; margin: 0 auto; padding: 34px clamp(24px, 4vw, 58px); }
.view { display: none; }
.view.active { display: block; }
.view > .eyebrow, .view > h1, .view > .lead { text-align: center; }
.view > .lead { max-width: 820px; margin: 0 auto 28px; }
.eyebrow { color: var(--gold); letter-spacing: .16em; font: 700 11px ui-monospace, monospace; }
h1 { color: #f5ead3; font-size: 30px; margin: 7px 0 10px; }
h2 { color: #f0dfbe; font-size: 17px; margin: 0 0 18px; }
.lead { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 22px; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.card, .panel {
  background: linear-gradient(145deg, #1f1e1b, #18191a);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 22px #0003;
}
.card { padding: 22px; }
.card span { display: block; color: #a89b86; font-size: 13px; }
.card strong { display: block; color: var(--gold-strong); font-size: 26px; margin-top: 14px; white-space: nowrap; }
.panel { padding: 24px; margin-bottom: 16px; }
.facts { display: grid; }
.facts div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 13px 0;
  border-top: 1px solid #39332a;
  font-size: 14px;
}
.facts div:first-child { border-top: 0; }
.facts b { min-width: 110px; color: #ddcaa7; font-weight: 600; }
.facts span, .facts code { color: #d1c2a8; text-align: right; overflow-wrap: anywhere; }
.facts code { font: 12px ui-monospace, monospace; }
.wallet-list { max-height: 280px; min-width: 0; flex: 1; overflow: auto; margin: 0; padding: 0 0 0 28px; color: #d1c2a8; font: 12px ui-monospace, monospace; overflow-wrap: anywhere; }
.wallet-list li { padding: 7px 0; }
.wallet-list li + li { border-top: 1px solid #332b21; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid label { display: grid; gap: 8px; min-width: 0; color: #d5c5aa; font-size: 13px; font-weight: 600; }
.form-grid input, .form-grid textarea, .form-grid select {
  width: 100%;
  min-width: 0;
  color: #f7efdf;
  background: #101112;
  border: 1px solid #625039;
  border-radius: 7px;
  font: 14px inherit;
  padding: 10px 12px;
}
.form-grid input, .form-grid select { height: 44px; }
.form-grid textarea { min-height: 88px; resize: vertical; }
.form-grid input::placeholder, .form-grid textarea::placeholder { color: #827765; }
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px #e6bc681d; outline: none; }
.actions { display: flex; flex-wrap: wrap; grid-column: 1 / -1; align-items: center; gap: 9px; margin-top: 5px; }
.actions button, .search-row button, .pager button {
  color: #efce8c;
  background: #2a241b;
  border: 1px solid #7d6035;
  border-radius: 7px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
}
.actions button:hover, .search-row button:hover, .pager button:hover { background: #40301d; border-color: var(--gold); }
.actions button.primary {
  color: #21180c;
  background: linear-gradient(135deg, #f0c675, #c99a49);
  border-color: #d5a959;
  box-shadow: 0 4px 10px #0004;
}
.actions button.primary:hover { filter: brightness(1.08); }
.actions button.danger { color: #e9a9a0; background: #30201f; border-color: #8c4a42; }
.actions button:disabled, .pager button:disabled { opacity: .48; cursor: default; }
.step-number {
  display: inline-grid;
  place-items: center;
  width: 29px;
  height: 29px;
  margin-right: 8px;
  vertical-align: middle;
  color: #eac379;
  background: #3c301f;
  border: 1px solid #775c32;
  border-radius: 7px;
  font: 700 12px ui-monospace, monospace;
}
#vault-panel form { margin-top: 18px; padding-top: 18px; border-top: 1px solid #3a3329; }
#vault-status { color: var(--gold); font-size: 13px; }
.controls p { color: #b9ab94; }

.task-log-table td:nth-child(5), td.round-error { white-space: normal; min-width: 220px; max-width: 560px; overflow-wrap: anywhere; }
.task-parameters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 16px 0 22px; }
.task-parameters div { min-width: 0; padding: 12px 0; border-top: 1px solid #3a3329; }
.task-parameters dt { color: #b9ab94; font-size: 12px; margin-bottom: 6px; }
.task-parameters dd { margin: 0; color: #eedfc4; overflow-wrap: anywhere; font-size: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 900px; border-collapse: collapse; text-align: left; font-size: 12px; }
th { color: #d3b67b; background: #26221b; font-weight: 600; padding: 11px; border-bottom: 1px solid #665035; }
td { color: #dfd4c2; padding: 13px 11px; border-bottom: 1px solid #373126; white-space: nowrap; }
td:last-child { color: #e6bf78; font: 11px ui-monospace, monospace; }
.search-row, .pager { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.search-row input {
  flex: 1;
  max-width: 520px;
  min-width: 0;
  padding: 11px 13px;
  color: #f7efdf;
  background: #101112;
  border: 1px solid #625039;
  border-radius: 7px;
}
.pager { justify-content: flex-end; color: #a99c83; font-size: 12px; }

#message, #auth-message { min-height: 0; margin-bottom: 0; color: #f1d29b; }
#message:not(:empty), #auth-message:not(:empty) { margin-bottom: 20px; padding: 12px 15px; background: #35291b; border: 1px solid #77572d; border-radius: 8px; font-size: 13px; }
.chart-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.chart-head h2 { margin: 0 auto 0 0; }
.chart-head span { color: var(--gold-strong); font: 600 18px ui-monospace, monospace; }
.chart-head label { color: #ada087; font-size: 12px; }
.chart-head select { margin-left: 6px; padding: 7px; color: #f2e5ce; background: #101112; border: 1px solid #625039; border-radius: 7px; }
#price-chart { width: 100%; height: auto; min-height: 200px; margin-top: 15px; background: #121513; border: 1px solid #302d25; border-radius: 8px; }
.chart-hint { color: #9d927e; font-size: 12px; margin: 8px 0 0; }
.readiness-result { margin-top: 16px; }
.readiness-result div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-top: 1px solid #3a3329; font-size: 13px; }
.readiness-result b { color: #dfc9a1; }
.readiness-result span { color: #c0b096; text-align: right; overflow-wrap: anywhere; }

.auth-screen { min-height: calc(100vh - 68px); display: grid; place-items: center; padding: 24px; }
.auth-panel { width: min(540px, 100%); }
@media (max-width: 800px) {
  .topbar { height: 64px; padding: 0 14px; gap: 8px; }
  .brand { min-width: 0; gap: 8px; }
  .brand strong { font-size: 15px; white-space: nowrap; }
  .brand small { display: none; }
  .top-actions { gap: 6px; }
  .top-actions button { white-space: nowrap; padding: 7px 9px; }
  .network { font-size: 10px; padding: 7px 9px; }
  .network #network-long { display: none; }
  .network .network-short { display: inline; }
  .shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid #393023; gap: 5px; }
  .sidebar button { white-space: nowrap; padding: 9px 12px; }
  main { padding: 25px 15px; }
  .view > .eyebrow, .view > h1, .view > .lead { text-align: left; }
  .view > .lead { margin-bottom: 22px; }
  .cards { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .task-parameters { grid-template-columns: 1fr; }
  .facts div { display: block; }
  .facts span, .facts code { display: block; text-align: left; margin-top: 7px; }
  .readiness-result div { display: block; }
  .readiness-result b { display: block; overflow-wrap: anywhere; }
  .readiness-result span { display: block; text-align: left; margin-top: 5px; }
}
