/* FlowDesk components (FlowSuite look). Most are produced by web/js/core/ui.js helpers;
   the class names are stable so views can also use them directly in markup. */

/* ================================================================== buttons */
.btn {
  --btn-bg: var(--panel);
  --btn-fg: var(--text);
  --btn-bd: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 22px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: 1.1;
  letter-spacing: var(--ls-body);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease), color var(--dur-fast);
}

.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled,
.btn.is-disabled { opacity: 0.5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }

/* primary blue pill (template "Get started" / "+ New") */
.btn--primary {
  --btn-bg: var(--blue);
  --btn-fg: #fff;
  box-shadow: var(--tag-highlight);
}
.btn--primary:hover { --btn-bg: #0047e0; box-shadow: var(--shadow-blue); }

/* black pill */
.btn--dark {
  --btn-bg: #000;
  --btn-fg: #fff;
}
.btn--dark:hover { --btn-bg: #1d1d1f; }
[data-theme="dark"] .btn--dark { --btn-bg: #f4f6fa; --btn-fg: #0c0e13; }
[data-theme="dark"] .btn--dark:hover { --btn-bg: #fff; }

/* outline (template "Sort", "Filter", "Monthly v") */
.btn--outline {
  --btn-bg: var(--panel);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  border-radius: var(--r-item);
  font-size: var(--fs-sm);
  min-height: 38px;
  padding: 8px 16px;
}
.btn--outline:hover { --btn-bg: var(--hover); --btn-bd: var(--border-strong); }
.btn--outline.is-active { --btn-bd: var(--blue); --btn-fg: var(--blue-ink); --btn-bg: var(--blue-tint); }

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-2);
  border-radius: var(--r-item);
  font-size: var(--fs-sm);
  padding: 8px 12px;
  min-height: 36px;
}
.btn--ghost:hover { --btn-bg: var(--hover); --btn-fg: var(--text); }

.btn--soft {
  --btn-bg: var(--blue-tint);
  --btn-fg: var(--blue-ink);
}
.btn--soft:hover { --btn-bg: color-mix(in srgb, var(--blue) 16%, var(--panel)); }

.btn--white {
  --btn-bg: #fff;
  --btn-fg: #000;
  box-shadow: var(--shadow-sm);
}
.btn--white:hover { --btn-bg: #f3f6ff; }

.btn--danger {
  --btn-bg: var(--red);
  --btn-fg: #fff;
}
.btn--danger:hover { --btn-bg: #f04444; }

.btn--success {
  --btn-bg: var(--green);
  --btn-fg: #fff;
}
.btn--success:hover { --btn-bg: #0ea35d; }

.btn--danger-soft {
  --btn-bg: var(--red-tint);
  --btn-fg: var(--red-ink);
}

.btn--sm {
  min-height: 32px;
  padding: 6px 14px;
  font-size: var(--fs-sm);
  gap: 6px;
}
.btn--sm svg { width: 16px; height: 16px; }

.btn--lg {
  min-height: 52px;
  padding: 14px 28px;
  font-size: 17px;
}

.btn--block { width: 100%; }

.btn--icon {
  padding: 0;
  width: 40px;
  min-width: 40px;
  height: 40px;
}
.btn--icon.btn--sm { width: 32px; min-width: 32px; height: 32px; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  animation: fd-spin 0.7s linear infinite;
}

/* small round icon button (menus, close, bell) */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-3);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn--sm svg { width: 16px; height: 16px; }
.icon-btn--round { border-radius: 50%; }
.icon-btn--bordered { border: 1px solid var(--border); background: var(--panel); }
.icon-btn.is-active { color: var(--blue-ink); background: var(--blue-tint); }

/* big Long / Short buttons */
.side-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 84px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: var(--ls-tight);
  transition: all var(--dur-fast) var(--ease);
}
.side-btn small { font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: var(--ls-body); }
.side-btn svg { width: 22px; height: 22px; }
.side-btn--long:hover { border-color: var(--green); background: var(--green-tint); }
.side-btn--short:hover { border-color: var(--red); background: var(--red-tint); }
.side-btn--long.is-active { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 8px 22px rgba(18, 183, 106, 0.3); }
.side-btn--short.is-active { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 8px 22px rgba(255, 91, 91, 0.3); }
.side-btn.is-active small { color: rgba(255, 255, 255, 0.85); }

/* ================================================================== segmented control */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-radius: var(--r-tag);
  background: var(--bg-soft);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }

.seg__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 16px;
  border-radius: var(--r-seg);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast);
}
.seg__item:hover { color: var(--text); background: color-mix(in srgb, var(--panel) 60%, transparent); }
.seg__item.is-active {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--tag-highlight), 0 2px 6px rgba(4, 84, 255, 0.25);
}
.seg__item svg { width: 16px; height: 16px; }
.seg__count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--panel);
  color: var(--text-3);
}
.seg__item.is-active .seg__count { background: rgba(255, 255, 255, 0.22); color: #fff; }

.seg--sm { padding: 4px; }
.seg--sm .seg__item { min-height: 28px; padding: 4px 12px; font-size: 13px; }
.seg--block { display: flex; width: 100%; }
.seg--block .seg__item { flex: 1 1 0; }

/* ================================================================== cards */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  color: var(--text-2);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 0;
  min-width: 0;
}

