/* App shell: navigation bar, screen content, tab bar. Colours only via tokens.css. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: var(--font-size-body);
  -webkit-font-smoothing: antialiased;
}

/* Content column: max 480 px, centred; never hidden behind the tab bar, and the last content
   scrolls fully above the floating "+" (16 px space, the button, 16 px above the tab bar). */
.app {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom) + var(--space-page) + var(--fab-size) + var(--space-page));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Navigation bar with large title. The 44 px top row (Finanzgruppen-Auswahl / back link, actions)
   sits 24 px below the safe area, clear of the system's blurred top edge; the large title follows 4 px below it. */
.nav-bar {
  --nav-bar-row-top: 24px;
  --nav-bar-row-gap: 4px;
  padding: calc(var(--nav-bar-row-top) + var(--touch-target) + var(--nav-bar-row-gap)) var(--space-page) 8px;
}

.nav-bar__title {
  margin: 0;
  font-size: var(--font-size-large-title);
  font-weight: 700;
  line-height: 41px;
  letter-spacing: 0.37px;
  overflow-wrap: anywhere;
}

/* Screen content */
.screen {
  padding: 0 var(--space-page);
}

.placeholder {
  margin: var(--space-section) 0 0;
  color: var(--label-secondary);
  font-size: var(--font-size-body);
  line-height: 22px;
  text-align: center;
}

/* Tab bar: background spans the full width, items centred in the 480 px column. */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: color-mix(in srgb, var(--bg-elevated) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  /* hairline drawn outside the box, so the bar stays exactly 49 px + safe area */
  box-shadow: 0 -0.5px 0 var(--separator);
}

.tab-bar__items {
  display: flex;
  max-width: var(--content-max-width);
  height: var(--tab-bar-height);
  margin: 0 auto;
}

.tab-bar__item {
  flex: 1 1 0;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--label-secondary);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar__item[aria-current="page"] {
  color: var(--accent);
}

.tab-bar__icon {
  width: var(--tab-icon-size);
  height: var(--tab-icon-size);
  flex: none;
}

.tab-bar__label {
  font-size: var(--font-size-tab-label);
  font-weight: 500;
  line-height: 12px;
  white-space: nowrap;
}

/* Floating action button (floating "+", Schnelle Zahlung): a full-width, click-through layer fixed
   16 px above the tab bar with a centred 480 px row, so the button sits at the right edge of the
   content column (16 px inset), not at the window edge. Above content and tab bar (10), below the
   pull-down / popover backdrop (20) and menus (21); sheets are in the top layer. */
.fab-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom) + var(--space-page));
  z-index: 15;
  pointer-events: none;
}

.fab-layer__inner {
  display: flex;
  justify-content: flex-end;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 calc(var(--space-page) + env(safe-area-inset-right)) 0 calc(var(--space-page) + env(safe-area-inset-left));
}

.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--fab-size);
  height: var(--fab-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 32px var(--separator);
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
  .fab {
    box-shadow: 0 0 0 0.5px var(--separator), 0 8px 32px var(--separator);
  }
}

.fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
}

.fab:active {
  opacity: 0.8;
}

/* The ring floats around the circle: on the --accent fill an outline in --accent needs the gap. */
.fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Navigation bar actions (e.g. "+"): top right, in the 44 px row above the large title. */
.nav-bar {
  position: relative;
}

.nav-bar__actions {
  position: absolute;
  top: var(--nav-bar-row-top);
  right: 8px;
  display: flex;
}

.nav-bar__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-bar__button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.nav-bar__button:disabled {
  color: var(--label-secondary);
  cursor: default;
}

