:root {
  color-scheme: light;
  --bg: #e9f0f0;
  --panel: #ffffff;
  --panel-soft: #f8fbfb;
  --line: #d4e0e1;
  --text: #10191d;
  --muted: #627480;
  --accent: #176d5d;
  --accent-strong: #0f5247;
  --danger: #b42318;
  --danger-bg: #fff0ee;
  --success: #167449;
  --success-bg: #ecfdf3;
  --shadow: 0 18px 50px rgba(16, 25, 29, 0.08);
  --focus: #f59e0b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 240px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: contain;
}

::selection {
  background: rgba(23, 109, 93, 0.18);
}

.shell {
  width: min(1480px, calc(100% - 40px));
  margin: 28px auto;
}

.search-panel {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
  align-items: end;
  padding: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 251, 0.94) 100%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.16), transparent 34%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: 0;
}

.search-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
}

input,
button {
  min-height: 44px;
  border-radius: 6px;
  font: inherit;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
  touch-action: manipulation;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #fbfcfc;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
}

input:focus {
  outline: 3px solid rgba(245, 158, 11, 0.26);
  border-color: var(--accent);
}

button:focus-visible,
.link-button:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.45);
  outline-offset: 3px;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.link-button {
  display: inline-flex;
  max-width: 100%;
  min-height: 44px;
  align-items: center;
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: #0b47ff;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  text-decoration: underline;
  overflow-wrap: anywhere;
  white-space: normal;
  cursor: pointer;
}

.link-button:hover {
  background: transparent;
  color: #082fb0;
}

.status-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  box-shadow: 0 10px 24px rgba(16, 25, 29, 0.04);
}

.status-panel.error {
  border-color: #f0b8b3;
  background: var(--danger-bg);
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.summary-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 3px solid rgba(23, 109, 93, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(16, 25, 29, 0.045);
}

.summary-grid div:nth-child(1) {
  border-top-color: #60a5fa;
}

.summary-grid div:nth-child(2) {
  border-top-color: #22c55e;
}

.summary-grid div:nth-child(3) {
  border-top-color: #ef4444;
}

.summary-grid div:nth-child(4) {
  border-top-color: #a78bfa;
}

.summary-grid div:nth-child(5) {
  border-top-color: #f59e0b;
}

.summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 24px;
}

.filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 24px rgba(16, 25, 29, 0.045);
}

.filter-panel > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.filter-button:hover {
  border-color: rgba(23, 109, 93, 0.42);
  background: #f4f8f8;
  color: var(--accent-strong);
}

.filter-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.table-wrap {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 38px rgba(16, 25, 29, 0.07);
}

.detail-body::-webkit-scrollbar {
  width: 10px;
}

.detail-body::-webkit-scrollbar-thumb {
  border: 2px solid #f4f8f8;
  border-radius: 999px;
  background: #b8c9cb;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  overflow-wrap: anywhere;
}

th:nth-child(1),
td:nth-child(1) {
  width: 76px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 118px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 126px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 17%;
}

th:nth-child(5),
td:nth-child(5),
th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7) {
  width: 15%;
}

th:nth-child(8),
td:nth-child(8) {
  width: 112px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: rgba(244, 248, 248, 0.96);
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

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

tbody tr {
  --row-accent: var(--line);
  --row-tint: #fff;
}

tbody tr:nth-child(even) td {
  background: rgba(248, 251, 251, 0.48);
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--row-tint) 70%, #ffffff);
}

tbody td {
  transition: background 140ms ease;
}

tbody td:first-child {
  box-shadow: inset 4px 0 0 var(--row-accent);
}

.badge {
  display: inline-flex;
  min-width: 52px;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.success {
  background: var(--success-bg);
  color: var(--success);
}

.badge.failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.mono {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

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

.ledger-tag {
  display: inline-flex;
  min-width: 96px;
  justify-content: center;
  padding: 8px 12px;
  border: 2px solid var(--ledger-border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, var(--ledger-bg) 100%);
  color: var(--ledger-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 850;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -4px 0 color-mix(in srgb, var(--ledger-accent) 28%, transparent),
    0 8px 18px color-mix(in srgb, var(--ledger-accent) 16%, transparent);
}

.amount-cell {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  white-space: nowrap;
  font-size: 13px;
}

.amount-cell.incoming {
  color: var(--success);
}

.amount-cell.incoming::before {
  content: "+";
}

.amount-cell.outgoing {
  color: var(--danger);
}

.amount-cell.outgoing::before {
  content: "-";
}

.amount-cell.neutral {
  color: var(--accent-strong);
}

.address-tag {
  display: inline-flex;
  max-width: 100%;
  flex-direction: column;
  gap: 3px;
  padding: 7px 9px;
  border: 1px solid hsl(var(--tag-hue) 45% 72%);
  border-radius: 8px;
  background: hsl(var(--tag-hue) 62% 96%);
  color: hsl(var(--tag-hue) 54% 23%);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.28;
  overflow-wrap: anywhere;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.address-tag.receive {
  box-shadow: inset 3px 0 0 hsl(var(--tag-hue) 60% 42%), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.address-tag.fee {
  border-style: dashed;
  background: hsl(var(--tag-hue) 45% 97%);
}

.address-parent {
  color: hsl(var(--tag-hue) 30% 38%);
  font-size: 11px;
  font-weight: 650;
}

.empty-row td {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 18, 22, 0.45);
}

.detail-panel {
  width: min(1240px, 100%);
  max-height: min(86vh, 900px);
  overflow: hidden;
  border: 1px solid rgba(212, 224, 225, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(10, 18, 22, 0.24);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.ghost-button {
  min-height: 36px;
  min-width: 64px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #fff;
  color: var(--text);
}

.ghost-button:hover {
  background: #f4f7f7;
}

.detail-body {
  max-height: calc(min(86vh, 900px) - 82px);
  overflow: auto;
  padding: 18px 22px 22px;
}

.detail-section {
  margin-top: 18px;
}

.detail-section:first-child {
  margin-top: 0;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.detail-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.detail-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong,
.detail-item code {
  overflow-wrap: anywhere;
}

.error-box {
  padding: 12px;
  border: 1px solid #f0b8b3;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
}

.operation-card {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.operation-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.operation-title strong {
  font-size: 15px;
}

.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.kv div:nth-child(odd) {
  color: var(--muted);
}

.kv div:nth-child(even) {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 14px, 1180px);
    margin: 10px auto;
  }

  .search-panel,
  .search-row,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }

  .search-panel {
    padding: 18px;
  }

  .table-wrap {
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    display: grid;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 12px 26px rgba(16, 25, 29, 0.06);
  }

  tbody tr:nth-child(even) td,
  tbody tr:hover td {
    background: transparent;
  }

  tbody td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    width: 100% !important;
    padding: 11px 12px;
    border-bottom: 1px solid rgba(212, 224, 225, 0.72);
    font-size: 13px;
  }

  tbody td:first-child {
    box-shadow: inset 4px 0 0 var(--row-accent);
  }

  tbody td:last-child {
    border-bottom: 0;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .empty-row {
    display: block;
  }

  .empty-row td {
    display: block;
    padding: 26px 14px;
    text-align: center;
  }

  .empty-row td::before {
    content: none;
  }

  .ledger-tag {
    min-width: 0;
    width: max-content;
    max-width: 100%;
  }

  .detail-overlay {
    padding: 10px;
  }

  .detail-grid,
  .kv {
    grid-template-columns: 1fr;
  }
}
