/* ============================================================
   POLYFOLIO — Warm editorial finance aesthetic
   Inspired by: cream/terracotta recruiting landing page
   ============================================================ */

/* ---------- LIGHT THEME (default) ---------- */
:root {
  --bg-page: #F5F0E8;
  --bg-hero: linear-gradient(180deg, #FAF7F2 0%, #F0EADF 100%);
  --bg-card: #FFFFFF;
  --bg-card-alt: #FAF7F2;
  --bg-input: #FFFFFF;
  --border: #E2DCD2;
  --border-strong: #CCC5B8;

  --text-primary: #1A1612;
  --text-secondary: #6B635A;
  --text-muted: #9C948A;
  --text-bright: #0E0C0A;

  --accent: #C0503A;
  --accent-hover: #A8422E;
  --accent-soft: rgba(192, 80, 58, 0.08);
  --accent-text: #C0503A;

  --green: #2D8A54;
  --green-bg: rgba(45, 138, 84, 0.08);
  --red: #C0503A;
  --red-bg: rgba(192, 80, 58, 0.08);

  --chart-border: #FFFFFF;
  --chart-grid: rgba(26, 22, 18, 0.06);
  --chart-grid-light: rgba(26, 22, 18, 0.03);
  --chart-grid-strong: rgba(26, 22, 18, 0.10);
  --chart-label: #6B635A;
  --amber: #B07848;
  --amber-muted: #8A6A50;

  --row-hover: rgba(192, 80, 58, 0.03);
  --shadow-sm: 0 1px 3px rgba(26, 22, 18, 0.04);
  --shadow-md: 0 4px 16px rgba(26, 22, 18, 0.06);

  --btn-primary-bg: #1A1612;
  --btn-primary-text: #FAF7F2;
  --btn-secondary-bg: transparent;
  --btn-secondary-text: #1A1612;
  --btn-secondary-border: #CCC5B8;

  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Bricolage Grotesque', 'Helvetica Neue', sans-serif;
  --font-data: 'IBM Plex Mono', 'Consolas', monospace;

  --gap: 16px;
}

/* ---------- DARK THEME ---------- */
[data-theme="dark"] {
  --bg-page: #151210;
  --bg-hero: linear-gradient(180deg, #1A1612 0%, #151210 100%);
  --bg-card: #1E1A16;
  --bg-card-alt: #231F1A;
  --bg-input: #1E1A16;
  --border: #2E2924;
  --border-strong: #3D362E;

  --text-primary: #E8E2D8;
  --text-secondary: #A09888;
  --text-muted: #706860;
  --text-bright: #FAF7F2;

  --accent: #D4674F;
  --accent-hover: #E07860;
  --accent-soft: rgba(212, 103, 79, 0.12);
  --accent-text: #E08870;

  --green: #4CC07A;
  --green-bg: rgba(76, 192, 122, 0.10);
  --red: #E07860;
  --red-bg: rgba(224, 120, 96, 0.10);

  --chart-border: #1E1A16;
  --chart-grid: rgba(250, 247, 242, 0.05);
  --chart-grid-light: rgba(250, 247, 242, 0.03);
  --chart-grid-strong: rgba(250, 247, 242, 0.08);
  --chart-label: #A09888;
  --amber: #D4944C;
  --amber-muted: #A07840;

  --row-hover: rgba(212, 103, 79, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);

  --btn-primary-bg: #FAF7F2;
  --btn-primary-text: #1A1612;
  --btn-secondary-bg: transparent;
  --btn-secondary-text: #E8E2D8;
  --btn-secondary-border: #3D362E;
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.3s ease;
}

/* ---------- ENTRY SCREEN ---------- */
.entry-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hero);
}

.entry-inner {
  text-align: center;
  max-width: 560px;
  width: 100%;
  padding: 0 28px;
}

.entry-theme-toggle {
  position: absolute;
  top: 28px;
  right: 28px;
  z-index: 5;
}

/* Brand */
.brand-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 24px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 4.8rem;
  font-weight: 900;
  color: var(--text-bright);
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.025em;
}

.brand-title-accent {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--accent-text);
  font-size: 4.8rem;
  line-height: 1.1;
}

.beta-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  vertical-align: super;
}

.beta-tag-sm {
  font-size: 0.5rem;
  padding: 2px 5px;
  vertical-align: middle;
}

.brand-sub {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 20px;
  margin-bottom: 40px;
  line-height: 1.6;
}

/* Input */
.input-block { width: 100%; }

