/* Reusable pieces: cards, trade rows, badges, stat tiles, forms, tables. */

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 16px; }

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

.trade-list { display: flex; flex-direction: column; gap: 10px; }

.trade-card { overflow: hidden; }

.trade-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: none;
  text-align: left;
}
.trade-row:hover { background: var(--surface-2); }

.ticker-chip {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
  flex-shrink: 0;
}
/* Real company logo overlaying the ticker; the ticker text remains as fallback. */
.ticker-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 15%;
}
.ticker-chip.has-logo {
  background: #fff;
  color: transparent; /* hide the fallback ticker text once the logo is shown */
}

.trade-main { min-width: 0; }
.trade-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trade-sub {
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trade-side { text-align: right; }
.trade-amount { font-weight: 650; font-size: 14.5px; }
.trade-date { color: var(--ink-muted); font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 1.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
/* Buys are the headline signal — a solid fill makes them prominent against the
   washed sell/muted badges. */
.badge-buy { background: var(--buy-mark); color: var(--buy-ink); }
.badge-sell { background: var(--sell-wash); color: var(--sell); }
.badge-muted { background: var(--muted-wash); color: var(--muted-tone); }

/* Rule 10b5-1 marker chip sitting beside a (toggled-in) automated-plan sale. */
.plan-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--muted-wash);
  color: var(--muted-tone);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

/* Marks a row that stands for several Form 4 lines (one order, many fills).
   Quieter than .plan-tag: this is a note about presentation, not about the trade. */
.fills-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--muted-wash);
  color: var(--ink-muted);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: middle;
  cursor: help;
}

/* The fills behind a grouped row, in the expanded card. Columns rather than a
   table: four short cells that must line up, with no header per row. */
.tranche-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.tranche-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
/* "8,852 @ $343.88" reads as one phrase on the left, with the fill's value in
   the right-hand column the card already uses for money. */
.tranche-row {
  display: grid;
  grid-template-columns: minmax(56px, auto) auto minmax(72px, auto) 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tranche-row .tranche-shares { text-align: right; }
.tranche-row .tranche-at { color: var(--ink-muted); }
.tranche-row .tranche-price { text-align: right; }
.tranche-row .tranche-value { text-align: right; font-weight: 600; }

/* A "noise" trade shown only because its category is toggled on — de-emphasised
   so the P/S signal stays dominant in any list. */
.trade-card.is-muted .trade-title,
.trade-card.is-muted .trade-amount { color: var(--muted-tone); }
.trade-card.is-muted .ticker-chip { opacity: 0.85; }

/* Filing footer strip — the always-visible "SEC Filing" link on every record */
.trade-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  border-top: 1px solid var(--hairline);
}
.trade-foot-meta {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sec-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-wash);
}
.sec-link:hover { background: var(--cta); color: #fff; }
.sec-link svg { width: 13px; height: 13px; }

.pill-link svg { width: 13px; height: 13px; }

/* Expanded details inside a trade card */
.trade-detail {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--hairline);
  animation: expand-in 0.15s ease-out;
}
@keyframes expand-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px 20px;
  padding: 12px 0;
}
.detail-grid dt { font-size: 11.5px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-grid dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; }
.detail-grid > div { min-width: 0; }

.trade-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--cta);
  border-color: var(--cta);
  color: #fff;
}
.btn-primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }

.btn-danger { color: var(--sell); }

/* A starred row is amber, not brand-red: the star means "kept", and red already
   means both "act on this" (buttons) and "sale" (badges). */
.btn-star.is-on { color: var(--highlight); border-color: var(--highlight-mark); background: var(--highlight-wash); }

/* ---------- Stat tiles ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.stat-tile { padding: 14px 16px; }
.stat-label { font-size: 12.5px; color: var(--ink-2); }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }
.stat-delta { font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.stat-delta.up { color: var(--buy); }
.stat-delta.down { color: var(--sell); }
.stat-delta.flat { color: var(--ink-muted); }

/* ---------- Leaderboard (insiders) ---------- */

.leader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

/* Horizontal carousel: a scrollable track flanked by prev/next arrows. */
.leader-carousel {
  position: relative;
  display: flex;
  align-items: center;
}
.leader-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  /* No CSS scroll-snap: releasing a drag would re-enable it and the browser
     would jump to the nearest card in one frame. Paging and post-drag settling
     are both eased in JS (rAF) instead, so the track never flicks. */
  /* only vertical padding so the first card sits flush at scrollLeft 0
     (horizontal padding would offset it and mis-trigger the prev arrow) */
  padding: 4px 0 8px;
  scrollbar-width: none; /* Firefox */
  cursor: grab;
  user-select: none; /* dragging the track shouldn't select card text */
}
.leader-scroll::-webkit-scrollbar { display: none; } /* WebKit */
.leader-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}
/* While a mouse drag is in progress: grabbing cursor, and links inert so a drag
   never reads as a click on a card. */