/* Back link of a pushed screen ("‹ Übersicht"): top left, in the same 44 px row. */
.nav-bar__back {
  position: absolute;
  top: var(--nav-bar-row-top);
  left: 0;
  display: flex;
  align-items: center;
  min-height: var(--touch-target);
  padding: 0 8px 0 4px;
  color: var(--accent);
  font-size: var(--font-size-body);
  line-height: 22px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-bar__back[hidden] {
  display: none;
}

.nav-bar__back svg {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Finanzgruppen-Auswahl: pull-down button top left in the 44 px row above the large title (tab screens). */
.finance-group-picker {
  position: absolute;
  top: var(--nav-bar-row-top);
  left: var(--space-page);
  /* ends 8 px before the actions at the right (8 px inset + one 44 px button) */
  max-width: calc(100% - var(--space-page) - var(--touch-target) - 16px);
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--touch-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 22px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.finance-group-picker__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-group-picker__chevron {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pull-down menu: below its button, above the content and the tab bar. */
.pull-down-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.pull-down-menu {
  position: absolute;
  top: calc(var(--nav-bar-row-top) + var(--touch-target));
  left: var(--space-page);
  z-index: 21;
  width: max-content;
  min-width: 220px;
  max-width: calc(100% - 2 * var(--space-page));
  /* scrolls inside itself and ends above the tab bar */
  max-height: calc(100dvh - env(safe-area-inset-top) - var(--nav-bar-row-top) - var(--touch-target) - var(--tab-bar-height) - env(safe-area-inset-bottom) - var(--space-page));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elevated);
  border-radius: var(--group-radius);
  box-shadow: 0 8px 32px var(--separator);
}

@media (prefers-color-scheme: dark) {
  .pull-down-menu {
    box-shadow: 0 0 0 0.5px var(--separator), 0 8px 32px var(--separator);
  }
}

.pull-down-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--touch-target);
  margin: 0;
  padding: var(--cell-padding);
  border: 0;
  background: none;
  color: var(--label);
  font: inherit;
  font-size: var(--font-size-body);
  line-height: 22px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pull-down-menu__item + .pull-down-menu__item {
  border-top: 0.5px solid var(--separator);
}

.pull-down-menu__item:active {
  background: var(--separator);
}

/* keyboard focus as a row highlight (like iOS menus) instead of a ring clipped by the rounded corners */
.pull-down-menu__item:focus-visible {
  outline: none;
  background: var(--separator);
}

.pull-down-menu__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pull-down-menu__check {
  flex: none;
  color: var(--accent);
  font-weight: 600;
}

/* Anchored to its button (#57): right-aligned with it, below or above it; pull-down-menu.js sets
   top / bottom / right / max-height from the layout. */
.pull-down-menu--anchored {
  top: 100%;
  right: 0;
  left: auto;
  max-width: 100%;
}

/* Sections: an 8 px band in the grouped background between them, an optional title */
.pull-down-menu__section + .pull-down-menu__section {
  border-top: 8px solid var(--bg);
}

.pull-down-menu__section-title {
  padding: 12px 16px 4px;
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
  text-transform: uppercase;
}

.pull-down-menu__title,
.pull-down-menu__detail {
  display: block;
}

.pull-down-menu__detail {
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

.pull-down-menu__item[aria-disabled="true"] {
  cursor: default;
}

/* Grouped inset list */
.grouped-section {
  margin-top: var(--space-section);
}

.screen .grouped-section:first-child,
.sheet__body .grouped-section:first-of-type {
  margin-top: 16px;
}

.section-header {
  margin: 0 0 6px;
  padding: 0 var(--cell-inset);
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  font-weight: 400;
  line-height: 18px;
  text-transform: uppercase;
}

.grouped-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--bg-elevated);
  border-radius: var(--group-radius);
  overflow: hidden;
}

.grouped-list > li {
  position: relative;
}

/* hairline between cells, inset 16 px from the left */
.grouped-list > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--cell-inset);
  right: 0;
  border-top: 0.5px solid var(--separator);
}

/* List cell: title (+ detail line) left, amount right */
.list-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--touch-target);
  margin: 0;
  padding: var(--cell-padding);
  border: 0;
  background: none;
  color: var(--label);
  font: inherit;
  font-size: var(--font-size-body);
  line-height: 22px;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

button.list-cell {
  cursor: pointer;
}

button.list-cell:active {
  background: var(--separator);
}

.list-cell__text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.list-cell__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* wraps between its " · " segments, never inside one (see createListCell) */
.list-cell__detail {
  color: var(--label-secondary);
  font-size: var(--font-size-detail);
  line-height: 20px;
}

