:root {
  --bg: #0f1115;
  --bg-card: #181b22;
  --bg-track: #232730;
  --border: #2a2e38;
  --text: #e6e8eb;
  --text-dim: #9aa0ab;
  --green: #3ecf8e;
  --red: #ef5b5b;
  --yellow: #e8b339;
  --accent: #5b8def;
  --chart-grid: rgba(255, 255, 255, 0.06);
}

/* Light theme: override the same custom properties; most of the UI is var-driven. */
:root[data-theme='light'] {
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-track: #e6e9ef;
  --border: #d6dae2;
  --text: #1a1d23;
  --text-dim: #5c636f;
  --green: #1f9d63;
  --red: #d93f3f;
  --yellow: #b5851a;
  --accent: #2f6fe0;
  --chart-grid: rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

/* Transient toast notifications. */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.toast-error {
  background: #b3261e;
}
.toast-ok {
  background: #2e7d52;
}
.toast-out {
  opacity: 0;
  transform: translateY(8px);
}

/* Native form controls don't inherit the page font by default — normalize them so
   inputs/selects/buttons (e.g. the sort filter) match the rest of the UI. */
input,
select,
textarea,
button {
  font-family: inherit;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  flex-wrap: nowrap; /* stay one row: the summary shrinks/scrolls instead of wrapping
                        the whole header into a broken multi-row block */
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
}

/* One horizontally-scrollable row instead of wrapping into a broken multi-row block —
   keeps the header compact and always within the viewport. */
.summary {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px 20px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
}
.summary::-webkit-scrollbar {
  display: none;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex-shrink: 0; /* items keep their size; the row scrolls instead of squishing */
}

.summary-item label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.summary-item .value {
  font-size: 16px;
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

.pill.positive {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}

.pill.negative {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0; /* keep refresh/profile intact; the summary wraps instead */
}

.update-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.last-updated {
  font-size: 12px;
  color: var(--text-dim);
}

/* Collector health indicator. */
.health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.health:hover .health-text {
  color: var(--text);
  text-decoration: underline;
}
.health[hidden] {
  display: none;
}
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}
.health-dot.health-ok {
  background: var(--green);
  box-shadow: 0 0 6px rgba(62, 207, 142, 0.6);
}
.health-dot.health-stale {
  background: var(--yellow);
}
.health-dot.health-error {
  background: var(--red);
  box-shadow: 0 0 6px rgba(239, 91, 91, 0.6);
}
.health-dot.health-pending {
  background: var(--text-dim);
}

/* Monitoring tab. */
.mon-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.mon-head h2 {
  margin: 0;
  font-size: 18px;
}
/* Dot rendered inline inside the h2 and vertically centered on the text. */
.mon-head h2 .health-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-right: 10px;
  position: relative;
  top: -1px; /* tiny optical lift toward the cap-height center */
}
.mon-status {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.mon-status.mon-ok {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}
.mon-status.mon-stale {
  background: rgba(232, 179, 57, 0.15);
  color: var(--yellow);
}
.mon-status.mon-error {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}
.mon-status.mon-pending {
  background: var(--bg-track);
  color: var(--text-dim);
}
.mon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.mon-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-track);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.mon-stat label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mon-stat .value {
  font-size: 17px;
  font-weight: 700;
}
.mon-abs {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
}
.mon-errors {
  margin-top: 20px;
}
.mon-errors h3 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--red);
}
.mon-errors ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

#refresh-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#refresh-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
  padding: 14px 24px 0;
}

/* Tabs stay on ONE line and scroll horizontally instead of wrapping into a broken
   multi-row mess; the network filter stays pinned on the right. */
.tab-group {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
}
.tab-group::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--accent);
}

/* Network filter (right side of the tabs row) */
.network-filter {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  flex-shrink: 0; /* never squished by the scrolling tab row */
}

.net-filter-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.net-filter-btn:hover {
  color: var(--text);
}

.net-filter-btn.active {
  background: var(--bg-track);
  color: var(--text);
}

/* Narrow screens: tighten padding and stack the tab row above the network filter so
   nothing overflows; tabs still scroll horizontally on one line. */
@media (max-width: 640px) {
  header {
    flex-wrap: wrap; /* tiny screens: let logo/actions/summary stack if needed */
    padding: 12px 14px;
    gap: 10px;
  }
  .tabs {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px 0;
  }
  .network-filter {
    align-self: flex-start;
    max-width: 100%;
    overflow-x: auto;
  }
}

