/* ==========================================================================
   Bookhouder — professional light/dark theme.
   Design language: calm neutral canvas, white elevated cards, one confident
   indigo accent, semantic green (profit) / red (cost & loss) / amber (warning).
   Benchmarked against finance/split tools (Splitwise, QuickBooks, Stripe).
   All colour + elevation is token-driven so light and dark stay in lockstep.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e6e9f0;
  --border-strong: #d5dbe6;

  /* Text */
  --text: #0f1729;
  --text-2: #33405a;
  --muted: #64748b;

  /* Brand + semantics */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-weak: #eef2ff;
  --on-primary: #ffffff;
  --ring: rgba(79, 70, 229, 0.32);

  --positive: #16a34a;
  --positive-weak: #ecfdf3;
  --danger: #dc2626;
  --danger-weak: #fef2f2;
  --warning: #b45309;
  --warning-weak: #fffaeb;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 41, 0.04), 0 1px 3px rgba(15, 23, 41, 0.06);
  --shadow-md: 0 6px 16px rgba(15, 23, 41, 0.08), 0 2px 6px rgba(15, 23, 41, 0.05);

  /* Shape */
  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0b0e14;
    --surface: #131722;
    --surface-2: #1a1f2b;
    --border: #262c3a;
    --border-strong: #333a4c;

    --text: #e8eaf0;
    --text-2: #c3c9d6;
    --muted: #8b94a7;

    --primary: #6366f1;
    --primary-hover: #7c7ef5;
    --primary-weak: rgba(99, 102, 241, 0.16);
    --on-primary: #ffffff;
    --ring: rgba(99, 102, 241, 0.45);

    --positive: #34d399;
    --positive-weak: rgba(52, 211, 153, 0.14);
    --danger: #f87171;
    --danger-weak: rgba(248, 113, 113, 0.14);
    --warning: #fbbf24;
    --warning-weak: rgba(251, 191, 36, 0.13);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* --- Top bar ---------------------------------------------------------------- */

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand__logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand__name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__tagline {
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* --- Workspace grid (form + sticky results) -------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.klus-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.results-col {
  position: sticky;
  top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.card__step {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 700;
}

.card__heading {
  min-width: 0;
}

.card__title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card__hint {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* --- Fields ----------------------------------------------------------------- */

.field {
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}

.field-row .field {
  margin-bottom: 0;
}

.field__label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 600;
}

.field__control {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field__control:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.field__prefix,
.field__suffix {
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 600;
  user-select: none;
}

.field__prefix {
  border-right: 1px solid var(--border);
}

.field__suffix {
  border-left: 1px solid var(--border);
}

.field__input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.field__input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

/* Bare inputs (not wrapped in a .field__control) carry their own frame. */
.roster__name,
.roster__add .field__input,
.category-row__name {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.roster__name:focus,
.roster__add .field__input:focus,
.category-row__name:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.field__error {
  min-height: 1.05rem;
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
}

.field--invalid .field__control,
.field--invalid .field__input {
  border-color: var(--danger);
}

.field--invalid .field__control:focus-within {
  box-shadow: 0 0 0 3px var(--danger-weak);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease,
    transform 0.05s ease;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
}

.btn--ghost:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.btn--danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
  font-weight: 500;
  box-shadow: none;
  padding: 0.5rem 0.7rem;
}

.btn--danger:hover {
  background: var(--danger-weak);
}

.btn--add {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--primary);
  box-shadow: none;
}

.btn--add:hover {
  background: var(--primary-weak);
  border-color: var(--primary);
}

/* --- Expenses / custom categories ------------------------------------------ */

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}

.category-row {
  display: grid;
  grid-template-columns: 1fr 8.5rem 8rem auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.category-row__amount-control {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.category-row--cost {
  border-left-color: var(--danger);
}

.category-row--addition {
  border-left-color: var(--positive);
}

.category-row__type {
  padding: 0.55rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.category-row__type:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* --- People chips ----------------------------------------------------------- */

.people-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chip {
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.94rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.chip--present {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.chip--present:hover {
  background: var(--primary-hover);
  color: var(--on-primary);
}

/* --- Split-method segmented control ----------------------------------------- */

.split-toggle {
  display: inline-flex;
  padding: 0.2rem;
  margin-bottom: 1rem;
  gap: 0.2rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
}

.split-toggle__option {
  margin: 0;
  cursor: pointer;
}

.split-toggle__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.split-toggle__label {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}

.split-toggle__input:checked + .split-toggle__label {
  background: var(--primary);
  color: var(--on-primary);
}

.split-toggle__input:focus-visible + .split-toggle__label {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

/* Days-worked rows reuse the share row grid; the /total hint sits after input. */
.days__total {
  color: var(--text-2);
  font-weight: 600;
}

/* --- Per-person share rows -------------------------------------------------- */

.shares-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.share__row {
  display: grid;
  grid-template-columns: 1fr 7.5rem;
  gap: 0.75rem;
  align-items: center;
}

.share__name {
  font-weight: 600;
}

.share__percent-control {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

/* --- Allocation meter ------------------------------------------------------- */

.allocation-counter {
  position: relative;
  margin: 0;
  padding: 0.7rem 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
}

/* Track + fill sit flush along the bottom edge; the fill width is driven by the
   --alloc custom property that app.js updates (0–100). */
.allocation-counter::before,
.allocation-counter::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
}

.allocation-counter::before {
  right: 0;
  background: var(--border);
}

.allocation-counter::after {
  width: calc(var(--alloc, 0) * 1%);
  background: var(--primary);
  transition: width 0.18s ease;
}

.allocation-counter--over {
  color: var(--danger);
  border-color: var(--danger);
}

.allocation-counter--over::after {
  background: var(--danger);
}

/* --- Company cut toggle switch ---------------------------------------------- */

.company-cut {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch {
  flex: none;
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.switch-input:checked + .switch {
  background: var(--primary);
}

.switch-input:checked + .switch::after {
  transform: translateX(18px);
}

.switch-input:focus-visible + .switch {
  box-shadow: 0 0 0 3px var(--ring);
}

.switch-label {
  color: var(--text-2);
  font-weight: 500;
}

.company-cut__field {
  margin-top: 0.9rem;
  margin-bottom: 0;
  max-width: 12rem;
}

/* --- Roster editor ---------------------------------------------------------- */

.people-manage {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.people-manage > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

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

.people-manage > summary::before {
  content: "▸";
  transition: transform 0.15s ease;
  display: inline-block;
}

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

.people-manage[open] > summary {
  margin-bottom: 0.85rem;
}

.roster__list {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.roster__item {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.roster__item .roster__name {
  flex: 1;
}

.roster__add {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.roster__add .field__input {
  flex: 1;
}

/* --- Not-ready hint (missing required fields / over-allocation) ------------- */

.klus-form--not-ready .card:first-child {
  box-shadow: var(--shadow-sm), inset 3px 0 0 var(--warning);
}

/* --- Results placeholder ---------------------------------------------------- */

.results-placeholder {
  display: none;
  text-align: center;
  padding: 2.25rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

/* Shown only while the results section is still hidden (before first calc). */
.results-col:has(#results[hidden]) .results-placeholder {
  display: block;
}

.results-placeholder__icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary-weak);
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.results-placeholder__title {
  margin: 0 0 0.3rem;
  color: var(--text);
  font-weight: 650;
}

.results-placeholder__hint {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* --- Results ---------------------------------------------------------------- */

.results {
  box-shadow: var(--shadow-md);
}

.results__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.results__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
  margin: 0 0 1.1rem;
}

.results__title {
  font-weight: 650;
  font-size: 1rem;
  color: var(--text);
}

.results__title:empty {
  display: none;
}

.results__tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.results__tags span:empty {
  display: none;
}

.results__tags span {
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table__caption {
  text-align: left;
  padding-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.breakdown__row {
  border-bottom: 1px solid var(--border);
}

.breakdown__row:last-child {
  border-bottom: none;
}

.breakdown__label {
  padding: 0.45rem 0;
  color: var(--text-2);
}

.breakdown__amount {
  padding: 0.45rem 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.breakdown__amount--negative {
  color: var(--danger);
}

.net-amount {
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.net-amount--positive {
  color: var(--positive);
  background: var(--positive-weak);
}

.net-amount--negative {
  color: var(--danger);
  background: var(--danger-weak);
}

.loss-warning {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-weak);
  color: var(--danger);
  font-weight: 600;
  font-size: 0.88rem;
}

.payout__row {
  border-bottom: 1px solid var(--border);
}

.payout__name {
  padding: 0.5rem 0;
  font-weight: 600;
}

.payout__percent {
  padding: 0.5rem 0.6rem;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.payout__amount {
  padding: 0.5rem 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.payout__row--company,
.payout__row--unallocated {
  color: var(--muted);
}

.payout__row--company .payout__name,
.payout__row--unallocated .payout__name {
  color: var(--muted);
  font-weight: 500;
}

.payout__row--unallocated {
  color: var(--warning);
}

.payout__row--unallocated .payout__name,
.payout__row--unallocated .payout__percent,
.payout__row--unallocated .payout__amount {
  color: var(--warning);
}

.results__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.results__copy-status {
  color: var(--positive);
  font-size: 0.85rem;
  font-weight: 600;
}

/* --- Footer ----------------------------------------------------------------- */

.app__foot {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

/* --- Responsive ------------------------------------------------------------- */

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .results-col {
    position: static;
  }
  /* On a single column the placeholder is redundant — the form is right there. */
  .results-placeholder {
    display: none !important;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 1.25rem 0.9rem 2.5rem;
  }
  .topbar {
    margin-bottom: 1.25rem;
  }
  .card {
    padding: 1.15rem;
  }
  .field-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .category-row {
    grid-template-columns: 1fr;
  }
  .category-row__amount-control,
  .category-row__type,
  .category-row__remove {
    width: 100%;
  }
  .category-row__remove {
    justify-self: start;
  }
  .share__row {
    grid-template-columns: 1fr 6.5rem;
  }
  .net-amount {
    font-size: 1.4rem;
  }
  .results__actions .btn {
    flex: 1 1 auto;
  }
}

/* --- Print: summary only ---------------------------------------------------- */
/* #results keeps its `hidden` latch, so an uncalculated klus prints nothing
   extra. We only strip chrome and flatten the layout for paper. */
@media print {
  .topbar,
  #klus-form,
  .results-placeholder,
  .results__actions,
  .app__foot {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .results-col {
    position: static;
  }

  .card,
  .results {
    background: #fff;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .net-amount {
    background: none;
    padding: 0;
  }

  .net-amount--positive,
  .payout__amount {
    color: #000;
  }

  .net-amount--negative,
  .breakdown__amount--negative,
  .payout__row--unallocated .payout__amount {
    color: #8a0000;
  }
}

/* --- Phase 6: backlog (history) page --------------------------------------- */

.unlock__row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

.unlock__row .field__control {
  flex: 1;
}

.select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.backlog-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.backlog-controls__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}

.backlog-controls__row .field {
  margin-bottom: 0;
}

.backlog-status {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.backlog-retry {
  margin-bottom: 0.75rem;
}

.backlog-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.backlog-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0.9rem 1rem;
}

.backlog-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.backlog-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.backlog-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.backlog-card__meta span:empty {
  display: none;
}

.backlog-card__meta span {
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.backlog-card__figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.backlog-card__payment {
  color: var(--text-2);
  font-weight: 600;
}

.backlog-card__net {
  color: var(--positive);
  font-weight: 700;
}

.backlog-card__people {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.backlog-card__people:empty {
  display: none;
}

/* --- Printable export container (hidden on screen; shown while printing) ---- */

.export-root {
  display: none;
  color: #000;
}

.export__title {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}

.export__generated {
  margin: 0 0 1rem;
  color: #444;
  font-size: 0.9rem;
}

.export-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.export-table th,
.export-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #ccc;
}

.export-table th {
  border-bottom: 2px solid #000;
}

.export-table th:nth-child(4),
.export-table th:nth-child(5),
.export-table td:nth-child(4),
.export-table td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.export-total td {
  font-weight: 700;
  border-top: 2px solid #000;
  border-bottom: none;
}

/* While exporting the backlog, hide the interactive page and print only the
   export table + totals. The is-exporting class is toggled by history.js. */
@media print {
  body.is-exporting > .app {
    display: none !important;
  }
  body.is-exporting .export-root {
    display: block !important;
  }
}