.card__heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card__heading > svg { width: 22px; height: 22px; color: var(--text-2); }

.card__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  color: var(--text);
  line-height: 1.2;
  min-width: 0;
}

.card__sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 2px; }
.card__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.card__body { padding: 20px 24px 24px; min-width: 0; flex: 1 1 auto; }
.card__body--flush { padding: 16px 0 0; }
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.card--raised { border-color: transparent; box-shadow: var(--shadow-card); }
.card--flat { background: var(--bg-soft); border-color: transparent; }
.card--big { border-radius: var(--r-big); }
.card--kpi { border-radius: var(--r-kpi); }
.card--clickable { cursor: pointer; transition: box-shadow var(--dur), border-color var(--dur); }
.card--clickable:hover { box-shadow: var(--shadow-card); border-color: transparent; }

.card--blue {
  background: var(--blue);
  border-color: var(--blue);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: var(--tag-highlight);
}
.card--blue .card__title,
.card--blue .card__heading > svg { color: #fff; }
.card--blue .card__sub,
.card--blue .card__foot { color: rgba(255, 255, 255, 0.75); }
.card--blue .card__foot { border-top-color: rgba(255, 255, 255, 0.2); }
.card--blue .icon-btn { color: rgba(255, 255, 255, 0.85); }
.card--blue .icon-btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.card--gradient {
  background: var(--grad);
  border-color: transparent;
  color: rgba(255, 255, 255, 0.92);
  overflow: hidden;
  isolation: isolate;
}
.card--gradient::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(80% 60% at 100% 100%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 70%);
}
.card--gradient .card__title { color: #fff; }
.card--gradient .card__sub { color: rgba(255, 255, 255, 0.82); }
.card--gradient .icon-btn { color: #fff; }
.card--gradient .icon-btn:hover { background: rgba(255, 255, 255, 0.18); }

.card--danger { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: color-mix(in srgb, var(--red-tint) 60%, var(--panel)); }
.card--success { border-color: color-mix(in srgb, var(--green) 45%, var(--border)); }

/* ================================================================== KPI cards */
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  min-height: 132px;
  padding: 18px 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-kpi);
  background: var(--panel);
  color: var(--text-2);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur), transform var(--dur-fast);
}

.kpi__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.kpi__label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--fs-base);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi__label small { color: var(--text-3); font-size: 13px; }
.kpi__menu { margin: -6px -8px -6px 0; }

.kpi__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; min-width: 0; flex-wrap: wrap; }
.kpi__value {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border-radius: 6px;
}
.kpi__delta {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.2;
}
.kpi__delta.up { color: var(--up-ink); }
.kpi__delta.down { color: var(--down-ink); }
.kpi__sub { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; min-width: 0; }
.kpi__spark { height: 34px; margin-top: -6px; }

