/* Semester Budget. site.css and demo.css supply the palette, panels, tables,
   fields, chips, tabs, toasts and dialogs; this adds the pieces a budgeting
   app needs on top. Every color comes from the token block below, which is
   built from the site's own tokens, so dark mode follows the site. */

:root {
  /* Category and subscription colors. Names always sit next to them, so a
     color is a second cue, never the only one. */
  --cat-1: var(--accent);
  --cat-2: var(--ink);
  --cat-3: var(--ok);
  --cat-4: var(--danger);
  --cat-5: var(--ink-3);
  --cat-6: color-mix(in srgb, var(--accent) 55%, var(--ink));
  --cat-7: color-mix(in srgb, var(--ok) 55%, var(--ink));
  --cat-8: color-mix(in srgb, var(--ink-3) 45%, var(--paper));
  --cat-9: color-mix(in srgb, var(--danger) 55%, var(--paper));

  /* Chart marks. The three projection lines also differ by dash pattern. */
  --line-actual: var(--ink);
  --line-pace: var(--accent);
  --line-plan: var(--ink-3);
  --line-reserve: var(--danger);
  --line-savings: var(--ok);
  --chart-grid: var(--rule);
  --chart-bar: var(--ink-2);

  /* Slices of the Save & invest allocation bar. */
  --alloc-planned: var(--ink-2);
  --alloc-reserve: var(--danger);
  --alloc-buffer: var(--ink-3);
  --alloc-keep: var(--ok);
  --alloc-invest: var(--accent);

  --tint-accent: color-mix(in srgb, var(--accent) 12%, transparent);
  --tint-hover: color-mix(in srgb, var(--ink) 5%, transparent);
}

[hidden] {
  display: none !important;
}

.is-invisible {
  visibility: hidden;
}

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

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.good {
  color: var(--ok);
}

.bad {
  color: var(--danger);
}

.muted {
  color: var(--ink-2);
}

.strong {
  font-weight: 600;
}

.pre-wrap {
  white-space: pre-wrap;
}

/* ---------- app frame ---------- */

.app {
  max-width: 1180px;
}

.app-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.period-pick {
  display: flex;
  align-items: center;
  gap: 10px;

  .select {
    width: auto;
    min-width: 12rem;
  }
}

.tabs {
  margin-bottom: 18px;

  kbd {
    margin-left: 4px;
    font-size: 0.68rem;
    opacity: 0.7;
  }
}

/* Single-column grids get a minmax(0, 1fr) track; an auto track never
   shrinks below its widest child, which pushes a phone screen sideways. */
.app .stack,
.demo-dialog .stack,
.sub-grid,
.up-list,
.meters,
.alerts,
.sub-list,
.cat-bars,
.detect-list,
.split-spare,
.split-cards,
.form-grid,
.ra-hero,
.ra-preview {
  grid-template-columns: minmax(0, 1fr);
}

.view {
  --stack-gap: 16px;

  &:focus-visible {
    outline-offset: 6px;
  }
}

.panel {
  min-width: 0;
}

.panel-head .hint {
  margin-top: 2px;
}

.callout {
  padding: 10px 14px;
  border-left: 3px solid var(--ink-3);
  border-radius: 0 8px 8px 0;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 0.93rem;
  line-height: 1.5;

  b {
    color: var(--ink);
  }

  .btn {
    margin-left: 4px;
  }
}

.callout-warn {
  border-left-color: var(--accent);
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;

  p {
    flex: 1 1 260px;
  }
}

.empty {
  padding: 22px 10px;
  color: var(--ink-3);
  text-align: center;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;

  &:hover {
    color: var(--ink);
  }
}

/* A pressable chip: filters, the category picker, sub-tab switches. */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: var(--line) solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.3;
  cursor: pointer;

  &:hover {
    border-color: var(--ink-3);
  }

  &[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--tint-accent);
  }

  &:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  kbd {
    font-size: 0.7rem;
  }
}

.btn-primary kbd {
  border-color: currentColor;
  background: transparent;
  color: inherit;
}

