/*
Falcon Syslog component vocabulary. Mirrors the Ex platform's "ds-*" naming
and behaviour (card, kpi tile, chart card, table, badge, filter bar, empty
state, skeleton, drawer, modal, tooltip, banner), folding in the older
"fds-*" family's more complete drawer/modal/table behaviour (focus-trap,
Escape-to-close, sortable headers). See CLAUDE.md in this directory.

Every colour here is a var(--token) from tokens.css. No hex codes below this
line: if you find one, it is a bug (the CLAUDE.md lint check catches this
before deploy).

Container queries, not media queries, for responsive layout (brief s3.2).
*/

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--action-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }

/* ---------------------------------------------------------------- layout */
.ds-shell { display: flex; min-height: 100vh; }
.ds-sidebar {
  width: 224px; flex: none; background: var(--surface-sidebar);
  color: var(--text-on-dark); display: flex; flex-direction: column;
  padding: var(--space-4) 0;
}
.ds-sidebar__brand {
  padding: 0 var(--space-4) var(--space-4); font-weight: var(--fw-semibold);
  font-size: var(--fs-md); border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: var(--space-2);
}
.ds-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 var(--space-2); }
.ds-nav__group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,.45); padding: var(--space-4) var(--space-2) var(--space-1);
}
.ds-nav__item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-2); border-radius: var(--radius-md);
  color: rgba(255,255,255,.78); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  transition: background var(--t-fast), color var(--t-fast);
}
.ds-nav__item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.ds-nav__item[aria-current="page"] {
  background: rgba(255,255,255,.12); color: #fff;
  box-shadow: inset 3px 0 0 var(--action-primary);
}

.ds-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ds-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-6); border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-card); gap: var(--space-4); flex-wrap: wrap;
}
.ds-breadcrumbs { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); }
.ds-breadcrumbs a { color: var(--text-secondary); }
.ds-breadcrumbs__sep { opacity: .5; }
.ds-page { padding: var(--space-6); container-type: inline-size; }
.ds-page__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.ds-page__title { font-size: var(--fs-2xl); font-weight: var(--fw-bold); margin: 0 0 var(--space-1); color: var(--text-primary); }
.ds-page__subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.ds-page__actions { display: flex; align-items: center; gap: var(--space-2); }

/* ------------------------------------------------------------------ grid */
.ds-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(12, 1fr); }
.ds-grid > * { grid-column: span 12; }
@container (min-width: 640px) {
  .ds-col-6 { grid-column: span 6; }
  .ds-col-4 { grid-column: span 4; }
  .ds-col-8 { grid-column: span 8; }
}
@container (min-width: 960px) {
  .ds-col-3 { grid-column: span 3; }
  .ds-col-4 { grid-column: span 4; }
  .ds-col-6 { grid-column: span 6; }
  .ds-col-8 { grid-column: span 8; }
  .ds-col-9 { grid-column: span 9; }
}

/* ------------------------------------------------------------------ card */
.card {
  background: var(--surface-card); border: 1px solid var(--surface-card-border);
  border-radius: var(--radius-lg); box-shadow: var(--surface-card-shadow);
}
.card--p3 { padding: var(--space-3); }
.card--p4 { padding: var(--space-4); }
.card--p6 { padding: var(--space-6); }
.card__title {
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-primary);
  margin: 0 0 var(--space-3); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
}

