:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #eef2f0;
  --ink: #1e2824;
  --muted: #63716b;
  --line: #dce3df;
  --green: #16724d;
  --green-soft: #e0f2e9;
  --red: #b6403a;
  --red-soft: #fae6e2;
  --blue: #315f83;
  --blue-soft: #e4eef6;
  --gold: #9b6f1d;
  --gold-soft: #f5edda;
  --shadow: 0 18px 50px rgba(31, 44, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Ledger intelligence */
.privacy-toggle.active {
  color: var(--green);
  background: var(--green-soft);
}

.private-value {
  all: unset !important;
}

.privacy-mode .private-value {
  color: transparent !important;
  text-shadow: none !important;
  position: relative !important;
  user-select: none !important;
}
.privacy-mode .private-value::after {
  content: "••••";
  position: absolute;
  left: 0;
  right: 0;
  color: var(--muted);
  text-align: center;
}

.bulk-action-bar {
  position: sticky;
  top: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 16px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.bulk-action-bar[hidden] {
  display: none;
}

.bulk-action-bar select {
  min-width: 180px;
}

.selection-cell {
  width: 40px;
  text-align: center;
}

.selection-cell input {
  width: 18px;
  height: 18px;
}

.transaction-tag,
.managed-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 4px 4px 0 0;
  padding: 3px 8px;
  border-left: 4px solid var(--tag-color);
  border-radius: 4px;
  background: color-mix(in srgb, var(--tag-color) 13%, var(--surface));
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
}

.classification-pill.excluded {
  color: var(--muted);
  background: var(--surface-soft);
}

.subscription-item.overdue {
  border-color: var(--red);
}

.category-management-list,
.tag-management-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.category-management-list {
  display: grid;
}

.managed-category {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
}

.managed-category.child {
  margin-left: 22px;
}

.managed-category span:nth-child(2) {
  display: grid;
}

.managed-category small {
  color: var(--muted);
}

.category-swatch {
  width: 12px;
  height: 28px;
  border-radius: 3px;
}

.tag-picker {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tag-picker legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 700;
}

.tag-picker > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag-option input {
  position: absolute;
  opacity: 0;
}

.tag-option span {
  display: inline-flex;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--tag-color);
  border-radius: 4px;
  cursor: pointer;
}

.tag-option input:checked + span {
  background: color-mix(in srgb, var(--tag-color) 16%, var(--surface));
  border-color: var(--tag-color);
}

.split-editor {
  display: grid;
  gap: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.split-editor-heading,
.split-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.split-row {
  grid-template-columns: minmax(0, 1fr) 130px 40px;
  margin-bottom: 7px;
}

.recurring-summary-grid,
.monthly-review-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.recurring-summary-grid > div,
.monthly-review-metrics > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.recurring-summary-grid span,
.monthly-review-metrics span {
  color: var(--muted);
  font-size: 0.78rem;
}

.monthly-review-metrics small,
.monthly-review-details small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.monthly-review-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  background: var(--gold-soft);
  color: var(--ink);
}

.recurring-summary-grid strong,
.monthly-review-metrics strong {
  font-size: 1.12rem;
}

.monthly-review-panel {
  margin-bottom: 18px;
}

.inline-month-field {
  width: 180px;
}

.monthly-review-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.monthly-review-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.monthly-review-details h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.monthly-review-details p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 640px) {
  .bulk-action-bar {
    top: 6px;
    margin: 0 0 12px;
    padding: 10px;
  }

  .bulk-action-bar strong,
  .bulk-action-bar select,
  .bulk-action-bar button {
    flex: 1 1 100%;
    width: 100%;
  }

  .recurring-summary-grid,
  .monthly-review-metrics,
  .monthly-review-details {
    grid-template-columns: 1fr;
  }

  .inline-month-field {
    width: 100%;
  }

  .split-row {
    grid-template-columns: minmax(0, 1fr) 100px 40px;
  }

  .review-item {
    touch-action: pan-y;
    transition: transform 160ms ease, border-color 160ms ease;
  }

  .review-item.swipe-actions-visible {
    border-color: var(--green);
    transform: translateX(-8px);
  }

  .review-item.swipe-actions-visible .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121514;
  --surface: #1b201e;
  --surface-soft: #252b28;
  --ink: #eef3f0;
  --muted: #9eaaa4;
  --line: #343c38;
  --green: #5ac997;
  --green-soft: #183a2c;
  --red: #f08b83;
  --red-soft: #472724;
  --blue: #82b7e0;
  --blue-soft: #233746;
  --gold: #e3bd68;
  --gold-soft: #41351f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--green-soft) 72%, transparent), transparent 360px),
    var(--bg);
  color: var(--ink);
}

