/* Credit stays a separate, informational source of financing in both themes. */
html[data-theme] #page .accounts-credit-section { margin-top: 20px; color: var(--text); }
html[data-theme] #page .accounts-credit-section .simple-section-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: start; }
html[data-theme] #page .accounts-credit-section .simple-section-head > div { min-width: 0; }
html[data-theme] #page .accounts-credit-section .simple-section-head strong { display: block; overflow-wrap: anywhere; }
html[data-theme] #page .accounts-credit-section p,
html[data-theme] #page .accounts-credit-section small { color: var(--muted); }
html[data-theme] #page .accounts-credit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; margin: 16px 0; }
html[data-theme] #page .accounts-credit-card { display: grid; gap: 16px; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface2); }
html[data-theme] #page .accounts-credit-card h3 { margin: 5px 0; font-size: 1.06rem; overflow-wrap: anywhere; }
html[data-theme] #page .accounts-credit-card > div > span { color: var(--muted); font-size: .8rem; }
html[data-theme] #page .accounts-credit-amount { display: grid; gap: 5px; }
html[data-theme] #page .accounts-credit-amount strong { font-size: 1.4rem; color: var(--text); overflow-wrap: anywhere; }
html[data-theme] #page .accounts-credit-card > button { min-height: 44px; align-self: end; }
html[data-theme] #page .accounts-credit-note { font-size: .85rem; line-height: 1.5; }
html[data-theme] #page .account-balance-kpi .dashboard-credit-reference { display: grid; gap: 4px; margin: 4px 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; line-height: 1.45; }
html[data-theme] #page .account-balance-kpi .money-summary-detail { margin-top: 10px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
html[data-theme] #page .account-balance-kpi .money-summary-detail summary { cursor: pointer; color: var(--text); }
html[data-theme] #page .account-balance-kpi .money-summary-detail summary:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; border-radius: 4px; }
html[data-theme] #page .account-balance-kpi .money-summary-detail small { display: block; margin-top: 8px; }
html[data-theme] #page .dashboard-credit-reference > span { display: flex; flex-wrap: wrap; gap: 3px 10px; justify-content: space-between; }
html[data-theme] #page .dashboard-credit-reference b { color: var(--text); font-size: inherit; overflow-wrap: anywhere; }
html[data-theme] #page .dashboard-credit-reference > small { color: var(--muted); font-size: .73rem; line-height: 1.4; }
html[data-theme] #page .debt-period-decision { display: grid; gap: 4px; flex-basis: 100%; padding: 10px 0; color: var(--text); font-size: .85rem; }
html[data-theme] #page .debt-period-decision small { color: var(--muted); line-height: 1.5; }

/* C131–C132: distinct dark surfaces and readable supporting text.
   Existing layouts, financial colors, amounts and interactions are retained. */
html[data-theme="dark"] #page .fv-history-view .fv-history-toolbar {
  background: var(--surface2);
  border-color: var(--line);
}

html[data-theme="dark"] #page .fv-history-view .fv-history-range {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--purple) 22%, var(--line));
}

html[data-theme="dark"] #page .fv-history-view .movement-date-range {
  background: var(--surface2);
  border-color: var(--line);
}

html[data-theme="dark"] #page .fv-history-view :is(.movement-date-range input, .history-search, .fv-origin-filter select) {
  background: var(--bg);
  border-color: color-mix(in srgb, var(--purple) 18%, var(--line));
  color: var(--text);
}

html[data-theme="dark"] #page .fv-history-view .history-search input {
  background: transparent;
  color: var(--text);
}

html[data-theme="dark"] #page .fv-history-view :is(.movement-date-range input, .history-search input, .fv-origin-filter select) {
  font-size: 13px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view input::placeholder {
  color: var(--muted);
  opacity: 1;
}

html[data-theme="dark"] #page .fv-history-view :is(.movement-date-range label > span, .fv-origin-filter > span, .history-search > small) {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

html[data-theme="dark"] #page .fv-history-view .fv-history-list-tools {
  border-color: var(--line);
}

html[data-theme="dark"] #page .fv-history-view :is(.fv-history-toolbar button, .history-quick-ranges button, .history-toggle) {
  min-height: 38px;
  padding: 8px 11px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

html[data-theme="dark"] #page .fv-history-view :is(.fv-history-toolbar button.active, .history-quick-ranges button.active) {
  background: color-mix(in srgb, var(--selector-accent, var(--purple)) 20%, var(--surface2));
  border-color: color-mix(in srgb, var(--selector-accent, var(--purple)) 50%, var(--line));
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--selector-accent, var(--purple)) 28%, transparent);
}