/* -------------------------------------------------------------- kpi tile */
.ds-metric-tile {
  display: block; position: relative; padding: var(--space-3) var(--space-4);
  background: var(--surface-card); border: 1px solid var(--surface-card-border);
  border-left: 4px solid var(--tile-accent, var(--c-quantity));
  border-top: 3px solid var(--tile-accent, var(--c-quantity));
  border-radius: var(--radius-md); box-shadow: 0 2px 8px rgba(0,0,0,.06);
  cursor: pointer; transition: box-shadow var(--t-fast);
  color: inherit; text-decoration: none;
}
.ds-metric-tile:hover, .ds-metric-tile:focus-visible {
  box-shadow: var(--shadow-mid); text-decoration: none; outline: none;
}
.ds-metric-tile:focus-visible { outline: 2px solid var(--action-primary); outline-offset: 2px; }
.ds-metric-tile--static { cursor: default; }
.ds-metric-tile__label {
  font-size: 9px; text-transform: uppercase; letter-spacing: .07em; font-weight: var(--fw-semibold);
  color: var(--text-label); margin: 0 0 var(--space-1);
}
.ds-metric-tile__value {
  font-size: var(--fs-2xl); font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--text-primary); line-height: var(--lh-tight); margin: 0;
}
.ds-metric-tile__delta { font-size: var(--fs-xs); font-weight: var(--fw-medium); margin-top: var(--space-1); }
.ds-metric-tile__delta--up { color: var(--c-positive); }
.ds-metric-tile__delta--down { color: var(--c-negative); }
.ds-metric-tile__sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-1); }

.ds-metric-row {
  display: flex; flex-wrap: wrap; gap: var(--space-3);
}
.ds-metric-row > .ds-metric-tile { flex: 1 1 160px; }
@container (max-width: 640px) {
  .ds-metric-row { display: grid; grid-template-columns: 1fr 1fr; }
  .ds-metric-row > .ds-metric-tile { flex: none; }
}

/* tone helper classes set the tile accent from a semantic token */
.tone-quantity { --tile-accent: var(--c-quantity); }
.tone-currency { --tile-accent: var(--c-currency); }
.tone-warning  { --tile-accent: var(--c-warning); }
.tone-negative { --tile-accent: var(--c-negative); }
.tone-positive { --tile-accent: var(--c-positive); }
.tone-muted    { --tile-accent: var(--c-muted); }

/* ------------------------------------------------------------ chart card */
.ds-chart-card { background: var(--surface-card); border: 1px solid var(--surface-card-border); border-radius: var(--radius-lg); box-shadow: var(--surface-card-shadow); padding: var(--space-4); }
.ds-chart-card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); gap: var(--space-2); flex-wrap: wrap; }
.ds-chart-card__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin: 0; }
.ds-chart-card__hint { font-size: var(--fs-xs); color: var(--text-muted); margin: 2px 0 0; }
.ds-chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--fs-xs); color: var(--ds-chart-legend-text); margin-top: var(--space-2); }
.ds-chart-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.ds-chart-legend__swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* ---------------------------------------------------------------- badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  line-height: 1.6; white-space: nowrap;
}
.badge--quantity { background: var(--c-quantity-bg); color: var(--c-quantity-strong); }
.badge--currency { background: var(--c-currency-bg); color: var(--c-currency-strong); }
.badge--warning  { background: var(--c-warning-bg);  color: var(--c-warning-strong); }
.badge--negative { background: var(--c-negative-bg); color: var(--c-negative-strong); }
.badge--positive { background: var(--c-positive-bg); color: var(--c-positive-strong); }
.badge--muted    { background: var(--c-muted-bg);    color: var(--c-muted-strong); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ----------------------------------------------------------------- table */
.ds-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ds-table th, .ds-table td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--border-subtle); }
.ds-table thead th {
  background: var(--surface-subtle); font-weight: var(--fw-semibold); color: var(--text-secondary);
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.ds-table tbody tr:hover { background: var(--surface-hover); }
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table__sort { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 4px; }
.ds-table__sort:hover { color: var(--text-primary); }
.ds-table td.num, .ds-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ds-table__clickable { cursor: pointer; }
.ds-table a.rowlink { color: inherit; display: block; }
.ds-table a.rowlink:hover { text-decoration: none; }

/* ------------------------------------------------------------ filter bar */
.ds-filter-bar {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  padding: var(--space-3); background: var(--surface-card); border: 1px solid var(--surface-card-border);
  border-radius: var(--radius-lg); margin-bottom: var(--space-4);
}
.ds-filter-bar__field { display: flex; flex-direction: column; gap: 2px; }
.ds-filter-bar__label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-label); }
.ds-filter-bar select, .ds-filter-bar input[type="text"], .ds-filter-bar input[type="search"], .ds-filter-bar input[type="date"] {
  border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: 5px 8px;
  font-size: var(--fs-sm); background: var(--surface-input); color: var(--text-primary); min-height: 30px;
}
.ds-filter-bar__chips { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.ds-filter-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--c-quantity-bg); color: var(--c-quantity-strong);
  border-radius: var(--radius-pill); padding: 3px 8px 3px 10px; font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.ds-filter-chip button { background: none; border: none; color: inherit; cursor: pointer; padding: 0; line-height: 1; font-size: 14px; }