.kpi--blue {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: var(--tag-highlight);
}
.kpi--blue .kpi__label,
.kpi--blue .kpi__value,
.kpi--blue .kpi__delta,
.kpi--blue .kpi__delta.up,
.kpi--blue .kpi__delta.down { color: #fff; }
.kpi--blue .kpi__label small,
.kpi--blue .kpi__sub { color: rgba(255, 255, 255, 0.78); }
.kpi--blue .icon-btn { color: rgba(255, 255, 255, 0.9); }
.kpi--blue .icon-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.kpi--blue .tag { background: rgba(255, 255, 255, 0.18); color: #fff; }

.kpi--gradient { background: var(--grad); border-color: transparent; color: #fff; }
.kpi--gradient .kpi__label, .kpi--gradient .kpi__value, .kpi--gradient .kpi__delta { color: #fff; }

.kpi--clickable { cursor: pointer; }
.kpi--clickable:hover { box-shadow: var(--shadow-card); border-color: transparent; }
.kpi--clickable.kpi--blue:hover { border-color: var(--blue); box-shadow: var(--shadow-blue); }
.kpi.is-active:not(.kpi--blue) { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }

.flash-up { animation: fd-flash-up 0.9s var(--ease); }
.flash-down { animation: fd-flash-down 0.9s var(--ease); }
.kpi--blue .flash-up,
.kpi--blue .flash-down { animation: fd-flash-white 0.9s var(--ease); }

/* ================================================================== stats */
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat__label { font-size: var(--fs-sm); color: var(--text-3); }
.stat__value { font-size: var(--fs-2xl); font-weight: 600; color: var(--text); letter-spacing: var(--ls-tight); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__sub { font-size: 13px; color: var(--text-3); }
.stat--sm .stat__value { font-size: var(--fs-lg); }

/* key / value list */
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 8px 18px; font-size: var(--fs-sm); }
.kv dt, .kv__k { color: var(--text-3); margin: 0; }
.kv dd, .kv__v { color: var(--text); margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ================================================================== tags / chips */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--r-tag);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: var(--tag-highlight);
  max-width: 100%;
}
.tag svg { width: 14px; height: 14px; }
.tag--sm { padding: 3px 10px; font-size: 12px; gap: 4px; }
.tag--sm svg { width: 12px; height: 12px; }
.tag--xs { padding: 1px 7px; font-size: 11px; font-weight: 600; gap: 3px; }

.tag--blue { background: var(--blue-tint); color: var(--blue-ink); }
.tag--red { background: var(--red-tint); color: var(--red-ink); }
.tag--green { background: var(--green-tint); color: var(--green-ink); }
.tag--amber { background: var(--amber-tint); color: var(--amber-ink); }
.tag--purple { background: var(--purple-tint); color: var(--purple-ink); }
.tag--gold { background: var(--gold-tint); color: var(--gold-ink); }
.tag--gray { background: var(--bg-soft); color: var(--text-3); }
.tag--dark { background: #111; color: #fff; }
[data-theme="dark"] .tag--dark { background: #f4f6fa; color: #0c0e13; }
.tag--solid { background: var(--blue); color: #fff; }
.tag--solid-red { background: var(--red); color: #fff; }
.tag--solid-green { background: var(--green); color: #fff; }
.tag--solid-amber { background: var(--amber); color: #1a1100; }
.tag--outline { background: transparent; color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border); }
.tag--striped {
  color: var(--text-3);
  background: repeating-linear-gradient(135deg, var(--bg-soft) 0 6px, color-mix(in srgb, var(--bg-soft) 40%, var(--border)) 6px 8px);
}

.tag--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.tag--clickable { cursor: pointer; transition: filter var(--dur-fast); }
.tag--clickable:hover { filter: brightness(0.96); }
.tag__x { margin-right: -6px; opacity: 0.6; display: inline-flex; }
.tag__x:hover { opacity: 1; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }

/* instrument chip (like the template's coloured project icons) */
.inst-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  color: #fff;
  background: var(--blue);
  flex-shrink: 0;
  box-shadow: var(--tag-highlight);
}
.inst-chip--NQ { background: #0454ff; }
.inst-chip--ES { background: #7e5bff; }
.inst-chip--CL { background: #1f2937; }
.inst-chip--GC { background: #d4a106; }
.inst-chip--YM { background: #0e9384; }
[data-theme="dark"] .inst-chip--CL { background: #3b4558; }
.inst-chip--sm { width: 22px; height: 22px; font-size: 9.5px; border-radius: 6px; }
.inst-chip--lg { width: 36px; height: 36px; font-size: 13px; border-radius: 10px; }
/* four-letter display names ("US30") */
.inst-chip--long { font-size: 8.5px; letter-spacing: -0.03em; }
.inst-chip--long.inst-chip--sm { font-size: 7px; letter-spacing: -0.04em; }
.inst-chip--long.inst-chip--lg { font-size: 11px; }

/* ================================================================== badges & dots */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  background: var(--bg-soft);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge--blue { background: var(--blue); color: #fff; }
.badge--red { background: var(--red); color: #fff; }
.badge--green { background: var(--green); color: #fff; }
.badge--amber { background: var(--amber); color: #1a1100; }
.badge--purple { background: var(--purple); color: #fff; }
.badge--soft-blue { background: var(--blue-tint); color: var(--blue-ink); }
.badge--soft-red { background: var(--red-tint); color: var(--red-ink); }
.badge--soft-green { background: var(--green-tint); color: var(--green-ink); }
.badge--soft-amber { background: var(--amber-tint); color: var(--amber-ink); }
.badge--soft-purple { background: var(--purple-tint); color: var(--purple-ink); }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--text-3); }
.badge--corner {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10.5px;
  border: 2px solid var(--panel);
  box-sizing: content-box;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-4);
  flex-shrink: 0;
}
.dot--green { background: var(--green); }
.dot--red { background: var(--red); }
.dot--amber { background: var(--amber); }
.dot--blue { background: var(--blue); }
.dot--purple { background: var(--purple); }
.dot--gray { background: var(--text-4); }
.dot--lg { width: 10px; height: 10px; }
.dot--pulse { position: relative; }
.dot--pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: fd-pulse 1.8s ease-out infinite;
}

/* live / mode pill */
.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-tag);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.mode-pill--live { background: var(--green-tint); color: var(--green-ink); }
.mode-pill--proxy { background: var(--blue-tint); color: var(--blue-ink); }
.mode-pill--replay { background: var(--purple-tint); color: var(--purple-ink); }
.mode-pill--delayed { background: var(--amber-tint); color: var(--amber-ink); }
.mode-pill--offline { background: var(--bg-soft); color: var(--text-3); }

/* ================================================================== tables */
.table-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap--scroll { overflow-y: auto; }

.table {
  width: 100%;
  font-size: var(--fs-md);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.table th {
  position: relative;
  padding: 14px 16px;
  text-align: left;
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
  color: var(--text-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.table-wrap--scroll .table th { position: sticky; top: 0; z-index: 1; }
.table--no-top th { border-top: 0; }

.table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table td.muted,
.table td .muted { color: var(--text-3); }
.table tr:last-child td { border-bottom: 0; }
.table--lined tr:last-child td { border-bottom: 1px solid var(--border); }

.table th:first-child,
.table td:first-child { padding-left: 24px; }
.table th:last-child,
.table td:last-child { padding-right: 24px; }

.table .is-right { text-align: right; }
.table .is-center { text-align: center; }
.table .is-nowrap { white-space: nowrap; }
.table .is-shrink { width: 1%; white-space: nowrap; }

.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-selected { background: var(--blue-tint); }
.table tbody tr.is-new { animation: fd-row-new 3s var(--ease); }

.table--dense { font-size: var(--fs-sm); }
.table--dense th { padding: 10px 12px; font-size: 13px; }
.table--dense td { padding: 10px 12px; }
.table--dense th:first-child, .table--dense td:first-child { padding-left: 16px; }
.table--dense th:last-child, .table--dense td:last-child { padding-right: 16px; }

.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text); }
.th-sort__icon { display: inline-block; margin-left: 4px; opacity: 0.35; font-size: 10px; vertical-align: 1px; }
.is-sorted-asc .th-sort__icon,
.is-sorted-desc .th-sort__icon { opacity: 1; color: var(--blue-ink); }

.table__empty { padding: 36px 16px !important; text-align: center; color: var(--text-3) !important; }

/* stacked rows on phones: add .table--stack, cells carry data-label */
@media (max-width: 599px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table--stack td { padding: 3px 0 !important; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--text-3); font-size: 13px; text-align: left; flex-shrink: 0; }
  .table--stack td[data-label=""]::before { display: none; }
  .table--stack td.is-primary { display: block; text-align: left; font-weight: 600; padding-bottom: 6px !important; }
  .table--stack td.is-primary::before { display: none; }
  /* "shrink" columns are 1% wide on desktop; stacked they need the full row or their chips collapse */
  .table--stack td.is-shrink { width: 100%; }
}

/* checkbox (template rounded square) */
.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  flex-shrink: 0;
}
.checkbox::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform var(--dur-fast) var(--ease);
}
.checkbox:checked { background: var(--blue); border-color: var(--blue); }
.checkbox:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.checkbox:indeterminate { background: var(--blue); border-color: var(--blue); }
.checkbox:indeterminate::after { border-left: 0; width: 10px; height: 0; transform: none; }

/* ================================================================== forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field__hint { font-size: 13px; color: var(--text-3); }
.field--error .input, .field--error .select, .field--error .textarea { border-color: var(--red); }
.field--error .field__hint { color: var(--red-ink); }
.field--warn .field__hint { color: var(--amber-ink); }
.fields { display: grid; gap: 14px; }
.fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: var(--fs-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-soft); color: var(--text-3); }
.input--num { font-variant-numeric: tabular-nums; }
.input--sm, .select--sm { min-height: 36px; padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--r-item); }
.input--lg { min-height: 52px; font-size: 18px; font-weight: 600; }
.textarea { min-height: 88px; resize: vertical; line-height: 1.45; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%236d6d6d' 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 12px center;
  background-size: 16px;
}
/* outline-button look ("Monthly v", "Total Product Insights v") */
.select--outline {
  min-height: 38px;
  padding: 7px 36px 7px 14px;
  border-radius: var(--r-item);
  font-size: var(--fs-sm);
  font-weight: 600;
  width: auto;
}

.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap > svg {
  position: absolute;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--text-3);
  pointer-events: none;
}
.input-wrap > .input { padding-left: 40px; }
.input-wrap__suffix {
  position: absolute;
  right: 12px;
  font-size: var(--fs-sm);
  color: var(--text-3);
  pointer-events: none;
}
.input-wrap--suffix > .input { padding-right: 52px; }
.input-wrap__clear {
  position: absolute;
  right: 8px;
}

/* search pill (filter bars) */
.search {
  border-radius: var(--r-tag);
  background: var(--bg-soft);
  border-color: transparent;
}
.search:hover { border-color: var(--border); }
.search:focus { background: var(--panel); }

/* switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch__track {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 24px;
  background: var(--border-strong);
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--blue); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--focus-ring); }
.switch input:disabled + .switch__track { opacity: 0.5; }
.switch--sm .switch__track { width: 32px; height: 20px; }
.switch--sm .switch__track::after { width: 14px; height: 14px; }
.switch--sm input:checked + .switch__track::after { transform: translateX(12px); }

/* ================================================================== tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  transition: color var(--dur-fast);
}
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { color: var(--text); }
.tabs__item.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
}
.tabs__item svg { width: 18px; height: 18px; }

/* ================================================================== popover / menu */
.popover {
  position: fixed;
  z-index: var(--z-popover);
  min-width: 200px;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 560px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  animation: fd-pop-in var(--dur) var(--ease);
  transform-origin: top right;
}
.popover--flush { padding: 0; }

.menu { display: flex; flex-direction: column; padding: 6px; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-item);
  text-align: left;
  font-size: var(--fs-sm);
  color: var(--text-2);
  white-space: nowrap;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--hover); color: var(--text); outline: none; }
.menu__item svg { width: 18px; height: 18px; color: var(--text-3); }
.menu__item.is-active { color: var(--blue-ink); }
.menu__item.is-active svg { color: var(--blue-ink); }
.menu__item--danger { color: var(--red-ink); }
.menu__item--danger svg { color: var(--red-ink); }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--border); }
.menu__label { padding: 8px 12px 4px; font-size: 12px; color: var(--text-3); }

/* ================================================================== drawer */
.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.drawer-backdrop { z-index: var(--z-drawer); }
.modal-backdrop { z-index: var(--z-modal); display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.drawer-backdrop.is-open,
.modal-backdrop.is-open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  width: min(520px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease);
}
.drawer--wide { width: min(760px, 100vw); }
.drawer.is-open { transform: none; }
.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer__title { font-size: var(--fs-xl); font-weight: 600; color: var(--text); letter-spacing: var(--ls-tight); line-height: 1.25; }
.drawer__sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 4px; }
.drawer__body { flex: 1 1 auto; overflow-y: auto; padding: 20px 24px 28px; overscroll-behavior: contain; }
.drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border);
}

/* phones: drawers become bottom sheets */
@media (max-width: 599px) {
  .drawer {
    top: auto;
    left: 0;
    width: 100vw;
    max-height: 92vh;
    max-height: 92dvh;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .drawer::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 4px;
    background: var(--border-strong);
  }
  .drawer__head { padding: 22px 16px 12px; }
  .drawer__body { padding: 16px 16px calc(24px + var(--safe-bottom)); }
  .drawer__foot { padding: 12px 16px calc(12px + var(--safe-bottom)); }
}

/* ================================================================== modal */
.modal {
  position: relative;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  background: var(--panel);
  border-radius: var(--r-big);
  box-shadow: var(--shadow-pop);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
}
.modal-backdrop.is-open .modal { transform: none; opacity: 1; }
.modal--sm { width: min(400px, 100%); }
.modal--lg { width: min(760px, 100%); }
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 24px 8px;
}
.modal__title { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.03em; line-height: 1.2; }
.modal__sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 6px; }
.modal__body { padding: 16px 24px 8px; overflow-y: auto; min-height: 0; }
.modal__foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 16px 24px 24px; }
.modal__foot--split { justify-content: space-between; }