.toggle-swatch {
  padding: 6px;
}

.count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-align: center;
}

.dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c, var(--ink-3));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent);
}

.dot-big {
  width: 16px;
  height: 16px;
}

.dot-keep {
  --c: var(--alloc-keep);
}

.dot-invest {
  --c: var(--alloc-invest);
}

.swatch {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.alloc-planned {
  background: var(--alloc-planned);
}

.alloc-reserve {
  background: var(--alloc-reserve);
}

.alloc-buffer {
  background: var(--alloc-buffer);
}

.alloc-keep {
  background: var(--alloc-keep);
}

.alloc-invest {
  background: var(--alloc-invest);
}

.cat-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cat-note {
  display: block;
  font-size: 0.82rem;
}

.input-sm {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 0.9rem;
}

.select-inline {
  display: inline-block;
  width: auto;
  min-height: 30px;
  padding: 2px 8px;
  font-weight: 600;
}

.check-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;

  input {
    margin-top: 3px;
  }
}

.form-grid {
  display: grid;
  gap: 12px;

  @media (min-width: 720px) {
    &.two {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    &.three {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    &.four {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .span-2 {
      grid-column: span 2;
    }
  }
}

.field-narrow {
  max-width: 240px;
}

.field-aside {
  align-self: end;
  padding-bottom: 9px;
}

/* Hidden header labels are absolutely positioned; this keeps them inside the
   scrolling wrapper instead of stretching the page on a phone. */
.table-wrap {
  position: relative;
}

.table-compact td {
  padding: 5px 8px;
}

.tx-note {
  max-width: 22em;
}

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

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
}

.tile {
  min-width: 0;
  padding: 14px 16px;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
}

.tile-value {
  margin-top: 6px;
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.tile-value-sm {
  font-size: 1.25rem;
}

.tile-value-text {
  font-size: 1.35rem;
  font-stretch: 80%;
  font-weight: 600;
}

.tile-hero .tile-value {
  font-size: 2rem;
}

.tile-unit {
  margin-left: 2px;
  color: var(--ink-3);
  font-size: 0.9rem;
  font-weight: 400;
}

.tile-sub {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 0.88rem;
}

.tiles-compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
}

.tiles-compact .tile {
  padding: 10px 12px;
}

.tiles-compact .tile-value {
  font-size: 1.2rem;
}

.pulse {
  @media (prefers-reduced-motion: no-preference) {
    animation: tile-pulse 1s ease;
  }
}

@keyframes tile-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
  }

  100% {
    box-shadow: 0 0 0 12px transparent;
  }
}

.delta {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0;
  vertical-align: middle;
  transition: opacity 0.8s;
}

.delta-up {
  border-color: var(--ok);
  color: var(--ok);
}

.delta-down {
  border-color: var(--danger);
  color: var(--danger);
}

.delta-flat {
  color: var(--ink-3);
}

.delta-gone {
  opacity: 0;
}

/* ---------- balances strip ---------- */

.balance-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.balance-cell {
  flex: 1 1 150px;
  min-width: 140px;
  padding: 4px 2px;
}

.balance-value {
  margin: 4px 0 2px;
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1.15;
}

.balance-net {
  padding: 10px 14px;
  border: var(--line) solid var(--ink);
  border-radius: 10px;
  background: var(--paper-2);

  .balance-value {
    font-size: 1.6rem;
  }
}

.balance-op {
  align-self: flex-start;
  padding-top: 24px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 1.4rem;
}

.balance-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule);

  .hint {
    margin-left: auto;
  }
}

@media (max-width: 720px) {
  .balance-op {
    display: none;
  }

  .balance-cell {
    flex-basis: 40%;
  }

  .balance-net {
    flex-basis: 100%;
  }
}

/* ---------- category meters ---------- */

.meters {
  display: grid;
  gap: 2px;
}