.list-cell__segment {
  white-space: nowrap;
  /* a single segment wider than the line (e.g. a long name of wide letters) ends with an ellipsis */
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

/* still moves to the next line as a whole first; only a segment wider than the line wraps between words */
.list-cell__detail--wrap-words .list-cell__segment {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.list-cell--emphasized {
  font-weight: 600;
}

.list-cell--destructive {
  justify-content: center;
  color: var(--negative);
  text-align: center;
}

.list-cell--action {
  color: var(--accent);
}

a.list-cell {
  text-decoration: none;
  cursor: pointer;
}

a.list-cell:active {
  background: var(--separator);
}

/* Trailing chevron of a navigation cell */
.list-cell__chevron {
  flex: none;
  margin-left: -4px;
  color: var(--label-secondary);
  font-size: 22px;
  line-height: 22px;
}

/* Trailing checkmark of the chosen cell in a choice list */
.list-cell__check {
  flex: none;
  color: var(--accent);
  font-size: var(--font-size-body);
  font-weight: 600;
}

/* Destructive button that is not available (e.g. "Finanzgruppe löschen" of a group that is not empty)
   and an Action cell while its request runs (e.g. „Anmelden“) */
.list-cell--destructive:disabled,
.list-cell--action:disabled {
  color: var(--label-secondary);
  cursor: default;
}

/* Hero amount ("Verfügbar"): the most prominent element of the app */
.hero {
  /* lets the amount size itself relative to the column width */
  container-type: inline-size;
  margin-top: 16px;
  padding: 0 var(--cell-inset);
}

.hero__caption {
  margin: 0;
  color: var(--label-secondary);
  font-size: var(--font-size-detail);
  line-height: 20px;
}

.hero__amount {
  margin: 2px 0 0;
  color: var(--label);
  /* 48 px; long amounts shrink to fit one line, never below 28 px.
     --hero-chars (set by the view) is the number of characters; 0.62 em is a
     conservative average glyph width for tabular digits. */
  font-size: clamp(28px, calc(100cqi / (var(--hero-chars, 10) * 0.62)), 48px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.hero__amount--negative {
  color: var(--negative);
}

.hero__uncertain {
  margin: 4px 0 0;
  font-size: var(--font-size-detail);
  line-height: 20px;
}

.hero__uncertain-amount {
  color: var(--warning);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero__uncertain-caption {
  color: var(--label-secondary);
}

/* Optional "Alle Finanzgruppen: {Betrag}" below the hero (setting on Einstellungen) */
.hero__total {
  margin: 4px 0 0;
  font-size: var(--font-size-detail);
  line-height: 20px;
}

.hero__total-caption {
  color: var(--label-secondary);
}

.hero__total-amount {
  color: var(--label);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero__total-amount--negative {
  color: var(--negative);
}

/* Section footer: explanation below a grouped list */
.section-footer {
  margin: 6px 0 0;
  padding: 0 var(--cell-inset);
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

/* Info cell: wrapping text with optional warning icon and text button (hints, status) */
.info-cell {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--touch-target);
  padding: var(--cell-padding);
}

.info-cell__icon {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: -1px;
  fill: none;
  stroke: var(--warning);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.info-cell__body {
  flex: 1 1 auto;
  min-width: 0;
}

.info-cell__title,
.info-cell__text {
  margin: 0;
  overflow-wrap: break-word;
}

.info-cell__title {
  font-size: var(--font-size-body);
  line-height: 22px;
}

.info-cell__text {
  font-size: var(--font-size-detail);
  line-height: 20px;
}

.info-cell__title + .info-cell__text {
  margin-top: 2px;
  color: var(--label-secondary);
}

/* Inline link inside the text (e.g. "Eingänge" in the waiting hint on Übersicht) */
.info-cell__link {
  color: var(--accent);
  text-decoration: none;
}

.info-cell__action {
  min-height: var(--touch-target);
  margin: 0 0 -11px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-body);
  cursor: pointer;
}

/* Result of the last export / import below the BACKUP section */
.feedback__message {
  margin: 16px 0 0;
  padding: 0 var(--cell-inset);
  color: var(--label);
  font-size: var(--font-size-detail);
  line-height: 20px;
  overflow-wrap: break-word;
}

.feedback__message--error {
  color: var(--negative);
}

/* Amounts: right-aligned, tabular numbers, never cut off */
.amount {
  flex: none;
  color: var(--label);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.amount--negative {
  color: var(--negative);
}

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

.amount--warning {
  color: var(--warning);
}

/* Amount with a smaller second amount below it (e.g. share and full amount of an Anteilige Zahlung) */
.list-cell__amounts {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
}

.amount--sub {
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

/* e.g. a paused Geldeingang: the whole cell content is dimmed */
.list-cell--dimmed > * {
  opacity: 0.45;
}

/* Month row: leading status mark + list cell; the mark is outside the cell,
   so it stays fully visible when the cell is dimmed. */
.status-row {
  display: flex;
  align-items: stretch;
}

/* Erledigt rows hidden in the period section (#66) */
.grouped-list > li[hidden] {
  display: none;
}

.status-row > .list-cell {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 4px;
}

/* hairline between month rows starts at the text, as in iOS Reminders */
.grouped-list > li.status-row + li.status-row::before {
  left: 54px;
}

/* Empty place of the status mark in a month row that cannot be ticked off (Anteilige Zahlung) */
.status-row__spacer {
  flex: none;
  width: var(--touch-target);
  margin: 0 0 0 calc(var(--cell-inset) - 10px);
}

/* Status mark: 24 px circle, 44 x 44 px touch target, circle aligned to the cell inset */
.status-mark {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  min-height: var(--touch-target);
  margin: 0 0 0 calc(var(--cell-inset) - 10px);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.status-mark__icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-mark__circle {
  stroke: var(--label-secondary);
  stroke-width: 1.5;
}

.status-mark__check {
  stroke: none;
}

.status-mark[aria-pressed="true"] .status-mark__circle {
  fill: var(--accent);
  stroke: var(--accent);
}

.status-mark[aria-pressed="true"] .status-mark__check {
  stroke: var(--on-accent);
  stroke-width: 2;
}

/* Toggle write failure: between the section header and the list */
.feedback__message.month-section__failure {
  margin: 0 0 6px;
}

/* Empty state and load-error notice */
.empty-state {
  margin-top: var(--space-section);
  text-align: center;
}

.empty-state__title {
  margin: 0 0 8px;
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 22px;
}

.empty-state__text,
.notice {
  margin: 0;
  color: var(--label-secondary);
  font-size: var(--font-size-body);
  line-height: 22px;
}

.notice {
  margin-top: var(--space-section);
  text-align: center;
}

.empty-state__button {
  min-height: var(--touch-target);
  margin-top: 8px;
  padding: 0 16px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-body);
  cursor: pointer;
}

/* Sheet: full-height modal sliding up; while open, sheet.js sizes it to the visual viewport
   (--sheet-top / --sheet-height), so with the iOS keyboard open it fills the area above it */
.sheet {
  top: var(--sheet-top, 0px);
  bottom: auto;
  width: 100%;
  max-width: var(--content-max-width);
  height: var(--sheet-height, 100%);
  max-height: none;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--label);
}

.sheet[open] {
  animation: sheet-slide-up 0.3s ease-out;
}

.sheet::backdrop {
  background: color-mix(in srgb, var(--label) 30%, transparent);
}

@keyframes sheet-slide-up {
  from {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet[open] {
    animation: none;
  }
}

.sheet__form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sheet__header {
  display: grid;
  /* side columns never narrower than their button, so a long title cannot overlap them */
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center;
  flex: none;
  padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
  background: var(--bg-elevated);
  box-shadow: 0 0.5px 0 var(--separator);
}

.sheet__title {
  margin: 0;
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 22px;
  text-align: center;
  white-space: nowrap;
}

.sheet__action {
  justify-self: start;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-body);
  cursor: pointer;
}

.sheet__action--primary {
  justify-self: end;
  font-weight: 600;
}

.sheet__action:disabled {
  color: var(--label-secondary);
  cursor: default;
}

.sheet__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 calc(var(--space-page) + env(safe-area-inset-right)) calc(var(--space-section) + env(safe-area-inset-bottom)) calc(var(--space-page) + env(safe-area-inset-left));
}

.sheet__alert {
  margin: 16px var(--cell-inset) 0;
  color: var(--negative);
  font-size: var(--font-size-detail);
  line-height: 20px;
}

/* Form cells inside a grouped list */
.form-cell__row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--touch-target);
  padding: var(--cell-padding);
  font-size: var(--font-size-body);
  line-height: 22px;
}

.form-cell__label {
  flex: none;
  width: 104px;
}

.form-cell__input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--label);
  font: inherit;
  font-size: var(--font-size-body);
  line-height: 22px;
  outline: none;
}

.form-cell__input::placeholder {
  color: var(--label-secondary);
}

.form-cell__suffix {
  flex: none;
  color: var(--label-secondary);
}

/* Value cell (select, date): label at its natural width, value right-aligned */
.form-cell__row--value .form-cell__label {
  width: auto;
}

.form-cell__row--value .form-cell__input {
  text-align: right;
  text-align-last: right;
  cursor: pointer;
}

.form-cell__row--value .form-cell__input::-webkit-date-and-time-value {
  text-align: right;
}

.form-cell__caption {
  margin: -6px 0 0;
  padding: 0 var(--cell-inset) 11px;
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

.field-error {
  margin: -6px 0 0;
  padding: 0 var(--cell-inset) 11px;
  color: var(--negative);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

/* Toggle: iOS switch */
.toggle {
  cursor: pointer;
}

.toggle__text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.toggle__caption {
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

.toggle__switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 16px;
  background: var(--separator);
  cursor: pointer;
  transition: background-color 0.2s;
}

.toggle__switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--switch-thumb);
  box-shadow: 0 1px 3px var(--separator);
  transition: transform 0.2s;
}

.toggle__switch:checked {
  background: var(--positive);
}

.toggle__switch:checked::before {
  transform: translateX(20px);
}

/* A switch that cannot be changed (e.g. „Standardkonto“ on the Standardkonto itself) */
.toggle:has(.toggle__switch:disabled),
.toggle__switch:disabled {
  cursor: default;
}

.toggle__switch:disabled {
  opacity: 0.5;
}

.toggle__switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .toggle__switch,
  .toggle__switch::before {
    transition: none;
  }
}

/* Segmented control (iOS): equal-width segments, the selected one raised */
.segmented {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--label-secondary) 20%, transparent);
}