@media (max-width: 599px) {
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal {
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    transform: translateY(40px);
  }
  .modal__head { padding: 20px 16px 6px; }
  .modal__body { padding: 12px 16px 8px; }
  .modal__foot { padding: 12px 16px calc(16px + var(--safe-bottom)); }
  .modal__foot .btn { flex: 1 1 auto; }
}

/* ================================================================== toasts */
.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 14px 14px 16px;
  border-radius: 14px;
  background: #111318;
  color: #fff;
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  font-size: var(--fs-sm);
  line-height: 1.4;
  animation: fd-toast-in var(--dur-slow) var(--ease);
  border-left: 4px solid transparent;
}
[data-theme="dark"] .toast { background: #1d2230; border: 1px solid var(--border); border-left-width: 4px; }
.toast.is-leaving { animation: fd-toast-out var(--dur) var(--ease) forwards; }
.toast--clickable { cursor: pointer; }
.toast__icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast__icon svg { width: 20px; height: 20px; }
.toast__body { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast__title { font-weight: 600; font-size: var(--fs-md); margin-bottom: 2px; }
.toast__text { color: rgba(255, 255, 255, 0.82); }
.toast__action { margin-top: 8px; }
.toast__action .btn { min-height: 30px; padding: 5px 12px; font-size: 13px; }
.toast__close { color: rgba(255, 255, 255, 0.6); margin: -4px -4px 0 0; }
.toast__close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.toast--success { border-left-color: var(--green); }
.toast--success .toast__icon { color: var(--green); }
.toast--error { border-left-color: var(--red); }
.toast--error .toast__icon { color: var(--red); }
.toast--warn { border-left-color: var(--amber); }
.toast--warn .toast__icon { color: var(--amber); }
.toast--info .toast__icon { color: var(--blue-light); }
.toast--blue { background: var(--blue); }
.toast--blue .toast__text { color: rgba(255, 255, 255, 0.9); }
.toast--critical { background: #b42318; border-left-color: #fff; }
.toast--critical .toast__text { color: rgba(255, 255, 255, 0.92); }

@media (max-width: 899px) {
  .toasts {
    left: 16px;
    right: 16px;
    width: auto;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
    align-items: stretch;
  }
}

/* ================================================================== gauge (half donut, hatched remainder) */
.gauge { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; }
.gauge__svg { width: 100%; max-width: 340px; height: auto; overflow: visible; }
.gauge__track { fill: none; stroke-linecap: round; }
.gauge__fill { fill: none; stroke-linecap: round; transition: stroke-dasharray 0.8s var(--ease), stroke var(--dur); }
.gauge__fill2 { fill: none; stroke-linecap: round; stroke: var(--gauge-2, #d6e3ff); transition: stroke-dasharray 0.8s var(--ease); }
[data-theme="dark"] .gauge__fill2 { stroke: #2a3a63; }
.gauge__value {
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: -0.05em;
  fill: var(--text);
  font-variant-numeric: tabular-nums;
}
.gauge__label { font-family: var(--font); fill: var(--blue-ink); font-weight: 500; letter-spacing: -0.02em; }
.gauge__hatch { stroke: var(--text); }
.gauge--red .gauge__label { fill: var(--red-ink); }
.gauge--green .gauge__label { fill: var(--green-ink); }
.gauge--amber .gauge__label { fill: var(--amber-ink); }
.gauge__note { margin-top: 6px; text-align: center; font-size: var(--fs-sm); color: var(--text-3); max-width: 340px; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 28px; font-size: var(--fs-md); }
.legend__item { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.legend__swatch { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }
.legend__swatch--hatch { border-radius: 4px; background: repeating-linear-gradient(135deg, var(--text-3) 0 2px, transparent 2px 5px); }
.legend__item--blue { color: var(--blue-ink); }
.legend__item--red { color: var(--red-ink); }
.legend__item--red .legend__swatch { background: var(--red); }
.legend__item--green { color: var(--green-ink); }
.legend__item--green .legend__swatch { background: var(--green); }
.legend__item--amber { color: #f08a5d; }
.legend__item--amber .legend__swatch { background: #fa9b72; }
.legend__item--light .legend__swatch { background: #d6e3ff; }

/* ================================================================== progress / meters */
.progress {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 8px;
  background: var(--bg-soft);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.6s var(--ease);
}
.progress--sm { height: 5px; }
.progress--lg { height: 12px; }
.progress--green .progress__bar { background: var(--green); }
.progress--red .progress__bar { background: var(--red); }
.progress--amber .progress__bar { background: var(--amber); }
.progress--gradient .progress__bar { background: var(--grad-deep); }
.progress--indeterminate .progress__bar {
  width: 35% !important;
  animation: fd-indeterminate 1.3s ease-in-out infinite;
}
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); margin-bottom: 6px; }

/* two-sided meter: imbalance, delta share, MAE/MFE (value -1..+1 from the centre) */
.meter {
  position: relative;
  height: 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  overflow: hidden;
}
.meter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: var(--border-strong);
  z-index: 1;
}
.meter__neg,
.meter__pos {
  position: absolute;
  top: 0;
  bottom: 0;
  transition: width 0.5s var(--ease);
}
.meter__neg { right: 50%; background: var(--red); border-radius: 10px 0 0 10px; }
.meter__pos { left: 50%; background: var(--green); border-radius: 0 10px 10px 0; }
.meter-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ================================================================== countdown */
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.countdown--chip {
  padding: 4px 10px;
  border-radius: var(--r-tag);
  background: var(--bg-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.countdown.is-soon { color: var(--amber-ink); }
.countdown--chip.is-soon { background: var(--amber-tint); }
.countdown.is-now { color: var(--red-ink); }
.countdown--chip.is-now { background: var(--red-tint); }
.countdown.is-done { color: var(--text-3); }

/* ================================================================== empty / skeleton / spinner */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  text-align: center;
  color: var(--text-3);
  min-width: 0;
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--blue-tint);
  color: var(--blue-ink);
  margin-bottom: 4px;
}
.empty__icon svg { width: 26px; height: 26px; }
.empty__title { font-size: var(--fs-lg); font-weight: 600; color: var(--text); letter-spacing: var(--ls-tight); }
.empty__text { font-size: var(--fs-sm); max-width: 420px; color: var(--text-3); }
.empty__action { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.empty--compact { padding: 20px 12px; gap: 6px; }
.empty--compact .empty__icon { width: 40px; height: 40px; border-radius: 12px; }
.empty--compact .empty__icon svg { width: 20px; height: 20px; }
.empty--compact .empty__title { font-size: var(--fs-md); }

.skeleton { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.skeleton__line,
.skel {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-soft) 0%, var(--hover) 40%, var(--bg-soft) 80%);
  background-size: 300% 100%;
  animation: fd-shimmer 1.4s ease-in-out infinite;
}
[data-theme="dark"] .skeleton__line,
[data-theme="dark"] .skel { background-image: linear-gradient(90deg, #161a22 0%, #20252f 40%, #161a22 80%); }
.skeleton__line:nth-child(3n + 1) { width: 92%; }
.skeleton__line:nth-child(3n + 2) { width: 76%; }
.skeleton__line:nth-child(3n) { width: 58%; }
.skeleton--block .skeleton__line { width: 100%; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--blue);
  animation: fd-spin 0.8s linear infinite;
  flex-shrink: 0;
}
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }

/* ================================================================== callouts */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--blue-tint);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.callout > svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--blue-ink); margin-top: 1px; }
.callout__title { font-weight: 600; color: var(--text); font-size: var(--fs-md); margin-bottom: 2px; }
.callout__body { flex: 1 1 auto; min-width: 0; }
.callout--warn { background: var(--amber-tint); }
.callout--warn > svg { color: var(--amber-ink); }
.callout--error { background: var(--red-tint); }
.callout--error > svg { color: var(--red-ink); }
.callout--success { background: var(--green-tint); }
.callout--success > svg { color: var(--green-ink); }
.callout--neutral { background: var(--bg-soft); }
.callout--neutral > svg { color: var(--text-3); }

/* ================================================================== lists */
.list { display: flex; flex-direction: column; min-width: 0; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.list-item:last-child { border-bottom: 0; }
.list-item--clickable { cursor: pointer; margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: 10px; border-bottom-color: transparent; }
.list-item--clickable:hover { background: var(--hover); }
.list-item__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-2);
  flex-shrink: 0;
}
.list-item__icon svg { width: 18px; height: 18px; }
.list-item__main { flex: 1 1 auto; min-width: 0; }
.list-item__title { color: var(--text); font-weight: 500; font-size: var(--fs-md); line-height: 1.3; }
.list-item__sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.list-item__right { flex-shrink: 0; text-align: right; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* ================================================================== timeline */
.timeline { position: relative; display: flex; flex-direction: column; gap: 0; padding-left: 22px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}
.timeline__item { position: relative; padding: 0 0 16px; min-width: 0; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute;
  left: -22px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--panel);
  border: 3px solid var(--blue);
}
.timeline__item--green .timeline__dot { border-color: var(--green); }
.timeline__item--red .timeline__dot { border-color: var(--red); }
.timeline__item--amber .timeline__dot { border-color: var(--amber); }
.timeline__item--purple .timeline__dot { border-color: var(--purple); }
.timeline__item--gray .timeline__dot { border-color: var(--text-4); }
.timeline__time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.timeline__text { font-size: var(--fs-sm); color: var(--text); margin-top: 2px; overflow-wrap: anywhere; }

/* ================================================================== misc */
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }
.divider--v { width: 1px; height: 24px; margin: 0 4px; }

.sparkline { display: block; width: 100%; height: 36px; overflow: visible; }
.sparkline--inline { display: inline-block; width: 80px; height: 24px; vertical-align: middle; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue-tint);
  color: var(--blue-ink);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.link-btn { color: var(--blue-ink); font-weight: 500; font-size: var(--fs-sm); }
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* CSS-only tooltip: <span data-tip="text"> */
[data-tip] { position: relative; }
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: var(--z-popover);
  width: max-content;
  max-width: 260px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #111318;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
}
[data-tip-pos="bottom"]:hover::after { bottom: auto; top: calc(100% + 8px); }
[data-tip-pos="left"]:hover::after { left: auto; right: 0; transform: none; }
[data-tip-pos="right"]:hover::after { left: 0; transform: none; }

/* glow background helper (template hero) */
.glow { position: relative; isolation: isolate; }
.glow::before {
  content: "";
  position: absolute;
  inset: -40px -40px auto -40px;
  height: 320px;
  z-index: -1;
  background: var(--glow);
  filter: blur(30px);
  opacity: 0.55;
  pointer-events: none;
}

/* ================================================================== animations */
@keyframes fd-spin { to { transform: rotate(360deg); } }
@keyframes fd-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes fd-pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(2.8); opacity: 0; } }
@keyframes fd-pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fd-toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fd-toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes fd-row-new { 0% { background: color-mix(in srgb, var(--blue) 18%, transparent); } 100% { background: transparent; } }
@keyframes fd-flash-up { 0% { background: var(--green-tint); color: var(--green-ink); } 100% { background: transparent; } }
@keyframes fd-flash-down { 0% { background: var(--red-tint); color: var(--red-ink); } 100% { background: transparent; } }
@keyframes fd-flash-white { 0% { background: rgba(255, 255, 255, 0.25); } 100% { background: transparent; } }
@keyframes fd-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@keyframes fd-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fd-slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.fade-in { animation: fd-fade-in var(--dur-slow) var(--ease); }
.slide-in { animation: fd-slide-in var(--dur-slow) var(--ease); }