body:has(dialog[open]) {
  overflow: hidden;
}

.mobile-more-nav {
  display: none;
}

.mobile-navigation-dialog {
  width: min(520px, 100%);
  max-width: none;
  max-height: min(78vh, 680px);
  margin: auto auto 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  box-shadow: 0 -18px 54px rgba(16, 24, 20, 0.24);
}

.mobile-navigation-dialog::backdrop {
  background: rgba(8, 14, 11, 0.56);
  backdrop-filter: blur(3px);
}

.mobile-navigation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.mobile-navigation-header h2 {
  margin: 0;
}

.mobile-navigation-grid {
  display: grid;
  gap: 6px;
}

.mobile-navigation-grid button {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 2px 10px;
  min-height: 60px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  padding: 9px 12px;
  text-align: left;
}

.mobile-navigation-grid button::before {
  grid-row: 1 / span 2;
  align-self: center;
  content: attr(data-mobile-icon);
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center;
}

.mobile-navigation-grid button span {
  align-self: end;
  font-weight: 900;
}

.mobile-navigation-grid button small {
  align-self: start;
  color: var(--muted);
  font-size: 0.72rem;
}

.mobile-navigation-grid button.active {
  border-color: color-mix(in srgb, var(--green) 30%, var(--line));
  background: var(--green-soft);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 16px;
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.language-switch {
  display: flex;
  justify-content: flex-end;
}

.language-switch label,
.language-inline {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.language-switch select,
.language-inline select {
  width: auto;
  min-width: 112px;
}

.auth-intro h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.3rem);
  line-height: 0.96;
}

.auth-intro p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(31, 44, 38, 0.08);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-error {
  margin: 0;
  border: 1px solid rgba(182, 64, 58, 0.24);
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 12px;
  font-weight: 800;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  max-width: 720px;
  font-size: 2rem;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.theme-toggle {
  width: 42px;
  flex: 0 0 42px;
  padding: 0;
  font-size: 1.15rem;
}

.language-inline {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0 10px;
}

.language-inline span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.language-inline select {
  min-height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
  font-weight: 900;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 900;
}

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

.ghost-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 0 14px;
}

.file-button input {
  display: none;
}

.primary-button {
  width: 100%;
  background: var(--green);
  color: white;
  padding: 0 18px;
}

.primary-button.danger {
  background: var(--red);
}

.ghost-button:hover,
.primary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 44, 38, 0.12);
}

.control-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.quick-action,
.text-button,
.dialog-close,
.entry-type-tabs button {
  border: 0;
  cursor: pointer;
}

.quick-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 900;
}

.quick-action > span:first-child {
  font-size: 1.15rem;
}

.quick-action.income-action {
  border-color: rgba(22, 114, 77, 0.28);
  background: var(--green-soft);
  color: var(--green);
}

