/* ==========================================================================
   Components.
   Status-coloured components (chip, tag, dot, nav) all read two local
   variables — --st and --st-bg — so a single rule covers every status and
   a new status is one modifier class, not a new component.
   ========================================================================== */

.is-draft     { --st: var(--st-draft);     --st-bg: var(--st-draft-bg); }
.is-scheduled { --st: var(--st-scheduled); --st-bg: var(--st-scheduled-bg); }
.is-approved  { --st: var(--st-approved);  --st-bg: var(--st-approved-bg); }
.is-published { --st: var(--st-published); --st-bg: var(--st-published-bg); }
.is-failed    { --st: var(--st-failed);    --st-bg: var(--st-failed-bg); }
.is-warn      { --st: var(--st-warn);      --st-bg: var(--st-warn-bg); }

/* --------------------------------- Dot ----------------------------------- */

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--st, var(--signal));
  flex-shrink: 0;
}

.dot--lg {
  width: 8px;
  height: 8px;
  box-shadow: 0 0 0 3px var(--st-bg, var(--signal-soft));
}

.dot--sm {
  width: 5px;
  height: 5px;
}

.dot--signal {
  background: var(--signal);
}

/* -------------------------------- Chip ----------------------------------- */
/* Calendar entry: a status band on the inline start edge. */

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  padding: 3px var(--sp-2);
  margin-block-end: 3px;
  border-radius: 5px;
  background: var(--st-bg);
  color: var(--st);
  border-inline-start: 3px solid var(--st);
}

.chip__time {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: 0.8;
}

/* --------------------------------- Tag ----------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--st-bg);
  color: var(--st);
  white-space: nowrap;
}

.tag--lg {
  font-size: 12px;
  padding: var(--sp-1) var(--sp-5);
}

/* The approvals list badge keeps the decision readable at rest. */
.tag--quiet {
  color: var(--fg);
}

/* ------------------------------- Buttons --------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: calc(9px * var(--dens)) var(--sp-8);
  border-radius: var(--r-control);
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: filter var(--dur-fast);
}

.btn:hover { filter: brightness(1.08); }

.btn--primary {
  background: var(--accent-ink);
  color: var(--btn-fg);
}

.btn--ghost {
  background: transparent;
  color: var(--fg-dim);
  border-color: var(--line-strong);
}

.btn--danger {
  background: var(--st-failed);
  color: #fff;
}

.btn--lg {
  padding: calc(11px * var(--dens)) var(--sp-9);
  font-size: 14px;
}

.btn--sm {
  padding: 5px var(--sp-5);
  font-size: 11px;
}

.btn--block {
  width: 100%;
}

/* ---------------------------- Segmented control -------------------------- */

.seg {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  padding: 3px;
  width: max-content;
}

.seg__btn {
  padding: 5px var(--sp-5);
  border: none;
  border-radius: var(--r-chip);
  background: transparent;
  color: var(--fg-dim);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.seg__btn[aria-pressed='true'] {
  background: var(--accent-ink);
  color: var(--btn-fg);
}

/* ------------------------------ Nav item --------------------------------- */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: none;
  border-radius: var(--r-chip);
  background: transparent;
  color: var(--fg-dim);
  font-size: 13px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}

.nav-item,
.nav-item:hover {
  text-decoration: none;
  color: var(--fg-dim);
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item[aria-current='page'],
.nav-item[aria-current='page']:hover {
  background: var(--signal-soft);
  color: var(--fg);
  box-shadow: inset 2px 0 0 var(--signal);
}

.nav-item__label {
  flex: 1;
  text-align: start;
}

.nav-item__star {
  color: var(--signal);
  font-size: 11px;
}

.nav-item__badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-dim);
  background: var(--surface-2);
  border-radius: var(--r-chip);
  padding: 1px var(--sp-2);
}

/* -------------------------------- Card ----------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--sp-7);
  box-shadow: var(--shadow);
}

.card--flat {
  box-shadow: none;
  padding: var(--sp-7) var(--sp-6);
}

.card--tinted {
  background: var(--signal-soft);
  box-shadow: none;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--fg-dim);
}

.card--selectable {
  cursor: pointer;
  text-align: start;
  color: var(--fg);
  font-family: inherit;
  display: block;
  width: 100%;
}

.card[aria-selected='true'],
.card--selectable[aria-selected='true'] {
  border-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal), var(--shadow);
}

.card__title {
  font-size: 12.5px;
  font-weight: 700;
  margin-block-end: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ------------------------------- Panel ----------------------------------- */
