:root {
  color-scheme: light;
  --paper: #f2f4f7;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --ink: #111827;
  --muted: #657083;
  --faint: #8b95a5;
  --line: #dfe4ea;
  --line-strong: #c7ced8;
  --budget: #4147a8;
  --budget-soft: #ececf8;
  --tether: #087f62;
  --tether-soft: #e1f2ec;
  --fee: #9a6717;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --focus: #2563eb;
  --placeholder: #667085;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.12);
  --font: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  --numbers: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}


* {
  box-sizing: border-box;
}
html {
  background: var(--paper);
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.material-symbols-outlined {
  font-size: 20px;
  font-variation-settings:
    'FILL' 0,
    'wght' 450,
    'GRAD' 0,
    'opsz' 20;
}

.desk-shell {
  min-height: 100vh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px clamp(18px, 4vw, 64px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.brand img {
  width: 66px;
  height: 38px;
  object-fit: contain;
}
.brand-rule {
  width: 1px;
  height: 26px;
  background: var(--line-strong);
}
.topbar-actions,
.command-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.integrity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.integrity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}
.integrity.ready .integrity-dot {
  background: var(--tether);
  box-shadow: 0 2px 9px color-mix(in srgb, var(--tether) 35%, transparent);
}
.integrity.error .integrity-dot {
  background: var(--danger);
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 46px) clamp(16px, 4vw, 64px) 36px;
}
.balance-band {
  display: grid;
  grid-template-columns: minmax(250px, 0.85fr) minmax(280px, 1fr) minmax(
      360px,
      1.25fr
    );
  gap: clamp(24px, 4vw, 64px);
  align-items: end;
  padding: clamp(26px, 4vw, 54px);
  color: #f8fafc;
  background: #151c2b;
  border-radius: 16px;
  box-shadow: 0 20px 54px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  position: relative;
}
.balance-band::after {
  content: '';
  position: absolute;
  inset: auto -8% -52% 42%;
  height: 170%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(65, 71, 168, 0.52),
    rgba(8, 127, 98, 0.2) 44%,
    transparent 69%
  );
  pointer-events: none;
}
.balance-band > * {
  position: relative;
  z-index: 1;
}
.balance-copy h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 0.98;
  letter-spacing: -0.04em;
}
.balance-copy p {
  max-width: 42ch;
  margin: 14px 0 0;
  color: #b7c0d0;
  font-size: 14px;
  line-height: 1.65;
}
.available-balance > span {
  display: block;
  color: #aeb8c9;
  font-size: 12px;
  font-weight: 700;
}
.available-balance strong {
  display: block;
  margin-top: 7px;
  font-family: var(--numbers);
  font-size: clamp(38px, 5.2vw, 68px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.available-balance strong small {
  color: #aeb8c9;
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 0;
}
.available-balance.over strong {
  color: #ffaaa4;
}
.balance-totals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 23px 30px;
  margin: 0;
}
.balance-totals div {
  min-width: 0;
}
.balance-totals dt {
  color: #aeb8c9;
  font-size: 11px;
  font-weight: 700;
}
.balance-totals dd {
  margin: 5px 0 0;
  color: #fff;
  font: 500 18px/1.2 var(--numbers);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status-banner {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
}
.status-banner.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}
.status-banner.success {
  color: var(--tether);
  background: var(--tether-soft);
  border-color: color-mix(in srgb, var(--tether) 25%, transparent);
}
.command-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 34px 0 22px;
}
.command-copy h2,
.section-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}
.command-copy p,
.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.secondary-button,
.quiet-button,
.danger-button,
.icon-button,
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}
.primary-button {
  color: white;
  background: #38409a;
  border-color: #38409a;
}
.primary-button:hover {
  background: #2f3584;
  transform: translateY(-1px);
}
.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}
.secondary-button:hover,
.quiet-button:hover,
.icon-button:hover,
.row-action:hover {
  background: var(--surface-subtle);
  border-color: var(--line-strong);
}
.quiet-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}
.danger-button {
  color: white;
  background: #b42318;
  border-color: #b42318;
}
.icon-button,
.row-action {
  width: 40px;
  padding: 8px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}
.row-action {
  width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none !important;
}