.tab-panel[hidden] {
  display: none;
}

/* Search + sort toolbar above the open/closed position grids. */
.positions-toolbar {
  display: flex;
  gap: 8px;
  margin: 16px 24px 0;
  flex-wrap: wrap;
}
.positions-toolbar[hidden] {
  display: none;
}
.pos-search,
.pos-sort {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
}
.pos-search {
  flex: 1;
  min-width: 200px;
}
.pos-search::placeholder {
  color: var(--text-dim);
}
.pos-sort {
  cursor: pointer;
}

/* Portfolio value/PnL change over 24h / 7d / 30d (open tab). */
.portfolio-deltas {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  margin: 16px 24px 0;
}
.portfolio-deltas[hidden] {
  display: none;
}
.delta-title {
  flex-basis: 100%;
  align-self: center;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.delta-card {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.delta-label {
  font-size: 11px;
  color: var(--text-dim);
}
.delta-value {
  font-size: 15px;
  font-weight: 600;
}
.delta-sub {
  font-size: 11px;
}
.delta-na {
  font-size: 12px;
  color: var(--text-dim);
}
/* Separate the change-over-time cards from the point-in-time metrics. */
.delta-card.delta-change:first-of-type {
  margin-left: 10px;
  border-left: 2px solid var(--accent);
}

/* Portfolio time-series chart (open tab). */
.portfolio-chart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 16px 24px 0;
}
.portfolio-chart[hidden] {
  display: none;
}
.pchart-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.pchart-title {
  font-size: 14px;
  font-weight: 600;
}
.pchart-range,
.pchart-metrics {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-track);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.pchart-range-btn,
.pchart-metric-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pchart-range-btn:hover,
.pchart-metric-btn:hover {
  color: var(--text);
}
.pchart-range-btn.active,
.pchart-metric-btn.active {
  background: var(--bg-card);
  color: var(--text);
}
.pchart-export {
  margin-left: auto;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pchart-export:hover {
  border-color: var(--accent);
}
/* Allocation & exposure section. */
.alloc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.alloc-grid[hidden] {
  display: none;
}
.alloc-box {
  min-width: 0;
}
.alloc-wide {
  grid-column: 1 / -1;
}
.alloc-title {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.alloc-canvas {
  position: relative;
  height: 220px;
}
.alloc-canvas-bar {
  height: 260px;
}
@media (max-width: 820px) {
  .alloc-grid {
    grid-template-columns: 1fr;
  }
}

/* Realized-PnL KPI grid (closed positions). */
.realized-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rkpi {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  background: var(--bg-track);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.rkpi-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rkpi-value {
  font-size: 18px;
  font-weight: 700;
}
.rkpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pchart-canvas {
  position: relative;
  height: 260px;
}

.positions,
.closed-positions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  padding: 24px;
}

/* Grouped-by-network mode: container becomes a stack of collapsible sections,
   each with its own card grid. */
/* :not([hidden]) so this doesn't override .tab-panel[hidden] (same specificity,
   later in source) — otherwise the inactive grid would show while grouped. */
.positions.grouped:not([hidden]),
.closed-positions.grouped:not([hidden]) {
  display: block;
  padding: 12px 24px 24px;
}
.pos-group + .pos-group {
  margin-top: 8px;
}
.pos-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 4px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.pos-group-caret {
  color: var(--text-dim);
  transition: transform 0.15s ease;
}
.pos-group.collapsed .pos-group-caret {
  transform: rotate(-90deg);
}
.pos-group-name {
  font-weight: 700;
  font-size: 15px;
}
.pos-group-count {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-track);
  padding: 1px 8px;
  border-radius: 10px;
}
.pos-group-total {
  margin-left: auto;
  font-weight: 600;
  color: var(--text-dim);
}
.pos-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  padding: 16px 0 4px;
}
.pos-group.collapsed .pos-group-grid {
  display: none;
}
.pos-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
}

.closed-card {
  opacity: 0.85;
  cursor: pointer;
}

.closed-card:hover {
  opacity: 1;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  padding: 48px 0;
}

.position-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.position-card:hover {
  border-color: var(--accent);
}

