@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #141714;
  --panel: #1b201c;
  --inset: #161a16;
  --line: #363e34;
  --line-soft: #2c342c;
  --ink: #f1f3e9;
  --muted: #aeb7a8;
  --accent: #d3ee91;
  --accent-hover: #e2f7ae;
  --warning: #ffd0a9;
  --body-font: "Instrument Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono-font: "IBM Plex Mono", "PingFang SC", monospace;
  font-family: var(--body-font);
  background: var(--background);
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
  background: radial-gradient(ellipse 760px 440px at 12% -32px, #202820, transparent);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, p, dl, dd { margin: 0; }

.shell { width: min(100% - 64px, 1120px); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--line-soft); }
.topbar-inner { min-height: 69px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -0.04em; white-space: nowrap; }
.brand-label { margin-inline-start: 3px; color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: 0; }
.brand-mark { width: 27px; height: 27px; border: 1px solid #596a46; border-radius: 7px; background: #293421; display: grid; place-items: center; }
.brand-mark::after { content: ""; width: 11px; height: 11px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: translateY(-3px) rotate(45deg); }
.external-link { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.external-link:hover, .external-link:focus-visible { color: var(--accent); }
.external-link span { color: var(--accent); }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-block: 46px 26px; }
h1 { font-size: clamp(30px, 4.2vw, 46px); font-weight: 700; letter-spacing: -0.05em; line-height: 1.18; }
.page-heading p { color: var(--muted); font-size: 14px; line-height: 1.7; margin-top: 9px; }
.connection-badge {
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}
.status-dot { background: #818b7d; inline-size: 6px; block-size: 6px; border-radius: 50%; }
.connection-badge[data-state="live"] { color: var(--accent); border-color: #536642; background: #232d21; }
.connection-badge[data-state="live"] .status-dot { background: var(--accent); }
.connection-badge[data-state="warning"] { color: var(--warning); }
.connection-badge[data-state="warning"] .status-dot { background: var(--warning); }

.top-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 20px; }
.panel { min-width: 0; border-radius: 15px; border: 1px solid var(--line); background: var(--panel); }
.balance-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 285px;
  overflow: hidden;
  border-color: #45533e;
  background:
    linear-gradient(100deg, transparent 60%, #26332366),
    repeating-linear-gradient(128deg, transparent 0 24px, #d3ee910a 25px 26px),
    #202920;
}
.balance-main { padding: 26px 26px 17px; }
.balance-main h2 { color: #d5dfce; font-size: 14px; font-weight: 500; }
.balance-amount { display: flex; align-items: baseline; flex-wrap: wrap; gap: 13px; margin: 10px 0 8px; }
#balance-usd {
  color: var(--accent);
  font-family: var(--mono-font);
  font-variant-numeric: tabular-nums;
  font-size: clamp(43px, 6.9vw, 75px);
  line-height: 1.12;
  letter-spacing: -0.08em;
  overflow-wrap: anywhere;
}
.balance-unit { color: #c4d1b4; font-family: var(--mono-font); font-size: 13px; }
.balance-info { color: var(--muted); min-height: 23px; font-size: 12px; line-height: 1.7; }
.wallets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid #45533e; background: #1820197a; }
.wallets > div { padding: 13px 17px 15px 25px; min-width: 0; }
.wallets > div + div { border-left: 1px solid #45533e; }
dt { color: var(--muted); font-size: 12px; line-height: 1.35; }
dd { color: var(--ink); font-family: var(--mono-font); font-variant-numeric: tabular-nums; }
.wallets dd { font-size: clamp(16px, 2.2vw, 23px); margin-top: 5px; overflow-wrap: anywhere; }

.connection-panel { padding: 24px 25px; }
.connection-panel h2, .section-heading h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
#connect-form { margin-top: 17px; }
#connect-form label { display: block; margin-bottom: 7px; color: #d5ddd0; font-size: 13px; }
.key-field {
  border: 1px solid #414c3e;
  border-radius: 8px;
  display: flex;
  background: #131713;
  overflow: hidden;
}
.key-field:focus-within { outline: 2px solid #b3d782; outline-offset: 2px; }
.key-field input { padding: 10px 12px; min-width: 0; width: 100%; min-height: 44px; font-family: var(--mono-font); font-size: 14px; color: var(--ink); background: transparent; border: 0; outline: none; }
.key-field input::placeholder { color: #a1a99d; }
.reveal-button { border: 0; border-left: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; padding: 0 12px; min-width: 50px; background: transparent; }
.reveal-button:hover, .reveal-button:focus-visible { color: var(--accent); }
.reveal-button:focus-visible { outline-offset: -3px; }
.scope-hint, .privacy-note { font-size: 12px; color: var(--muted); line-height: 1.65; }
.scope-hint { margin-block: 9px 14px; }
.privacy-note { margin-top: 10px; }
.transport-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 13px; }
#connect-form .transport-row label { margin: 0; color: var(--muted); font-size: 12px; }
.button {
  border: 1px solid transparent;
  border-radius: 8px;
  line-height: 1.25;
  min-height: 40px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.button-primary { background: var(--accent); color: #182115; }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-primary:disabled { background: #404a39; color: #d4dacd; }
#connect-button { width: 100%; justify-content: space-between; }
.button-secondary { border-color: #475144; background: transparent; color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.button-secondary:disabled { color: #879082; border-color: var(--line-soft); }
.session-name { color: var(--accent); margin-top: 24px; font-size: 18px; font-weight: 600; }
.session-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.notice { color: var(--warning); font-size: 12px; line-height: 1.6; margin-top: 11px; }

.trend-panel, .ledger-panel { margin-top: 20px; padding: 22px 25px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.section-heading p { color: var(--muted); font-size: 12px; line-height: 1.65; margin-top: 5px; }
.currency-picker select, .transport-row select {
  min-height: 35px;
  border: 1px solid #475144;
  border-radius: 7px;
  padding: 5px 8px;
  background: var(--inset);
  color: var(--ink);
  font-size: 13px;
}
.trend-totals { display: flex; flex-wrap: wrap; gap: 16px 36px; margin-block: 17px 12px; }
.trend-totals > div { display: flex; align-items: baseline; gap: 9px; }
.trend-totals dd { color: var(--accent); font-size: 19px; }
.chart-frame { position: relative; min-height: 173px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--inset); }
.chart-frame canvas { display: block; inline-size: 100%; block-size: 173px; }
.chart-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  margin: 0;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}
.chart-message::before {
  position: absolute;
  inset: 12px 18px 27px;
  content: "";
  border-block-end: 1px solid var(--line-soft);
  background: repeating-linear-gradient(to bottom, transparent 0 calc(25% - 1px), #30382e 25%);
  opacity: 0.5;
}
.chart-message span { position: relative; }

.table-scroll { overflow: auto; margin-top: 16px; border-radius: 7px; }
table { border-collapse: collapse; inline-size: 100%; min-width: 490px; text-align: left; font-size: 13px; }
thead th { background: #242a24; color: #c7d0c3; font-weight: 500; padding: 11px 12px; white-space: nowrap; }
thead th:last-child, tbody td:last-child { text-align: right; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); color: #d5ddd0; }
tbody td:first-child { white-space: nowrap; font: 12px var(--mono-font); }
tbody td:nth-child(3), tbody td:nth-child(4) { font: 12px var(--mono-font); white-space: nowrap; }
tbody td:nth-child(4) { color: var(--accent); }
tbody td.table-empty { text-align: center; padding: 28px 12px; color: var(--muted); font: 13px var(--body-font); }
.line-model { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.line-sku { margin-top: 3px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.currency-key { color: var(--muted); font: 12px var(--mono-font); white-space: nowrap; }
.ledger-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.ledger-nav > div { display: flex; gap: 7px; }
.ledger-nav .button { min-height: 32px; padding-inline: 9px; }
.footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding-block: 23px 31px; color: var(--muted); font-size: 12px; }
.screen-reader-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .shell { width: calc(100% - 36px); }
  .page-heading { padding-block: 31px 19px; }
  .top-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .balance-panel { min-height: 220px; }
  .balance-main { padding-inline: 19px; }
  .wallets > div { padding-inline: 14px; }
  .connection-panel, .trend-panel, .ledger-panel { padding: 19px; }
  .trend-panel, .ledger-panel { margin-top: 14px; }
}

@media (max-width: 400px) {
  .shell { width: calc(100% - 28px); }
  .topbar-inner { min-height: 58px; }
  .page-heading { gap: 10px; }
  .page-heading p { font-size: 12px; }
  .connection-badge { padding-inline: 8px; }
  .balance-main { padding-top: 20px; }
  .footer { flex-wrap: wrap; }
}

@media (max-width: 540px) {
  table { min-width: 0; table-layout: fixed; font-size: 12px; }
  thead th, tbody td { padding-inline: 7px; }
  thead th:nth-child(1) { width: 23%; }
  thead th:nth-child(2) { width: 35%; }
  thead th:nth-child(3) { width: 15%; }
  thead th:nth-child(4) { width: 27%; }
  tbody td:first-child, tbody td:nth-child(3), tbody td:nth-child(4) {
    font-size: 11px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