.meter {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(80px, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;

  &:hover {
    background: var(--tint-hover);
  }
}

.meter-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;

  span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.meter-track {
  position: relative;
  height: 10px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--paper-2);
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 5px;
  background: var(--chart-bar);

  &.over {
    background: var(--danger);
  }
}

.meter-pace {
  position: absolute;
  top: -5px;
  width: 2px;
  height: 18px;
  border-radius: 1px;
  background: var(--accent);
}

.meter-amount {
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .meter {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
  }

  .meter-track {
    grid-column: 1 / -1;
    order: 3;
  }
}

/* ---------- charts ---------- */

.chart-wrap {
  position: relative;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;

  &:focus-visible {
    outline-offset: 6px;
  }
}

.grid-line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.axis-line {
  stroke: var(--ink-3);
  stroke-width: 1;
}

.tick-label {
  fill: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
}

.line-actual,
.line-pace,
.line-plan,
.line-reserve,
.line-savings,
.line-savings-ahead,
.line-history,
.line-realigned {
  fill: none;
  stroke-linejoin: round;
}

.line-actual {
  stroke: var(--line-actual);
  stroke-width: 2.25;
}

.line-pace {
  stroke: var(--line-pace);
  stroke-width: 2.25;
  stroke-dasharray: 7 5;
}

.line-plan {
  stroke: var(--line-plan);
  stroke-width: 2.5;
  stroke-dasharray: 0.5 5;
  stroke-linecap: round;
}

.line-reserve {
  stroke: var(--line-reserve);
  stroke-width: 1.5;
  stroke-dasharray: 12 4 3 4;
}

.reserve-label {
  fill: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.area-actual {
  fill: url(#balance-fade);
}

.fade-top {
  stop-color: var(--fade, var(--line-actual));
  stop-opacity: 0.16;
}

.fade-bottom {
  stop-color: var(--fade, var(--line-actual));
  stop-opacity: 0;
}

.fade-ok {
  --fade: var(--line-savings);
}

.dot-now {
  fill: var(--line-actual);
  stroke: var(--paper);
  stroke-width: 2;
}

.dot-pace {
  fill: var(--paper);
  stroke: var(--line-pace);
  stroke-width: 2;
}

.dot-plan {
  fill: var(--paper);
  stroke: var(--line-plan);
  stroke-width: 2;
}

.end-label {
  fill: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
}

.end-label-strong {
  fill: var(--ink);
  font-weight: 500;
}

.crosshair {
  stroke: var(--ink-3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* The dashboard chart keeps its marks between renders; these glide. */
.chart-svg .mv {
  @media (prefers-reduced-motion: no-preference) {
    transition:
      d 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
      cx 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
      cy 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
      transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
  }
}

.chart-bar {
  fill: var(--chart-bar);
}

.chart-bar-partial {
  opacity: 0.5;
}

.bar-label {
  fill: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.line-savings {
  stroke: var(--line-savings);
  stroke-width: 2.25;
}

.line-savings-ahead {
  stroke: var(--line-savings);
  stroke-width: 2;
  stroke-dasharray: 7 5;
}

.area-savings {
  fill: url(#savings-fade);
}

.dot-interest {
  fill: var(--line-savings);
  stroke: var(--paper);
  stroke-width: 1.5;
}

.line-history {
  stroke: var(--ink-3);
  stroke-width: 2;
}

.line-realigned {
  stroke: var(--accent);
  stroke-width: 2.75;
}

.dot-realigned {
  fill: var(--paper);
  stroke: var(--accent);
  stroke-width: 2;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 0.88rem;

  li {
    display: inline-flex;
    align-items: center;
    gap: 7px;
  }

  b {
    color: var(--ink);
    font-weight: 500;
  }
}

.legend-line {
  width: 24px;
  height: 10px;
  overflow: visible;
}

.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 170px;
  padding: 10px 12px 12px;
  font-size: 0.74rem;
  pointer-events: none;

  .readout-head {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  p {
    color: var(--screen-dim);
  }
}

.chart-note {
  margin-top: 8px;
}

/* ---------- alerts and upcoming charges ---------- */

.alerts {
  display: grid;
  gap: 8px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-3);
  border-radius: 0 10px 10px 0;
  background: var(--paper);
}

.alert-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--ink-3);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;

  &::before {
    content: "i";
  }
}

.alert-crit {
  border-left-color: var(--danger);

  .alert-icon {
    background: var(--danger);

    &::before {
      content: "!";
    }
  }
}

.alert-warn {
  border-left-color: var(--accent);

  .alert-icon {
    background: var(--accent);
    color: var(--on-accent);

    &::before {
      content: "▲";
    }
  }
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: 600;
  line-height: 1.35;
}

.alert-actions {
  justify-content: flex-end;
}

@media (max-width: 560px) {
  .alert {
    flex-wrap: wrap;
  }

  .alert-actions {
    justify-content: flex-start;
    width: 100%;
  }
}

.up-list {
  display: grid;
}

.up-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 6px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;

  &:last-child {
    border-bottom: 0;
  }

  &:hover {
    background: var(--tint-hover);
  }
}

.up-date {
  flex: none;
  width: 96px;
  color: var(--ink-2);
  font-size: 0.82rem;
}

.up-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .up-date {
    width: 88px;
  }

  .up-when {
    display: none;
  }
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: var(--line) solid var(--c, var(--ink-3));
  border-radius: 8px;
  background: color-mix(in srgb, var(--c, var(--ink-3)) 18%, var(--paper));
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.avatar-big {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 0.95rem;
}

/* ---------- subscriptions ---------- */

.sub-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sub-grid {
  display: grid;
  gap: 16px;

  @media (min-width: 900px) {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }
}

.cat-bars {
  display: grid;
  gap: 9px;
}

.cat-bar {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  font-size: 0.92rem;
}

.cat-bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subs-empty h2 {
  font-size: 1.5rem;
  font-stretch: 78%;
  font-weight: 600;
}

.empty-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
  margin-top: 16px;
}

.empty-option {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;

  &:hover {
    border-color: var(--accent);
  }

  span {
    color: var(--ink-2);
    font-size: 0.88rem;
  }
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;

  .input[type="search"] {
    max-width: 260px;
  }
}

.list-selects {
  margin-left: auto;

  .select {
    width: auto;
  }
}

.sub-list {
  display: grid;
  margin-top: 12px;
}

.sub-row,
.detect-row {
  display: grid;
  gap: 8px 14px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--rule);
}