/* Out-of-range positions are surfaced to the top and flagged with a left accent. */
.position-card.needs-attention {
  border-color: rgba(239, 91, 91, 0.45);
  box-shadow: inset 3px 0 0 0 var(--red);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  /* leave room for the absolute gear in the top-right corner */
  padding-right: 32px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* status badge sits at the right edge of the meta row */
.card-meta .status-badge {
  margin-left: auto;
}

.token-icons {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
}

.token-icons .token-icon:not(:first-child) {
  margin-left: -10px;
}

.token-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  background: var(--bg-track);
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.token-mono {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.pair-label {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.network-badge,
.fee-tier,
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.network-badge.solana {
  background: rgba(91, 141, 239, 0.15);
  color: var(--accent);
}

.network-badge.avalanche {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}

.network-badge.arbitrum {
  background: rgba(40, 160, 240, 0.15);
  color: #29a0f0;
}

.chain-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-track);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fee-tier {
  background: var(--bg-track);
  color: var(--text-dim);
}

.status-badge.in-range {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}

.status-badge.out-of-range {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}

.status-badge.closed {
  background: var(--bg-track);
  color: var(--text-dim);
}

.range-bar {
  margin-bottom: 14px;
  padding-top: 22px;
}

.range-bar-track {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, rgba(91, 141, 239, 0.35), rgba(62, 207, 142, 0.35));
  overflow: visible;
}

.range-bar-track.out-of-range {
  background: linear-gradient(90deg, rgba(232, 179, 57, 0.3), rgba(239, 91, 91, 0.35));
}

.range-bar-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--green);
  border-radius: 1px;
  transform: translateX(-1px);
}

.range-bar-marker.out-of-range {
  background: var(--red);
}

.range-bar-marker-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
}

.range-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.stat label {
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  word-break: break-word;
}

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

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

.warning {
  color: var(--yellow);
}

/* Login overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* `display: flex` above would otherwise override the [hidden] UA rule (equal
   specificity, author wins), keeping the overlay visible after login. This
   higher-specificity rule restores hide-on-[hidden]. */