/* --------------------------------------------------------------- button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-md); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  padding: 7px 14px; border: 1px solid var(--border-default); background: var(--surface-card);
  color: var(--text-primary); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast);
  min-height: var(--ds-touch-tight, 36px);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); text-decoration: none; }
.btn--primary { background: var(--action-primary); border-color: var(--action-primary); color: var(--action-primary-text); }
.btn--primary:hover { background: var(--action-primary-hover); border-color: var(--action-primary-hover); }
.btn--icon { padding: 6px; width: 32px; height: 32px; }
.btn[aria-busy="true"] .icon-spin { animation: ds-spin 0.8s linear infinite; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------- empty state */
.ds-empty {
  text-align: center; padding: var(--space-10) var(--space-6); color: var(--text-muted);
}
.ds-empty__icon { font-size: 28px; margin-bottom: var(--space-3); opacity: .55; }
.ds-empty__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-secondary); margin: 0 0 var(--space-1); }
.ds-empty__body { font-size: var(--fs-sm); max-width: 46ch; margin: 0 auto; }
.ds-empty--kind-nodata { border-left: 3px solid var(--c-muted); }
.ds-empty--kind-notcollecting { border-left: 3px solid var(--c-warning); }
.ds-empty--kind-notemitted { border-left: 3px solid var(--c-negative); }

/* -------------------------------------------------------------- skeleton */
@keyframes ds-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes ds-spin { to { transform: rotate(360deg); } }
.ds-skeleton { background: var(--surface-hover); border-radius: var(--radius-md); animation: ds-pulse 1.4s ease-in-out infinite; }
.ds-skeleton--chart { height: 220px; width: 100%; }
.ds-skeleton--tile { height: 74px; width: 100%; }
.ds-skeleton--row { height: 32px; width: 100%; margin-bottom: 4px; }

/* --------------------------------------------------------------- drawer */
.ds-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(12, 10, 20, .45); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
}
.ds-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.ds-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw);
  background: var(--surface-card); box-shadow: var(--shadow-high); z-index: 51;
  transform: translateX(100%); transition: transform var(--t-fast) ease-out;
  display: flex; flex-direction: column;
}
.ds-drawer.is-open { transform: translateX(0); }
.ds-drawer__header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.ds-drawer__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: 0; }
.ds-drawer__body { padding: var(--space-4); overflow-y: auto; flex: 1; }
.ds-drawer__close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* ---------------------------------------------------------------- modal */
.ds-modal-backdrop { position: fixed; inset: 0; background: rgba(12,10,20,.45); z-index: 60; display: none; align-items: center; justify-content: center; }
.ds-modal-backdrop.is-open { display: flex; }
.ds-modal { background: var(--surface-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-high); width: min(640px, 92vw); max-height: 86vh; display: flex; flex-direction: column; }
.ds-modal__header { padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; }
.ds-modal__body { padding: var(--space-4); overflow-y: auto; }
.ds-modal__footer { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: var(--space-2); }