.sub-row {
  grid-template-columns:
    auto minmax(180px, 1.6fr) minmax(120px, 0.9fr) minmax(110px, 0.7fr)
    auto;
  cursor: pointer;

  &:hover {
    background: var(--tint-hover);
  }
}

.detect-row {
  grid-template-columns: auto minmax(200px, 1.6fr) minmax(130px, 0.8fr) auto;
}

.sub-name {
  min-width: 0;

  .hint {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.sub-when {
  font-size: 0.92rem;
}

.sub-amount {
  text-align: right;
  white-space: nowrap;
}

.sub-yearly {
  display: block;
}

.sub-actions {
  justify-content: flex-end;
}

@media (max-width: 820px) {
  .sub-row,
  .detect-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .sub-when,
  .sub-actions,
  .detect-row > .cluster {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }
}

.list-foot {
  justify-content: space-between;
  margin-top: 10px;
}

.cal-nav .cal-title {
  min-width: 9.5rem;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-names {
  margin-bottom: 4px;

  span {
    padding: 2px 6px;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}

.cal-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 86px;
  padding: 5px 6px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: inherit;
  font: inherit;
  text-align: left;
}

button.cal-cell {
  cursor: pointer;

  &:hover {
    background: var(--paper-2);
  }
}

.cal-blank {
  border: 0;
  background: none;
}

.cal-past {
  opacity: 0.7;
}

.cal-today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.cal-num {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;

  b {
    color: var(--ink);
    font-weight: 500;
  }
}

.cal-chips {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 1px 5px;
  border-left: 3px solid var(--c);
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  font-size: 0.72rem;
  white-space: nowrap;
}

.cal-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-mark {
  color: var(--ink-3);
  font-style: normal;
}

.cal-mark-ok {
  color: var(--ok);
}

@media (max-width: 820px) {
  .cal-cell {
    min-height: 60px;
  }

  .cal-chip-name {
    display: none;
  }
}

@media (max-width: 480px) {
  .cal-cell {
    padding: 3px;
  }

  .cal-num b {
    display: none;
  }
}

.review-progress {
  flex-wrap: nowrap;
}

.review-bar {
  flex: 1;
}

.review-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 16px;

  h2 {
    font-size: 1.5rem;
    font-stretch: 78%;
    font-weight: 600;
  }
}

.review-cost {
  margin-left: auto;
  font-size: 1.7rem;
}

.review-buttons {
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}

.review-skip {
  margin-left: auto;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 10px;
  margin: 0;

  > div {
    padding: 9px 12px;
    border: 1px solid var(--rule);
    border-radius: 10px;
  }

  dd {
    margin: 4px 0 0;
  }
}

.fact-big {
  font-size: 1.2rem;
  font-weight: 500;
}

.fact-sub {
  display: block;
}

.stars {
  display: inline-flex;
  gap: 2px;
}

.star {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--rule);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;

  &:hover,
  &.star-on {
    color: var(--accent);
  }
}

.scan-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;

  .field {
    min-width: 200px;
  }
}

