:root {
  color-scheme: light;
  --ink: #0f172a;
  --slate: #2f3a4a;
  --mist: #e6ecef;
  --sand: #f7f3ea;
  --sun: #f5c36a;
  --coral: #ff6b3d;
  --mint: #21b489;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Futura", "Trebuchet MS", sans-serif;
  background: var(--sand);
  color: var(--ink);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(247, 243, 234, 0.78);
  display: grid;
  place-items: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.loading-card {
  background: #fff;
  padding: 18px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--slate);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(15, 23, 42, 0.15);
  border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
}

.loading-text {
  font-weight: 500;
}

body.loading .loading-overlay {
  opacity: 1;
  pointer-events: auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.bg-gradient {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, #fff7e6 0%, transparent 55%),
    radial-gradient(circle at 80% 0%, #fde4d5 0%, transparent 60%),
    linear-gradient(135deg, #f7f3ea 0%, #eef2f5 100%);
  z-index: -2;
}

.bg-orb {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(33, 180, 137, 0.22), transparent 70%);
  filter: blur(20px);
  z-index: -1;
  opacity: 0.7;
}

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.78rem;
  line-height: 1.35;
  min-width: 220px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.28);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip .tooltip-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.chart-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.orb-a {
  top: -120px;
  right: -120px;
}

.orb-b {
  bottom: -180px;
  left: -120px;
  background: radial-gradient(circle, rgba(255, 107, 61, 0.2), transparent 70%);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero {
  padding: 36px 36px 32px;
  background: linear-gradient(125deg, #ffffff 0%, #f7f3ea 40%, #ffe5d4 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -60% auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 195, 106, 0.6), transparent 70%);
  opacity: 0.6;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(33, 180, 137, 0.15);
  color: #0b3f2f;
  font-weight: 600;
}

h1,
h2,
h3 {
  font-family: "Fraunces", "Georgia", serif;
  margin: 14px 0 10px;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2.2rem, 3vw, 3.2rem);
}

h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

h3 {
  font-size: 1.2rem;
}

.hero-sub {
  margin: 0;
  max-width: 620px;
  font-size: 1.05rem;
  color: var(--slate);
}

.hero-meta {
  display: flex;
  gap: 14px;
  margin-top: 20px;
  font-size: 0.95rem;
  color: var(--slate);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.stat-card {
  padding: 22px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.stat-label {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.stat-value {
  font-size: 1.6rem;
  margin: 10px 0 6px;
  font-weight: 600;
}

.stat-sub {
  font-size: 0.95rem;
  color: var(--slate);
}

.panel {
  padding: 26px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.panel-sub {
  margin: 6px 0 0;
  color: var(--slate);
}

.daily-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 8px 0 16px;
}

.chart-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 250px;
}

.bar {
  width: 14px;
  border-radius: 8px 8px 4px 4px;
  transition: transform 0.2s ease;
}

.bar.supply {
  background: linear-gradient(180deg, #4fe0a3 0%, #1da77e 100%);
}

.bar.withdraw {
  background: linear-gradient(180deg, #ff8a61 0%, #ff5b3b 100%);
}

.bar.borrow {
  background: linear-gradient(180deg, #ffd66b 0%, #d59a2c 100%);
  width: 10px;
}

.bar.repay {
  background: linear-gradient(180deg, #8ad9ff 0%, #3b7bd6 100%);
  width: 10px;
}

.bar.liquidation {
  background: linear-gradient(180deg, #ff8ad1 0%, #d84f9f 100%);
  width: 10px;
}

.bar.liquidity {
  background: linear-gradient(180deg, #c8a6ff 0%, #6f3fd6 100%);
  width: 10px;
}

.bar.liquidity.negative {
  background: linear-gradient(180deg, #ff8a61 0%, #b22f2f 100%);
}

.chart-day:hover .bar {
  transform: translateY(-4px);
}

.chart-day.active .bar {
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.12);
}

.day-label {
  font-size: 0.75rem;
  color: var(--slate);
}

.day-count {
  font-size: 0.8rem;
  font-weight: 600;
}

.day-amounts {
  font-size: 0.72rem;
  color: var(--slate);
}

.net-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.net-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.net-fill.positive {
  background: linear-gradient(90deg, #1da77e 0%, #9be8c9 100%);
}

.net-fill.negative {
  background: linear-gradient(90deg, #ff5b3b 0%, #ffb39f 100%);
}

.net-value {
  font-size: 0.72rem;
  color: var(--slate);
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--slate);
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.legend-item.supply::before {
  background: #1da77e;
}

.legend-item.withdraw::before {
  background: #ff5b3b;
}

.legend-item.net::before {
  background: #1da77e;
}

.legend-item.borrow::before {
  background: #d59a2c;
}

.legend-item.repay::before {
  background: #3b7bd6;
}

.legend-item.liquidation::before {
  background: #d84f9f;
}

.legend-item.liquidity::before {
  background: #6f3fd6;
}


.controls {
  display: flex;
  gap: 10px;
}

select,
input,
button {
  font-family: inherit;
  font-size: 0.95rem;
}

select,
input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: #fff;
}

button {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(15, 23, 42, 0.2);
  box-shadow: none;
}

.detail-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.detail-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-chip {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.summary-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
  font-weight: 700;
}

.summary-value {
  font-size: 1.2rem;
  font-weight: 400;
  margin-top: 8px;
}

.summary-total {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.detail-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  max-height: 360px;
  overflow: auto;
}

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

.event-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: #f6f7f9;
  font-size: 0.82rem;
}

.event-symbol {
  font-size: 0.75rem;
  color: #5b6775;
}

.address-link {
  background: none;
  border: none;
  padding: 0;
  color: #1b4f72;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}

.address-link:hover {
  color: #0b3f2f;
}

.address-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0 8px;
}

.address-form input {
  flex: 1 1 260px;
}

.address-summary {
  margin-top: 10px;
  color: var(--slate);
}

.address-totals {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
}

.address-sub {
  font-size: 0.78rem;
  color: var(--slate);
}

.address-external {
  margin-left: 8px;
  font-size: 0.78rem;
  color: #1b4f72;
}

.address-external:hover {
  color: #0b3f2f;
}

.event-table {
  margin-top: 18px;
  width: auto;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.day-events {
  margin-top: 22px;
}

.day-events-table {
  display: inline-block;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.event-table-row {
  background: #f6f7f9;
  font-size: 0.9rem;
}

.event-table thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
  padding: 0 12px 2px;
}

.event-table thead th.amount {
  text-align: right;
}

.event-table-row td {
  padding: 10px 12px;
}

.event-date {
  font-size: 0.8rem;
  color: var(--slate);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.event-date-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-amount {
  white-space: nowrap;
  text-align: right;
}

.event-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ecf6f0;
  color: #14704c;
}

.event-type.withdraw {
  background: #fbeeee;
  color: #b63a30;
}

.event-type.borrow {
  background: #fff4d6;
  color: #8a5a0a;
}

.event-type.repay {
  background: #e6f2ff;
  color: #1f5aa8;
}

.event-type.liquidation {
  background: #ffe5f3;
  color: #9b266b;
}

.footer {
  text-align: center;
  color: var(--slate);
  font-size: 0.85rem;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

body.loaded .reveal {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 720px) {
  .hero {
    padding: 28px 22px;
  }

  .event-table thead {
    display: none;
  }

  .event-table-row td {
    display: block;
  }

  .event-amount {
    margin-top: 6px;
  }
}