/* -------------------------------------------------------------- tooltip */
.ds-tooltip { position: relative; display: inline-flex; }
.ds-tooltip__bubble {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ds-chart-tooltip-bg); color: var(--ds-chart-tooltip-text); border: 1px solid var(--ds-chart-tooltip-border);
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: var(--fs-xs); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast); z-index: 30; box-shadow: var(--shadow-mid);
}
.ds-tooltip:hover .ds-tooltip__bubble, .ds-tooltip:focus-within .ds-tooltip__bubble { opacity: 1; }

/* ------------------------------------------------------------- popover  */
.ds-popover { position: relative; }
.ds-popover__panel {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; z-index: 40;
  background: var(--surface-card); border: 1px solid var(--surface-card-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-mid); padding: var(--space-3); display: none;
}
.ds-popover.is-open .ds-popover__panel { display: block; }

/* --------------------------------------------------------------- banner */
.ds-alert-banner { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border-left: 4px solid var(--banner-accent, var(--c-quantity)); background: var(--banner-bg, var(--c-quantity-bg)); }
.ds-alert-banner--warning { --banner-accent: var(--c-warning); --banner-bg: var(--c-warning-bg); }
.ds-alert-banner--negative { --banner-accent: var(--c-negative); --banner-bg: var(--c-negative-bg); }
.ds-alert-banner--positive { --banner-accent: var(--c-positive); --banner-bg: var(--c-positive-bg); }
.ds-alert-banner--muted { --banner-accent: var(--c-muted); --banner-bg: var(--c-muted-bg); }
.ds-alert-banner__title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); margin: 0 0 2px; color: var(--text-primary); }
.ds-alert-banner__body { font-size: var(--fs-sm); color: var(--text-secondary); margin: 0; }

/* ----------------------------------------------------------- freshness  */
.ds-freshness { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.ds-freshness__dot { width: 7px; height: 7px; border-radius: 50%; }
.ds-freshness--fresh .ds-freshness__dot { background: var(--c-positive); }
.ds-freshness--warm .ds-freshness__dot { background: var(--c-warning); }
.ds-freshness--stale .ds-freshness__dot { background: var(--c-negative); }
.ds-refresh-toast {
  position: fixed; bottom: var(--space-4); right: var(--space-4); z-index: 70; width: 22rem; max-width: calc(100vw - 2rem);
  background: var(--surface-card); border: 1px solid var(--surface-card-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high); padding: var(--space-3) var(--space-4); display: none; gap: var(--space-2);
}
.ds-refresh-toast.is-open { display: flex; align-items: flex-start; }

/* -------------------------------------------------------------- misc  */
.ds-hash { font-family: var(--font-mono); font-size: var(--fs-xs); word-break: break-all; }
.ds-timeline { position: relative; padding-left: 28px; }
.ds-timeline::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--border-default); }
.ds-timeline__item { position: relative; padding-bottom: var(--space-5); }
.ds-timeline__dot { position: absolute; left: -28px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--dot-color, var(--c-quantity)); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px var(--surface-card); }
.ds-timeline__time { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ds-timeline__title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); margin: 2px 0; }
.ds-timeline__detail { font-size: var(--fs-sm); color: var(--text-secondary); }

.ds-funnel { display: flex; flex-direction: column; gap: 2px; }
.ds-funnel__stage { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; }
.ds-funnel__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.ds-funnel__bar-track { background: var(--surface-subtle); border-radius: var(--radius-sm); height: 28px; overflow: hidden; }
.ds-funnel__bar-fill { height: 100%; background: var(--c-quantity); border-radius: var(--radius-sm); transition: width .3s ease; }
.ds-funnel__count { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); font-size: var(--fs-sm); text-align: right; min-width: 44px; }
.ds-funnel__dropoff { font-size: var(--fs-xs); color: var(--c-negative); grid-column: 2 / 3; margin-top: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--action-primary); color: #fff; padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