.sub-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.template-box {
  padding: 12px;
  border: 1px dashed var(--ink-3);
  border-radius: 10px;
}

.template-chips {
  max-height: 104px;
  margin-top: 9px;
  overflow: auto;
}

.more-fields summary {
  color: var(--ink-2);
  font-size: 0.92rem;
  cursor: pointer;
}

.more-fields > .stack {
  margin-top: 12px;
}

.fx-row {
  flex-wrap: nowrap;
}

.fx-code {
  width: 3rem;
}

.fx-input {
  width: 8rem;
}

/* ---------- savings and Save & invest ---------- */

.ladder {
  font-size: 0.97rem;

  [data-list] {
    display: contents;
  }
}

.ladder-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--rule);
}

.ladder-key {
  color: var(--ink-2);

  small {
    display: block;
    margin-top: 2px;
    color: var(--ink-3);
    font-size: 0.82rem;
  }
}

.ladder-value {
  font-weight: 500;
  white-space: nowrap;
}

.ladder-strong .ladder-key,
.ladder-strong .ladder-value {
  color: var(--ink);
  font-weight: 600;
}

.ladder-neg .ladder-value {
  color: var(--danger);
}

.ladder-sum {
  margin-top: 2px;
  border-top: 2px solid var(--ink);
  border-bottom: 0;

  .ladder-key,
  .ladder-value {
    color: var(--ink);
    font-size: 1.15rem;
    font-weight: 600;
  }
}

.split-spare {
  display: grid;
  gap: 10px;
  margin-top: 20px;

  input[type="range"] {
    width: 100%;
  }
}

.split-head {
  justify-content: space-between;
}

.split-cards {
  display: grid;
  gap: 12px;

  @media (min-width: 560px) {
    grid-template-columns: 1fr 1fr;
  }
}

.split-card {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;

  .label {
    display: flex;
    align-items: center;
    gap: 7px;
  }
}

.split-value {
  margin-top: 4px;
  font-size: 1.5rem;
  font-weight: 500;
}

.alloc-bar {
  display: flex;
  gap: 2px;
  height: 36px;
  overflow: hidden;
  border: var(--line) solid var(--ink);
  border-radius: 8px;
}

.alloc-segment {
  flex-basis: 0;
  min-width: 2px;
  transition: flex-grow 0.3s;
}

.realign-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;

  > div {
    flex: 1 1 280px;
  }

  h2 {
    font-size: 1.3rem;
    font-stretch: 78%;
    font-weight: 600;
  }
}

.cat-table .rate-edit {
  .input {
    width: 90px;
  }

  .select {
    width: 110px;
  }
}

