:root {
  --bg: #F1F7F6;
  --surface: #FFFFFF;
  --ink: #06302B;
  --ink-soft: #5E7A74;
  --ink-faint: #8FA7A1;
  --accent: #03624C;
  --accent-soft: #E3F1EC;
  --accent-ink: #03624C;
  --warn: #FF7A59;
  --warn-soft: #FFE9E1;
  --good: #17876D;
  --good-soft: #E3F5EE;
  --line: #DCEBE6;
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-card: 0 12px 30px -12px rgba(2, 27, 26, 0.18);
  --shadow-float: 0 18px 40px -14px rgba(2, 27, 26, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #E7E6F0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  /* Stops iOS Safari's double-tap-to-zoom gesture (pinch-zoom still works). */
  touch-action: manipulation;
}

.phone {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
  border-radius: 0;
  box-shadow: none;
}

@media (min-width: 540px) {
  .phone {
    padding: 24px 0;
  }

  .app {
    max-width: 430px;
    height: auto;
    min-height: 860px;
    max-height: 932px;
    border-radius: 44px;
    box-shadow: 0 40px 80px -30px rgba(21, 20, 43, 0.45), 0 0 0 10px #0E0D1F;
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: transform 0.38s cubic-bezier(.32,.72,0,1), opacity 0.3s ease;
}

.screen-home { z-index: 1; }

.screen-detail {
  transform: translateX(100%);
  z-index: 2;
}

.app.show-detail .screen-detail { transform: translateX(0); }
.app.show-detail .screen-home { transform: translateX(-12%); opacity: 0.4; }

/* ---------- HOME ---------- */

.home-topbar {
  padding: max(24px, env(safe-area-inset-top)) 24px 4px;
  flex-shrink: 0;
}

.home-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.home-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.switch-state {
  color: var(--ink-faint);
  font-weight: 600;
}

/* The side matching the switch position is the one in bold ink. */
.home-switch[data-on="false"] .state-off,
.home-switch[data-on="true"] .state-on {
  color: var(--ink);
  font-weight: 700;
}

.fetch-banner {
  margin: 10px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: #B5590F;
  background: var(--warn-soft);
  border: 1px solid #FFD2BD;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.card-list::-webkit-scrollbar { display: none; }

.p-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}

.p-card:active { transform: scale(0.98); }

.p-card-pending {
  border-color: #D9D7E8;
}

.p-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.p-card-merchant-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.p-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* #FFE1EC matches one of the former random-palette entries, kept as the
   fixed "needs attention" color instead of being assigned by chance. */
.p-logo-pending { background: #FFE1EC; }
.p-logo-done { background: var(--good-soft); }

.p-merchant-name {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
}

.p-merchant-date {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}

.p-amount {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.p-amount-income { color: var(--good); }

.p-card-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(21, 20, 43, 0.06);
}

.card-cta {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  padding: 10px 16px;
  border-radius: 100px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.card-cta:active { transform: scale(0.95); }

.card-cta.secondary {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ---------- DETAIL SCREEN ---------- */

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 16px 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--surface);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

.icon-btn-spacer { width: 40px; }

.detail-topbar-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.detail-scroll {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 24px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.detail-scroll::-webkit-scrollbar { display: none; }

.detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 4px 24px 20px;
  flex-shrink: 0;
}

.detail-hero-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.detail-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.detail-hero-text { min-width: 0; }

.detail-merchant {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-amount {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-meta {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}

.field-group {
  margin-bottom: 22px;
}

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 10px;
}

.field-sublabel {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}

.field-sublabel + .cat-groups {
  margin-top: 12px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.split-slider-wrap {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.split-amounts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.split-amount-col-right { text-align: right; }

.split-amount-label {
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.split-amount-value {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--accent-ink);
}

.split-amount-input-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  border-radius: 8px;
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 0.15s ease;
}

.split-amount-input-wrap:focus-within {
  background: var(--accent-soft);
}

.split-amount-input {
  width: 64px;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-ink);
  padding: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

.split-amount-input::-webkit-outer-spin-button,
.split-amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.split-amount-suffix {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--accent-ink);
}

.split-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 100px;
  background: var(--accent-soft);
  outline: none;
  margin: 0;
}

.split-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(3, 98, 76, 0.4);
  cursor: pointer;
  border: 3px solid #fff;
}

.split-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(3, 98, 76, 0.4);
  cursor: pointer;
  border: 3px solid #fff;
}

/* Category blocks: tiles inside a block are close, blocks are further apart. */
.cat-group {
  display: grid;
  /* minmax(0, 1fr): a long label must not widen its column past the container */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.cat-group + .cat-group {
  margin-top: 22px;
}

.cat-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--line);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.cat-tile:active { transform: scale(0.97); }

.cat-tile-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.cat-tile-label {
  font-size: 11.5px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}

.cat-tile-selected {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}

.cat-tile-selected .cat-tile-icon {
  background: rgba(255, 255, 255, 0.2);
}

.cat-tile-selected .cat-tile-label {
  color: #fff;
}

/* Same card idiom as .cat-tile, so the split toggle reads as part of the
   same family of controls as the category grid right above it. */
.split-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  margin: 10px 0 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--line);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.split-card:active { transform: scale(0.98); }

.split-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.split-card-text { flex: 1; min-width: 0; }
.split-card-title { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.split-card-sub { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }

.split-card-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.split-card[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}

.split-card[aria-pressed="true"] .split-card-icon { background: rgba(255, 255, 255, 0.2); }
.split-card[aria-pressed="true"] .split-card-title,
.split-card[aria-pressed="true"] .split-card-sub { color: #fff; }
.split-card[aria-pressed="true"] .split-card-check {
  background: #fff;
  border-color: #fff;
  color: var(--accent);
}

/* ---------- UNSAVED-CHANGES DIALOG ---------- */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(21, 20, 43, 0.35);
}

/* Author display rules would otherwise override the hidden attribute. */
.confirm-backdrop[hidden] { display: none; }

.confirm-card {
  width: 100%;
  max-width: 340px;
  padding: 24px 20px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.confirm-text {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--ink-soft);
}

.confirm-btn {
  padding: 14px;
  border: none;
  border-radius: 100px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.confirm-btn.secondary {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.portfolio-lock-error { color: #B5490F; margin: -4px 0 0; }

.confirm-cancel {
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.period-choice {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.period-choice-btn {
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.period-choice-btn:active { transform: scale(0.97); }

.period-choice-btn[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- PLACE / LOCATION ---------- */

.place-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.place-selected[hidden] { display: none; }

.place-selected:active { transform: scale(0.98); }

.place-selected-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.place-selected-text { flex: 1; min-width: 0; }

.place-selected-name {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-selected-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
}

.place-selected-clear {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--line);
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.place-selected-clear:active { background: var(--ink-faint); }

.place-name-input {
  width: 100%;
  margin-top: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}

.place-name-input::placeholder { color: var(--ink-faint); font-weight: 400; }

.place-name-input:focus { border-color: var(--accent); }

.place-search-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(.32,.72,0,1);
}

.place-search-overlay.show { transform: translateY(0); }

.place-search-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(20px, env(safe-area-inset-top)) 16px 12px;
  flex-shrink: 0;
}

.place-search-input {
  flex: 1;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  outline: none;
}

.place-search-input:focus { border-color: var(--accent); }

.place-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.place-search-results::-webkit-scrollbar { display: none; }

.place-results-list {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.place-suggestion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.place-suggestion-row:last-child { border-bottom: none; }

.place-suggestion-row:active {
  background: var(--accent-soft);
}

.place-suggestion-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.place-suggestion-text { flex: 1; min-width: 0; }

.place-suggestion-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.place-suggestion-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-suggestion-distance {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  flex-shrink: 0;
}

.place-suggestion-address {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.place-load-more {
  width: 100%;
  padding: 12px;
  margin-top: 2px;
  border: 1.5px dashed var(--ink-faint);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.place-load-more:active { background: var(--accent-soft); }

.place-load-more:disabled {
  color: var(--ink-faint);
  border-color: var(--line);
  cursor: default;
}

.place-load-more:disabled:active { background: transparent; }

.field-textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
}

.field-textarea:focus { border-color: var(--accent); }

.toggle {
  width: 50px;
  height: 30px;
  border-radius: 100px;
  background: var(--line);
  border: none;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle[aria-pressed="true"] { background: var(--accent); }

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}

.toggle[aria-pressed="true"] .toggle-knob { transform: translateX(20px); }

.receipt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.receipt-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1.5px solid var(--line);
}

.receipt-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.receipt-tile-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(21, 20, 43, 0.65);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.receipt-tile-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed var(--ink-faint);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
}

.receipt-tile-add:active { transform: scale(0.97); }

.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  height: 36px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 100px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tag-pill.is-selected {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.tag-new-row {
  height: 36px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 0 4px 0 14px;
  border-radius: 100px;
  border: 1.5px dashed var(--ink-faint);
  background: transparent;
}

.tag-new-row:focus-within { border-style: solid; }

.tag-new-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px; /* 16px stops iOS zooming in on focus */
  color: var(--ink);
}

.tag-new-input:focus { outline: none; }

.tag-new-add {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tag-new-add:active { transform: scale(0.94); }

.detail-bottom-spacer { height: 110px; }

.detail-footer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  flex-shrink: 0;
}

.save-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-float);
  transition: transform 0.15s ease;
  margin-bottom: 10px;
}

/* Last step: Weiter is hidden and Speichern shows alone, so no gap needed. */
.save-btn:has(+ .footer-next-btn[hidden]) {
  margin-bottom: 0;
}

.save-btn:active { transform: scale(0.97); }

/* ---------- TOAST ---------- */

.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 10;
  box-shadow: var(--shadow-float);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- LOGIN ---------- */

.login-screen {
  padding: max(24px, env(safe-area-inset-top)) 24px 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

/* ---------- DETAIL STEPS ---------- */

.step-indicator {
  margin: 4px 0 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.step[hidden] { display: none; }

/* Header controls: the start and end slots have a fixed width, so the title
   stays centred whichever of the controls are showing. */
.topbar-start,
.topbar-end {
  min-width: 104px;
  display: flex;
  align-items: center;
}

.topbar-start { justify-content: flex-start; }
.topbar-end { justify-content: flex-end; }

/* Same look as the back button. */
.step-next-btn {
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.step-next-btn[hidden] { display: none; }

.header-save-btn {
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.header-save-btn[hidden] { display: none; }

/* Steps slide in the same way the detail screen does. */
@keyframes step-swipe-forward {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes step-swipe-back {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.step.swipe-forward { animation: step-swipe-forward 0.38s cubic-bezier(.32,.72,0,1); }
.step.swipe-back { animation: step-swipe-back 0.38s cubic-bezier(.32,.72,0,1); }

/* ---------- SPLIT ACROSS CATEGORIES ---------- */

.basis-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.basis-choice[hidden] { display: none; }

.allocation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.allocation-select,
.allocation-amount {
  height: 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px; /* 16px stops iOS zooming in on focus */
  padding: 0 12px;
  min-width: 0;
}

.allocation-amount { text-align: right; }

.allocation-other {
  grid-column: 1 / -1;
}

.allocation-remove {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 18px;
  cursor: pointer;
}

.allocation-remove[hidden] { display: none; }

.allocation-add {
  align-self: flex-start;
  padding: 8px 14px;
  border: 1.5px dashed var(--ink-faint);
  border-radius: 100px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.allocation-remaining {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn);
}

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

/* ---------- DESKTOP LAYOUT (wide windows, see desk.js) ----------
   Modelled on macOS apps: a translucent sidebar with selected items filled in
   the accent colour, a toolbar with the title on the left and tools on the
   right, and a content area with a white, hairline-divided table. */

.desk { display: none; }

body.is-desktop .phone { display: none; }

/* Layout is driven by two widths on the grid, set by the state attributes.
   The more specific selectors below win over the base rule. */
body.is-desktop .desk {
  --sb: 232px;
  --pn: clamp(340px, 30vw, 420px); /* a length, so the width can animate */
  display: grid;
  grid-template-columns: var(--sb) minmax(0, 1fr) var(--pn);
  height: 100vh;
  height: 100dvh;
  background: #FBFBFD;
  transition: grid-template-columns 0.25s ease;
  overflow: hidden;
}

body.is-desktop .desk[data-sidebar="collapsed"] { --sb: 60px; }
body.is-desktop .desk[data-panel="collapsed"] { --pn: 44px; }
body.is-desktop .desk[data-view="haushaltsbuch"] { --pn: 0px; }
body.is-desktop .desk[data-view="analyse"] { --pn: 0px; }
body.is-desktop .desk[data-view="reimbursements"] { --pn: 0px; }

/* ----- Sidebar ----- */

.desk-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 10px;
  background: rgba(240, 240, 245, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(21, 20, 43, 0.07);
  overflow: hidden;
}

.desk-sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 4px;
  margin-bottom: 14px;
}

.desk-brand {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.desk-section-label {
  margin: 6px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.desk-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 2px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.desk-nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--accent);
}

.desk-nav-item:hover { background: rgba(21, 20, 43, 0.05); }

.desk-nav-item.is-active,
.desk-nav-item.is-active:hover {
  background: var(--accent);
  color: #fff;
}

.desk-nav-item.is-active svg { color: #fff; }

/* Collapsed sidebar: icons only. */
.desk[data-sidebar="collapsed"] .desk-sidebar { padding: 14px 8px; align-items: center; }
.desk[data-sidebar="collapsed"] .desk-sidebar-head { justify-content: center; padding: 0; }
.desk[data-sidebar="collapsed"] .desk-brand,
.desk[data-sidebar="collapsed"] .desk-section-label,
.desk[data-sidebar="collapsed"] .desk-nav-label { display: none; }
.desk[data-sidebar="collapsed"] .desk-nav-item { justify-content: center; width: 40px; padding: 8px 0; }

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

.desk-icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  flex-shrink: 0;
}

.desk-icon-btn svg { width: 18px; height: 18px; }

.desk-icon-btn[hidden] { display: none; }
.desk-icon-btn:hover { background: rgba(21, 20, 43, 0.06); color: var(--ink); }
.desk-icon-btn[aria-expanded="true"] { color: var(--accent); }

/* ----- Main area ----- */

.desk-main,
.desk-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.desk-main[hidden],
.desk-view[hidden] { display: none; }

.desk-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px 8px;
}

.desk-toolbar-title { min-width: 0; }

.desk-heading {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.desk-count {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.desk-toolbar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.desk-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 220px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--ink-soft);
}

.desk-search svg { width: 15px; height: 15px; flex-shrink: 0; }

.desk-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}

.desk-search input::placeholder { color: var(--ink-faint); }

.desk-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 24px 14px;
}

.desk-filter {
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(21, 20, 43, 0.1);
  border-radius: 7px;
  background: #FFFFFF;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.desk-filter:focus,
.desk-search:focus-within { outline: 2px solid rgba(3, 98, 76, 0.25); outline-offset: 1px; }

/* ----- Table ----- */

.desk-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 24px 24px;
  background: #FFFFFF;
  border: 1px solid rgba(21, 20, 43, 0.07);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(21, 20, 43, 0.04);
}

.desk-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.desk-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px;
  background: #FFFFFF;
  border-bottom: 1px solid rgba(21, 20, 43, 0.08);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.desk-table th[data-sort] { cursor: pointer; }
.desk-table th[data-sort]:hover { color: var(--ink); }
.desk-table th[data-dir="asc"]::after { content: " ↑"; color: var(--accent); }
.desk-table th[data-dir="desc"]::after { content: " ↓"; color: var(--accent); }

.desk-table td {
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(21, 20, 43, 0.05);
  vertical-align: middle;
  color: var(--ink);
}

.desk-table tbody tr { cursor: default; }
.desk-table tbody tr:hover td { background: rgba(21, 20, 43, 0.025); }
.desk-table tbody tr.is-selected td { background: var(--accent-soft); }
.desk-table tbody tr:last-child td { border-bottom: none; }

.desk-table .num,
.desk-table th.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.desk-amount-income { color: var(--good); }

.desk-note {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-soft);
}

.desk-badge {
  display: inline-block;
  margin-right: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(21, 20, 43, 0.07);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.desk-badge.open { background: rgba(255, 122, 89, 0.14); color: #B5490F; }
.desk-badge.done { background: rgba(34, 197, 139, 0.14); color: #0B7A52; }
.desk-badge.pending { background: var(--accent-soft); color: var(--accent-ink); }

/* ----- Haushaltsbuch page ----- */

.desk-view {
  padding-bottom: 0;
}

/* ----- Details panel ----- */

.desk-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #FFFFFF;
  border-left: 1px solid rgba(21, 20, 43, 0.07);
}

.desk-panel[hidden] { display: none; }

.desk-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 0 10px 0 18px;
  border-bottom: 1px solid rgba(21, 20, 43, 0.07);
  flex-shrink: 0;
}

.desk-panel-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.desk-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.desk-panel-head #btn-panel-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

/* Collapsing and expanding: content fades first, so the column can move
   without text reflowing inside it; it fades back in once the column is open. */
.desk-panel-title,
.desk-close,
.desk-panel-body,
.desk-panel-head #btn-panel-toggle svg {
  transition: opacity 0.18s ease 0.12s, visibility 0s linear 0.12s;
}

.desk[data-panel="collapsed"] .desk-panel-title,
.desk[data-panel="collapsed"] .desk-close,
.desk[data-panel="collapsed"] .desk-panel-body {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease, visibility 0s linear 0.1s;
}

/* Collapsed: only the chevron remains, as a thin strip like the sidebar. */
.desk[data-panel="collapsed"] .desk-panel-head {
  justify-content: center;
  padding: 0;
  border-bottom: none;
}

/* The title gives up its width too, so the chevron is centred in the strip. */
.desk[data-panel="collapsed"] .desk-panel-title {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.desk[data-panel="collapsed"] .desk-panel-head #btn-panel-toggle svg {
  transform: rotate(180deg);
  transition: transform 0.25s ease;
}

.desk-close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.14);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.desk-close[hidden] { display: none; }
.desk-close:hover { background: rgba(118, 118, 128, 0.24); color: var(--ink); }

.desk-empty {
  margin: auto;
  font-size: 13px;
  color: var(--ink-faint);
}

.desk-empty[hidden] { display: none; }

/* The detail form, inside the panel instead of a full screen. */
body.is-desktop .screen-detail {
  position: relative;
  inset: auto;
  transform: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
}

body.is-desktop .screen-detail[hidden] { display: none; }
body.is-desktop .detail-topbar,
body.is-desktop .step-indicator { display: none; }
body.is-desktop .detail-footer {
  position: relative;
  background: #FFFFFF;
  border-top: 1px solid rgba(21, 20, 43, 0.07);
}
body.is-desktop .detail-scroll { padding-top: 0; }
body.is-desktop .detail-hero { padding-top: 20px; }

/* ----- Detail form in the desktop panel: denser than on the phone ----- */

body.is-desktop .detail-scroll { padding: 0 20px; }
body.is-desktop .detail-hero { padding: 16px 20px 14px; gap: 10px; }
body.is-desktop .detail-logo { width: 40px; height: 40px; font-size: 18px; border-radius: 12px; }
body.is-desktop .detail-merchant { font-size: 15px; }
body.is-desktop .detail-meta { font-size: 12px; }
body.is-desktop .detail-amount { font-size: 20px; }

body.is-desktop .field-group { margin-bottom: 16px; }
body.is-desktop .field-label { font-size: 12px; margin-bottom: 8px; }
body.is-desktop .field-sublabel { font-size: 11px; }

/* Categories as wrapping pills rather than phone-sized tiles. */
body.is-desktop .cat-group { display: flex; flex-wrap: wrap; gap: 6px; }
body.is-desktop .cat-group + .cat-group { margin-top: 8px; }
body.is-desktop .cat-tile {
  width: auto;
  gap: 6px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  box-shadow: none;
}
body.is-desktop .cat-tile-icon { width: 26px; height: 26px; border-radius: 50%; font-size: 13px; }
body.is-desktop .cat-tile-label { font-size: 12px; font-weight: 600; white-space: nowrap; }

body.is-desktop .place-selected { padding: 10px 12px; }
body.is-desktop .place-selected-name { font-size: 13px; }
body.is-desktop .place-selected-sub { font-size: 11px; }

body.is-desktop .period-choice { gap: 6px; }
body.is-desktop .period-choice-btn { padding: 7px 6px; font-size: 12px; border-radius: 9px; }

body.is-desktop .field-textarea { font-size: 13px; padding: 10px 12px; border-radius: 10px; }
body.is-desktop .place-name-input { height: 36px; font-size: 13px; border-radius: 10px; }
body.is-desktop .allocation-select,
body.is-desktop .allocation-amount { height: 34px; font-size: 13px; border-radius: 10px; }
body.is-desktop .allocation-remove { width: 30px; height: 30px; }

body.is-desktop .detail-footer { padding: 12px 20px 16px; }
body.is-desktop .save-btn {
  height: 40px;
  font-size: 14px;
  border-radius: 10px;
}

/* Receipt photos: thumbnails, not phone-sized squares. */
body.is-desktop .receipt-grid { grid-template-columns: repeat(4, 72px); gap: 6px; }
body.is-desktop .receipt-tile,
body.is-desktop .receipt-tile-add { width: 72px; height: 72px; border-radius: 10px; }

/* ----- Receipt viewer ----- */

.receipt-viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: rgba(15, 14, 30, 0.88);
  touch-action: pinch-zoom;
  cursor: zoom-out;
}

.receipt-viewer[hidden] { display: none; }

.receipt-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  cursor: default;
}

.receipt-viewer-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.receipt-viewer-close:hover { background: rgba(255, 255, 255, 0.28); }

/* ----- Haushaltsbuch table (desktop): plain, months across ----- */

.hb-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 24px 16px;
  background: #FFFFFF;
  border: 1px solid rgba(21, 20, 43, 0.07);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(21, 20, 43, 0.04);
}

.hb-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  color: var(--ink);
}

.hb-table th,
.hb-table td {
  padding: 3px 10px;
  border-bottom: 1px solid rgba(21, 20, 43, 0.05);
  white-space: nowrap;
  text-align: left;
}

.hb-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #FFFFFF;
  border-bottom: 1px solid rgba(21, 20, 43, 0.1);
  font-weight: 600;
  color: var(--ink-soft);
}