/* A card whose header and rows are flush to the border. */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-7);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 13px;
}

.panel__row {
  padding: var(--sp-5) var(--sp-7);
  border-bottom: 1px solid var(--line);
}

.panel__row:last-child {
  border-bottom: none;
}

/* -------------------------------- Table ---------------------------------- */
/* CSS-grid rows; every table sets --cols for its own column template. */

.table__head,
.table__row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: var(--sp-5);
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.table__head {
  padding: var(--sp-5) var(--sp-7);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--fg-mute);
}

.table__row {
  padding: var(--sp-5) var(--sp-7);
  font-size: 12.5px;
  transition: background var(--dur-fast);
}

.table__row:hover {
  background: var(--surface-2);
}

.table__row:last-child {
  border-bottom: none;
}

.table__scroll {
  overflow-x: auto;
}

.table__empty {
  padding: var(--sp-9);
  text-align: center;
  color: var(--fg-mute);
  font-size: 12.5px;
}

/* -------------------------------- Meter ---------------------------------- */
/* Track + fill. Callers set --pct; --over flips it to the failure colour at
   85% of a length or cadence budget. */

.meter {
  height: 5px;
  border-radius: var(--sp-1);
  background: var(--surface-2);
  overflow: hidden;
}

.meter--thick {
  height: 6px;
}

.meter__fill {
  height: 100%;
  width: var(--pct, 0%);
  background: var(--signal);
  border-radius: var(--sp-1);
}

.meter--over .meter__fill {
  background: var(--st-failed);
}

/* ------------------------------- Fields ---------------------------------- */

.field {
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  padding-inline: var(--sp-5);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
}

.field--inset {
  background: var(--ground-1);
}

.field--area {
  min-height: 74px;
  height: auto;
  resize: vertical;
  padding: var(--sp-4) var(--sp-5);
  line-height: 1.6;
}

.field--search {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

.field:focus {
  outline: none;
  border-color: var(--signal);
}

.field__label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg-dim);
  margin-block-end: var(--sp-2);
}

/* A read-only box that stands in for a field in a static mockup. */
.field-stub {
  height: 40px;
  display: flex;
  align-items: center;
  padding-inline: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--ground-1);
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ------------------------------- Toolbar --------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
  margin-block-end: var(--sp-6);
}

.toolbar__filters {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.filter {
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 7px;
  padding: 5px var(--sp-5);
  background: var(--surface-2);
  color: var(--fg-dim);
  border: 1px solid var(--line);
  cursor: default;
}

.filter[aria-pressed='true'] {
  background: var(--accent-ink);
  color: var(--btn-fg);
  border-color: var(--accent-ink);
}

.toolbar__count {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-mute);
}

/* ---------------------------- Confidence arcs ---------------------------- */
/* Three arcs radiating from the mark's signal dot: 3 lit = high, 1 = low. */

.arcs__arc {
  fill: none;
  stroke: var(--mute-arc);
  stroke-linecap: round;
}

/* --accent-ink resolves to the accent in dark and to the AA-safe darkened
   teal in light, so a lit arc stays legible against either ground. */
.arcs__arc--lit {
  stroke: var(--accent-ink);
}

.arcs__source {
  fill: var(--signal);
}

.confidence {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}

.confidence__value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--st);
}

.confidence__note {
  font-size: 11px;
  color: var(--fg-dim);
  text-align: center;
  line-height: 1.5;
}

/* -------------------------------- Toast ---------------------------------- */

.toast {
  position: fixed;
  bottom: var(--sp-9);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-inline-start: 3px solid var(--st, var(--signal));
  border-radius: var(--r-card);
  padding: var(--sp-5) var(--sp-8);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 13px;
}

[dir='rtl'] .toast {
  transform: translateX(50%);
}

/* -------------------------------- Modal ---------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--scrim);
  display: grid;
  place-items: center;
  padding: var(--sp-9);
  border: 0;
}

.modal__dialog {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: var(--sp-9);
  text-align: start;
}

.modal__title {
  font-size: var(--fs-h2);
  font-weight: 800;
  margin-block-end: var(--sp-3);
}

.modal__body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg-dim);
  margin-block-end: var(--sp-7);
}

.modal__actions {
  display: flex;
  gap: var(--sp-4);
  justify-content: flex-end;
}

.modal__field {
  width: 100%;
  margin-block-end: var(--sp-7);
}

/* -------------------------------- Avatar --------------------------------- */

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-control);
  background: var(--signal-soft);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.avatar--square {
  width: 28px;
  height: 28px;
  border-radius: var(--r-chip);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
}