.segmented__segment {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  cursor: pointer;
}

.segmented__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented__label {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: var(--font-size-caption);
  font-weight: 500;
  line-height: 20px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segmented__input:checked + .segmented__label {
  background: var(--segment-selected);
  box-shadow: 0 1px 3px var(--separator);
  font-weight: 600;
}

.segmented__input:focus-visible + .segmented__label {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Day chart (shared by the charts over a period): inline SVG with equal-width day slots,
   the day axis below the plot, the "Heute" marker and the tap / drag selection band. */
.day-chart {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  /* horizontal drags select days; vertical swipes stay with the page */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.day-chart:focus {
  outline: none;
}

.day-chart:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.day-chart__band {
  fill: var(--separator);
}

.day-chart__today-line {
  stroke: var(--accent);
  stroke-width: 1;
}

.day-chart__today-caption {
  fill: var(--accent);
  font-size: var(--font-size-caption);
}

.day-chart__baseline,
.day-chart__tick {
  stroke: var(--separator);
  stroke-width: 1;
}

.day-chart__label {
  fill: var(--label-secondary);
  font-size: var(--font-size-caption);
}

/* Row above a zoomed plot: the zoom range (caption) left, "Ganze Periode" right */
.day-chart__zoom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* the 44 px touch target reaches into the cell's top padding */
  margin-top: -12px;
}

.day-chart__zoom[hidden] {
  display: none;
}

.day-chart__zoom-label {
  min-width: 0;
  color: var(--label-secondary);
  font-size: var(--font-size-caption);
  line-height: 18px;
}

.day-chart__zoom-reset {
  flex: none;
  min-height: var(--touch-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-detail);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Accent text buttons in section header rows of Eingänge / Zahlungen: "Alle anzeigen" /
   "Erledigte ausblenden" (period section), "Anzeigen" / "Ausblenden" (REGELMÄSSIG, EINMALIG) */
.items__done-toggle,
.items__list-toggle {
  flex: none;
  min-height: var(--touch-target);
  margin: 0;
  padding: 0 var(--cell-inset);
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-body);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Bar timeline ("ZEITLEISTE") on Eingänge / Zahlungen */
.timeline__plot {
  padding: 12px var(--cell-inset) 8px;
}

.timeline__segment--positive {
  fill: var(--positive);
}

.timeline__segment--negative {
  fill: var(--negative);
}

.timeline__segment--warning {
  fill: var(--warning);
}

/* a day whose occurrences are all erledigt: same opacity as a dimmed list cell */
.timeline__bar--done {
  opacity: 0.45;
}

.timeline__name {
  fill: var(--label-secondary);
  font-size: 11px;
}

/* Line chart ("VERLAUF") of Verfügbar on Übersicht */

/* Header row: "VERLAUF" left, "Ansicht" and ⓘ right (#57). The 44 px row starts 13 px higher, so the
   header text stays where a plain section header sits; the anchored menu / popover are placed in it.
   The period section on Eingänge / Zahlungen uses the same row for „Alle anzeigen“ (#68). */
.available-chart__header,
.month-section__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--touch-target);
  margin-top: -13px;
}

.available-chart__header .section-header,
.month-section__header .section-header {
  margin: 0;
}

.available-chart__controls {
  display: flex;
  align-items: center;
  flex: none;
}

.available-chart__view-button,
.available-chart__info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-detail);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.available-chart__view-button {
  gap: 3px;
}