.quick-action.expense-action {
  border-color: rgba(182, 64, 58, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

.period-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.period-range {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 10px;
}

.period-range[hidden] {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 114, 77, 0.14);
}

.classification-box {
  display: grid;
  gap: 10px;
  border-left: 3px solid var(--green);
  background: var(--surface-soft);
  padding: 12px;
}

.classification-box[hidden] {
  display: none;
}

.classification-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.classification-pill {
  display: inline-block;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 900;
}

.classification-pill.unknown {
  border-color: rgba(182, 64, 58, 0.35);
  background: var(--red-soft);
  color: var(--red);
}

.classification-pill.rule {
  border-color: rgba(22, 114, 77, 0.3);
  background: var(--green-soft);
  color: var(--green);
}

.classification-pill.learned {
  border-color: rgba(22, 114, 77, 0.3);
  background: var(--green-soft);
  color: var(--green);
}

.classification-pill.collective {
  border-color: rgba(49, 95, 131, 0.3);
  background: #eaf4fb;
  color: #315f83;
}

.collective-learning-option span {
  display: grid;
  gap: 3px;
}

.collective-learning-option small {
  color: var(--muted);
  font-weight: 500;
}

.classification-pill.suggested {
  border-color: rgba(178, 112, 20, 0.3);
  background: #fff6df;
  color: #8b5b17;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
}

@media (max-width: 760px) {
  .period-range {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.period-total {
  display: grid;
  gap: 2px;
  min-width: 190px;
  text-align: right;
}

.period-total span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.period-total strong {
  font-size: 1.65rem;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 6px;
  backdrop-filter: blur(10px);
}

.app-nav-button,
.bank-tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
}

.app-nav-button.active,
.bank-tab.active {
  background: var(--green);
  color: #fff;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

.summary-grid,
.accounts-grid,
.accounts-overview,
.dashboard-grid,
.investment-summary-grid,
.workspace-grid,
.insights-grid,
.records-grid,
.settings-grid {
  display: grid;
  gap: 16px;
}

.summary-grid {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  margin-bottom: 16px;
}

.dashboard-grid {
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  margin-bottom: 16px;
}

.cashflow-panel {
  order: -2;
}

.automation-health-panel {
  order: -1;
}

.investment-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1.05;
}

.accounts-grid,
.workspace-grid,
.insights-grid,
.records-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.accounts-overview {
  grid-template-columns: 1fr;
  margin-bottom: 16px;
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding: 4px 2px 16px;
}

.section-toolbar h2 {
  margin: 0;
  font-size: 1.45rem;
}

.section-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.auto-width {
  width: auto;
}

.bank-action-shell,
.recurring-action-shell {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.action-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.action-tabs button {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 900;
  white-space: nowrap;
}

.action-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(31, 44, 38, 0.08);
}

.compact-form {
  box-shadow: none;
}

.compact-form .panel-heading {
  margin-bottom: 4px;
}

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

.import-mapping {
  display: grid;
  gap: 12px;
}

.import-mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.inline-connect-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(240px, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.connect-form-actions {
  display: flex;
  gap: 8px;
}

.connection-list,
.rule-list {
  display: grid;
  gap: 8px;
}

.connection-row,
.rule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
}

.connection-main,
.rule-row > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.connection-main .status-badge {
  justify-self: start;
  margin-bottom: 2px;
}

.connection-main small,
.rule-row span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.form-help.warning {
  background: var(--gold-soft);
  color: var(--gold);
}

.status-badge.error {
  background: var(--red-soft);
  color: var(--red);
}

.full-span {
  grid-column: 1 / -1;
}

.path-display {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 11px 12px;
  color: var(--ink);
  font-size: 0.8rem;
  white-space: nowrap;
}

.automation-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.automation-status span {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.automation-status strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.automation-health-list {
  display: grid;
}

.automation-health-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.automation-health-row:last-child {
  border-bottom: 0;
}

.automation-health-row > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.automation-health-row strong,
.automation-health-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-health-row > div > strong {
  font-size: 0.86rem;
}

.automation-health-row > div > span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.automation-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.automation-health-dot.active {
  background: var(--green);
}

.automation-health-dot.warning {
  background: var(--gold);
}

.automation-health-status {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 0.7rem;
  font-weight: 900;
}

.automation-health-status.active {
  background: var(--green-soft);
  color: var(--green);
}

.automation-health-status.warning {
  background: var(--gold-soft);
  color: var(--gold);
}

.automation-sync-button {
  width: 100%;
  margin-top: 12px;
}

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

.data-actions > * {
  width: 100%;
}

.panel {
  padding: 18px;
}

.text-button {
  min-height: 32px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--green);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.cashflow-panel,
.movements-ledger {
  min-width: 0;
}

.cashflow-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 210px;
  padding-top: 8px;
}

.cashflow-month {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 0;
  height: 180px;
}

.cashflow-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  height: 148px;
  border-bottom: 1px solid var(--line);
}

.cashflow-bar {
  width: min(18px, 42%);
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--green);
}

.cashflow-bar.expense {
  background: var(--red);
}

.cashflow-month > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-list,
.budget-list,
.budget-settings-list {
  display: grid;
  gap: 8px;
}

.activity-row,
.budget-row,
.budget-setting {
  display: grid;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.activity-row {
  grid-template-columns: 10px minmax(0, 1fr) auto;
  width: 100%;
  margin: 0;
  text-align: left;
}

.activity-row:last-child,
.budget-row:last-child,
.budget-setting:last-child {
  border-bottom: 0;
}

.activity-mark {
  width: 8px;
  height: 32px;
  border-radius: 4px;
  background: var(--blue);
}

.activity-mark.income {
  background: var(--green);
}

.activity-mark.expense {
  background: var(--red);
}

.activity-copy,
.activity-value {
  min-width: 0;
}

.activity-copy {
  justify-self: stretch;
  text-align: left;
}

.activity-value {
  justify-self: end;
}

.activity-copy strong,
.activity-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.activity-value {
  font-size: 0.88rem;
  font-weight: 900;
  white-space: nowrap;
}

.budget-row {
  grid-template-columns: minmax(0, 1fr);
}

.budget-row-info {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.budget-row > .activity-value {
  color: var(--muted);
  text-align: right;
}

.budget-row-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.83rem;
  font-weight: 900;
}

.budget-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-soft);
}