html[data-theme="dark"] #page .fv-history-view :is(.fv-history-toolbar button, .history-quick-ranges button, .history-toggle):hover {
  border-color: var(--purple);
  color: var(--text);
}

html[data-theme="dark"] #page .fv-history-view .fv-history-export {
  min-height: 40px;
  font-size: 12px;
}

html[data-theme="dark"] #page .fv-history-view .history-toggle {
  min-width: 0;
  max-width: 100%;
  padding-inline: 9px;
  font-size: 11px;
  white-space: normal;
}

html[data-theme="dark"] #page .fv-history-view .history-kpi {
  border-color: color-mix(in srgb, var(--summary-tone, var(--purple)) 35%, var(--line)) !important;
  background:
    radial-gradient(ellipse at 100% 0, color-mix(in srgb, var(--summary-tone, var(--purple)) 9%, transparent), transparent 70%),
    var(--surface2) !important;
}

html[data-theme="dark"] #page .fv-history-view .history-kpi small {
  font-size: 11px !important;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view .fv-history-month {
  background: var(--surface2);
  border-color: color-mix(in srgb, var(--purple) 22%, var(--line));
}

html[data-theme="dark"] #page .fv-history-view .history-month-name b {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view :is(.history-month-name small, .history-month-name > span) {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view .history-month-summary > strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

html[data-theme="dark"] #page .fv-history-view .history-month-summary > strong::before {
  color: var(--muted);
}

html[data-theme="dark"] #page .fv-history-view .fv-history-preview {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

html[data-theme="dark"] #page .fv-history-view .fv-history-detail-heading {
  border-color: var(--line);
}

html[data-theme="dark"] #page .fv-history-view :is(.fv-history-detail-heading small, .fv-history-detail-heading > span) {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view .fv-history-detail-heading b {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view .fv-history-ledger {
  scrollbar-color: var(--surface3) transparent;
}

html[data-theme="dark"] #page .fv-history-view .history-ledger-row {
  border-color: var(--line);
}

html[data-theme="dark"] #page .fv-history-view .history-ledger-row:hover {
  background: var(--surface2);
}

html[data-theme="dark"] #page .fv-history-view .history-ledger-row > div b {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-history-view .history-ledger-row > div small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

html[data-theme="dark"] #page .fv-history-view .history-ledger-row > strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account {
  border-color: color-mix(in srgb, var(--purple) 22%, var(--line));
  background:
    radial-gradient(ellipse at 100% 0, color-mix(in srgb, var(--purple) 10%, transparent), transparent 65%),
    linear-gradient(145deg, var(--surface2), var(--surface));
}

html[data-theme="dark"] #page .fv-accounts-view .live-account::after {
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--purple) 35%, transparent), transparent);
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .account-currency {
  border-color: var(--line);
  background: var(--surface3);
  color: var(--text);
  font-size: 11px;
  line-height: 1.4;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .account-identity h2 {
  color: var(--text);
  font-size: 18px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .account-identity span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .account-balance {
  color: var(--text);
  font-size: 28px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .account-balance small {
  color: var(--muted);
  font-size: 11px;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .account-native {
  color: var(--cyan);
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .ownership {
  flex-wrap: wrap;
  gap: 6px 12px;
  border-color: var(--line);
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .ownership span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: .06em;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account .ownership b {
  margin-left: auto;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account > .modal-actions .secondary {
  min-height: 40px;
  border-color: color-mix(in srgb, var(--purple) 30%, var(--line));
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}

html[data-theme="dark"] #page .fv-accounts-view .live-account > .modal-actions .secondary:hover {
  border-color: var(--purple);
  background: var(--surface3);
  color: var(--text);
}

html[data-theme="dark"] #page :is(.fv-history-view, .fv-accounts-view) :is(button, input, select):focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
}

@media (max-width: 760px) {
  html[data-theme="dark"] #page .fv-history-view .fv-history-range {
    min-width: 0;
  }

  html[data-theme="dark"] #page .fv-history-view .movement-date-range {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    max-width: 100%;
  }

  html[data-theme="dark"] #page .fv-history-view .movement-date-range > label {
    width: auto;
    min-width: 0;
    max-width: 100%;
  }

  html[data-theme="dark"] #page .fv-history-view :is(.movement-date-range input, .history-search input, .fv-origin-filter select) {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  html[data-theme="dark"] #page .fv-history-view input[type="date"]::-webkit-date-and-time-value {
    min-width: 0;
    text-align: left;
  }

  html[data-theme="dark"] #page .fv-history-view :is(.fv-history-list-tools, .movement-search, .fv-origin-filter) {
    min-width: 0;
    max-width: 100%;
  }

  html[data-theme="dark"] #page .fv-history-view .history-search {
    height: auto;
    min-height: 46px;
  }

  html[data-theme="dark"] #page .fv-history-view .history-search > small {
    flex-shrink: 0;
    white-space: nowrap;
  }

  html[data-theme="dark"] #page .fv-history-view .fv-history-list-tools .fv-origin-filter {
    flex-basis: auto;
  }

  html[data-theme="dark"] #page .fv-history-view .history-quick-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  html[data-theme="dark"] #page .fv-history-view .history-quick-ranges button {
    flex: 1 1 64px;
    min-width: 0;
    white-space: normal;
  }

  html[data-theme="dark"] #page .fv-history-view :is(.fv-history-toolbar button, .history-quick-ranges button, .history-toggle, .fv-history-export),
  html[data-theme="dark"] #page .fv-accounts-view .live-account > .modal-actions .secondary {
    min-height: 44px;
  }

  html[data-theme="dark"] #page .fv-history-view .fv-history-detail-heading {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* Shared typography also takes precedence over the older light-only sheet. */