.setup-reset {
  margin-left: auto;
}

@media (max-width: 560px) {
  .hide-sm {
    display: none;
  }
}

/* ---------- dialogs ---------- */

.demo-dialog {
  max-height: calc(100dvh - 32px);

  .stack {
    --stack-gap: 14px;
  }
}

.dialog-wide {
  width: min(94vw, 50rem);
}

.dialog-xwide {
  width: min(96vw, 68rem);
}

.dialog-desc {
  margin-top: -4px;
  color: var(--ink-2);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 4px;
}

.dialog-left {
  margin-right: auto;
}

.picker {
  margin: 0;
  padding: 0;
  border: 0;

  > legend {
    margin-bottom: 7px;
    padding: 0;
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}

.statement-picks .check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;

  &:has(input:checked) {
    border-color: var(--accent);
    background: var(--tint-accent);
  }

  input {
    margin-top: 3px;
  }
}

.key-list {
  display: grid;
  gap: 8px;
  margin: 0;

  > div {
    display: grid;
    grid-template-columns: 6.5rem 1fr;
    gap: 12px;
    align-items: center;
  }

  dd {
    margin: 0;
  }
}

.cancel-link {
  justify-self: start;
}

.ir-controls {
  justify-content: space-between;
}

.ir-table,
.ra-table {
  max-height: 44vh;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;

  thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--paper);
  }
}

.ir-desc {
  max-width: 260px;
}

.ir-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ir-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.ir-flags:empty {
  display: none;
}

.ir-dim td {
  opacity: 0.5;
}

.ir-type {
  min-width: 8.5rem;
}

.ir-pick .select {
  min-width: 9rem;
}

.ir-why {
  display: block;
  max-width: 200px;
  margin-top: 3px;
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ra-hero {
  display: grid;
  gap: 12px;

  @media (min-width: 820px) {
    grid-template-columns: 1.4fr 1fr;
  }

  > div {
    padding: 12px 15px;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--paper-2);
  }
}

.ra-big {
  margin: 5px 0 3px;
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1.1;
}

.ra-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px 24px;

  fieldset {
    margin: 0;
    padding: 0;
    border: 0;
  }

  legend {
    margin-bottom: 7px;
    padding: 0;
  }
}

.ra-cushion {
  min-width: 200px;
}

.ra-preview {
  display: grid;
  gap: 16px;
  align-items: start;

  @media (min-width: 820px) {
    grid-template-columns: 1fr 1.25fr;
  }
}

.ra-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ra-box {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;

  p.num {
    margin-top: 4px;
    font-size: 0.95rem;
  }
}

.ra-off td:not(:first-child) {
  opacity: 0.42;
}

.ra-slide {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ra-track {
  position: relative;
  display: block;
  flex: 1;
  min-width: 110px;
}

.ra-tick {
  position: absolute;
  top: 1px;
  z-index: 1;
  width: 2px;
  height: 22px;
  border-radius: 1px;
  pointer-events: none;
  translate: -1px 0;
}

.ra-tick-actual {
  background: var(--accent);
}

.ra-tick-current {
  background: var(--ink-3);
}

.ra-range {
  position: relative;
  z-index: 2;
  width: 100%;
}

.ra-num {
  width: 78px;
}

/* ---------- toasts ---------- */

/* A manual popover, so a toast shows above an open dialog. */
.toast-stack {
  position: fixed;
  inset: auto var(--gutter) 20px auto;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--ink);

  &:popover-open {
    display: grid;
    justify-items: end;
    gap: 8px;
  }

  .toast {
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;

    @media (prefers-reduced-motion: no-preference) {
      animation: toast-in 0.18s ease-out;
    }
  }
}

.toast-good {
  border-left: 4px solid var(--ok);
}

.toast-bad {
  border-left: 4px solid var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

@media (max-width: 640px) {
  .tabs kbd,
  .app-bar kbd {
    display: none;
  }

  .toast-stack {
    inset: auto 12px 12px 12px;
  }
}