.budget-progress > span {
  display: block;
  width: var(--budget-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.budget-row.warning .budget-progress > span {
  background: var(--gold);
}

.budget-row.over .budget-progress > span {
  background: var(--red);
}

.budget-setting {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.ledger-heading {
  align-items: center;
}

.compact-button {
  min-height: 36px;
}

.ledger-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(150px, 0.6fr) minmax(180px, 0.8fr);
  gap: 12px;
  margin-bottom: 14px;
}

.movements-ledger {
  margin-bottom: 16px;
}

.entry-workspace {
  padding-top: 0;
}

[data-app-view="movements"] > .records-grid {
  display: none;
}

.view-section.active[data-app-view="banks"] {
  flex-direction: column;
}

.view-section.active[data-app-view="banks"] .accounts-overview {
  order: 1;
}

.view-section.active[data-app-view="banks"] .accounts-grid {
  order: 2;
}

.ledger-type {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 900;
}

.ledger-type::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  content: "";
}

.ledger-type.income::before {
  background: var(--green);
}

.ledger-type.expense::before {
  background: var(--red);
}

.quick-entry-dialog {
  width: min(540px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(22, 32, 27, 0.24);
  padding: 20px;
}

.quick-entry-dialog::backdrop {
  background: rgba(20, 29, 25, 0.46);
  backdrop-filter: blur(3px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1.4rem;
}

.entry-type-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 4px;
}

.entry-type-tabs button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.entry-type-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(31, 44, 38, 0.08);
}

.quick-entry-form {
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100% - 40px));
  border: 1px solid rgba(22, 114, 77, 0.24);
  border-radius: 8px;
  background: #173c2f;
  color: white;
  box-shadow: 0 18px 50px rgba(20, 29, 25, 0.24);
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 800;
}

@media (min-width: 921px) {
  main {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    gap: 0 16px;
  }

  .control-band {
    grid-column: 2;
    grid-row: 1;
  }

  .investment-nav button {
    padding-inline: 10px;
    font-size: 0.82rem;
  }

  .app-nav {
    grid-column: 1;
    grid-row: 2;
    top: 16px;
  }

  .app-nav-button {
  }

  .view-section {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
  }

  .view-section.active[data-app-view="banks"] {
    display: flex;
  }
}

.form-panel {
  display: grid;
  gap: 14px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 2px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 1.15rem;
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--green);
  font-weight: 900;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.5fr) minmax(0, 1fr);
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  background: var(--green-soft);
  color: var(--green);
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.status-badge.paused {
  background: var(--gold-soft);
  color: var(--gold);
}

.form-help,
.form-success {
  margin: 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.4;
}

.form-help {
  background: var(--surface-soft);
  color: var(--muted);
}

.form-success {
  background: var(--green-soft);
  color: var(--green);
}

.chart-list {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(104px, 1fr) minmax(140px, 2fr) minmax(92px, auto);
  align-items: center;
  gap: 12px;
}

.chart-label {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.chart-fill {
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.chart-fill.expense {
  background: var(--red);
}

.chart-value {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: right;
}

.allocation-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.allocation-chart {
  display: grid;
  place-items: center;
  width: 210px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 18px rgba(255, 255, 255, 0.86);
}

.allocation-chart span {
  display: grid;
  place-items: center;
  width: 130px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.allocation-legend,
.bank-summary-grid,
.investment-dashboard-list {
  display: grid;
  gap: 10px;
}

.allocation-row,
.bank-summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.allocation-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
}

.allocation-row strong {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.allocation-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot-color);
}

.bank-summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bank-summary-card {
  display: grid;
  gap: 5px;
  min-height: 118px;
  padding: 14px;
}

.bank-summary-card span,
.bank-summary-card em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
}

.bank-summary-card strong {
  font-size: 1.1rem;
}

.bank-summary-card b {
  margin-top: 4px;
  color: var(--green);
  font-size: 1rem;
}