.leader-scroll.dragging { cursor: grabbing; }
.leader-scroll.dragging a { pointer-events: none; }
.leader-scroll .leader-card {
  flex: 0 0 clamp(240px, 26%, 280px);
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.carousel-arrow.prev { left: -6px; }
.carousel-arrow.next { right: -6px; }
.carousel-arrow:hover { background: var(--cta); color: #fff; border-color: var(--cta); }
.carousel-arrow[hidden] { display: none; }

.leader-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  text-align: left;
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.leader-card:hover { border-color: var(--accent); }

.leader-top { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.leader-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.leader-role { font-size: 12.5px; color: var(--ink-2); }

.leader-stats { display: flex; gap: 16px; align-items: flex-end; }
.leader-stat .ls-label { font-size: 11px; color: var(--ink-muted); }
.leader-stat .ls-value { font-size: 15px; font-weight: 650; }
.leader-stat .ls-value.up { color: var(--buy); }
.leader-stat .ls-value.down { color: var(--sell); }
.leader-spark { margin-left: auto; }

/* ---------- Sparkline ---------- */

.sparkline { display: block; }
.sparkline .spark-line { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sparkline .spark-fill { fill: var(--accent); opacity: 0.1; }
.sparkline .spark-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.sparkline .spark-base { stroke: var(--grid); stroke-width: 1; }

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.filter-bar select,
.filter-bar input[type="search"],
.filter-bar input[type="number"],
.filter-bar .combo input {
  padding: 7px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
}
.filter-bar input[type="search"] { flex: 1 1 180px; min-width: 140px; }

/* The search combobox takes the search field's slot; its input fills the wrapper
   and leaves room for the chevron that sits over the right end. */
.filter-bar .combo { flex: 1 1 180px; min-width: 140px; }
.filter-bar .combo input { width: 100%; padding-right: 34px; }
.filter-bar select:focus, .filter-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  padding: 2px;
}
.seg button {
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.seg button.is-active { background: var(--cta); color: #fff; }

/* A buy/sell segment carries the same colour as the PURCHASE/SALE badges, so the
   filter and the rows it produces speak one language: solid green for buys, a
   washed red for sells. "All" stays on the neutral accent. */
.seg button[data-type="buy"] { color: var(--buy-mark); }
.seg button[data-type="sell"] { color: var(--sell); }
.seg button[data-type="buy"].is-active { background: var(--buy-mark); color: var(--buy-ink); }
/* The washed sell chip keeps its red ink; it must outrank the solid-fill rule above. */
.seg button[data-type="sell"].is-active {
  background: var(--sell-wash);
  color: var(--sell);
}

.result-count { font-size: 13px; color: var(--ink-muted); margin: 4px 2px 10px; }

/* Active bucket-range chip — shown when the Database was opened from a chart bar. */
.range-row:empty { display: none; }
.range-row { margin: 2px 2px 0; }
.range-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink);
}
.range-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.range-chip-x:hover { background: var(--border); color: var(--ink); }

/* ---------- Forms ---------- */

.form-grid { display: grid; gap: 12px; }
.form-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-field select,
.form-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--page);
}
/* Drop the browser's default arrow for a themed chevron pinned to the same
   gutter the sibling comboboxes use — icon centre 16px from the right edge — so
   every arrow in the alert form lines up in one column. */
.form-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2352525b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}
/* Dark-theme caret: the SVG's stroke is baked in, so swap the whole data URI to
   the dark --ink-2 (zinc-400) that the sibling combo carets use. */
:root[data-theme="dark"] .form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.form-field select:focus, .form-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.form-hint { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.form-hint.is-valid { color: var(--buy); }

/* ---------- Combobox (type-to-filter + browsable list) ---------- */

.combo { position: relative; }

/* The input keeps the .form-field box styling; just reserve room for the chevron. */
.form-field .combo input { padding-right: 34px; }

.combo-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 32px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

/* A <select> can't render markup inside its options, so a field whose choices are
   badges uses this button + .combo-list pair instead. It borrows the select box
   styling so it sits in the same column as its plain-<select> siblings. */
.combo-button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 39px;
  padding: 6px 34px 6px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--page);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.combo-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
/* The chevron is a sibling overlay on the input variant; here it's inside the
   button, so pin it to the padding gutter rather than letting it join the flow.
   The 8px inset puts its centre 16px from the edge — where .combo-toggle centres
   the identical icon in its 32px well, so the two fields' chevrons line up. */
.combo-button .combo-caret {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-2);
  pointer-events: none;
}

/* Joins the two badges of a combined choice ("Purchase & Sale"). The button lays
   its children out with flex gap; a list row is plain inline flow, so it needs
   its own margins. */