html[data-theme] #page .fv-history-view.history-view :is(.history-kpi strong, .history-month-summary > strong, .history-ledger-row > strong),
html[data-theme] #page .fv-accounts-view :is(.account-balance, .account-native),
html[data-theme] #page .accounts-credit-amount strong { font-family: var(--niwwi-heading-font, Manrope, sans-serif); font-variant-numeric: tabular-nums; }
html[data-theme] #page .fv-history-view.history-view :is(.fv-history-toolbar, .fv-history-range, .fv-history-month) { border-color: color-mix(in srgb, var(--purple) 28%, var(--line)); background: radial-gradient(ellipse at 100% 0, color-mix(in srgb, var(--purple) 9%, transparent), transparent 65%), var(--surface); }
html[data-theme] #page .fv-history-view.history-view .fv-history-range { padding: 20px; }
/* The legacy history --purple alias can be undefined when no business accent
   was injected. Keep panel borders independent of that alias/currentColor. */
html[data-theme="dark"] #page .fv-history-view.history-view :is(.fv-history-toolbar, .fv-history-range, .fv-history-month, .movement-date-range, .movement-date-range input, .history-search, .fv-origin-filter select, .fv-history-list-tools) { border-color: var(--niwwi-edge, var(--line)); }
html[data-theme] #page .fv-history-view.history-view :is(.movement-date-range label > span, .fv-origin-filter > span, .history-search > small, .history-month-name small, .fv-history-detail-heading small, .fv-history-detail-heading > span, .history-ledger-row > div small) { font-size: 13px; line-height: 1.55; color: var(--muted); }
html[data-theme] #page .fv-history-view.history-view :is(.fv-history-toolbar button, .history-quick-ranges button, .history-toggle, .fv-history-export) { min-height: 44px; font-size: 13px; line-height: 1.45; }
html[data-theme] #page .fv-history-view.history-view .history-quick-ranges { gap: 8px; }
html[data-theme] #page .fv-history-view.history-view :is(.history-month-name b, .fv-history-detail-heading b, .history-ledger-row > div b) { font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
html[data-theme] #page .fv-history-view.history-view :is(.history-month-summary > strong, .history-ledger-row > strong) { font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; }
html[data-theme] #page .fv-history-view.history-view .history-kpi { padding: 18px; min-width: 0; }
html[data-theme] #page .fv-history-view.history-view .history-kpi small { font-size: 12px !important; line-height: 1.5; letter-spacing: .035em; }
html[data-theme] #page .fv-history-view.history-view .history-kpi strong { font-size: clamp(22px, 2.1vw, 28px); line-height: 1.35; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
html[data-theme] #page .fv-history-view.history-view .history-ledger-row { gap: 12px; padding-block: 14px; }
html[data-theme] #page .fv-history-view.history-view .history-ledger-row > div { min-width: 0; }
html[data-theme] #page .fv-history-view.history-view .history-ledger-row > div small { white-space: normal; overflow-wrap: anywhere; }
html[data-theme] #page .fv-accounts-view .live-account { padding: 22px; border-color: color-mix(in srgb, var(--purple) 30%, var(--line)); background: radial-gradient(ellipse at 100% 0, color-mix(in srgb, var(--cyan) 10%, transparent), transparent 65%), linear-gradient(145deg, var(--surface2), var(--surface)); }
html[data-theme] #page .fv-accounts-view .live-account .account-identity h2 { color: var(--text); font-size: 20px; line-height: 1.4; margin-bottom: 6px; overflow-wrap: anywhere; }
html[data-theme] #page .fv-accounts-view .live-account :is(.account-currency, .account-identity span, .account-balance small, .ownership span) { color: var(--muted); font-size: 12px; line-height: 1.5; letter-spacing: .035em; }
html[data-theme] #page .fv-accounts-view .live-account .account-balance { color: var(--text); font-size: clamp(28px, 2.8vw, 36px); line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
html[data-theme] #page .fv-accounts-view .live-account :is(.account-native, .ownership b) { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
html[data-theme] #page .fv-accounts-view .live-account .ownership { flex-wrap: wrap; gap: 8px 12px; padding-block: 14px; }
html[data-theme] #page .fv-accounts-view .live-account > .modal-actions .secondary { min-height: 44px; font-size: 13px; }
html[data-theme] #page .accounts-credit-card { border-color: color-mix(in srgb, var(--purple) 30%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--purple) 10%, var(--surface2)), var(--surface)); }
html[data-theme] #page .accounts-credit-amount strong { font-size: clamp(24px, 2vw, 30px); font-variant-numeric: tabular-nums; line-height: 1.3; }
html[data-theme] #page .accounts-credit-card > div > span { font-size: 13px; line-height: 1.5; }
html[data-theme] #page :is(.fv-history-view, .fv-accounts-view) :is(button, input, select):focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
html[data-theme] #page .fv-accounts-view .account-activity { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); min-width: 0; text-align: left; }
html[data-theme] #page .fv-accounts-view .account-activity-heading h3 { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.5; color: var(--text); }
html[data-theme] #page .fv-accounts-view .account-activity :is(small, .account-activity-caption, .account-activity-empty) { color: var(--muted); font-size: 12px; line-height: 1.5; }
html[data-theme] #page .fv-accounts-view .account-activity-heading small { display: block; margin-top: 3px; }
html[data-theme] #page .fv-accounts-view .account-activity-caption { margin: 12px 0 4px; }
html[data-theme] #page .fv-accounts-view .account-activity ol { list-style: none; padding: 0; margin: 0; }
html[data-theme] #page .fv-accounts-view .account-activity li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding-block: 10px; border-bottom: 1px solid var(--line); }
html[data-theme] #page .fv-accounts-view .account-activity li :is(b, strong) { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
html[data-theme] #page .fv-accounts-view .account-activity li small { display: block; }
html[data-theme] #page .fv-accounts-view .account-activity-value { text-align: right; font-variant-numeric: tabular-nums; }
html[data-theme] #page .fv-accounts-view .account-activity li p { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
html[data-theme] #page .fv-accounts-view .account-activity > button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 8px; white-space: nowrap; }
@media (max-width: 760px) {
  html[data-theme] #page .fv-history-view.history-view .fv-history-range { padding: 16px; }
  html[data-theme] #page .fv-history-view.history-view .movement-date-range { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
  html[data-theme] #page .fv-history-view.history-view .movement-date-range > label { width: auto; min-width: 0; max-width: 100%; }
  html[data-theme] #page .fv-history-view.history-view :is(.movement-date-range input, .history-search input, .fv-origin-filter select) { min-width: 0; max-width: 100%; min-height: 44px; font-size: 16px; box-sizing: border-box; }
  html[data-theme] #page .fv-history-view.history-view .history-quick-ranges { display: flex; flex-wrap: wrap; }
  html[data-theme] #page .fv-history-view.history-view .history-quick-ranges button { flex: 1 1 80px; white-space: normal; }
  html[data-theme] #page .fv-accounts-view .live-account { padding: 18px; }
}
@media (max-width: 480px) {
  html[data-theme] #page .fv-history-view.history-view .history-ledger-row { grid-template-columns: 32px minmax(0, 1fr); gap: 6px 12px; }
  html[data-theme] #page .fv-history-view.history-view .history-ledger-row > strong { grid-column: 2; justify-self: start; }
}