/* ================================================================== direction calls (SPEC 4.9)
   One look everywhere: ▲ UP green · ▼ DOWN red · NO CLEAR EDGE grey, probability, typical points, time window. */
.dc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 10px;
  border-radius: var(--r-tag);
  font-size: 13px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: var(--bg-soft);
  color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.dc-pill > * { min-width: 0; }
.dc-pill__word { font-weight: 700; letter-spacing: 0.01em; }
.dc-pill__prob { font-weight: 600; }
.dc-pill__pts { color: inherit; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; }
.dc-pill__when { font-weight: 500; opacity: 0.75; }
.dc-when-short { display: none; }
.dc-pill__when::after { content: ""; display: inline-block; width: 1px; height: 0.9em; margin-left: 6px; vertical-align: -1px; background: currentColor; opacity: 0.35; }
.dc-pill--up { background: var(--green-tint); color: var(--green-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--green) 30%, transparent); }
.dc-pill--down { background: var(--red-tint); color: var(--red-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 30%, transparent); }
.dc-pill--none { background: var(--bg-soft); color: var(--text-3); }
.dc-pill--sm { font-size: 12px; padding: 2px 9px; gap: 5px; }
.dc-pill--md { font-size: 14px; padding: 5px 12px; }
.dc-pill--lg { font-size: 16px; padding: 7px 14px; }
.kpi--blue .dc-pill { background: #fff; box-shadow: none; }
.kpi--blue .dc-pill--none { color: var(--text-3); }

.dc-kpi { display: flex; min-width: 0; }
.dc-kpi .dc-pill { overflow: hidden; }
.dc-kpi--none { font-size: 12px; color: var(--text-3); }
.kpi--blue .dc-kpi--none { color: rgba(255, 255, 255, 0.78); }

.dc-trade { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 13px; color: var(--text-3); min-width: 0; }
.dc-trade__lbl { font-weight: 600; color: var(--text-2); }
.dc-trade__rel { font-weight: 600; }
.dc-trade--green .dc-trade__rel { color: var(--green-ink); }
.dc-trade--red .dc-trade__rel { color: var(--red-ink); }
.dc-trade--none { gap: 6px; flex-wrap: nowrap; }

.dc-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
.dc-strip__label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); margin-right: 2px; }
.dc-strip__none { font-size: 13px; color: var(--text-3); }
.dc-strip__why { font-size: 13px; }