.hb-label {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 170px;
  max-width: 210px;
  white-space: normal;
  background: #FFFFFF;
}

.hb-table thead th.hb-label { z-index: 3; }

.hb-table .hb-num {
  text-align: right;
  min-width: 80px;
  padding-left: 2px;
  padding-right: 4px;
  font-variant-numeric: tabular-nums;
}

.hb-section th {
  padding-top: 14px;
  padding-bottom: 4px;
  background: #F7F7FA;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hb-section th,
.hb-section th.hb-label { background: #F7F7FA; }

.hb-group td { font-weight: 700; }
.hb-group .hb-label { color: var(--ink); }

.hb-indent { padding-left: 24px !important; }
.hb-flush { padding-left: 10px !important; }

.hb-input {
  width: 80px;
  padding: 2px 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hb-input:hover { background: rgba(21, 20, 43, 0.04); }
.hb-input:focus { outline: 2px solid rgba(3, 98, 76, 0.3); background: #FFFFFF; }

.hb-computed { color: var(--ink-soft); }

.hb-sum td,
.hb-sum .hb-label {
  padding-top: 6px;
  padding-bottom: 6px;
  font-weight: 700;
  border-top: 1px solid rgba(21, 20, 43, 0.1);
}

.hb-grand td,
.hb-grand .hb-label {
  font-weight: 700;
  background: #FAFAFD;
}

.hb-year-total { font-weight: 700; }

.hb-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding-bottom: 2px; /* optical centring: the + glyph sits high in the line box */
  vertical-align: middle;
  cursor: pointer;
  visibility: hidden; /* shown on hovering the header row; the space stays reserved */
}

.hb-group:hover .hb-add,
.hb-section:hover .hb-add,
.hb-add:focus-visible { visibility: visible; }

.hb-add-row td,
.hb-add-row .hb-label { border-bottom: 1px solid rgba(21, 20, 43, 0.05); }

.hb-new {
  width: 300px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(21, 20, 43, 0.12);
  border-radius: 7px;
  font-family: inherit;
  font-size: 12.5px;
}

.hb-delete {
  visibility: hidden; /* keeps its space, so hovering does not shift the columns */
  width: 18px;
  height: 18px;
  margin-left: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.14);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
}

.hb-row:hover .hb-delete { visibility: visible; }

/* Same inner margin on the right as on the left. */
.hb-table .hb-num:last-child { padding-right: 10px; }

/* Phone: a large Weiter below Speichern, same look as the header's Weiter. */
.footer-next-btn {
  display: block;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.footer-next-btn[hidden] { display: none; }
body.is-desktop .footer-next-btn { display: none; }

.hb-name-input {
  width: calc(100% - 28px);
  padding: 2px 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 12.5px;
}

.hb-name-input:hover { background: rgba(21, 20, 43, 0.04); }
.hb-name-input:focus { outline: 2px solid rgba(3, 98, 76, 0.3); background: #FFFFFF; }

/* Haushaltsbuch: faint colour per kind of row. Opaque, so the sticky label
   column does not show content scrolling underneath it. */
.hb-section.hb-income th { background: #EDFAF4; color: #0B7A52; }
.hb-section.hb-fixed th { background: #FFF1EB; color: #B5490F; }
.hb-section.hb-variable th { background: #E6F2EE; color: var(--accent-ink); }

.hb-surplus-cell.is-positive,
.hb-table .hb-total-cell.is-positive { color: #0B7A52; }
.hb-table .hb-total-cell.is-negative { color: #B5490F; }

.hb-unit {
  margin-left: 6px;
  font-weight: 500;
  color: var(--ink-faint);
}

/* Compact rows. */
.hb-table .hb-add { padding: 0; line-height: 1.2; }
.hb-name-input { padding: 1px 4px; }

.hb-table thead th { padding-top: 8px; padding-bottom: 8px; }

.hb-section { cursor: pointer; user-select: none; }
.hb-chevron {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  color: inherit;
  transition: transform 0.2s ease;
}

/* Open sections point down, folded ones point right. */
.hb-section:not(.is-collapsed) .hb-chevron { transform: rotate(90deg); }

/* Highlighted rows: a click selects a row, a second click clears it. */
.hb-table tbody tr.hb-row { cursor: pointer; }
.hb-table tbody tr.hb-row.is-picked td { background: var(--accent-soft); }
.hb-table tbody tr.hb-row.is-picked td.hb-label { background: var(--accent-soft); }

/* ----- Analyse (desktop) ----- */

.analyse-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 24px 16px;
}

.analyse-card {
  min-width: 0;
  padding: 14px 16px;
  background: #FFFFFF;
  border: 1px solid rgba(21, 20, 43, 0.07);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(21, 20, 43, 0.04);
}

.analyse-title {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.analyse-chart { width: 100%; }
.analyse-chart svg { display: block; width: 100%; height: auto; }

/* KPI row */
.analyse-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.analyse-kpi {
  padding: 12px 16px;
  background: #FFFFFF;
  border: 1px solid rgba(21, 20, 43, 0.07);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(21, 20, 43, 0.04);
}

.analyse-kpi-label {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.analyse-kpi-value {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.analyse-kpi-change {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
}

.analyse-kpi-change.is-good { color: #0B7A52; }
.analyse-kpi-change.is-warn { color: #B5490F; }

/* Row of three cards */
.analyse-row3 {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: 14px;
}

/* Sankey and trend labels */
.analyse-label {
  font-size: 11.5px;
  fill: var(--ink);
  pointer-events: none;
}

.analyse-legend-text {
  font-size: 10.5px;
  fill: var(--ink-soft);
}

.analyse-empty {
  font-size: 12.5px;
  fill: var(--ink-faint);
}

/* Donut */
.analyse-donut { display: block; width: 100%; max-width: 200px; height: auto; margin: 0 auto 6px; }
.analyse-donut path.slice { cursor: pointer; transition: opacity 0.2s ease; }

.analyse-donut-total {
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
  text-anchor: middle;
}

.analyse-donut-caption {
  font-size: 9.5px;
  fill: var(--ink-soft);
  text-anchor: middle;
}

/* Legend (also selects a category) */
.analyse-legend {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 170px;
  overflow: auto;
}

.analyse-legend li {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.analyse-legend li:hover { background: rgba(21, 20, 43, 0.04); }
.analyse-legend li.is-selected { background: var(--accent-soft); }
.analyse-legend li.is-dim { opacity: 0.5; }
.analyse-legend .dot { width: 9px; height: 9px; border-radius: 50%; }
.analyse-legend .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analyse-legend .group { display: block; font-size: 10.5px; color: var(--ink-faint); }
.analyse-legend .value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.analyse-legend .share { font-size: 11px; color: var(--ink-soft); text-align: right; }

/* Vendors */
.analyse-vendors { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow: auto; }

.analyse-vendor { animation: analyse-rise 0.4s ease both; }

.analyse-vendor-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.analyse-vendor-top .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.analyse-vendor-top .value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.analyse-vendor-bar {
  height: 6px;
  margin: 4px 0 2px;
  border-radius: 4px;
  background: rgba(21, 20, 43, 0.06);
  overflow: hidden;
}

.analyse-vendor-bar span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(.32, .72, 0, 1);
}

.analyse-vendor .count { font-size: 11px; color: var(--ink-faint); }

@keyframes analyse-rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.analyse-empty-row { font-size: 12px; color: var(--ink-faint); margin: 0; }

/* Tooltip */
.analyse-tooltip {
  position: fixed;
  z-index: 80;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(21, 20, 43, 0.92);
  color: #FFFFFF;
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(21, 20, 43, 0.25);
}

.analyse-tooltip[hidden] { display: none; }

/* Errors */
.analyse-error {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border-radius: 12px;
  background: #FFF1EB;
  color: #B5490F;
  font-size: 13px;
}

.analyse-error p { margin: 0 0 8px; }

.analyse-retry {
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .analyse-vendor, .analyse-vendor-bar span { animation: none; transition: none; }
  .boot-mark img, .boot-bar span { animation: none; }
}

/* Page load overlay: covers the screen until the first render is done. */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease;
}
.boot-overlay.is-done { opacity: 0; pointer-events: none; }
.boot-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  animation: boot-in 0.5s ease both;
}
.boot-mark img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(2, 27, 26, 0.18);
  animation: boot-breathe 1.8s ease-in-out infinite;
}
.boot-bar {
  width: 120px;
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.boot-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  animation: boot-slide 1.2s ease-in-out infinite;
}
@keyframes boot-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes boot-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes boot-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}

/* Donut centre text never blocks clicks on the slices. */
.analyse-donut text { pointer-events: none; }

/* Sankey: centred, at most 900px wide. */
#analyse-sankey { max-width: 900px; margin: 0 auto; }

/* Analyse: Sankey with a side card, below the three cards. */
.analyse-flow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.analyse-split { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.analyse-split-top { display: grid; grid-template-columns: minmax(0, 1fr) auto 48px; gap: 8px; font-size: 12.5px; align-items: baseline; }
.analyse-split-top .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.analyse-split-top .value { font-variant-numeric: tabular-nums; font-weight: 600; }
.analyse-split-top .share { text-align: right; color: var(--ink-soft); font-size: 11.5px; }
.analyse-split-bar { height: 6px; margin-top: 4px; border-radius: 4px; background: rgba(21, 20, 43, 0.06); overflow: hidden; }
.analyse-split-bar span { display: block; height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(.32, .72, 0, 1); }

/* ----- Analyse accents: dark greens from the brand palette, on the light page ----- */

#view-analyse .analyse-title { color: #095544; }
#view-analyse .analyse-kpi-change.is-good { color: #03624C; }
#view-analyse .analyse-kpi-change.is-warn { color: #B5490F; }
#view-analyse .analyse-legend li.is-selected { background: #F1F7F6; box-shadow: inset 3px 0 0 #17876D; }
#view-analyse .analyse-legend .value { color: #06302B; }
#view-analyse .analyse-vendor-top .value { color: #06302B; }
#view-analyse .analyse-vendor-bar span { background: #17876D; }
#view-analyse .analyse-split-top .value { color: #06302B; }
#view-analyse .analyse-split-bar { background: #F1F7F6; }
#view-analyse .analyse-donut-total { fill: #021B1A; }
#view-analyse .analyse-label { fill: #06302B; }

/* Investments view. */
body.is-desktop .desk[data-view="investments"] { --pn: 0px; }
#view-investments [hidden] { display: none !important; }
/* The page scrolls inside its own body, like the Analyse view. */
.inv-body {
  flex: 1; min-height: 0; overflow-y: auto;
  max-width: 1240px; padding: 4px 24px 32px; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 16px;
}
.inv-row { display: grid; gap: 16px; }
.inv-hero { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; }
.inv-hero-donut { display: flex; flex-direction: column; gap: 14px; }
.inv-hero-stats { display: flex; align-items: center; }
.inv-hero-stats .inv-stats { width: 100%; }
.inv-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.inv-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1300px) {
  .inv-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .inv-hero, .inv-row-2, .inv-row-4 { grid-template-columns: 1fr; }
}
.inv-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; box-shadow: 0 1px 2px rgba(2, 27, 26, 0.04); min-width: 0;
}
.inv-card-head { margin-bottom: 18px; }
.inv-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.inv-h2 { font-size: 16px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.inv-hint { font-size: 13px; color: var(--ink-soft); margin: 0; line-height: 1.5; }
.inv-empty { font-size: 13px; color: var(--ink-faint); margin: 6px 0; }
.inv-error { font-size: 13px; color: #B5490F; margin: 8px 0 0; }
.is-pos { color: #17876D; }
.is-neg { color: #B5490F; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Headline figures */
.inv-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .inv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.inv-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.inv-stat-main { background: var(--accent-soft); border-color: #CFE6DD; }
.inv-stat-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.inv-stat-value { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-stat-main .inv-stat-value { font-size: 28px; color: #06302B; }
.inv-stat-sub { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.inv-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #03624C; }
.inv-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #17876D; box-shadow: 0 0 0 0 rgba(23, 135, 109, 0.5); animation: inv-pulse 2s infinite; }
@keyframes inv-pulse {
  0% { box-shadow: 0 0 0 0 rgba(23, 135, 109, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(23, 135, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 135, 109, 0); }
}
@media (prefers-reduced-motion: reduce) { .inv-live-dot { animation: none; } }

/* Chart */
.inv-tabs { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.inv-tab {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.inv-tab.is-active { background: var(--surface); color: #03624C; box-shadow: 0 1px 2px rgba(2, 27, 26, 0.08); }
.inv-chart { position: relative; min-height: 240px; }
.inv-chart svg { display: block; }
.inv-axis .tick text { fill: var(--ink-faint); font-size: 11px; font-family: inherit; }
.inv-axis .tick line { stroke: var(--line); }
.inv-line { fill: none; stroke: #03624C; stroke-width: 2; }
.inv-line-muted { fill: none; stroke: #8FA7A1; stroke-width: 1.5; stroke-dasharray: 4 4; }
.inv-area-neg { fill: rgba(181, 73, 15, 0.18); stroke: #B5490F; stroke-width: 1.5; }
.inv-caption { font-size: 12px; color: var(--ink-soft); margin-top: 6px; min-height: 16px; font-variant-numeric: tabular-nums; }

/* Tables */
.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-table th, .inv-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
.inv-table th { color: var(--ink-soft); font-weight: 600; font-size: 12px; }
.inv-table .num { text-align: right; }
.inv-table-wrap { overflow-x: auto; }

/* Collapsed-by-default "N reviewed" row, same idiom as the Haushaltsbuch
   section headers (.hb-chevron rotates open/closed). */
.steuern-reviewed-toggle { cursor: pointer; user-select: none; background: #F7F7FA; }
.steuern-reviewed-toggle td { font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.steuern-reviewed-toggle:hover td { color: var(--ink); }
.steuern-reviewed-toggle:not(.is-collapsed) .hb-chevron { transform: rotate(90deg); }
.inv-returns td:first-child { color: var(--ink-soft); white-space: normal; }
.inv-returns tr:last-child td { font-weight: 700; color: var(--ink); }

/* Lists */
.inv-list, .inv-alloc { list-style: none; margin: 0; padding: 0; }
.inv-row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.inv-row-item:last-child { border-bottom: 0; }
.inv-item-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-item-meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.inv-row-item .num { font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.inv-row-item > :first-child { min-width: 0; flex: 1; }
.inv-mover-change { text-align: right; }
.inv-alloc-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.inv-alloc-row:last-child { border-bottom: 0; }
.inv-alloc-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink); }
.inv-alloc-bar { height: 8px; background: var(--bg); border-radius: 4px; margin: 8px 0 4px; overflow: hidden; }
.inv-alloc-bar span { display: block; height: 100%; background: #03624C; border-radius: 4px; }
.inv-alloc-value { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* Gold form */
.inv-gold-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; align-items: end; margin-bottom: 12px; }
.inv-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.inv-field input {
  font: inherit; font-size: 14px; color: var(--ink); font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface);
}
.inv-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* Upload card */
.inv-form { display: flex; flex-direction: column; gap: 14px; }
.inv-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 20px; border: 1.5px dashed #B9D3CB; border-radius: 14px;
  background: var(--bg); text-align: center; cursor: pointer; position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.inv-drop:hover, .inv-drop.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.inv-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.inv-drop-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(2, 27, 26, 0.08);
}
.inv-drop-icon svg { width: 22px; height: 22px; }
.inv-drop-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.inv-drop-sub { font-size: 13px; color: var(--ink-soft); }
.inv-drop-link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.inv-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.inv-selected { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.inv-selected li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--ink);
}
.inv-selected li.is-invalid { border-color: #F0C2B0; background: #FDF5F1; color: #B5490F; }
.inv-selected .inv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-selected .inv-size { color: var(--ink-faint); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.inv-selected .inv-reason { color: inherit; flex-shrink: 0; font-size: 12px; }
.inv-remove {
  border: 0; background: transparent; color: var(--ink-faint); cursor: pointer;
  width: 26px; height: 26px; border-radius: 8px; font-size: 16px; line-height: 1; flex-shrink: 0;
}
.inv-remove:hover { background: var(--accent-soft); color: var(--accent); }
.inv-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.inv-limits { font-size: 12px; color: var(--ink-faint); }
.inv-submit {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 24px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.inv-submit:hover:not(:disabled) { background: #025240; }
.inv-submit:disabled { background: #C9DCD6; cursor: default; }
.inv-results { list-style: none; padding: 0; margin: 18px 0 0; font-size: 13px; border-top: 1px solid var(--line); }
.inv-results li { padding: 9px 0; border-bottom: 1px solid var(--line); line-height: 1.4; overflow-wrap: anywhere; }
.inv-results li.is-ok { color: var(--ink); }
.inv-results li.is-error { color: #B5490F; }

/* Ticker strip at the bottom of the Investments view. */
.inv-ticker {
  flex-shrink: 0; display: flex; align-items: center; height: 56px;
  background: var(--ink); color: #fff; overflow: hidden;
  box-shadow: 0 -10px 24px -14px rgba(2, 27, 26, 0.35);
}
.inv-ticker-label {
  flex-shrink: 0; height: 100%; display: flex; align-items: center; padding: 0 20px;
  background: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; z-index: 1; box-shadow: 10px 0 18px -8px rgba(2, 27, 26, 0.5);
}
.inv-ticker-viewport {
  flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; overflow: hidden;
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.inv-ticker-track { display: flex; width: max-content; animation: inv-ticker-scroll 60s linear infinite; }
.inv-ticker:hover .inv-ticker-track { animation-play-state: paused; }
.inv-ticker-group { display: flex; flex-shrink: 0; align-items: center; }
.inv-ticker-item { display: flex; align-items: center; gap: 10px; padding: 0 22px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.inv-ticker-name { color: #A9CFC3; font-weight: 500; }
.inv-ticker-value { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.inv-ticker-change { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.inv-ticker-change.up { color: #7FE0B8; }
.inv-ticker-change.down { color: #FF9C84; }
.inv-ticker-sep { width: 5px; height: 5px; border-radius: 50%; background: #7FC2AD; flex-shrink: 0; }
@keyframes inv-ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) { .inv-ticker-track { animation-duration: 180s; } }

/* Donut and legend, top left of the Investments page. */
.inv-donut { width: 100%; max-width: 240px; margin: 0 auto; }
.inv-donut svg { display: block; }
.inv-donut-total { font-size: 16px; font-weight: 700; fill: #06302B; font-variant-numeric: tabular-nums; }
.inv-donut-sub { font-size: 12px; fill: #8FA7A1; }
.inv-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.inv-legend li { display: flex; align-items: center; gap: 8px; color: var(--ink); min-width: 0; }
.inv-legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.inv-legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-legend-share { color: var(--ink-soft); font-weight: 600; }

/* Performance chart: green above zero, red below. */
.inv-perf-pos { fill: rgba(23, 135, 109, 0.22); stroke: none; }
.inv-perf-neg { fill: rgba(181, 73, 15, 0.2); stroke: none; }
.inv-perf-line { fill: none; stroke: #0D5C49; stroke-width: 1.6; }
.inv-zero { stroke: #B9D3CB; stroke-width: 1; }
.inv-caption.is-neg { color: #B5490F; }

/* Password prompt before the Investments view opens. */
.inv-gate {
  position: fixed; inset: 0; z-index: 2000; background: rgba(2, 27, 26, 0.35);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.inv-gate-card {
  background: var(--surface); border-radius: 18px; padding: 24px; width: 100%; max-width: 340px;
  box-shadow: 0 24px 48px -16px rgba(2, 27, 26, 0.35); display: flex; flex-direction: column; gap: 12px;
}
.inv-gate-title { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.inv-gate-hint { font-size: 13px; color: var(--ink-soft); margin: 0; }
.inv-gate-input {
  font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--ink); background: var(--surface);
}
.inv-gate-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.inv-gate-error { font-size: 13px; color: #B5490F; margin: 0; }
.inv-gate-actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.inv-gate-cancel { border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px 10px; }

/* Range filter above the charts. */
.inv-range { display: flex; gap: 4px; flex-wrap: wrap; }
.inv-range-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px; cursor: pointer;
}
.inv-range-btn:hover { color: var(--accent); }
.inv-range-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.inv-entry-hint { margin-bottom: 14px; }
.inv-select {
  font: inherit; font-size: 14px; color: var(--ink); font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface);
}
#inv-entry-metal { margin-top: 4px; }
#inv-entry-metal .inv-gold-form { margin-bottom: 12px; }
#inv-entry-metal .inv-list { margin-top: 6px; }

/* Portfolio page, Parqet-style layout. Shared by the Analyse page. */
#view-investments .inv-body, #view-analyse .inv-body { max-width: none; padding: 8px 32px 40px; gap: 20px; }
#view-investments .inv-header, #view-analyse .inv-header { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; align-items: center; padding: 28px 36px; }
#view-investments .inv-donut-wrap, #view-analyse .inv-donut-wrap { display: flex; flex-direction: column; gap: 16px; }
#view-investments .inv-donut, #view-analyse .inv-donut { max-width: 280px; margin: 0 auto; }
#view-investments .inv-legend, #view-analyse .inv-legend { font-size: 13px; }
#view-investments .inv-kpis-main, #view-analyse .inv-kpis-main { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 32px; align-items: start; }
#view-investments .inv-kpis-small, #view-analyse .inv-kpis-small { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
#view-investments .inv-kpi, #view-analyse .inv-kpi { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#view-investments .inv-kpi-label, #view-analyse .inv-kpi-label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
#view-investments .inv-kpi-value, #view-analyse .inv-kpi-value { font-size: 26px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; }
#view-investments .inv-kpi-big .inv-kpi-value, #view-analyse .inv-kpi-big .inv-kpi-value { font-size: 40px; font-weight: 600; }
#view-investments .inv-kpi-sub, #view-analyse .inv-kpi-sub { font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
#view-investments .inv-kpis-small .inv-kpi-value, #view-analyse .inv-kpis-small .inv-kpi-value { font-size: 20px; }
#view-investments .inv-range, #view-analyse .inv-range { justify-content: flex-end; }
#view-investments .inv-row-2, #view-analyse .inv-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#view-investments .inv-row-2 .inv-card, #view-analyse .inv-row-2 .inv-card { padding: 22px 24px 18px; }
#view-investments .inv-row-2 .inv-card-top, #view-analyse .inv-row-2 .inv-card-top { align-items: center; margin-bottom: 8px; }
#view-investments .inv-row-2 .inv-chart, #view-analyse .inv-row-2 .inv-chart { min-height: 320px; }
#view-investments .inv-card-top .inv-hint, #view-analyse .inv-card-top .inv-hint { margin: 0; font-size: 13px; }
#view-investments .inv-row-4, #view-analyse .inv-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
#view-investments .inv-kpi-sub, #view-analyse .inv-kpi-sub { display: block; }
@media (max-width: 1400px) {
  #view-investments .inv-row-4, #view-analyse .inv-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
  #view-investments .inv-header, #view-analyse .inv-header { grid-template-columns: 1fr; }
  #view-investments .inv-row-2, #view-analyse .inv-row-2 { grid-template-columns: 1fr; }
}

/* Range filter, in the page toolbar. */
#view-investments .inv-toolbar-tools { display: flex; align-items: center; gap: 16px; }
#view-investments .inv-range { display: flex; gap: 6px; }
#view-investments .inv-range-btn { font-size: 13px; padding: 7px 14px; }

/* Hover guide on the Portfolio charts. */
.inv-guide { stroke: #8FA7A1; stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.inv-guide-dot { fill: #03624C; stroke: #FFFFFF; stroke-width: 2; pointer-events: none; }

/* Analyse page: the same look as the Portfolio page. */
#view-analyse .analyse-body { max-width: none; padding: 8px 32px 40px; gap: 20px; flex: 1; min-height: 0; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; }
#view-analyse .analyse-header { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; align-items: center; padding: 28px 36px; }
#view-analyse .inv-donut-wrap { display: flex; flex-direction: column; gap: 16px; }
#view-analyse .analyse-donut { width: 100%; max-width: 280px; height: auto; margin: 0 auto; display: block; }
#view-analyse .analyse-donut-total { font-size: 16px; font-weight: 700; fill: #06302B; text-anchor: middle; font-variant-numeric: tabular-nums; }
#view-analyse .analyse-donut-caption { font-size: 12px; fill: #8FA7A1; text-anchor: middle; }
#view-analyse .analyse-donut text { pointer-events: none; }
#view-analyse .analyse-legend li { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: center; padding: 3px 0; font-size: 12px; color: var(--ink); }
#view-analyse .analyse-legend .dot { width: 9px; height: 9px; border-radius: 3px; }
#view-analyse .analyse-legend .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-analyse .analyse-legend .group { display: block; font-size: 11px; color: var(--ink-faint); }
#view-analyse .analyse-legend .value { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
#view-analyse .analyse-legend .share { font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
#view-analyse .analyse-kpis-main { display: grid; grid-template-columns: 1.5fr 1fr; gap: 32px; align-items: start; }
#view-analyse .analyse-kpis-small { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
#view-analyse .analyse-kpis-main .inv-kpi-value { font-size: 26px; }
#view-analyse .analyse-kpis-main .inv-kpi-big .inv-kpi-value { font-size: 40px; }
#view-analyse .analyse-kpis-small .inv-kpi-value { font-size: 20px; }
#view-analyse .analyse-kpi-change.is-good { color: #17876D; }
#view-analyse .analyse-kpi-change.is-warn { color: #B5490F; }
#view-analyse .inv-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#view-analyse .inv-row-2 .inv-card { padding: 22px 24px 18px; }
#view-analyse .analyse-chart { min-height: 300px; }
#view-analyse .analyse-chart svg { display: block; width: 100%; }
#view-analyse .analyse-vendors, #view-analyse .analyse-split { font-size: 13px; }
@media (max-width: 1200px) {
  #view-analyse .analyse-header { grid-template-columns: 1fr; }
  #view-analyse .inv-row-2 { grid-template-columns: 1fr; }
}

/* Analyse: compact header with the calendar beside it. */
#view-analyse .analyse-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
#view-analyse .analyse-header { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: center; padding: 20px 26px; }
#view-analyse .analyse-header .inv-donut-wrap { gap: 10px; }
#view-analyse .analyse-donut { max-width: 190px; }
#view-analyse .analyse-donut-total { font-size: 14px; }
#view-analyse .analyse-donut-caption { font-size: 11px; }
#view-analyse .analyse-legend { font-size: 11px; }
#view-analyse .analyse-legend li { padding: 2px 6px 2px 10px; }
#view-analyse .analyse-kpis-main { grid-template-columns: 1fr 1fr; gap: 24px; }
#view-analyse .analyse-kpis-main .inv-kpi-value { font-size: 22px; }
#view-analyse .analyse-kpis-main .inv-kpi-big .inv-kpi-value { font-size: 32px; }
#view-analyse .analyse-kpis-small { margin-top: 16px; padding-top: 14px; gap: 24px; }
#view-analyse .analyse-kpis-small .inv-kpi-value { font-size: 17px; }
#view-analyse .analyse-kpi-change { font-size: 12px; }
#view-analyse .analyse-calendar-card { padding: 20px 22px; display: flex; flex-direction: column; }
#view-analyse .analyse-calendar-card .inv-card-top { margin-bottom: 10px; }
#view-analyse .analyse-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
#view-analyse .analyse-weekday { font-size: 11px; color: var(--ink-faint); text-align: center; padding-bottom: 2px; }
#view-analyse .analyse-day {
  position: relative; aspect-ratio: 1.25 / 1; border-radius: 7px; background: #F6FAF9;
  display: flex; flex-direction: column; justify-content: space-between; padding: 4px 6px; min-width: 0; overflow: hidden;
}
#view-analyse .analyse-day.is-empty { background: transparent; }
#view-analyse .analyse-day-num { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
#view-analyse .analyse-day.has-spend .analyse-day-num { color: #FFFFFF; }
#view-analyse .analyse-day.has-spend .analyse-day-val { color: #FFFFFF; }
#view-analyse .analyse-day.has-spend { color: #FFFFFF; }
#view-analyse .analyse-day-val { font-size: 10px; font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1200px) {
  #view-analyse .analyse-top { grid-template-columns: 1fr; }
}

/* Analyse: three cards in one row, shorter calendar cells so the header stays compact. */
#view-analyse .analyse-row3 { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
#view-analyse .analyse-row3 .inv-card { padding: 20px 22px 16px; }
#view-analyse .analyse-day { aspect-ratio: 1.9 / 1; padding: 3px 5px; }
#view-analyse .analyse-grid { gap: 4px; }
@media (max-width: 1200px) {
  #view-analyse .analyse-row3 { grid-template-columns: 1fr; }
}

/* Analyse: Geldfluss beside the header, calendar and Monatstrend below, then the lists. */
#view-analyse #analyse-sankey { max-width: none; margin: 0; }
#view-analyse .analyse-sankey-card { padding: 20px 22px 16px; display: flex; flex-direction: column; }
#view-analyse .analyse-sankey-card .inv-card-top { margin-bottom: 8px; }
#view-analyse .analyse-sankey-toggle {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 100px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
#view-analyse .analyse-sankey-toggle[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}
#view-analyse .analyse-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
#view-analyse .analyse-calendar-card { padding: 20px 22px 16px; }
#view-analyse .analyse-day { aspect-ratio: 1.6 / 1; }

/* Analyse: three cards in the third row, and the largest-purchases list. */
#view-analyse .analyse-row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#view-analyse .analyse-largest { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 13px; }
#view-analyse .analyse-largest li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
#view-analyse .analyse-largest li:last-child { border-bottom: 0; }
#view-analyse .analyse-largest .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
#view-analyse .analyse-largest .meta { display: block; font-size: 11px; color: var(--ink-faint); font-weight: 400; margin-top: 2px; }
#view-analyse .analyse-largest .value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); white-space: nowrap; }

/* The page scrolls as a whole: its rows keep their natural height instead of shrinking into the fixed body. */
#view-investments .inv-body > *, #view-analyse .analyse-body > * { flex-shrink: 0; }

/* Neue Position and Verkaufte Positionen share a row; with no sales yet, the entry card takes the full width. */
#view-investments .inv-entry-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: stretch; }
#view-investments .inv-entry-row:has(#inv-sold-card[hidden]) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1200px) { #view-investments .inv-entry-row { grid-template-columns: minmax(0, 1fr); } }

/* The sold table in the entry row is narrow: tighter cells so all columns fit. */
#view-investments .inv-entry-row .inv-table { font-size: 12px; }
#view-investments .inv-entry-row .inv-table th, #view-investments .inv-entry-row .inv-table td { padding: 8px 6px; }

/* A divider between the analysis views and the portfolio in the sidebar. */
.desk-nav-divider { width: 28px; height: 1px; background: #B9D3CB; margin: 14px auto; flex-shrink: 0; }

/* Benchmark chips under the Performance chart, and the lines they draw. */
.inv-bench { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.inv-bench-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.inv-bench-chip.is-active { color: #FFFFFF; border-color: transparent; }
.inv-bench-chip-model.is-active { background: #B88A2E; }
.inv-bench-chip-sp500.is-active { background: #5E7A74; }
.inv-bench-chip-dax.is-active { background: #17876D; }
.inv-bench-line { fill: none; stroke-width: 1.6; stroke-dasharray: 5 4; }
.inv-bench-model { stroke: #B88A2E; }
.inv-bench-sp500 { stroke: #5E7A74; }
.inv-bench-dax { stroke: #17876D; }

/* Holding detail page. */
.inv-clickable { cursor: pointer; }
.inv-clickable:hover td { background: var(--accent-soft); }
.inv-holding { display: flex; flex-direction: column; gap: 20px; }
.inv-holding-head { display: flex; align-items: center; gap: 18px; }
.inv-back {
  border: 1px solid var(--line); background: var(--surface); color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.inv-holding-title { font-size: 24px; font-weight: 700; margin: 0; color: var(--ink); }
.inv-holding-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1200px) { .inv-holding-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.inv-holding-kpis .inv-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.inv-holding-kpis .inv-kpi-value { font-size: 24px; }

/* Phone landing page: one list of purchases instead of large cards. */
.card-list { gap: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.p-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.p-row:first-child { border-top-left-radius: 16px; border-top-right-radius: 16px; }
.p-row:last-child { border-bottom: 0; border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; }
.p-row:active { background: var(--accent-soft); }
.p-row-logo {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.p-row-text { flex: 1; min-width: 0; }
.p-row .p-merchant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.p-row .p-merchant-date { margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-row .p-amount { font-size: 14.5px; font-variant-numeric: tabular-nums; }
.p-row-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: #FFE1EC; color: #8A2250; font-size: 10px; font-weight: 700; vertical-align: 1px;
}
.p-row-tag-verified { background: var(--accent-soft); color: var(--accent-ink); }

/* Swipe-left action (like archiving a WhatsApp chat): the action sits behind
   the row, revealed as the row is dragged, confirmed with a tap on it. */
.p-row-swipe {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.p-row-swipe:first-child { border-top-left-radius: 16px; border-top-right-radius: 16px; }
.p-row-swipe:last-child { border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; }
.p-row-swipe .p-row {
  position: relative;
  z-index: 1;
  touch-action: pan-y;
}
.p-row-swipe:last-child .p-row { border-bottom: 0; }
.p-row-verify-action {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.p-row-verify-action.is-on { background: var(--ink-faint); }

/* PDF receipts: a tile that opens the file. */
.receipt-pdf-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; height: 100%; text-decoration: none; color: var(--accent-ink, #03624C);
  font-weight: 800; font-size: 13px; letter-spacing: 0.04em;
}
.receipt-pdf-link span { font-size: 10px; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }
.receipt-tile-pdf { background: var(--accent-soft); }

/* Steuern view. */
#view-steuern .steuern-body { max-width: none; padding: 8px 32px 40px; gap: 20px; flex: 1; min-height: 0; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; }
#view-steuern .steuern-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#view-steuern .steuern-note { margin-top: 12px; }
#view-steuern .steuern-row-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
#view-steuern .steuern-row-line:last-child { border-bottom: 0; }
#view-steuern .steuern-row-line b { font-variant-numeric: tabular-nums; }
#view-steuern .steuern-status { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
#view-steuern select, #view-steuern input[type="text"] { font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; background: var(--surface); color: var(--ink); }
#view-steuern input.steuern-share { width: 64px; text-align: right; }
#view-steuern input.steuern-note-input { width: 150px; }
#view-steuern .steuern-save { border: 0; background: var(--accent); color: #fff; font: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
#view-steuern .steuern-remove { border: 0; background: transparent; color: var(--ink-faint); font-size: 16px; cursor: pointer; }
#view-steuern .steuern-remove:hover { color: var(--accent); }
#view-steuern .steuern-receipt { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 12px; }
#view-steuern .steuern-warn { color: #B5490F; }
@media (max-width: 1200px) { #view-steuern .steuern-top { grid-template-columns: 1fr; } }

/* "Für die Steuer merken" switch in the purchase details. */
.tax-mark-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tax-mark-hint { font-size: 12px; color: var(--ink-soft); margin: 2px 0 0; }
.tax-mark-switch {
  position: relative; width: 44px; height: 26px; border-radius: 999px; border: 0; flex-shrink: 0;
  background: #D9E4E0; cursor: pointer; transition: background 0.2s ease; padding: 0;
}
.tax-mark-switch span {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(2, 27, 26, 0.25); transition: transform 0.2s ease;
}
.tax-mark-switch.is-on { background: var(--accent); }
.tax-mark-switch.is-on span { transform: translateX(18px); }
.tax-mark-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#view-steuern .steuern-toggle-all { margin-left: 10px; }

/* Manual pick: nearby bookings when even the widened verified window finds nothing. */
.pending-match-wrap { margin-top: 14px; }
.pending-match-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.pending-match-row:active { background: var(--accent-soft); }
.pending-match-merchant { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-match-date { font-size: 11.5px; color: var(--ink-soft); flex-shrink: 0; }
.pending-match-amount { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* The metal form fits the half-width entry card: two columns, note and button full width. */
#inv-metal-form .inv-field-wide, #inv-metal-form > .inv-submit { grid-column: 1 / -1; }
#inv-metal-form > .inv-submit { justify-self: end; }
#inv-metal-form .inv-field { min-width: 0; }
#inv-metal-form .inv-field input, #inv-metal-form .inv-field select { width: 100%; box-sizing: border-box; }

/* Steuern: purchase rows open their details; receipts are uploaded there. */
#view-steuern .steuern-open { cursor: pointer; color: var(--ink); font-weight: 600; text-decoration: none; }
#view-steuern .steuern-open:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
#view-steuern .steuern-upload { border: 1px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
#view-steuern .steuern-upload:hover { background: var(--accent-soft); }

/* "Ausgaben zuordnen": the merchant column takes the spare width; the others stay compact with the same padding, so nothing scrolls sideways. */
#view-steuern table:has(#steuern-candidates) { table-layout: auto; width: 100%; }
#view-steuern table:has(#steuern-candidates) th,
#view-steuern table:has(#steuern-candidates) td { padding: 8px 14px; white-space: nowrap; }
#view-steuern table:has(#steuern-candidates) th:nth-child(2),
#view-steuern table:has(#steuern-candidates) td:nth-child(2) { width: 100%; }
#view-steuern table:has(#steuern-candidates) select { max-width: 200px; }
#view-steuern table:has(#steuern-candidates) .steuern-share { width: 56px; }

/* Share fields show their unit: "100 %". */
#view-steuern .steuern-share-field { display: inline-flex; align-items: center; gap: 4px; }
#view-steuern .steuern-unit { font-size: 12px; color: var(--ink-soft); }

/* Classification panel on the right, for an assigned purchase. */
#steuern-panel { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px; }
#steuern-panel[hidden] { display: none; }
.steuern-panel-merchant { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.steuern-panel-meta { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.steuern-panel-field { display: flex; flex-direction: column; gap: 6px; }
.steuern-panel-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.steuern-panel-field select, .steuern-panel-field input { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--surface); color: var(--ink); }
.steuern-panel-field .steuern-share { width: 80px; }
.steuern-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.steuern-danger { border-color: #B5490F !important; color: #B5490F !important; }

/* The classification panel: same look as the rest of the app. */
#steuern-panel { gap: 18px; padding: 16px 18px; }
#steuern-panel .steuern-panel-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
#steuern-panel .steuern-panel-merchant { font-size: 17px; }
#steuern-panel .steuern-panel-field { gap: 7px; }
#steuern-panel select,
#steuern-panel input[type="text"] {
  font: inherit; font-size: 14px; width: 100%; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: var(--surface); color: var(--ink);
}
#steuern-panel .steuern-share-field { display: flex; align-items: center; gap: 8px; }
#steuern-panel .steuern-share-field input { width: 96px; text-align: right; }
#steuern-panel .steuern-unit { font-size: 14px; color: var(--ink-soft); }
#steuern-panel .steuern-receipt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#steuern-panel .steuern-receipt-chip {
  padding: 6px 12px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none;
}
#steuern-panel .steuern-receipt-chip:hover { background: #D3EBE2; }
#steuern-panel .steuern-upload {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent); font: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
#steuern-panel .steuern-upload:hover { background: var(--accent-soft); }
#steuern-panel .steuern-primary { background: var(--accent); border-color: transparent; color: #FFFFFF; }
#steuern-panel .steuern-primary:hover { background: #025240; }
#steuern-panel .steuern-panel-actions { flex-direction: column; gap: 10px; margin-top: 2px; }
#steuern-panel .steuern-link-danger {
  align-self: center; border: 0; background: transparent; color: #B5490F;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px;
}
#steuern-panel .steuern-link-danger:hover { text-decoration: underline; text-underline-offset: 2px; }
#steuern-panel .steuern-warn { font-size: 13px; color: #B5490F; font-weight: 600; }

/* Receipt chips in the panel can be removed. */
#steuern-panel .steuern-receipt-chip-wrap { display: inline-flex; align-items: center; background: var(--accent-soft); border-radius: 999px; padding-right: 4px; }
#steuern-panel .steuern-receipt-chip-wrap .steuern-receipt-chip { background: transparent; padding-right: 6px; }
#steuern-panel .steuern-receipt-chip-wrap:hover { background: #D3EBE2; }
#steuern-panel .steuern-receipt-remove { border: 0; background: transparent; color: var(--ink-faint); font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 999px; }
#steuern-panel .steuern-receipt-remove:hover { color: #B5490F; }

/* The purchase's own details, under the tax fields in the panel. */
#steuern-panel .steuern-own { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
#steuern-panel .steuern-own-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; font-size: 13px; }
#steuern-panel .steuern-own-row > span:first-child { color: var(--ink-soft); }
#steuern-panel .steuern-own-value { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- ERSTATTUNGEN (reimbursement matching) ---------- */
#reimb-group-btn { border: 0; background: var(--accent); color: #fff; font: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
#reimb-group-btn:disabled { background: var(--ink-faint); cursor: not-allowed; }
#view-reimbursements tr.is-picked td { background: var(--accent-soft); }
#view-reimbursements .inv-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

#reimb-groups-open, #reimb-groups-settled { display: flex; flex-direction: column; gap: 10px; }
#reimb-groups-settled { margin-top: 10px; }
.reimb-group {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px;
  background: var(--surface); box-shadow: 0 1px 2px rgba(2, 27, 26, 0.04);
}
.reimb-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.reimb-group-net {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--good-soft); color: var(--good);
}
.reimb-group-net.is-negative { background: var(--warn-soft); color: var(--warn); }
.reimb-group-actions { display: flex; align-items: center; gap: 10px; }
.reimb-group-settle {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft);
  cursor: pointer; user-select: none;
}
.reimb-group-settle input { width: 15px; height: 15px; cursor: pointer; }
.reimb-group-settle:hover { color: var(--ink); }
.reimb-group-rows { display: flex; flex-direction: column; }
.reimb-group-row {
  display: grid; grid-template-columns: 80px 1fr 90px 24px; align-items: center; gap: 10px;
  font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--line);
}
.reimb-group-row:last-child { border-bottom: 0; }
.reimb-group-date { color: var(--ink-soft); }
.reimb-group-amount { text-align: right; font-variant-numeric: tabular-nums; }
.reimb-remove { border: 0; background: transparent; color: var(--ink-faint); font-size: 16px; cursor: pointer; line-height: 1; }
.reimb-remove:hover { color: var(--accent); }

/* Reusable "N collapsed things" disclosure -- settled Erstattungen groups,
   reviewed Steuern entries. Closed by default; state persists via deskPrefs. */
.collapse-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 10px 2px; margin-top: 6px; border: none; border-top: 1px solid var(--line);
  background: transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-soft);
}
.collapse-toggle:hover { color: var(--ink); }
.collapse-toggle[hidden] { display: none; }
.collapse-chevron { width: 14px; height: 14px; transition: transform 0.2s ease; flex-shrink: 0; }
.collapse-toggle[aria-expanded="true"] .collapse-chevron { transform: rotate(90deg); }

/* Privacy mode on the Portfolio page: figures and charts are blurred. */
.inv-privacy {
  border: 1px solid var(--line); background: var(--surface); color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.inv-privacy:hover { background: var(--accent-soft); }
/* Privacy mode: every explicit euro amount is blurred; curves, bars and percentages stay.
   The fade sits on the base rule, so it runs both when blurring and when revealing. */
.inv-abs { transition: filter 0.6s ease-in-out, opacity 0.6s ease-in-out; }
#view-investments.is-private .inv-abs { filter: blur(9px); user-select: none; }
#view-investments.is-private span.inv-abs { display: inline-block; }