.table-panel {
  min-width: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.bank-list {
  display: grid;
  gap: 14px;
}

.bank-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.bank-tab {
  border: 1px solid var(--line);
}

.investment-account-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

[data-app-view="investments"] > :not(.investment-workbench) {
  display: none;
}

.investment-workbench {
  display: grid;
  gap: 18px;
}

.investment-toolbar,
.investment-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.investment-toolbar h2,
.investment-section-heading h2 {
  margin: 2px 0 0;
}

.investment-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status {
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
}

.investment-kpi-grid,
.investment-income-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

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

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

.crypto-kpi-grid .metric {
  min-height: 92px;
  padding: 15px;
}

.crypto-kpi-grid .compact-value {
  font-size: 0.94rem;
  line-height: 1.3;
}

.crypto-wallet-list {
  display: grid;
}

.crypto-wallet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.crypto-wallet-row:last-child {
  border-bottom: 0;
}

.crypto-wallet-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.crypto-wallet-main code {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
}

.crypto-wallet-main small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-weight: 750;
}

.wallet-network {
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.wallet-address-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.wallet-consent {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.investment-kpi-grid .metric,
.investment-income-grid .metric {
  min-height: 102px;
  padding: 16px;
}

.investment-kpi-grid .metric strong,
.investment-income-grid .metric strong {
  font-size: clamp(1.05rem, 1.6vw, 1.45rem);
}

.investment-kpi-grid .metric small {
  display: block;
  margin-top: 4px;
  font-weight: 900;
}

.investment-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.investment-nav button {
  flex: 0 0 auto;
  min-height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 850;
}

.investment-nav button.active {
  border-bottom-color: var(--green);
  color: var(--ink);
}

.investment-view {
  display: none;
  gap: 16px;
}

.investment-view.active {
  display: grid;
}

.investment-dashboard-grid,
.analysis-grid,
.investment-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.expense-sector-layout,
.investment-holdings-allocation {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.sector-chart,
.holdings-chart {
  width: 160px;
  aspect-ratio: 1;
}

.holdings-chart {
  border: 0;
  border-radius: 50%;
  padding: 0;
}

.holdings-legend {
  display: grid;
  gap: 5px;
}

.loan-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.loan-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.loan-list-panel {
  grid-column: 1 / -1;
}

.loan-results {
  display: grid;
  gap: 8px;
}

.loan-results > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.loan-results span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.asset-search-results {
  display: grid;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.asset-search-results[hidden] {
  display: none;
}

.asset-search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.asset-search-result:last-child {
  border-bottom: 0;
}

.asset-search-result span {
  color: var(--muted);
  font-size: 0.75rem;
}

.asset-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.asset-details summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 850;
}

.asset-details[open] summary {
  margin-bottom: 12px;
}

.asset-details > .form-row + .form-row {
  margin-top: 12px;
}

[data-app-view="movements"] > .records-grid,
[data-app-view="movements"] > .entry-workspace {
  display: none;
}

@media (max-width: 760px) {
  .expense-sector-layout,
  .investment-holdings-allocation,
  .loan-workspace,
  .loan-summary-grid {
    grid-template-columns: 1fr;
  }

  .sector-chart,
  .holdings-chart {
    justify-self: center;
  }
}

.investment-dashboard-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
}

.investment-dashboard-grid .panel,
.analysis-grid .panel,
.investment-two-column .panel {
  min-width: 0;
}

.portfolio-chart {
  min-height: 210px;
}

.portfolio-period-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 3px;
}

.portfolio-period-control button {
  min-width: 36px;
  min-height: 30px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  padding: 0 7px;
  font-size: 0.72rem;
  font-weight: 850;
}

.portfolio-period-control button.active {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(31, 44, 38, 0.12);
  color: var(--ink);
}

.portfolio-chart-summary {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.portfolio-chart-summary > strong {
  font-size: 1.35rem;
}

.portfolio-chart-summary > span {
  font-size: 0.82rem;
  font-weight: 900;
}

.portfolio-chart-summary small {
  color: var(--muted);
  font-size: 0.72rem;
}

.portfolio-line-chart {
  display: block;
  width: 100%;
  height: 170px;
  overflow: visible;
}

.portfolio-line-chart polyline {
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.portfolio-line-chart .portfolio-area {
  fill: color-mix(in srgb, var(--green) 14%, transparent);
  stroke: none;
}

.investment-overview-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
  gap: 14px;
}

.investment-overview-side {
  display: grid;
  align-content: start;
  gap: 14px;
}

.investment-movers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mover-heading {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mover-row,
.overview-watchlist > div,
.portfolio-health-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}

.mover-row:last-child,
.overview-watchlist > div:last-child,
.portfolio-health-list > div:last-child {
  border-bottom: 0;
}

.mover-row span,
.overview-watchlist span {
  min-width: 0;
}

.mover-row small,
.overview-watchlist small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-empty {
  min-height: 80px;
  padding-inline: 4px;
  text-align: left;
}

.health-score {
  border-radius: 5px;
  background: var(--surface-soft);
  padding: 6px 8px;
  font-size: 0.82rem;
}

.warning {
  color: var(--gold) !important;
}

.portfolio-health-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

.portfolio-health-list span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.overview-watchlist {
  display: grid;
}

.watchlist-quote {
  flex: 0 0 auto;
  text-align: right;
}

.recent-investment-activity table {
  min-width: 680px;
}

.investment-more-button {
  flex: 0 0 auto;
  background: var(--surface-soft);
  color: var(--muted);
}

.single-snapshot {
  display: grid;
  place-content: center;
  min-height: 205px;
  text-align: center;
}

.single-snapshot span,
.single-snapshot small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.single-snapshot strong {
  margin: 5px 0;
  font-size: 1.8rem;
}

.spark-bars {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 170px;
  padding-top: 10px;
}

.spark-bars span {
  flex: 1;
  min-width: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--green);
  opacity: 0.82;
}

.chart-axis {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.chart-axis strong {
  color: var(--ink);
  font-size: 1rem;
}

.compact-allocation {
  grid-template-columns: 140px 1fr;
}

.small-allocation {
  width: 140px;
  height: 140px;
}

.compact-allocation .allocation-legend > div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.compact-allocation .allocation-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.compact-allocation .allocation-legend strong {
  text-align: right;
}

.account-value-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.investment-account-row,
.activity-list > div,
.tax-summary-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.investment-account-row:last-child,
.activity-list > div:last-child,
.tax-summary-list > div:last-child {
  border-bottom: 0;
}

.investment-account-row span,
.activity-list small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.analysis-bars,
.chart-list,
.tax-summary-list {
  display: grid;
  gap: 10px;
}

.analysis-row > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.analysis-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.analysis-row progress {
  width: 100%;
  height: 8px;
  accent-color: var(--green);
}

.transaction-badge {
  display: inline-block;
  border-radius: 4px;
  background: var(--surface-soft);
  padding: 4px 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.dividend-calendar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.dividend-calendar > div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.dividend-calendar span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.dividend-calendar strong {
  font-size: 0.86rem;
}

.investment-workbench .activity-list {
  margin-top: 14px;
}

.investment-workbench table {
  min-width: 780px;
}

.investment-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.investment-account-card span,
.muted-cell {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.investment-account-card strong {
  display: block;
  margin-top: 3px;
}

.investment-account-card > div:last-child {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.import-preview {
  display: grid;
  gap: 10px;
}

.import-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.import-preview-grid span,
.import-preview-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  color: var(--muted);
  font-weight: 800;
}

.import-preview-list {
  display: grid;
  gap: 6px;
}

.import-preview-list p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

.positive {
  color: var(--green);
  font-weight: 900;
}

.negative {
  color: var(--red);
  font-weight: 900;
}

.bank-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.bank-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface-soft);
  padding: 14px 16px;
}

.bank-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.bank-heading span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.bank-heading strong {
  text-align: right;
  white-space: nowrap;
}

.bank-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

.numeric {
  text-align: right;
}

.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 1px solid transparent;
  background: var(--red-soft);
  color: var(--red);
  font-size: 1rem;
  font-weight: 900;
}

.icon-button.save-button {
  background: var(--green-soft);
  color: var(--green);
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.icon-button.edit-button {
  background: var(--blue-soft);
  color: var(--blue);
}

.icon-button.neutral-button {
  background: var(--surface-soft);
  color: var(--ink);
}

.icon-button.skip-button {
  background: var(--gold-soft);
  color: var(--gold);
}

[data-theme="dark"] .ghost-button,
[data-theme="dark"] .language-inline,
[data-theme="dark"] .control-band,
[data-theme="dark"] .app-nav {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

[data-theme="dark"] .auth-tab.active,
[data-theme="dark"] .entry-type-tabs button.active,
[data-theme="dark"] .action-tabs button.active {
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .allocation-chart {
  box-shadow: inset 0 0 0 18px rgba(18, 21, 20, 0.64);
}

.table-input {
  width: 120px;
  min-height: 34px;
  padding: 0 8px;
  text-align: right;
}

.price-editor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.price-editor .table-input {
  width: 92px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 920px) {
  .investment-kpi-grid,
  .crypto-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .investment-dashboard-grid,
  .analysis-grid,
  .investment-two-column {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .investment-summary-grid,
  .dashboard-grid,
  .accounts-grid,
  .workspace-grid,
  .insights-grid,
  .records-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .three-columns,
  .import-mapping-grid,
  .inline-connect-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .connect-form-actions {
    grid-column: 1 / -1;
  }

  .ledger-filters {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .investment-toolbar,
  .investment-section-heading,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .section-toolbar-actions {
    justify-content: stretch;
  }

  .section-toolbar-actions > * {
    flex: 1 1 140px;
  }

  .investment-toolbar-actions {
    flex-wrap: wrap;
  }

  .investment-toolbar-actions .ghost-button,
  .investment-toolbar-actions .primary-button {
    flex: 1 1 140px;
  }

  .investment-overview-lower-grid,
  .investment-movers,
  .portfolio-health-list {
    grid-template-columns: 1fr;
  }

  .portfolio-period-control {
    flex: 1 0 100%;
    width: 100%;
  }

  .performance-panel .panel-heading {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .portfolio-period-control button {
    flex: 1;
  }

  .portfolio-chart-summary {
    grid-template-columns: auto 1fr;
  }

  .portfolio-chart-summary small {
    grid-column: 1 / -1;
  }

  .investment-kpi-grid,
  .investment-income-grid,
  .crypto-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .investment-kpi-grid .metric,
  .investment-income-grid .metric {
    min-height: 90px;
    padding: 13px;
  }

  .crypto-wallet-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .compact-allocation {
    grid-template-columns: 1fr;
  }

  .small-allocation {
    margin-inline: auto;
  }

  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .control-band {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > * {
    flex: 1 1 130px;
  }

  .quick-actions {
    justify-content: stretch;
  }

  .quick-action {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
  }

  .allocation-layout,
  .bank-summary-grid {
    grid-template-columns: 1fr;
  }

  .allocation-chart {
    justify-self: center;
  }

  .allocation-row {
    grid-template-columns: 12px minmax(0, 1fr);
  }

  .allocation-row strong {
    grid-column: 2;
  }

  .bank-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .bank-heading-actions {
    width: 100%;
    justify-content: space-between;
  }

  .summary-grid,
  .accounts-grid,
  .form-row,
  .form-actions,
  .data-actions,
  .import-preview-grid,
  .three-columns,
  .import-mapping-grid,
  .inline-connect-form,
  .automation-status {
    grid-template-columns: 1fr;
  }

  .connect-form-actions {
    display: grid;
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid .metric:first-child {
    grid-column: 1 / -1;
  }

  .cashflow-chart {
    gap: 5px;
  }

  .ledger-filters {
    grid-template-columns: 1fr;
  }

  .search-field {
    grid-column: auto;
  }

  .app-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    top: auto;
    z-index: 20;
    justify-content: flex-start;
    margin: 0;
    box-shadow: 0 14px 40px rgba(20, 29, 25, 0.18);
  }

  .app-shell {
    padding-bottom: 96px;
  }

  .toast {
    bottom: 86px;
  }

  .period-total {
    text-align: left;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }

  .chart-value {
    text-align: left;
  }

  .automation-health-row {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .automation-health-status {
    grid-column: 2;
    justify-self: start;
  }
}

.global-search-shell {
  position: relative;
  width: min(320px, 28vw);
}

.global-search-shell input {
  min-height: 42px;
  padding-left: 14px;
}

.global-search-results {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, 88vw);
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(24, 37, 33, 0.18);
  padding: 6px;
}

.global-search-results button {
  display: grid;
  width: 100%;
  gap: 3px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.global-search-results button:hover { background: var(--surface-soft); }
.global-search-results span { color: var(--muted); font-size: 0.78rem; }
.global-search-results p { margin: 10px; color: var(--muted); }

.nav-count {
  margin-left: auto;
  min-width: 22px;
  border-radius: 999px;
  background: #df5b53;
  color: #fff;
  font-size: 0.72rem;
  line-height: 22px;
  text-align: center;
}

.forecast-panel,
.net-worth-history-panel { grid-column: span 6 !important; }

.forecast-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.forecast-kpis div {
  display: grid;
  gap: 6px;
  border-left: 3px solid #2bad75;
  background: var(--surface-soft);
  padding: 12px;
}

.forecast-kpis div:nth-child(2) { border-left-color: #e69a34; }
.forecast-kpis div:nth-child(3) { border-left-color: #3486b7; }
.forecast-kpis span { color: var(--muted); font-size: 0.78rem; }
.forecast-kpis strong { font-size: 1.1rem; }

.history-chart {
  display: flex;
  align-items: end;
  min-height: 150px;
  gap: 6px;
  padding-top: 10px;
}

.history-column {
  display: grid;
  grid-template-rows: 120px 18px;
  align-items: end;
  flex: 1 1 0;
  min-width: 10px;
  text-align: center;
}

.history-column > span {
  display: block;
  min-height: 5px;
  border-radius: 3px 3px 0 0;
  background: #3486b7;
}

.history-column small { overflow: hidden; color: var(--muted); font-size: 0.64rem; }

.subscriptions-panel { margin-bottom: 18px; }
.subscription-grid { display: grid; gap: 18px; }
.recurring-detection-group { display: grid; gap: 9px; }
.recurring-detection-group > h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 0.88rem; }
.recurring-detection-group > h3 span { min-width: 24px; border-radius: 999px; background: var(--surface-soft); padding: 3px 7px; color: var(--muted); font-size: 0.7rem; text-align: center; }
.recurring-detection-group > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.recurring-kind-label { width: fit-content; border-left: 3px solid var(--blue); padding-left: 7px; color: var(--muted); font-size: 0.72rem; font-weight: 750; }
.recurring-detection-group.income .recurring-kind-label { border-left-color: var(--green); }
.subscription-item,
.review-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 13px;
}

.subscription-item > div:first-child,
.subscription-value,
.review-item > div:nth-child(2) { display: grid; gap: 3px; }
.subscription-item span,
.review-item span { color: var(--muted); font-size: 0.78rem; }
.subscription-item .row-actions { grid-column: 1 / -1; justify-self: end; }
.subscription-item.active { border-left: 3px solid #2bad75; }
.subscription-item.candidate { border-left: 3px solid #e69a34; }

.confidence-pill {
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 8px;
  color: var(--ink) !important;
  font-weight: 700;
}

.compact-button { min-height: 34px; width: auto; padding: 0 12px; }
.review-list { display: grid; gap: 8px; }
.review-item { grid-template-columns: 34px minmax(0, 1fr) auto auto; }
.review-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #fff1d9; color: #9a6111 !important; font-size: 1rem !important; }

.goals-layout { display: grid; grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr); gap: 16px; }
.goal-list { display: grid; gap: 12px; }
.goal-item { display: grid; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 0 14px; }
.goal-heading,
.goal-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.goal-heading > span { display: grid; gap: 2px; }
.goal-heading small,
.goal-footer span { color: var(--muted); }
.goal-progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.goal-progress span { display: block; height: 100%; border-radius: inherit; background: #2bad75; }

.dashboard-period-controls {
  display: grid;
  grid-template-columns: auto minmax(142px, 1fr) minmax(142px, 1fr) auto;
}

.period-presets {
  display: inline-flex;
  align-items: center;
  align-self: end;
  gap: 2px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 3px;
}

.period-presets button {
  min-width: 40px;
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.period-presets button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(25, 40, 35, 0.1);
}

.period-shift-actions {
  display: inline-flex;
  align-self: end;
  gap: 4px;
}

.classification-movement-summary {
  margin: 0;
  border-left: 3px solid #3486b7;
  background: var(--surface-soft);
  padding: 12px;
  font-weight: 700;
}

@media (max-width: 920px) {
  .global-search-shell { order: 5; width: 100%; }
  .subscription-grid,
  .recurring-detection-group > div,
  .goals-layout { grid-template-columns: 1fr; }
  .forecast-panel,
  .net-worth-history-panel { grid-column: span 12 !important; }
  .dashboard-period-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-presets { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .forecast-kpis { grid-template-columns: 1fr; }
  .subscription-item,
  .review-item { grid-template-columns: minmax(0, 1fr) auto; }
  .review-mark { display: none; }
  .review-item .row-actions { grid-column: 1 / -1; }
  .dashboard-period-controls { grid-template-columns: 1fr; width: 100%; }
  .period-presets { grid-column: auto; width: 100%; }
  .period-presets button { flex: 1; }
}


/* Keep secondary investment tools within their parent area. */
.investment-subnav { border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.investment-nav[hidden], .investment-view[hidden] { display: none !important; }
.investment-subnav button { font-size: .85rem; padding: .55rem .85rem; }