.login-overlay[hidden] {
  display: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 360px;
  width: calc(100% - 48px);
  text-align: center;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 13px;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wallet-btn {
  padding: 11px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.wallet-btn:hover {
  border-color: var(--accent);
  background: var(--bg-track);
}

.login-error {
  margin: 14px 0 0 !important;
  color: var(--red) !important;
  font-size: 13px;
}

#logout-btn {
  background: transparent;
}

.session-address {
  font-size: 12px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.logo {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0; /* logo keeps its size; the summary absorbs the shrinking */
}

.logo-mark {
  flex-shrink: 0;
  display: block;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.app-version {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-decoration: none;
}

.app-version:hover {
  color: var(--accent);
}

/* Profile dropdown */
.profile {
  position: relative;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  cursor: pointer;
}

.profile-caret {
  color: var(--text-dim);
  font-size: 10px;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  padding: 6px;
  z-index: 150;
}

.profile-menu[hidden] {
  display: none;
}

.profile-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: var(--bg-track);
}

/* Card gear (notification settings) */
.card-gear {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  z-index: 2;
}

.card-gear:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* The gear is only for the grid cards; hide it inside the expanded overlay
   (notification settings stay reachable from the grid card). */
.modal-content .card-gear {
  display: none;
}

/* Interval picker (number + unit) */
.interval-input {
  display: flex;
  gap: 6px;
}

.interval-input input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-size: 13px;
}

.interval-input select {
  padding: 8px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-size: 13px;
}

.set-test {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.set-test button {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.set-test-status {
  font-size: 12px;
  color: var(--text-dim);
}

.set-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* Settings modal */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(15, 17, 21, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
}

.settings-modal[hidden] {
  display: none;
}

.settings-content {
  width: 100%;
  max-width: 460px;
  margin: auto;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.settings-card h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.set-sub {
  margin: 12px 0 8px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.set-warn {
  margin: 8px 0;
  font-size: 12px;
  color: var(--yellow);
}

/* Section heading inside the grouped Global settings form. */
.set-section {
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.settings-card h2 + .set-section {
  margin-top: 12px;
}

/* Sent-message overlay. */
.notify-msg-title {
  margin: 8px 0 4px;
  font-weight: 600;
}
.notify-msg-body {
  margin: 0;
  padding: 12px;
  background: var(--bg-track);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow: auto;
}
.check-status.check-clickable {
  cursor: pointer;
}
.check-status.check-clickable:hover {
  filter: brightness(1.25);
  text-decoration: underline;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 10px 0;
  cursor: pointer;
}

.set-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  margin: 10px 0;
}

.set-field input,
.set-field select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-size: 13px;
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.set-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.set-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.set-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Watch-wallet form */
.watch-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.watch-form input {
  flex: 1;
  min-width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.watch-form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text);
  font-size: 13px;
}

.watch-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.watch-form button:hover {
  filter: brightness(1.05);
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Risk tab */
.risk-section {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 16px 24px;
}

.risk-section h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.aave-wallet {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  word-break: break-all;
}

/* Dominant collateral token icon in the Aave position header. */
.aave-card h2 .token-icon {
  width: 22px;
  height: 22px;
  border-width: 0;
  vertical-align: middle;
  margin-right: 8px;
}

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

.risk-table th,
.risk-table td {
  text-align: right;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.risk-table th:first-child,
.risk-table td:first-child {
  text-align: left;
}

.risk-table th {
  color: var(--text-dim);
  font-weight: 500;
}

.aave-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 14px;
}

.aave-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aave-stat label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.aave-stat .value {
  font-size: 16px;
  font-weight: 600;
}

/* Liquidation price: current price -> drop to liquidation, shown small + dim. */
.liq-drop {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}

/* LP range simulator in the position overlay. */
.range-sim {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--bg-track);
  border-radius: 10px;
}
.range-sim-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.range-sim-head label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.range-sim-hint {
  font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 6px;
}
.range-sim-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.range-sim-inputs input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.range-sim-inputs input:focus {
  outline: none;
  border-color: var(--accent);
}
.range-sim-out {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.range-sim-out b {
  color: var(--text);
  font-weight: 700;
}
.range-sim-rebalance {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.rs-rebalance-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* Actions bar in the position overlay (Collect fees, etc.). */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0;
}
.action-btn {
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.action-btn:hover {
  filter: brightness(1.08);
}
.action-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.action-btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
}
.action-btn-danger:hover {
  background: var(--red);
  color: #fff;
  filter: none;
}

/* Fee/IL breakeven block in the position overlay. */
.fee-il {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--bg-track);
  border-radius: 10px;
}
.fee-il-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fee-il-val {
  font-size: 14px;
  font-weight: 700;
}
.fee-il-sub {
  width: 100%;
  font-size: 12px;
  color: var(--text-dim);
}

/* Drag-to-reorder for Analytics sections: a grip handle in a left gutter. */
#analytics-panel > .drag-item {
  position: relative;
  padding-left: 32px;
}
#analytics-panel > .drag-item > .drag-handle {
  position: absolute;
  left: 8px;
  top: 16px;
  cursor: grab;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  user-select: none;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}
#analytics-panel > .drag-item > .drag-handle:hover {
  opacity: 1;
}
#analytics-panel > .drag-item > .drag-handle:active {
  cursor: grabbing;
}
.drag-item.dragging {
  opacity: 0.5;
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* dr4upn1r (Ph4s30) — shadow strategies panel. */
.dr4-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 24px 4px;
}
.dr4-title {
  margin: 16px 24px 4px;
  font-size: 18px;
}
.dr4-head-row .dr4-title {
  margin: 0;
}
.dr4-periods {
  display: inline-flex;
  gap: 4px;
}
.dr4-period-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-track);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}
.dr4-period-btn.active {
  border-color: var(--accent);
  color: var(--text);
}
.dr4-compare {
  margin: 8px 24px 0;
}
.dr4-compare h3 {
  margin: 0 0 8px;
  font-size: 13px;
}
.dr4-compare-chart {
  height: 200px;
}
.dr4-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  padding: 8px 24px 24px;
}
.dr4-card {
  margin: 0;
}
.dr4-basket {
  margin: 8px 24px 0;
  border-color: var(--accent);
}
.dr4-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.dr4-label {
  font-weight: 700;
  font-size: 15px;
}
.dr4-class {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-track);
  padding: 1px 8px;
  border-radius: 10px;
}
.dr4-age {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
}
.dr4-guard {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
}
.guard-normal {
  color: var(--green);
  background: rgba(62, 207, 142, 0.14);
}
.guard-caution {
  color: var(--yellow);
  background: rgba(232, 179, 57, 0.14);
}
.guard-halt {
  color: var(--red);
  background: rgba(239, 91, 91, 0.16);
}
.guard-none {
  color: var(--text-dim);
  background: var(--bg-track);
}
.dr4-rangebar {
  position: relative;
  height: 6px;
  background: var(--green);
  opacity: 0.5;
  border-radius: 3px;
  margin: 4px 0 18px;
}
.dr4-rangebar.out {
  background: var(--red);
}
.dr4-rangebar-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  background: var(--text);
  transform: translateX(-50%);
}
.dr4-rangebar-lo,
.dr4-rangebar-hi {
  position: absolute;
  top: 9px;
  font-size: 10px;
  color: var(--text-dim);
}
.dr4-rangebar-hi {
  right: 0;
}
.dr4-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.dr4-metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dr4-metric label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
/* подсказка-интерпретация на наведение: курсор help + лёгкое пунктирное подчёркивание подписи */
.dr4-metric[title] { cursor: help; }
.dr4-metric[title] label { text-decoration: underline dotted var(--border); text-underline-offset: 2px; }
.dr4-frontier-table th[title],
.dr4-intents-table th[title],
.dr4-guard[title] { cursor: help; }
.dr4-metric span {
  font-size: 14px;
  font-weight: 600;
}
.dr4-est {
  color: var(--text-dim);
  cursor: help;
}
.dr4-chart {
  height: 120px;
  margin-top: 12px;
}
.dr4-empty {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

/* dr4 intent queue + Squads vault */
.dr4-intents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.dr4-intents-table th,
.dr4-intents-table td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dr4-intents-table th {
  color: var(--text-dim);
  font-weight: 500;
}
.dr4-intent-reason {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}
.dr4-intent-act {
  white-space: nowrap;
  text-align: right;
}
/* #1 net-APR frontier readout */
.dr4-frontier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.dr4-frontier-table th,
.dr4-frontier-table td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dr4-frontier-table th {
  color: var(--text-dim);
  font-weight: 500;
}
.dr4-fr-asset { font-weight: 600; }
.dr4-fr-best {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(62, 207, 142, 0.18);
  color: #3ecf8e;
}
.dr4-fr-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.dr4-fr-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  background: var(--surface-2, rgba(127, 127, 127, 0.12));
  color: var(--text-dim);
}
.dr4-fr-chip.best {
  background: rgba(62, 207, 142, 0.16);
  color: #3ecf8e;
  font-weight: 600;
}
.dr4-fr-note {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

.dr4-status {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.dr4-status.st-proposed { background: rgba(91, 141, 239, 0.18); color: #5b8def; }
.dr4-status.st-blocked { background: rgba(239, 91, 91, 0.18); color: #ef5b5b; }
.dr4-status.st-approved { background: rgba(62, 207, 142, 0.18); color: #3ecf8e; }
.dr4-status.st-other { background: var(--surface-2, rgba(127, 127, 127, 0.15)); color: var(--text-dim); }
.dr4-act {
  margin-left: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.dr4-act:hover { background: rgba(62, 207, 142, 0.12); border-color: #3ecf8e; }
.dr4-act.reject:hover { background: rgba(239, 91, 91, 0.12); border-color: #ef5b5b; }
.dr4-act:disabled { opacity: 0.5; cursor: default; }
/* .dr4-card обнуляет горизонтальный margin .risk-section — возвращаем боковой инсет 24px,
   иначе карточка Squads растягивается шире соседних секций. */
.dr4-squads { margin: 12px 24px 0; }

/* Tax / realized-gains report table (can be wide — allow horizontal scroll). */
.tax-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

/* Admin wallets section in the Monitoring panel. */
.mon-admins {
  margin-top: 16px;
}
.admin-add {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
}
.admin-add input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: var(--bg-track);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.admin-add input:focus {
  outline: none;
  border-color: var(--accent);
}
.mon-admins .td-wallet {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}
.admin-src {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-track);
  padding: 1px 7px;
  border-radius: 10px;
}

/* Backups section in the Monitoring panel. */
.mon-backups {
  margin-top: 16px;
}
.mon-backups-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.mon-backups-head h2 {
  margin: 0;
}
.set-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-track);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.set-btn:hover {
  border-color: var(--accent);
}
.mon-restore-pending {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(232, 179, 57, 0.12);
  color: var(--yellow);
  font-size: 13px;
}

/* Per-source health rows in the Monitoring panel. */
.mon-sources {
  margin-top: 20px;
}
.mon-sources h3 {
  margin: 0 0 10px;
  font-size: 13px;
}
.src-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.src-dot.src-ok {
  background: var(--green);
}
.src-dot.src-err {
  background: var(--red);
}

/* Clickable token in the net-exposure table -> opens the drill-down overlay. */
.token-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}
.token-link:hover {
  border-bottom-color: var(--accent);
}
.token-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.token-detail-head h2 {
  margin: 0;
}
.token-detail-head .value {
  font-size: 18px;
  font-weight: 700;
}
.token-detail .td-wallet {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
}

/* HF "what if" simulator: slider that drops the dominant collateral price. */
.hf-sim {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--bg-elevated, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
}
.hf-sim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.hf-sim-head label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hf-sim-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.hf-sim-range {
  width: 100%;
  accent-color: var(--accent, #6c8cff);
  cursor: pointer;
}
.hf-sim.liquidated .hf-sim-range {
  accent-color: var(--red, #ff5c5c);
}
.hf-sim-out {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.hf-sim-newprice {
  font-weight: 600;
  color: var(--text);
}
.hf-sim-hf {
  font-weight: 700;
  font-size: 15px;
}
.hf-sim-liq {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.card-charts {
  display: none;
  /* Value & PnL side by side, price chart spans the full width below. minmax(0,1fr)
     lets tracks shrink below the canvas's intrinsic width instead of overflowing. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.position-card.expanded .card-charts {
  display: grid;
}

.chart-box {
  min-width: 0; /* critical: allow the grid item (and its canvas) to shrink to fit */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
}

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

.chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.chart-canvas {
  position: relative;
  min-height: 0;
  height: 200px;
}

.chart-wide .chart-canvas {
  height: 230px;
}

.chart-canvas canvas {
  max-width: 100%;
}

/* Position detail overlay (opened on card click, above the grid) */
.position-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 17, 21, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
}

.position-modal[hidden] {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 960px;
  margin: auto;
}

/* The cloned card sits at full overlay width, isn't clickable-to-toggle, and
   anchors the close button. */
.modal-content .position-card {
  position: relative;
  width: 100%;
  cursor: default;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal-content .position-card:hover {
  border-color: var(--border);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-track);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  z-index: 1;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Transactions section inside the position overlay */
.tx-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.tx-section h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.tx-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-track);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
}

.tx-empty {
  color: var(--text-dim);
  font-size: 13px;
}

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

.tx-table th,
.tx-table td {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.tx-table th:first-child,
.tx-table td:first-child,
.tx-table th:nth-child(2),
.tx-table td:nth-child(2) {
  text-align: left;
}

.tx-table th {
  color: var(--text-dim);
  font-weight: 500;
}

.tx-table a {
  color: var(--accent);
  text-decoration: none;
}

.tx-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-track);
  color: var(--text-dim);
}

.tx-open,
.tx-increase,
.tx-deposit {
  background: rgba(91, 141, 239, 0.15);
  color: var(--accent);
}

.tx-collect {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}

.tx-decrease,
.tx-withdraw {
  background: rgba(232, 179, 57, 0.15);
  color: var(--yellow);
}

/* Notifications activity log */
.notify-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.notify-chip {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-track);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

.notify-chip.positive {
  color: var(--green);
}

.notify-chip.negative {
  color: var(--red);
}

.notify-table .notify-title-cell {
  text-align: left;
}

.notify-target {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

/* Type filter bar inside the Notifications tab. */
.notify-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin: 0 0 12px;
  width: fit-content;
}
.notify-filter-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.notify-filter-btn:hover {
  color: var(--text);
}
.notify-filter-btn.active {
  background: var(--bg-track);
  color: var(--text);
}
.notify-filter-count {
  opacity: 0.6;
  font-weight: 500;
}

/* Check-type badges (LP range / Aave HF / Aave APY). */
.notify-lp {
  background: rgba(91, 141, 239, 0.15);
  color: var(--accent);
}

.notify-hf {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}

.notify-apy {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}

.notify-risk {
  background: rgba(91, 141, 239, 0.15);
  color: var(--accent);
}

.notify-stats {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}

.notify-test {
  background: var(--bg-track);
  color: var(--text-dim);
}

/* Per-check outcome. */
.check-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
}
.check-status.check-ok {
  background: rgba(62, 207, 142, 0.12);
  color: var(--green);
}
.check-status.check-alert {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}
.check-status.check-throttled {
  background: var(--bg-track);
  color: var(--text-dim);
}
.check-status.check-sent {
  background: rgba(91, 141, 239, 0.12);
  color: var(--accent);
}
.check-status.check-failed {
  background: rgba(239, 91, 91, 0.15);
  color: var(--red);
}

/* Stack the charts on narrower viewports for readability. */
@media (max-width: 820px) {
  .card-charts {
    grid-template-columns: 1fr;
  }
  .chart-box.chart-wide {
    grid-column: auto;
  }
}