.available-chart__view-button:active,
.available-chart__info-button:active {
  opacity: 0.6;
}

.available-chart__view-button:focus-visible,
.available-chart__info-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 8px;
}

/* smaller than the Finanzgruppen-Auswahl's chevron (14 px) */
.available-chart__chevron {
  width: 12px;
  height: 12px;
}

.info-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Info popover: the pull-down menu's surface with text */
.info-popover {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 21;
  width: max-content;
  min-width: 240px;
  max-width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--group-radius);
  box-shadow: 0 8px 32px var(--separator);
  color: var(--label);
  font-size: var(--font-size-detail);
  line-height: 20px;
}

@media (prefers-color-scheme: dark) {
  .info-popover {
    box-shadow: 0 0 0 0.5px var(--separator), 0 8px 32px var(--separator);
  }
}

.info-popover:focus {
  outline: none;
}

.info-popover__text {
  margin: 0;
}

.info-popover__text + .info-popover__text {
  margin-top: 8px;
}

.available-chart__plot {
  padding: 12px var(--cell-inset) 8px;
}

.available-chart__line {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.available-chart__line--positive {
  stroke: var(--positive);
}

.available-chart__line--negative {
  stroke: var(--negative);
}

/* Konten, Offene Geldeingänge, Offene Zahlungen: thinner than Verfügbar, no area */
.available-chart__line--accounts,
.available-chart__line--open-incomes,
.available-chart__line--open-payments {
  stroke-width: 2;
}

.available-chart__line--accounts {
  stroke: var(--label-secondary);
}

.available-chart__line--open-incomes {
  stroke: var(--chart-incomes);
}

.available-chart__line--open-payments {
  stroke: var(--chart-payments);
}

/* the Vorschau after today; butt caps keep the dashes 4 px long */
.available-chart__line--projected {
  stroke-dasharray: 4 4;
  stroke-linecap: butt;
}

.available-chart__dot--accounts,
.available-chart__marker--accounts,
.available-chart__swatch--accounts {
  fill: var(--label-secondary);
  background: var(--label-secondary);
}

.available-chart__dot--open-incomes,
.available-chart__marker--open-incomes,
.available-chart__swatch--open-incomes {
  fill: var(--chart-incomes);
  background: var(--chart-incomes);
}

.available-chart__dot--open-payments,
.available-chart__marker--open-payments,
.available-chart__swatch--open-payments {
  fill: var(--chart-payments);
  background: var(--chart-payments);
}

.available-chart__swatch--positive {
  background: var(--positive);
}

/* Swatch of a line: 16 × 4 px in the menu's „Linien“ rows */
.available-chart__swatch {
  flex: none;
  width: 16px;
  height: 4px;
  border-radius: 2px;
}

/* Colour key below the plot (#57): the visible lines only, not interactive, wrapping instead of scrolling */
.available-chart__key {
  display: flex;
  flex-wrap: wrap;
  column-gap: 10px;
  margin-top: 4px;
  color: var(--label-secondary);
  font-size: 11px;
  line-height: 14px;
}

.available-chart__key-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.available-chart__swatch--key {
  width: 12px;
  height: 3px;
  border-radius: 1.5px;
}

.available-chart__area {
  stroke: none;
  fill-opacity: 0.2;
}

.available-chart__area--positive,
.available-chart__dot--positive,
.available-chart__marker--positive {
  fill: var(--positive);
}

.available-chart__area--negative,
.available-chart__dot--negative,
.available-chart__marker--negative {
  fill: var(--negative);
}

/* the selection dots stand out from the line with a ring in the cell colour */
.available-chart__marker {
  stroke: var(--bg-elevated);
  stroke-width: 2;
}

.available-chart__zero-line {
  stroke: var(--separator);
  stroke-width: 1;
}

/* a halo in the cell colour keeps the label readable where the line passes behind it */
.available-chart__y-label {
  fill: var(--label-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--bg-elevated);
  stroke-width: 3;
  stroke-linejoin: round;
}

.available-chart__change--positive {
  color: var(--positive);
}

.available-chart__change--negative {
  color: var(--negative);
}