.dc-card__sub { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.dc-card__mode .mode-pill { vertical-align: middle; }
.dc-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.dc-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: var(--r-kpi);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.dc-tile:hover { border-color: var(--border-strong); }
.dc-tile.is-selected { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.dc-tile--empty { cursor: default; color: var(--text-3); background: var(--bg-soft); }
.dc-tile__when { font-size: 13px; color: var(--text-3); font-weight: 500; }
.dc-tile__word { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.dc-tile--none .dc-tile__word { font-size: 16px; color: var(--text-3); line-height: 1.35; }
.dc-tile--up .dc-tile__word { color: var(--green-ink); }
.dc-tile--down .dc-tile__word { color: var(--red-ink); }
.dc-tile--up { background: color-mix(in srgb, var(--green-tint) 55%, var(--panel)); }
.dc-tile--down { background: color-mix(in srgb, var(--red-tint) 55%, var(--panel)); }
.dc-tile__prob { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dc-tile--none .dc-tile__prob { font-weight: 500; color: var(--text-2); }
.dc-tile__meta { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.dc-tile__conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.dc-conf { width: 8px; height: 8px; border-radius: 50%; background: var(--text-4); }
.dc-conf--medium { background: var(--amber); }
.dc-conf--high { background: var(--green); }

.dc-detail { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dc-detail__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dc-detail__sent { font-size: 14px; color: var(--text-2); min-width: 0; }
.dc-detail__note { margin: 0; font-size: 13px; color: var(--text-3); }
.dc-hit { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bg-soft); font-size: 13px; color: var(--text-2); }
.dc-hit > svg { flex-shrink: 0; margin-top: 2px; color: var(--blue); }
.dc-hit__track { color: var(--text-3); margin-top: 2px; }
.dc-reasons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.dc-reason { min-width: 0; }
.dc-reason.is-off { opacity: 0.65; }
.dc-reason__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 14px; }
.dc-reason__list { margin: 0; padding-left: 16px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.dc-reason__list li { overflow-wrap: anywhere; }
.dc-reason__list li.is-off { color: var(--text-3); }
.dc-foot { margin: 0; font-size: 12px; color: var(--text-3); }

@media (max-width: 899px) {
  .dc-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dc-reasons { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 599px) {
  .dc-when-long { display: none; }
  .dc-when-short { display: inline; }
  .dc-kpi .dc-pill { font-size: 11px; padding: 2px 8px; gap: 4px; white-space: nowrap; flex-wrap: nowrap; }
  .dc-tile { padding: 10px 12px; }
  .dc-tile__word { font-size: 19px; }
  .dc-tile--none .dc-tile__word { font-size: 14px; }
  .dc-pill { white-space: normal; flex-wrap: wrap; row-gap: 0; }
}
.dc-risk { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); min-width: 0; }
.dc-risk__head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.dc-risk__age { font-size: 12px; color: var(--text-3); }
.dc-risk__text { overflow-wrap: anywhere; }
.dc-risk__advice { color: var(--text-3); font-size: 12.5px; overflow-wrap: anywhere; }
.dc-risk--high .dc-risk__advice, .dc-risk--critical .dc-risk__advice { color: var(--red-ink); }
.dc-risk__list { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--text-3); }
.dc-risk__list b { color: var(--text-2); font-variant-numeric: tabular-nums; }
