@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --umbra:       #3d304c;
  --umbra-deep:  #261c33;
  --umbra-lift:  #4e3f60;
  --accent:      #9a0dff;
  --accent-15:   rgba(154, 13, 255, .15);
  --accent-30:   rgba(154, 13, 255, .30);
  --accent-50:   rgba(154, 13, 255, .50);
  --glint:       #f8f8ff;
  --glint-60:    rgba(248, 248, 255, .60);
  --glint-35:    rgba(248, 248, 255, .35);
  --glint-10:    rgba(248, 248, 255, .10);
  --glint-06:    rgba(248, 248, 255, .06);

  /* Semantic */
  --bg:          var(--umbra-deep);
  --surface:     var(--umbra);
  --surface-hi:  var(--umbra-lift);
  --border:      rgba(248, 248, 255, .08);
  --border-acc:  rgba(154, 13, 255, .40);
  --text:        var(--glint);
  --text-2:      var(--glint-60);
  --text-3:      var(--glint-35);
  --green:       #34d399;
  --red:         #f87171;
  --amber:       #fbbf24;

  --radius:      10px;
  --radius-sm:   6px;
  --font-ui:     'Outfit', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Mono', monospace;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: rgba(38, 28, 51, .92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-symbol {
  height: 22px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.logo-wordmark {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--glint);
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.header-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  flex-shrink: 0;
}

/* ── Range selector ── */
.range-selector {
  display: flex;
  gap: 3px;
  background: var(--glint-06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.range-selector button {
  padding: 4px 11px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  transition: all .15s;
}

.range-selector button:hover { color: var(--text); background: var(--glint-06); }

.range-selector button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 6px rgba(154, 13, 255, .5);
}

/* ── Header right ── */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

#refreshedAt {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

#refreshBtn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--glint-06);
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}

#refreshBtn:hover { border-color: var(--accent-50); color: var(--text); }
#refreshBtn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Main layout ── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Card base ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ── Hero row ── */
.hero-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 860px) { .hero-row { grid-template-columns: 1fr; } }

/* Total Cash hero card */
.hero-cash {
  background: linear-gradient(145deg, #3d304c 0%, #4e2668 55%, #3d304c 100%);
  border: 1px solid var(--border-acc);
  box-shadow:
    0 0 0 1px rgba(154, 13, 255, .08),
    0 6px 28px rgba(154, 13, 255, .25),
    0 24px 64px rgba(154, 13, 255, .10),
    inset 0 1px 0 rgba(248, 248, 255, .06);
  padding: 28px 32px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
}

.hero-cash .card-label { color: rgba(248, 248, 255, .45); margin-bottom: auto; }

.hero-cash .hero-amount {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--glint);
  line-height: 1;
  margin: 16px 0 4px;
}

.hero-cash .hero-sub {
  font-size: 12px;
  color: rgba(248, 248, 255, .40);
}

/* Tres holdings peer card */
.tres-card {
  display: flex;
  flex-direction: column;
  min-height: 180px;
}

.tres-card .card-label { margin-bottom: 14px; }

/* ── Metrics row ── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 680px) { .metrics-row { grid-template-columns: 1fr; } }

.metric-card .metric-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-top: 6px;
  color: var(--text);
}

.metric-card.is-green .metric-value { color: var(--green); }
.metric-card.is-red .metric-value { color: var(--red); }
.metric-card.net-pos .metric-value { color: var(--green); }
.metric-card.net-neg .metric-value { color: var(--red); }

/* ── Analysis row ── */
.analysis-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) { .analysis-row { grid-template-columns: 1fr; } }

/* ── Category bars ── */
.cat-list { display: flex; flex-direction: column; gap: 11px; }

.cat-row { display: flex; align-items: center; gap: 10px; }

.cat-name {
  width: 140px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-track {
  flex: 1;
  height: 7px;
  background: var(--glint-06);
  border-radius: 4px;
  overflow: hidden;
}

.cat-fill {
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #c050ff);
  box-shadow: 0 0 8px rgba(154, 13, 255, .4);
}

.cat-amt {
  width: 78px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex-shrink: 0;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--glint-06); }

.mono { font-family: var(--font-mono); }
.amt-cell { text-align: right; font-family: var(--font-mono); font-weight: 500; }
.date-cell { color: var(--text-3); font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.trunc { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dim { color: var(--text-2); }
.small { font-size: 11px; }

/* ── Direction badge ── */
.dir {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
}

.dir.inflow  { background: rgba(52, 211, 153, .15); color: var(--green); }
.dir.outflow { background: rgba(248, 113, 113, .15); color: var(--red); }

/* ── Connections ── */
.conn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.conn-chip {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--glint-06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s;
}

.conn-chip:hover { border-color: var(--accent-30); }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.connected { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.error     { background: var(--red); box-shadow: 0 0 5px var(--red); }
.dot.warning   { background: var(--amber); }
.dot.not_run   { background: var(--glint-35); }

.conn-info { flex: 1; min-width: 0; }

.conn-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text);
}

.conn-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.conn-note {
  font-size: 11px;
  color: var(--red);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}

.sync-btn:hover { border-color: var(--accent-50); color: var(--accent); }
.sync-btn:disabled { opacity: .35; cursor: not-allowed; }
.sync-btn.syncing { border-color: var(--accent-50); color: var(--accent); }

/* ── Error banner ── */
#errorBanner {
  display: none;
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .35);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
}

/* ── States ── */
.loading, .empty {
  font-size: 13px;
  color: var(--text-3);
  padding: 20px 0;
  text-align: center;
}
