/* Valora brand palette — Espresso, Warm Sand, Soft Linen, Blush Pink.
   Dark mode is the default; light mode swaps to Soft Linen/White surfaces
   with Espresso text, same brand, different mode. */
:root {
  --bg: #15100A;
  --panel: #1F1810;
  --panel-border: #382C1E;
  --panel-border-strong: #4A3B28;
  --text: #F4E3CE;           /* Soft Linen, for dark-bg readability */
  --text-dim: #AD9B82;
  --text-faint: #7A6A54;
  --sold: #D1B48E;            /* Warm Sand — "sold" line */
  --deposited: #F4E3CE;        /* Soft Linen — "deposited" line */
  --fees: #FBCECF;              /* Blush Pink — the single pop accent, used for fees */
  --gap-warn: #C99A4E;
  --gap-bad: #CE5B45;
  --sample-tag: #6B5A42;
  --font-body: 'Montserrat', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

:root[data-theme='light'] {
  --bg: #FAF5EE;
  --panel: #FFFFFF;
  --panel-border: #EADBC7;
  --panel-border-strong: #DDC8AC;
  --text: #2A1C0E;
  --text-dim: #8A7660;
  --text-faint: #B6A48D;
  --sold: #8B5E34;
  --deposited: #482F13;
  --fees: #C15C74;
  --gap-warn: #B5793F;
  --gap-bad: #C0392B;
  --sample-tag: #B6A48D;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

.wrap {
  max-width: 1150px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  color: var(--fees);
  font-size: 22px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand .sub {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-row {
  display: flex;
  gap: 8px;
}

.status-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}

.status-pill.live .dot {
  background: var(--fees);
  animation: pulse-dot 1.6s ease-in-out infinite;
}
.status-pill.live { color: var(--text); }
.status-pill.error { color: var(--gap-bad); border-color: var(--gap-bad); cursor: help; }
.status-pill.error .dot { background: var(--gap-bad); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.theme-toggle {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 14px;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--fees); }

#repullRangeBtn { font-size: 22px; }

.refresh-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.refresh-btn:hover { border-color: var(--fees); }
.refresh-btn:disabled { opacity: 0.5; cursor: default; }

.stat-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.custom-range input[type="date"] {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 16px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-sub-row {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

.stat-fee {
  color: var(--fees);
}

.sample-flag {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--sample-tag);
  border: 1px solid var(--sample-tag);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.03em;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 18px;
}

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

.range-select {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.range-select:hover { border-color: var(--fees); }

.panel-head h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}

.panel-note {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 680px;
  line-height: 1.6;
}

.panel-note code {
  font-family: var(--font-mono);
  background: rgba(127,127,127,0.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

@media (max-width: 600px) {
  .chart-wrap { height: 260px; }
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

th {
  text-align: right;
  font-weight: 500;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}
th:first-child { text-align: left; }

td {
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td:first-child { text-align: left; color: var(--text-dim); }

#txnTable th:nth-child(2) { text-align: center; }
#txnTable td:nth-child(2) { text-align: left; }

@media (max-width: 600px) {
  #txnTable { table-layout: fixed; width: 100%; }
  #txnTable th, #txnTable td { padding: 6px 4px; font-size: 11px; }
  #txnTable th:nth-child(1), #txnTable td:nth-child(1) { width: 20%; white-space: normal; }
  #txnTable th:nth-child(2), #txnTable td:nth-child(2) { width: 52%; white-space: normal; word-break: break-word; }
  #txnTable th:nth-child(3), #txnTable td:nth-child(3) { width: 28%; white-space: nowrap; }
}

.cell-sample { color: var(--sample-tag); }
.cell-sample::after { content: " ·"; }

.cell-fee { color: var(--fees); }

.gap-ok { color: var(--text-dim); }
.gap-warn { color: var(--gap-warn); }
.gap-bad { color: var(--gap-bad); }

.footer {
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--font-mono);
  text-align: right;
}