.input-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: left;
  text-transform: uppercase;
}

.input-row {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-prefix {
  padding: 16px 0 16px 18px;
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.95rem;
  user-select: none;
  flex-shrink: 0;
}

#address-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-data);
  font-size: 0.95rem;
  color: var(--text-primary);
  padding: 16px 18px 16px 4px;
  letter-spacing: 0.02em;
}

#address-input::placeholder { color: var(--text-muted); }

.load-btn {
  width: 100%;
  margin-top: 14px;
  padding: 15px 28px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.load-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.load-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-arrow {
  transition: transform 0.2s;
  font-size: 1.1rem;
}

.load-btn:not(:disabled):hover .btn-arrow {
  transform: translateX(3px);
}

.entry-error {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--red);
  min-height: 1.2em;
}

.entry-footer {
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.entry-footer a {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.15s;
}

.entry-footer a:hover { opacity: 0.75; }

.responsible-warning {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Divider above footer */
.entry-divider {
  width: 80px;
  height: 1px;
  background: var(--border);
  margin: 44px auto 0;
}

/* ---------- THEME TOGGLE ---------- */
.theme-toggle {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 9px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- LOADING SCREEN ---------- */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
}

.loading-inner { text-align: center; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.7s linear infinite;
}

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

.loading-label {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.loading-address {
  margin-top: 6px;
  font-family: var(--font-data);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---------- DASHBOARD ---------- */
.dashboard {
  padding: 0 28px 80px;
  max-width: 1360px;
  margin: 0 auto;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--text-bright);
  letter-spacing: -0.02em;
  text-decoration: none;
  cursor: pointer;
}

.top-brand:hover {
  opacity: 0.75;
}

.top-sep {
  color: var(--border-strong);
  font-weight: 300;
}

.top-address {
  font-family: var(--font-data);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
}
.top-address:hover {
  text-decoration: underline;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- DOWNLOAD DROPDOWN ---------- */
.download-wrapper {
  position: relative;
  display: inline-block;
}

.download-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md), 0 8px 24px rgba(0, 0, 0, 0.10);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 120px;
  overflow: hidden;
}

.download-dropdown.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.download-option {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.download-option:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
  color: var(--accent-text);
}

.download-option + .download-option {
  border-top: 1px solid var(--border);
}

/* ---------- METRICS STRIP ---------- */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--gap);
  margin-bottom: 28px;
}

.metrics-strip::-webkit-scrollbar { display: none; }
.metrics-strip { scrollbar-width: none; }

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.metric-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-family: var(--font-data);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-bright);
}

.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }

/* ---------- CHARTS ---------- */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.charts-row-full {
  grid-template-columns: 1fr;
}

.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: background 0.3s, border-color 0.3s;
  overflow: hidden;
  min-width: 0;
}

.chart-panel-wide { grid-column: 1 / -1; }

.panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alloc-toggle-group {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-left: auto;
  margin-right: 12px;
}
.alloc-toggle {
  background: transparent;
  border: none;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}
.alloc-toggle:not(:last-child) {
  border-right: 1px solid var(--border);
}
.alloc-toggle.active {
  background: var(--accent);
  color: #fff;
}
.alloc-toggle:hover:not(.active) {
  background: var(--bg-body);
}

.chart-download {
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  display: inline-flex;
  align-items: center;
}
.chart-download:hover {
  opacity: 1;
}

.icon-download {
  display: inline-block;
  vertical-align: middle;
}

.chart-wrap {
  position: relative;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-wrap-alloc {
  height: auto;
  display: flex;
  align-items: center;
  position: relative;
}

.alloc-chart-col {
  flex: 0 0 380px;
  height: 380px;
  position: relative;
  margin: 0 auto;
}

.alloc-chart-col canvas {
  width: 100% !important;
  height: 100% !important;
}

.alloc-legend {
  flex: 0 0 auto;
  max-width: 300px;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  max-height: 380px;
  padding-right: 4px;
}

.alloc-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
}

.alloc-legend-swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.alloc-legend-text {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alloc-legend-link {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
  cursor: pointer;
  transition: text-decoration-color 0.15s;
}

.alloc-legend-link:hover {
  text-decoration-color: var(--accent);
}
.chart-wrap-bar { height: 260px; }
.chart-wrap-line { height: 300px; }
.chart-wrap canvas { max-width: 100%; max-height: 100%; }

/* ---------- TABLES ---------- */
.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow-sm);
  transition: background 0.3s, border-color 0.3s;
}

