/* ============================================================================
   App shell and components, hand-ported from the shadcn-admin reference.
   Plain CSS, no build step. Class names mirror the reference's component
   names so the mapping stays obvious.
   ========================================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: var(--border);
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  font-variation-settings: "opsz" 32;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* --- layout -------------------------------------------------------------- */

.layout {
  display: flex;
  min-height: 100svh;
}

/* --- sidebar ------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right-width: 1px;
  border-color: var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100svh;
  transition: width 200ms ease-linear;
}

.sidebar-header,
.sidebar-footer {
  padding: 0.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  width: 100%;
  text-align: start;
}

.sidebar-brand:hover {
  background: var(--sidebar-accent);
}

.sidebar-brand .mark {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--sidebar-primary);
  color: var(--sidebar-primary-foreground);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8125rem;
}

.sidebar-brand .meta {
  display: grid;
  gap: 0;
  min-width: 0;
  flex: 1;
}

.sidebar-brand .name {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand .sub {
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: grid;
  align-content: start;
  gap: 1rem;
}

.nav-group {
  display: grid;
  gap: 0.125rem;
}

.nav-label {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--sidebar-foreground);
  transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

.nav-item[aria-current="page"] {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 500;
}

.nav-item svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.nav-item .count {
  margin-inline-start: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding-inline: 0.375rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.75rem;
  font-weight: 500;
  display: grid;
  place-items: center;
}

.nav-item .chev {
  margin-inline-start: auto;
  opacity: 0.6;
}

.sidebar-footer {
  border-top-width: 1px;
  border-color: var(--sidebar-border);
}

/* --- topbar -------------------------------------------------------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  container-name: content;
}

.topbar {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--background);
}

.topbar[data-scrolled="true"] {
  box-shadow: var(--shadow);
  background: color-mix(in oklab, var(--background) 80%, transparent);
  backdrop-filter: blur(12px);
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  border-width: 1px;
  background: var(--background);
  box-shadow: var(--shadow-xs);
}

.icon-btn:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.icon-btn.ghost {
  border-width: 0;
  box-shadow: none;
  background: none;
  border-radius: 999px;
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
}

.topbar-sep {
  width: 1px;
  height: 1.5rem;
  background: var(--border);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-inline-end: auto;
}

.top-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  transition: color 120ms ease;
}

.top-nav a:hover {
  color: var(--foreground);
}

.top-nav a[aria-current="page"] {
  color: var(--foreground);
}

.search {
  position: relative;
  height: 2rem;
  width: 100%;
  max-width: 16rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem 0 0.5rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  background: color-mix(in oklab, var(--muted) 25%, transparent);
  color: var(--muted-foreground);
  font-size: 0.875rem;
  box-shadow: var(--shadow-xs);
}

.search svg {
  width: 1rem;
  height: 1rem;
}

.search kbd {
  margin-inline-start: auto;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.0625rem 0.3125rem;
  border-radius: var(--radius-sm);
  border-width: 1px;
  background: var(--muted);
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--foreground);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  flex-shrink: 0;
}

/* --- content ------------------------------------------------------------- */

.content {
  flex: 1;
  padding: 1.5rem 1rem;
  width: 100%;
  margin-inline: auto;
}

@container content (min-width: 80rem) {
  .content {
    max-width: 80rem;
  }
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

h1.page-title {
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-sub {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding-inline: 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-xs);
  transition: background 120ms ease, opacity 120ms ease;
}

.btn:hover {
  background: color-mix(in oklab, var(--primary) 90%, transparent);
}

.btn svg {
  width: 1rem;
  height: 1rem;
}

.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border-width: 1px;
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-ghost {
  background: none;
  color: var(--foreground);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--accent);
}

.btn-sm {
  height: 2rem;
  padding-inline: 0.75rem;
}

/* --- tabs (segmented control) -------------------------------------------- */

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem;
  border-radius: var(--radius-lg);
  background: var(--muted);
  color: var(--muted-foreground);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.75rem;
  padding-inline: 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted-foreground);
  transition: background 120ms ease, color 120ms ease;
}

.tab:hover {
  color: var(--foreground);
}