.badge-sep { color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.combo-item .badge-sep { margin: 0 6px; }

.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
}
.combo-item {
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.combo-item.is-active { background: var(--accent-wash); }
.combo-item.is-selected { font-weight: 600; }
.combo-empty { padding: 10px 12px; font-size: 13px; color: var(--ink-muted); }

/* A combobox dressed as the header's global search: same pill, same magnifier,
   same wide rows with a logo and a dim trailing note. The chevron stays — this
   field also browses the whole list, which the header search doesn't offer. */
.combo-search .search-icon { z-index: 1; }
/* `.combo.combo-search` rather than `.combo-search`, to match the specificity of
   the `.filter-bar .combo input` padding this has to override. */
.combo.combo-search input { padding-left: 36px; }
/* The pill is the filter bar's shape, not the search field's. In a form the box
   keeps its `.form-field` corners, so it sits in the same column as its siblings. */
.filter-bar .combo-search input { border-radius: 999px; }
/* The field is a filter-bar pill, far narrower than the header's search box, so
   the list is allowed to grow past it rather than wrapping every long name. */
.combo-search .combo-list {
  padding: 0;
  min-width: min(420px, 86vw);
  max-height: 60vh;
  border-radius: var(--radius);
}
.combo-group {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.combo-item-rich { display: flex; align-items: center; gap: 10px; padding: 9px 14px; }
/* The name yields first: it truncates, while the chip and the note keep their size. */
.combo-item-rich .ci-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-item-rich .ci-sub { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }

/* ---------- Range slider ---------- */

/* Sits in the same bordered box as the sibling <select>s, at the same height,
   so the field reads as one of the row rather than a bare control. */
.range-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--page);
}
.range-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.range-value {
  flex: 0 0 auto;
  min-width: 62px;
  text-align: right;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.range-ends {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-muted);
  /* clear the value readout so the ends line up under the track itself */
  margin: 4px 86px 0 12px;
}

/* Undo the .form-field input box styling — a range is a track, not a textbox. */
.form-field input[type="range"] {
  flex: 1;
  width: auto;
  padding: 0;
  border: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  height: 20px;
  cursor: pointer;
}
.form-field input[type="range"]:focus { box-shadow: none; }

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--hairline);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--hairline);
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px; /* centres the thumb on the 4px track */
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--page);
  box-shadow: var(--shadow);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--page);
  box-shadow: var(--shadow);
}

/* ---------- Switch ---------- */

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--cta); border-color: var(--cta); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: #fff; }
/* The locked "strictly necessary" switch: on, and visibly not yours to change. */
.switch:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Cookie consent (see js/consent.js) ----------
   Banner and dialog share the accept/reject pair. "Reject all" is a peer of
   "Accept all" — same size, same row, same prominence — because refusing must
   be no harder than consenting. Neither is styled to be the obvious choice. */

.ck-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 70;
  width: min(940px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.ck-banner-copy { max-width: 62ch; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.ck-banner-copy a { color: var(--accent); text-decoration: underline; }
.ck-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ck-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  overflow-y: auto;
}

.ck-panel {
  width: min(600px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.ck-head { padding: 22px 24px 18px; border-bottom: 1px solid var(--hairline); }
.ck-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.ck-head p { margin-top: 6px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.ck-head a { color: var(--ink); text-decoration: underline; font-weight: 600; }

.ck-rows { overflow-y: auto; padding: 0 24px; }
.ck-row { padding: 20px 0; border-top: 1px solid var(--hairline); }
.ck-row:first-child { border-top: 0; }
.ck-row-head { display: flex; align-items: center; gap: 10px; }
.ck-row-head h3 { font-size: 14px; font-weight: 600; color: var(--ink); }
.ck-row-head .switch { margin-left: auto; }

.ck-always {
  padding: 3px 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.ck-row-body { margin-top: 8px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.ck-row-note { margin-top: 8px; font-size: 11.5px; line-height: 1.5; color: var(--ink-muted); }

.ck-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px;
  border-top: 1px solid var(--hairline);
}

@media (max-width: 560px) {
  .ck-banner-actions, .ck-actions { width: 100%; }
  .ck-banner-actions .btn, .ck-actions .btn { flex: 1; justify-content: center; }
}

/* ---------- History table ---------- */

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; }
.data-table th.num { text-align: right; }

/* The trade being viewed, marked in its own history row rather than filtered
   out — a wash tint plus a static label standing where the "View" link is on
   every other row. */
.data-table tr.is-current-row { background: var(--accent-wash); }
.pill-link.is-current { color: var(--ink-muted); font-weight: 600; cursor: default; }
.roi-up { color: var(--buy); font-weight: 600; }
.roi-down { color: var(--sell); font-weight: 600; }

/* ---------- Empty state ---------- */

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty .empty-icon { font-size: 34px; margin-bottom: 8px; }
.empty h3 { font-size: 16px; margin-bottom: 4px; color: var(--ink); }
.empty p { font-size: 13.5px; max-width: 380px; margin: 0 auto 16px; }

/* ---------- Misc ---------- */

.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.pill-link:hover { text-decoration: underline; }

.muted { color: var(--ink-muted); }
.mono-num { font-variant-numeric: tabular-nums; }

/* ---------- Loading skeletons ---------- */

.skl-bar, .skl-chip {
  display: block;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--hairline) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: skl-shimmer 1.4s ease-in-out infinite;
}
@keyframes skl-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skl-bar, .skl-chip { animation: none; }
}

.skl-head { margin-bottom: 20px; }
.skl-head .skl-bar + .skl-bar,
.stat-tile .skl-bar + .skl-bar { margin-top: 10px; }

.skl-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}
.skl-chip { width: 44px; height: 44px; border-radius: 10px; }
.skl-lines { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.skl-amt { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