.ledger-section {
  margin-bottom: 24px;
}
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 2px 12px;
}
.count-badge {
  padding: 5px 9px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.table-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.05);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th {
  padding: 12px 14px;
  color: var(--muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.035em;
  font-weight: 750;
  text-transform: uppercase;
  white-space: nowrap;
}
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: color-mix(in srgb, var(--surface-subtle) 70%, transparent);
}
.number {
  font-family: var(--numbers);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.budget-number {
  color: var(--budget);
  font-weight: 700;
}
.tether-number {
  color: var(--tether);
  font-weight: 700;
}
.fee-number {
  color: var(--fee);
}
.negative {
  color: var(--danger);
}
.record-title {
  color: var(--ink);
  font-weight: 750;
  white-space: nowrap;
}
.record-meta {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 10px;
}
.note-cell {
  max-width: 260px;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}
.wallet {
  display: block;
  max-width: 190px;
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--numbers);
  font-size: 10px;
}
.network-badge {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 7px;
  color: var(--tether);
  background: var(--tether-soft);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.table-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--tether);
  font-weight: 700;
  text-decoration: none;
}
.table-link:hover {
  text-decoration: underline;
}
.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}
.empty-state {
  padding: 52px 18px;
  text-align: center;
}
.empty-state .material-symbols-outlined {
  color: var(--faint);
  font-size: 28px;
}
.empty-state h3 {
  margin: 12px 0 0;
  font-size: 15px;
}
.empty-state p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.ledger-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 2px 0;
  color: var(--muted);
  font-size: 11px;
}
.ledger-footer p {
  margin: 0;
}
.ledger-footer code {
  max-width: 55%;
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desk-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.desk-dialog.wide {
  width: min(680px, calc(100vw - 28px));
}
.desk-dialog.compact {
  width: min(440px, calc(100vw - 28px));
}
.desk-dialog::backdrop {
  background: rgba(9, 14, 23, 0.62);
  backdrop-filter: blur(3px);
}
.desk-dialog form {
  display: grid;
  gap: 17px;
  padding: 22px;
}
.desk-dialog form > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 2px;
}
.desk-dialog h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}
.desk-dialog header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.dialog-close:hover {
  background: var(--surface-subtle);
}
.field-grid {
  display: grid;
  gap: 13px;
}
.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.desk-dialog label {
  display: grid;
  gap: 7px;
}
.desk-dialog label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.desk-dialog label em {
  color: var(--faint);
  font-style: normal;
  font-weight: 500;
}
.desk-dialog input,
.desk-dialog select,
.desk-dialog textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 13px;
}
.desk-dialog textarea {
  resize: vertical;
  line-height: 1.5;
}
.desk-dialog input::placeholder,
.desk-dialog textarea::placeholder {
  color: var(--placeholder);
}
.input-suffix {
  position: relative;
}
.input-suffix input {
  padding-right: 48px;
  font-family: var(--numbers);
}
.input-suffix b {
  position: absolute;
  top: 50%;
  right: 11px;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 10px;
}
.conversion-preview {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
}
.conversion-preview strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font: 600 13px var(--numbers);
}
.form-status {
  min-height: 18px;
  color: var(--danger);
  font-size: 11px;
}
.desk-dialog form > footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 3px;
}

@media (max-width: 1050px) {
  .balance-band {
    grid-template-columns: 1fr 1fr;
  }
  .balance-totals {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, 1fr);
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.13);
  }
  .table-frame {
    overflow-x: auto;
  }
  table {
    min-width: 980px;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 60px;
  }
  .brand img {
    width: 54px;
  }
  .brand-rule,
  .brand > span:last-child,
  .integrity {
    display: none;
  }
  .topbar-actions .quiet-button {
    width: 40px;
    padding: 8px;
    font-size: 0;
  }
  main {
    padding-top: 16px;
  }
  .balance-band {
    grid-template-columns: 1fr;
    gap: 27px;
    padding: 25px 22px;
  }
  .balance-copy h1 {
    font-size: 37px;
  }
  .balance-copy p {
    font-size: 13px;
  }
  .available-balance strong {
    font-size: 46px;
  }
  .balance-totals {
    grid-column: auto;
    grid-template-columns: repeat(2, 1fr);
  }
  .command-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .command-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }
  .command-actions .primary-button {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .command-actions button {
    width: 100%;
  }
  .section-heading {
    align-items: flex-start;
  }
  .ledger-footer {
    flex-direction: column;
  }
  .ledger-footer code {
    max-width: 100%;
  }
  .field-grid.two {
    grid-template-columns: 1fr;
  }
  .desk-dialog {
    max-height: calc(100vh - 12px);
  }
  .desk-dialog form {
    padding: 18px;
  }
  .conversion-preview {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