.tab[aria-selected="true"] {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.tab[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* --- cards --------------------------------------------------------------- */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border-width: 1px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-block: 1.5rem;
}

.card-header {
  padding-inline: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-top: 0.375rem;
}

.card-content {
  padding-inline: 1.5rem;
}

.card-tight {
  gap: 0.75rem;
}

/* --- stat card ----------------------------------------------------------- */

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@container content (min-width: 40rem) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@container content (min-width: 64rem) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat .card-header {
  align-items: center;
  padding-bottom: 0;
}

.stat .label {
  font-size: 0.875rem;
  font-weight: 500;
}

.stat .icon {
  color: var(--muted-foreground);
}

.stat .icon svg {
  width: 1rem;
  height: 1rem;
}

.stat .value {
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat .delta {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* --- split row (the reference's 7-column 4:3 split) ---------------------- */

.split-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1rem;
}

@container content (min-width: 64rem) {
  .split-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  .split-grid > .span-4 {
    grid-column: span 4;
  }
  .split-grid > .span-3 {
    grid-column: span 3;
  }
  .split-grid > .span-7 {
    grid-column: span 7;
  }
}

/* --- prose (for long-form page copy) ------------------------------------- */

.prose {
  max-width: 68ch;
}

.prose h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.prose h3 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 0.5rem;
}

.prose p {
  font-size: 0.9375rem;
  color: var(--muted-foreground);
}

.prose p + p {
  margin-top: 0.75rem;
}

/* --- list rows (the reference's "Recent Sales" pattern) ------------------ */

.rows {
  display: grid;
  gap: 1.5rem;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.row-item .meta {
  min-width: 0;
  flex: 1;
}

.row-item .name {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
}

.row-item .sub {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-item .amount {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
}

/* --- badges -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
}

.badge-default {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: transparent;
}

.badge-outline {
  color: var(--foreground);
}

/* --- tables -------------------------------------------------------------- */

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

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

table.data th {
  height: 2.5rem;
  padding: 0 0.5rem;
  text-align: start;
  vertical-align: middle;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  border-bottom-width: 1px;
}

table.data td {
  padding: 0.5rem;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom-width: 1px;
}

table.data tbody tr:last-child td {
  border-bottom-width: 0;
}

table.data tbody tr {
  transition: background 120ms ease;
}

table.data tbody tr:hover {
  background: color-mix(in oklab, var(--muted) 50%, transparent);
}

.num {
  font-variant-numeric: tabular-nums;
}

/* --- chart helpers ------------------------------------------------------- */

.chart {
  width: 100%;
  height: 21rem;
}

.chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart .bar {
  fill: var(--primary);
}

.chart .axis {
  fill: var(--muted-foreground);
  font-size: 0.75rem;
}

.chart .gridline {
  stroke: var(--border);
  stroke-width: 1;
}

/* --- footer -------------------------------------------------------------- */

.app-footer {
  margin-top: auto;
  flex-shrink: 0;
  border-top-width: 1px;
  padding: 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* --- responsive ---------------------------------------------------------- */

.sidebar-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    inset-inline-start: 0;
    top: 0;
    width: 18rem;
    transform: translateX(-100%);
    transition: transform 200ms ease-out;
  }
  .sidebar[data-open="true"] {
    transform: none;
  }
  .sidebar[data-open="true"] + .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(0 0 0 / 0.5);
  }
  .top-nav {
    display: none;
  }
}

/* --- charts drawn from our own feed ------------------------------------- */

/* The plot stretches to fill the card; the labels do not. Axis text lives in
   HTML so it keeps the page's font and true size at every width, instead of
   being scaled unevenly along with the paths. */

.chart {
  display: grid;
  gap: 0.5rem;
}

.chart-plot {
  position: relative;
  height: 18rem;
  padding-right: 3.25rem;
}

.chart-plot svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-plot .line {
  fill: none;
  stroke: var(--chart-2);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart-plot .area {
  stroke: none;
}

.chart-plot .fill-top {
  stop-color: var(--chart-2);
  stop-opacity: 0.18;
}

.chart-plot .fill-bottom {
  stop-color: var(--chart-2);
  stop-opacity: 0;
}

.chart-plot .gridline {
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-dot {
  position: absolute;
  right: 3.25rem;
  width: 0.5rem;
  height: 0.5rem;
  margin: -0.25rem -0.25rem 0 0;
  border-radius: 999px;
  background: var(--chart-2);
  box-shadow: 0 0 0 2px var(--card);
}

.y-axis {
  position: absolute;
  inset: 0 0 0 auto;
  width: 3.25rem;
  pointer-events: none;
}

.y-axis span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  padding-left: 0.5rem;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.x-axis {
  display: flex;
  justify-content: space-between;
  padding-right: 3.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.chart-empty {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  padding: 2rem 0;
  text-align: center;
}

svg.spark {
  width: 7.5rem;
  height: 2rem;
}

svg.spark path {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

svg.spark.up path {
  stroke: var(--chart-2);
}

svg.spark.down path {
  stroke: var(--destructive);
}

/* --- value colouring ----------------------------------------------------- */

.pos {
  color: var(--chart-2);
}

.neg {
  color: var(--destructive);
}

.chart-meta {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.chart-price {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* --- notices ------------------------------------------------------------- */

.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.notice-error {
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
  color: var(--destructive);
}

.notice-inline {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-top: 0.75rem;
  min-height: 1.2em;
}

.notice-inline.error {
  color: var(--destructive);
}

.notice-inline.warn {
  color: var(--chart-1);
}

/* --- meters -------------------------------------------------------------- */

.meter-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.meter-track {
  height: 0.625rem;
  border-radius: 999px;
  background: var(--muted);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--chart-2);
}

.meter-fill.alt {
  background: var(--chart-1);
}

.meter-note {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.375rem;
}

/* --- mini stat list ------------------------------------------------------ */

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top-width: 1px;
}

.mini-stats dt {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.25rem;
}

.mini-stats dd {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- misc ---------------------------------------------------------------- */

td.r, th.r {
  text-align: end;
}

.footnote {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 1rem;
}

.prose-p {
  font-size: 0.9375rem;
  color: var(--muted-foreground);
}

ol.steps {
  display: grid;
  gap: 0.875rem;
  padding-left: 1.25rem;
  font-size: 0.9375rem;
  color: var(--muted-foreground);
}

ol.steps strong {
  color: var(--foreground);
  font-weight: 600;
}

.dim {
  color: var(--muted-foreground);
}

/* --- pages not yet rebuilt ----------------------------------------------- */

/* Shown but not clickable, so the interface never leads to a 404 while the
   rebuild is only part way through. */
.nav-item.is-pending,
.top-nav .is-pending {
  color: var(--muted-foreground);
  opacity: 0.55;
  cursor: default;
}

.nav-item.is-pending:hover {
  background: none;
}

.top-nav .is-pending {
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-item .soon {
  margin-inline-start: auto;
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.0625rem 0.3125rem;
  border-radius: var(--radius-sm);
  border-width: 1px;
  color: var(--muted-foreground);
}

.tab.is-pending {
  opacity: 0.45;
  cursor: default;
}

.notice-info {
  background: color-mix(in oklab, var(--chart-2) 10%, transparent);
  border-color: color-mix(in oklab, var(--chart-2) 30%, transparent);
  color: var(--foreground);
}

.notice-info a {
  color: var(--chart-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- notice tones -------------------------------------------------------- */

.notice-warn {
  background: color-mix(in oklab, var(--chart-1) 10%, transparent);
  border-color: color-mix(in oklab, var(--chart-1) 32%, transparent);
  color: var(--foreground);
}

/* --- definition list ----------------------------------------------------- */

.detail-list {
  display: grid;
  gap: 0.875rem;
}

.detail-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.detail-list dt {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.detail-list dd {
  font-size: 0.875rem;
  font-weight: 500;
  text-align: end;
}

/* --- symbol pills -------------------------------------------------------- */

.pill-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  max-height: 14rem;
  overflow-y: auto;
}

.sym {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-sm);
  border-width: 1px;
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
  transition: background 120ms ease;
}

.sym:hover {
  background: var(--accent);
}

.sym.up {
  color: var(--chart-2);
  border-color: color-mix(in oklab, var(--chart-2) 35%, transparent);
}

.sym.down {
  color: var(--destructive);
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
}

.sym.stale {
  opacity: 0.5;
}

.sym-link {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--foreground) 30%, transparent);
  text-underline-offset: 3px;
}

.sym-link:hover {
  color: var(--chart-2);
}

/* --- trade table extras -------------------------------------------------- */

.tiny {
  font-size: 0.6875rem;
  line-height: 1.3;
}

.chip {
  display: inline-block;
  padding: 0.0625rem 0.3125rem;
  margin: 0 0.125rem 0.125rem 0;
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.625rem;
  white-space: nowrap;
}

.flag {
  display: inline-block;
  padding: 0.0625rem 0.25rem;
  margin: 0 0.125rem 0.125rem 0;
  border-radius: var(--radius-sm);
  border-width: 1px;
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: help;
}

.flag-ok    { color: var(--chart-2);     border-color: color-mix(in oklab, var(--chart-2) 40%, transparent); }
.flag-info  { color: var(--muted-foreground); }
.flag-warn  { color: var(--chart-1);     border-color: color-mix(in oklab, var(--chart-1) 40%, transparent); }
.flag-error { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }

.scroll-tall {
  max-height: 46rem;
  overflow-y: auto;
}

.scroll-wide {
  overflow-x: auto;
}

/* --- projection table ---------------------------------------------------- */

table.projection th.grouped {
  text-align: start;
  border-bottom-width: 1px;
  font-weight: 600;
  color: var(--foreground);
}

table.projection th.grouped .tiny {
  display: block;
  font-weight: 400;
}

table.projection tbody tr.total-row {
  background: var(--muted);
  font-weight: 600;
}

table.projection td,
table.projection th {
  white-space: nowrap;
}

table.projection tbody td:first-child,
table.projection thead th:first-child {
  position: sticky;
  inset-inline-start: 0;
  background: var(--card);
  z-index: 1;
}

table.projection tbody tr.total-row td:first-child {
  background: var(--muted);
}

/* --- search input -------------------------------------------------------- */

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--foreground);
  font-size: 0.875rem;
}

.search input::placeholder {
  color: var(--muted-foreground);
}

.search:focus-within {
  border-color: var(--ring);
}

/* --- monitor tiles ------------------------------------------------------- */

.tile-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.tile {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  background: var(--muted);
}

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

.tile-label {
  font-size: 0.8125rem;
  font-weight: 500;
}

.tile-note {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.tile-value {
  font-size: 0.875rem;
  font-weight: 600;
}

.tile-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--muted-foreground);
}

.tile-ok     .tile-dot, .tile-dot.tile-ok     { background: var(--chart-2); }
.tile-danger .tile-dot, .tile-dot.tile-danger { background: var(--destructive); }
.tile-warn   .tile-dot, .tile-dot.tile-warn   { background: var(--chart-3); }
.tile-idle   .tile-dot, .tile-dot.tile-idle   { background: var(--muted-foreground); opacity: 0.6; }

.tile-ok     { border-color: color-mix(in oklab, var(--chart-2) 25%, transparent); }
.tile-danger { border-color: color-mix(in oklab, var(--destructive) 35%, transparent); }
.tile-warn   { border-color: color-mix(in oklab, var(--chart-3) 30%, transparent); }

.legend {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top-width: 1px;
}

.legend > div {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}

.legend dt { padding-top: 0.375rem; }

.legend dd {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* --- bar chart ----------------------------------------------------------- */

.chart-plot .bar { fill: var(--chart-2); }
.chart-plot .bar.neg { fill: var(--destructive); }

/* --- NFT gallery --------------------------------------------------------- */

.nft-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}

.nft-card {
  position: relative;
  display: block;
  border-radius: var(--radius-lg);
  border-width: 1px;
  overflow: hidden;
  background: var(--muted);
  transition: border-color 120ms ease, transform 120ms ease;
}

.nft-card:hover {
  border-color: var(--ring);
  transform: translateY(-2px);
}

.nft-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface, var(--muted));
}

.nft-meta {
  display: grid;
  gap: 0.125rem;
  padding: 0.625rem 0.75rem;
}

.nft-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nft-sold {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.625rem;
  font-weight: 600;
}

.swatch {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 2px;
  margin-inline-end: 0.25rem;
  vertical-align: -1px;
  border-width: 1px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: 0.8125rem;
}

/* --- long-form document (Labs charter) ----------------------------------- */

.doc { max-width: 72ch; }

.doc-h {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.doc-h:first-child { margin-top: 0; }

.doc p {
  font-size: 0.9375rem;
  color: var(--muted-foreground);
  margin-bottom: 0.75rem;
}

.doc-list {
  margin: 0 0 0.75rem 1.125rem;
  padding: 0;
  display: grid;
  gap: 0.375rem;
  font-size: 0.9375rem;
  color: var(--muted-foreground);
}

/* --- forms --------------------------------------------------------------- */

.form-stack { display: grid; gap: 0.875rem; }

.field { display: grid; gap: 0.375rem; }

.field > span {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.field input {
  height: 2.25rem;
  padding: 0 0.625rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.875rem;
}

.field input:focus { outline: 2px solid var(--ring); outline-offset: 1px; }

/* --- full width document page -------------------------------------------- */

.card.full { margin-bottom: 1rem; }

.doc-wide { max-width: 80ch; margin-inline: auto; }

.apply-block {
  margin: 2rem 0 2.5rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border-width: 1px;
  background: var(--muted);
}

.apply-h {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
}

.apply-form {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  align-items: end;
}

.apply-form .btn { height: 2.25rem; }

/* --- settings rows ------------------------------------------------------- */

.setting-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  padding-block: 0.875rem;
  border-bottom-width: 1px;
}

/* The field takes the room; the button keeps its own height and sits on the
   same baseline as the input rather than being stretched by the grid. */
.setting-row .field {
  flex: 1 1 12rem;
}

.setting-row > .btn {
  flex: 0 0 auto;
  height: 2.25rem;
  align-self: flex-end;
}

.setting-row:last-of-type { border-bottom-width: 0; }

.setting-row .field { min-width: 0; }

.setting-row .field em {
  font-style: normal;
  font-size: 0.6875rem;
}

.setting-row select {
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.875rem;
}



/* --- multi-series charts ------------------------------------------------- */

.chart-plot .line.s1 { stroke: var(--chart-2); }
.chart-plot .line.s2 { stroke: var(--chart-3); }
.chart-plot .line.s3 { stroke: var(--chart-4); }
.chart-plot .line.s4 { stroke: var(--chart-5); }
.chart-plot .line.s5 { stroke: var(--chart-1); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.chart-legend .key {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.chart-legend .key::before {
  content: "";
  width: 0.75rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.chart-legend .key.s1 { color: var(--chart-2); }
.chart-legend .key.s2 { color: var(--chart-3); }
.chart-legend .key.s3 { color: var(--chart-4); }
.chart-legend .key.s4 { color: var(--chart-5); }
.chart-legend .key.s5 { color: var(--chart-1); }

.axis-note {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  text-align: center;
  margin-top: 0.25rem;
}


/* --- open vs closed trades ----------------------------------------------- */

/* A closed trade is history; an open one is live money. The open rows carry a
   left marker and slightly stronger text so the two are never confused at a
   glance. */
table.data tr.is-open td:first-child {
  box-shadow: inset 3px 0 0 0 var(--chart-2);
}

table.data tr.is-open td {
  background: color-mix(in oklab, var(--chart-2) 5%, transparent);
}

table.data tr.is-closed td {
  color: var(--muted-foreground);
}

table.data tr.is-closed td strong {
  font-weight: 500;
}

.state-open,
.state-closed {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.state-open { color: var(--chart-2); }
.state-closed { color: var(--muted-foreground); }

.state-open::before,
.state-closed::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: currentColor;
}

/* --- connect card actions ------------------------------------------------ */

/* One clear primary action, with the secondary choice sitting quietly under
   it rather than competing for the same visual weight. */
.connect-actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-quiet {
  justify-self: center;
  padding: 0.25rem 0.5rem;
  border: 0;
  background: none;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.btn-quiet:hover { color: var(--foreground); }

.connect-actions .notice-inline {
  margin-top: 0.25rem;
  text-align: center;
}

.connect-secondary {
  display: grid;
  gap: 0.625rem;
  margin-top: 1.25rem;
}

.connect-secondary .prose-p {
  font-size: 0.8125rem;
  margin: 0;
}

.card-content > .rule { margin-top: 1.25rem; }

/* --- sidebar footer, signed in only -------------------------------------- */

.sidebar-balance {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.375rem 0.5rem 0.125rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.sidebar-balance b {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--foreground);
}

.pill-strip-tall { max-height: 26rem; }

/* --- table of contents --------------------------------------------------- */

.toc {
  display: grid;
  gap: 0.375rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
}

.toc a { color: var(--muted-foreground); }
.toc a:hover { color: var(--foreground); text-decoration: underline; }

.doc-h[id] { scroll-margin-top: 5rem; }

/* --- footer risk warning ------------------------------------------------- */

.app-footer {
  text-align: start;
}

.risk {
  max-width: 80ch;
  margin: 0 auto 1rem;
  border-width: 1px;
  border-radius: var(--radius-md);
  background: var(--muted);
}

.risk > summary {
  cursor: pointer;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--foreground);
  list-style: none;
}

.risk > summary::-webkit-details-marker { display: none; }

.risk > summary::before {
  content: "\25B8";
  display: inline-block;
  margin-inline-end: 0.5rem;
  transition: transform 120ms ease;
}

.risk[open] > summary::before { transform: rotate(90deg); }

.risk-body {
  padding: 0 0.875rem 0.875rem;
  display: grid;
  gap: 0.75rem;
}

.risk-body p {
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

.footer-line {
  text-align: center;
  font-size: 0.8125rem;
}

.footer-line a { text-decoration: underline; text-underline-offset: 2px; }

/* --- risk warning: always shown, full width ------------------------------ */

.risk {
  max-width: none;
  margin: 0 0 1rem;
  border-width: 1px;
  border-radius: var(--radius-md);
  background: var(--muted);
  padding: 0.875rem 1rem;
}

.risk-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.risk-body {
  padding: 0;
  display: grid;
  gap: 0.625rem;
}

/* --- sidebar subscribe call to action ------------------------------------ */

.sidebar-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.5rem 0.25rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: filter 120ms ease;
}

.sidebar-cta:hover { filter: brightness(1.08); }

.sidebar-cta svg { width: 0.875rem; height: 0.875rem; }

/* --- exchange API guide -------------------------------------------------- */

.guide {
  margin-top: 0.875rem;
  border-width: 1px;
  border-radius: var(--radius-md);
  background: var(--muted);
}

.guide > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  list-style: none;
}

.guide > summary::-webkit-details-marker { display: none; }

.guide > summary svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--chart-2);
}

.guide > summary::after {
  content: "\25B8";
  margin-inline-start: auto;
  transition: transform 120ms ease;
}

.guide[open] > summary::after { transform: rotate(90deg); }

.guide-body { padding: 0 0.875rem 0.875rem; }

.guide-steps {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--muted-foreground);
}

.guide-steps > li { margin-bottom: 0.3rem; }
.guide-steps > li:last-child { margin-bottom: 0; }

/* The original padded its steps with <br> between every line. Those would
   otherwise reopen the gaps the 60px bullet used to create. */
.guide-steps > li br { display: none; }

.guide-steps > li > div {
  display: block;
  margin: 0.3rem 0 0;
}

.guide-body a {
  color: var(--chart-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- guide content (markup carried from the original) -------------------- */

.guide-body b,
.guide-body strong { color: var(--foreground); }

.guide-body div { margin: 0.375rem 0; }

.guide-body > div:has(b) {
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  background: var(--background);
  border-width: 1px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-all;
}

.guide-shot-title {
  font-size: 0.75rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: var(--muted-foreground);
}

.guide-shots {
  display: grid;
  gap: 0.75rem;
}

.guide-shots img {
  width: 100%;
  border-radius: var(--radius-md);
  border-width: 1px;
}

/* --- daily performance line (Chart::seriesLine) -------------------------- */

.chart-plot .zeroline {
  stroke: var(--muted-foreground);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.55;
  vector-effect: non-scaling-stroke;
}

/* --- overview hero: scrolling statement ---------------------------------- */

.hero {
  margin-bottom: 1.25rem;
}

.marquee {
  position: relative;
  overflow: hidden;
  border-block: 1px solid var(--border);
  padding-block: 0.7rem;
  margin-bottom: 1.1rem;
  /* Fade both ends so the loop point is never visible as a jump. */
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

.marquee-track {
  display: flex;
  width: max-content;
  align-items: center;
  gap: 3.5rem;
  padding-right: 3.5rem;
  animation: marquee-scroll 38s linear infinite;
}

/* Two identical halves, so translating by exactly half the track loops
   seamlessly however wide the viewport is. */
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.marquee:hover .marquee-track {
  animation-play-state: paused;
}

.marquee-item {
  flex: none;
  font-size: clamp(0.95rem, 2.1vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.marquee-item .caret {
  color: var(--chart-2);
  font-weight: 700;
}

.hero-lede {
  max-width: 68ch;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--muted-foreground);
}

@media (prefers-reduced-motion: reduce) {
  .marquee-track {
    animation: none;
    justify-content: center;
  }
}