.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.table-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-right: 4px;
  text-transform: uppercase;
}

.sort-btn,
.closed-sort-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.68rem;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.sort-btn:hover,
.closed-sort-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.sort-btn.active,
.closed-sort-btn.active {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
}

.data-table th.th-num { text-align: right; }

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
  font-family: var(--font-data);
  font-size: 0.8rem;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--row-hover); }

.data-table .td-title {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
}

.data-table .td-outcome {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.outcome-yes { color: var(--green); }
.outcome-no { color: var(--red); }

.td-num { text-align: right; font-variant-numeric: tabular-nums; }

.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }

.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------- TABLE PAGINATION ---------- */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0 8px;
}

.page-btn {
  background: var(--card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.page-btn:hover:not(.disabled):not(.active) {
  background: var(--hover);
  border-color: var(--text-muted);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.page-btn.disabled {
  opacity: 0.35;
  cursor: default;
}

.page-ellipsis {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0 4px;
}

/* ---------- ACTIVITY TIMELINE ---------- */
.tl-panel-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.tl-filters {
  flex-wrap: wrap;
}

.tl-filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.68rem;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tl-filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.tl-filter-btn.active {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.tl-filter-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  align-self: center;
}

.activity-timeline {
  max-height: 480px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  min-width: 0;
}

.tl-day {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
}

.tl-day::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.tl-day:last-child::before { display: none; }

.tl-date {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 0 8px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.tl-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.tl-event:hover { background: var(--row-hover); }

.tl-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  background: var(--bg-card-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tl-icon.tl-buy { color: var(--green); border-color: var(--green); background: var(--green-bg); }
.tl-icon.tl-sell { color: var(--red); border-color: var(--red); background: var(--red-bg); }

.tl-body {
  flex: 1;
  min-width: 0;
}

.tl-headline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.tl-side {
  font-family: var(--font-data);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tl-side.tl-buy { color: var(--green); }
.tl-side.tl-sell { color: var(--red); }

.tl-type {
  font-family: var(--font-data);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.tl-title {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 100%;
}

.tl-title-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.tl-title-link:hover { text-decoration-color: var(--accent); }

.tl-details {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.tl-details > span {
  font-family: var(--font-data);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.tl-outcome {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.65rem !important;
}

.tl-usdc { font-weight: 600; color: var(--text-secondary) !important; }

.tl-time { color: var(--text-muted); }

/* ---------- EMBED POPOVER ---------- */
.embed-popover {
  position: fixed;
  z-index: 100;
  width: 420px;
  height: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md), 0 8px 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(4px);
}

.embed-popover.visible {
  opacity: 0.88;
  pointer-events: auto;
  transform: translateY(0);
}

.embed-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
}

.td-title[data-slug] {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.td-title[data-slug]:hover {
  text-decoration-color: var(--accent);
}

/* ---------- ANIMATIONS ---------- */
.anim-reveal {
  opacity: 0;
  transform: translateY(22px);
  animation: revealUp 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--delay, 0) * 0.12s);
}

@keyframes revealUp {
  to { opacity: 1; transform: translateY(0); }
}

.anim-card {
  opacity: 0;
  transform: translateY(14px);
  animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--ci, 0) * 0.06s + 0.08s);
}

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- SKELETON LOADING ---------- */
@keyframes skeletonPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.15; }
}

.skeleton-pulse {
  background: var(--border);
  border-radius: 6px;
  animation: skeletonPulse 1.6s ease-in-out infinite;
}

.metric-value.skeleton-pulse {
  color: transparent;
  min-width: 50px;
  min-height: 1.3em;
}

.chart-skeleton {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  animation: skeletonPulse 1.6s ease-in-out infinite;
  background: var(--border);
}

.table-skeleton {
  padding: 32px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-skeleton-row {
  height: 14px;
  border-radius: 4px;
  animation: skeletonPulse 1.6s ease-in-out infinite;
  background: var(--border);
}

/* Stagger skeleton row animations */
.table-skeleton-row:nth-child(1) { width: 95%; animation-delay: 0s; }
.table-skeleton-row:nth-child(2) { width: 88%; animation-delay: 0.1s; }
.table-skeleton-row:nth-child(3) { width: 92%; animation-delay: 0.2s; }
.table-skeleton-row:nth-child(4) { width: 85%; animation-delay: 0.3s; }
.table-skeleton-row:nth-child(5) { width: 90%; animation-delay: 0.4s; }

/* Section reveal animation when data loads */
@keyframes sectionReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-loaded {
  animation: sectionReveal 0.35s ease-out forwards;
}

/* ---------- UTILITY ---------- */
.hidden { display: none !important; }
.no-anim .anim-card,
.no-anim .anim-reveal {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) {
  .metrics-strip { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
  /* Dashboard shell */
  .dashboard { padding: 0 16px 60px; }

  /* Metrics — horizontal scroll carousel */
  .metrics-strip {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 6px;
  }
  .metric-card {
    flex: 0 0 auto;
    min-width: 140px;
    padding: 14px 16px;
    scroll-snap-align: start;
  }
  .metric-value { font-size: 1.1rem; }

  /* Charts */
  .charts-row { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
  .chart-panel { padding: 18px 14px; }
  .chart-wrap { height: 220px; }
  .chart-wrap-bar { height: 200px; }
  .chart-wrap-line { height: 240px; }

  /* Pie chart allocation — needs .chart-wrap prefix for specificity over .chart-wrap height */
  .chart-wrap.chart-wrap-alloc {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    overflow: visible;
  }
  .alloc-chart-col {
    flex: 0 0 auto;
    height: 280px;
    margin: 0 auto;
    width: 280px;
  }
  .alloc-legend {
    position: static;
    transform: none;
    max-width: none;
    max-height: 180px;
    overflow-y: auto;
    margin-top: 12px;
  }

  /* Top bar */
  .top-bar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 0;
    margin-bottom: 20px;
  }
  .top-bar-right {
    margin-left: auto;
  }
  .top-address {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Tables */
  .table-section { padding: 16px 12px; }
  .sort-controls { flex-wrap: wrap; gap: 5px; }
  .data-table .td-title { max-width: 160px; }

  /* Entry screen */
  .brand-title, .brand-title-accent { font-size: 3.2rem; }
  .brand-sub { font-size: 0.95rem; }

  /* Timeline */
  .activity-timeline { max-height: 360px; }
  .tl-filters { gap: 5px; }
  .tl-filter-btn { font-size: 0.62rem; padding: 4px 8px; }
  .tl-title { font-size: 0.75rem; }
  .tl-details { gap: 8px; }

  /* Embed popover */
  .embed-popover {
    width: calc(100vw - 24px);
    max-width: 420px;
    left: 12px !important;
    right: 12px !important;
    height: 360px;
  }
}

@media (max-width: 480px) {
  .dashboard { padding: 0 12px 48px; }

  /* Metrics — smaller cards in carousel */
  .metric-card { min-width: 120px; padding: 12px 14px; gap: 4px; }
  .metric-value { font-size: 1rem; }

  /* Entry screen */
  .brand-title, .brand-title-accent { font-size: 2.5rem; }
  .brand-sub { font-size: 0.88rem; margin-bottom: 28px; }
  .entry-inner { padding: 0 16px; }
  .input-prefix { padding: 14px 0 14px 14px; font-size: 0.85rem; }
  #address-input { padding: 14px 14px 14px 4px; font-size: 0.85rem; }
  .load-btn { padding: 13px 20px; font-size: 0.82rem; }

  /* Charts */
  .chart-panel { padding: 14px 10px; border-radius: 10px; }
  .panel-title { font-size: 0.9rem; margin-bottom: 14px; padding-bottom: 10px; }
  .chart-wrap { height: 200px; }
  .chart-wrap-bar { height: 180px; }
  .chart-wrap-line { height: 200px; }

  /* Pie chart */
  .chart-wrap.chart-wrap-alloc { height: auto; overflow: visible; }
  .alloc-chart-col { width: 240px; height: 240px; }

  /* Tables */
  .table-section { padding: 14px 10px; border-radius: 10px; }
  .table-controls { flex-direction: column; align-items: flex-start; gap: 8px; }
  .data-table .td-title { max-width: 130px; font-size: 0.78rem; }
  .data-table td { padding: 10px 10px; font-size: 0.75rem; }
  .data-table th { padding: 8px 10px; font-size: 0.6rem; }

  /* Top bar */
  .top-bar-left { flex-wrap: wrap; gap: 8px; }
  .top-address { max-width: 160px; font-size: 0.7rem; }
  .back-btn { padding: 7px 14px; font-size: 0.7rem; }

  /* Embed popover */
  .embed-popover { height: 320px; }

  /* Sort buttons */
  .sort-btn, .closed-sort-btn { font-size: 0.62rem; padding: 4px 8px; }
}
