:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --card: #ffffff;
  --border: #e4e7eb;
  --text: #1c2430;
  --muted: #6b7280;
  --accent: #1f6a4f;
  --accent-soft: #e8f4ee;
  --sidebar: #ffffff;
  --sidebar-border: #e6eaee;
  --section-line: #eceff2;
  --income: #15803d;
  --expense: #b91c1c;
  --shadow: 0 10px 28px rgba(28, 36, 48, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar-brand {
  padding: 6px 12px 14px;
  border-bottom: 1px solid var(--section-line);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.brand-mark {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-title {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}

.brand-tagline {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  align-content: start;
}

.nav-section {
  display: grid;
  gap: 2px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--section-line);
  align-content: start;
}

.nav-section:last-of-type {
  border-bottom: 0;
}

.nav-section-title {
  margin: 0 0 8px;
  padding: 0 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.nav-section-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}

.nav-section-btn:hover {
  background: #f3f5f7;
}

.nav-section-btn.active {
  background: var(--accent-soft);
}

.nav-sub-item {
  padding-left: 18px;
  font-size: 14px;
}

.nav-sub-item-nested {
  padding-left: 30px;
}

.nav-subsection-title {
  margin: 14px 0 6px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.nav-item,
.nav-account-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover,
.nav-account-item:hover {
  background: #f3f5f7;
}

.nav-item.active,
.nav-account-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-account-list {
  display: grid;
  gap: 2px;
  margin: 2px 0 0 8px;
  padding-left: 10px;
  border-left: 2px solid #e8ecef;
}

.nav-account-item {
  font-size: 13px;
  padding: 7px 10px;
  color: #44505c;
}

.nav-account-owner {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.nav-owner-group {
  display: grid;
  gap: 2px;
  margin: 8px 0 4px;
}

.nav-owner-title {
  margin: 0;
  padding: 4px 12px 2px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.nav-owner-item {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
}

.nav-owner-item:hover {
  background: #f3f5f7;
}

.nav-owner-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.owner-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--section-line);
}

.owner-panel:first-child {
  border-top: 0;
  padding-top: 0;
}

.owner-panel h3 {
  margin: 0 0 6px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 560;
}

.owner-panel .tab-total {
  margin: 0 0 10px;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 22px 24px 28px;
  gap: 16px;
}

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

.workspace-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.workspace-title {
  margin: 6px 0 0;
  font-family: "Fraunces", serif;
  font-size: 32px;
  font-weight: 560;
  line-height: 1.1;
}

.workspace-content {
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.nested-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #fafbfc;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.content-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 14px 0 18px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(40, 60, 50, 0.06);
}

.content-tabs-nested {
  margin: 10px 0 14px;
}

.view-switch-tabs {
  width: fit-content;
  margin-top: 4px;
}

.chart-frame {
  position: relative;
  height: 300px;
  max-width: 920px;
  margin: 4px 0 8px;
}

.chart-frame-pie {
  height: 320px;
  max-width: 640px;
}

.mix-snapshot {
  max-width: 640px;
  margin: 8px 0 4px;
}

.mix-bar {
  display: flex;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceff2;
}

.mix-bar-fixed {
  background: #7a4e3a;
}

.mix-bar-variable {
  background: #c23b3b;
}

.mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  margin-top: 12px;
  font-size: 14px;
}

.mix-legend > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.mix-legend em {
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
}

.mix-swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex: 0 0 auto;
}

.mix-swatch-fixed {
  background: #7a4e3a;
}

.mix-swatch-variable {
  background: #c23b3b;
}

.mix-bar-paycheck {
  background: #15803d;
}

.mix-bar-other {
  background: #c4a35a;
}

.mix-swatch-paycheck {
  background: #15803d;
}

.mix-swatch-other {
  background: #c4a35a;
}

.ytd-pie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 24px;
  margin-top: 18px;
}

.ytd-pie-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.ytd-pie-grid .chart-frame-pie {
  height: 240px;
  max-width: 420px;
}

.member-expense-section {
  margin-top: 22px;
}

.asset-finance-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.asset-finance-summary {
  margin-top: 12px;
}

.rental-ytd {
  margin: 8px 0 6px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--section-line);
}

.rental-ytd .import-result-title {
  margin-top: 0;
}

.rental-detail {
  margin-top: 8px;
}

.asset-detail-panel {
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.asset-list-row-active td {
  background: var(--accent-soft);
}

.asset-type-group-row td {
  background: #e8eef2;
  color: #1f4a5c;
}

.asset-type-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.asset-type-group-label {
  font-weight: 700;
}

.asset-type-group-count {
  font-weight: 600;
  color: var(--muted);
}

.member-asset-group {
  margin-top: 14px;
}

.member-asset-group:first-child {
  margin-top: 0;
}

.member-asset-group-title {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.insights-overview .insights-section {
  margin-top: 28px;
}

.insights-overview .insights-section:first-child {
  margin-top: 12px;
}

.matrix-wrap {
  overflow-x: auto;
}

.category-month-matrix {
  min-width: 480px;
  border-collapse: collapse;
}

.category-month-matrix th,
.category-month-matrix td {
  white-space: nowrap;
  text-align: right;
  padding: 8px 8px;
}

.category-month-matrix thead th:not(.matrix-sticky):not(:last-child) {
  min-width: 2.5rem;
  padding-left: 6px;
  padding-right: 6px;
}

.category-month-matrix th.matrix-sticky,
.category-month-matrix td.matrix-sticky,
.category-month-matrix th[scope="row"] {
  text-align: left;
}

.category-month-matrix .matrix-sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel, #fff);
  box-shadow: 1px 0 0 var(--border);
}

.category-month-matrix thead .matrix-sticky {
  z-index: 2;
}

.category-month-matrix .matrix-empty {
  color: var(--muted);
}

.category-month-matrix .matrix-total-row th,
.category-month-matrix .matrix-total-row td {
  font-weight: 700;
  border-top: 1px solid var(--border);
}

.category-month-matrix .matrix-income-parent th,
.category-month-matrix .matrix-income-parent td {
  font-weight: 700;
  background: #eef6ef;
  border-top: 1px solid #c9e0cc;
}

.category-month-matrix .matrix-income-parent .matrix-sticky {
  background: #eef6ef;
}

.category-month-matrix .matrix-income-child th,
.category-month-matrix .matrix-income-child td {
  background: #f6faf6;
}

.category-month-matrix .matrix-income-child .matrix-sticky {
  padding-left: 22px;
  color: var(--muted);
  background: #f6faf6;
}

.category-month-matrix .matrix-income-child:last-of-type th,
.category-month-matrix .matrix-income-child:last-of-type td {
  border-bottom: 1px solid #c9e0cc;
}

.category-month-matrix .matrix-expense-parent th,
.category-month-matrix .matrix-expense-parent td {
  font-weight: 700;
  background: #fff3f1;
  border-top: 1px solid #efc5bf;
}

.category-month-matrix .matrix-expense-parent .matrix-sticky {
  background: #fff3f1;
}

.category-month-matrix .matrix-expense-child th,
.category-month-matrix .matrix-expense-child td {
  background: #fffaf9;
}

.category-month-matrix .matrix-expense-child .matrix-sticky {
  padding-left: 22px;
  color: var(--muted);
  background: #fffaf9;
}

.category-month-matrix .matrix-expense-grandchild th,
.category-month-matrix .matrix-expense-grandchild td {
  background: #fffdfc;
}

.category-month-matrix .matrix-expense-grandchild .matrix-sticky {
  padding-left: 36px;
  color: var(--muted);
  font-weight: 500;
  background: #fffdfc;
}

.category-month-matrix .matrix-expense-child:last-of-type th,
.category-month-matrix .matrix-expense-child:last-of-type td {
  border-bottom: 1px solid #efc5bf;
}

.content-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
}

.content-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}

.content-tab.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 2px rgba(30, 45, 40, 0.08);
}

.content-tab-family {
  color: var(--accent);
  background: var(--accent-soft);
}

.content-tab-family:hover {
  color: var(--accent);
  background: #dceee5;
}

.content-tab-family.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(31, 106, 79, 0.28);
}

.content-tab-panel.hidden {
  display: none;
}

.content-tab-panel.active {
  display: block;
}

.btn-linkish-name {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.btn-linkish-name:hover {
  color: var(--accent);
}

/* Utility must win over component display rules defined later in this file. */
.hidden {
  display: none !important;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  background: #fafbfc;
  margin-bottom: 16px;
}

.import-format-hint {
  max-width: 34em;
  margin: 8px auto 0;
  line-height: 1.45;
}

#importSetupFilters {
  margin-bottom: 8px;
}

#importParsedActions,
#importSaveActions {
  margin-top: 14px;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-label {
  display: inline-block;
  margin-top: 6px;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.upload-label input {
  display: none;
}

.statement-summary {
  display: grid;
  gap: 12px;
  margin: 0;
}

.import-result-section {
  margin: 24px 0 28px;
}

.import-result-title {
  margin: 0 0 12px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 560;
}

.section-title-with-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.statement-summary-wrap {
  border-radius: 10px;
}

.statement-summary-table {
  min-width: 560px;
}

.statement-summary-table th {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.statement-summary-table td {
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.summary-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}

.summary-item h3 {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.summary-item p {
  margin: 8px 0 0;
  font-size: 24px;
  font-weight: 700;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 4px;
}

.auth-menu {
  position: relative;
}

.auth-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.auth-menu-btn:hover .auth-user,
.auth-menu-btn:focus-visible .auth-user {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-user {
  font-size: 14px;
  color: var(--accent);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  line-height: 1.35;
}

.auth-menu-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--accent);
  opacity: 0.7;
}

.account-profile {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 20px;
  margin: 0 0 8px;
}

.account-profile div {
  min-width: 0;
}

.account-profile dt {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.account-profile dd {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.account-billing-summary {
  margin-bottom: 12px;
}

.account-billing-summary p {
  margin: 0 0 8px;
}

.account-history-title {
  margin: 28px 0 10px;
  font-size: 16px;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(120, 170, 140, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(70, 110, 130, 0.22), transparent 50%),
    linear-gradient(160deg, #e8efe9 0%, #d5e0e4 48%, #c9d4d0 100%);
}

.login-gate.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  margin-top: 80px;
  padding: 36px 32px 28px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(40, 60, 50, 0.12);
  box-shadow: 0 18px 40px rgba(30, 45, 40, 0.12);
  text-align: center;
}

.login-card .brand-mark {
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
}

.login-card .brand-title {
  margin: 0 0 8px;
  font-family: "Fraunces", serif;
  font-size: 32px;
  font-weight: 700;
}

.login-card .brand-tagline {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.google-signin-host {
  display: flex;
  justify-content: center;
  margin: 18px 0 12px;
  min-height: 44px;
}

/* Landing page (within login-gate) */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(40, 60, 50, 0.08);
  z-index: 100;
}
.landing-nav-link {
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}
.landing-nav-link:hover {
  color: var(--accent);
}
.landing-nav-login {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  padding: 6px 18px;
  border-radius: 6px;
  font-weight: 600;
}
.landing-nav-login:hover {
  background: #1b4332;
  color: #fff;
}

.landing-section {
  width: min(900px, 100%);
  margin-top: 60px;
  text-align: center;
}
.landing-heading {
  font-family: "Fraunces", serif;
  font-size: 1.8rem;
  margin-bottom: 28px;
  color: var(--text);
}
.landing-subtitle {
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 1rem;
}
.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  text-align: left;
}
.landing-card {
  background: rgba(255, 255, 255, 0.75);
  padding: 22px;
  border-radius: 12px;
  border: 1px solid rgba(40, 60, 50, 0.08);
}
.landing-card h3 {
  font-size: 0.95rem;
  margin: 0 0 6px;
  color: var(--accent);
}
.landing-card p {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.landing-price-card {
  display: inline-block;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 32px 44px;
  text-align: center;
}
.landing-price-amount {
  font-family: "Fraunces", serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent);
}
.landing-price-period {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.landing-price-list {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 0;
}
.landing-price-list li {
  padding: 5px 0;
  font-size: 0.9rem;
  color: var(--text);
}
.landing-price-list li::before {
  content: "✓ ";
  color: var(--accent);
  font-weight: 700;
}

.landing-footer {
  width: 100%;
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid rgba(40, 60, 50, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  font-size: 0.85rem;
}
.landing-footer a {
  color: var(--muted);
  text-decoration: none;
}
.landing-footer a:hover {
  color: var(--accent);
}
.landing-footer-copy {
  color: var(--muted);
}

.household-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--section-line);
}

.invite-token-box {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(40, 60, 50, 0.06);
  font-size: 12px;
  word-break: break-all;
  text-align: left;
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 14px;
}

.detail-list > div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.household-section:first-of-type {
  margin-top: 12px;
  padding-top: 0;
  border-top: 0;
}

.household-inline-form {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--section-line);
}

.household-section h3 {
  margin: 0 0 10px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 560;
}

.row-actions {
  white-space: nowrap;
  display: flex;
  gap: 8px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 28, 36, 0.45);
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}

.modal-card-wide {
  width: min(720px, 100%);
}

.modal-card h3 {
  margin: 0 0 6px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 560;
}

.modal-card label {
  margin-top: 12px;
}

.app-dialog-card {
  width: min(440px, 100%);
}

.app-dialog-message {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

.app-dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.app-dialog-danger .app-dialog-card {
  border-color: #f0d0d0;
}

.app-dialog-danger #appDialogTitle {
  color: var(--expense);
}

.ask-transcript {
  margin-top: 12px;
  max-height: min(420px, 50vh);
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8faf9;
}

.ask-bubble {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
}

.ask-bubble strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.ask-bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.ask-bubble-user {
  background: #eef6f2;
}

.ask-bubble-assistant {
  background: #fff;
}

.file-summary {
  display: inline-block;
  max-width: 280px;
  line-height: 1.35;
}

.insights-overview-title {
  margin: 0 0 4px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 560;
}

.insights-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--section-line);
}

.insights-section:first-of-type {
  border-top: 0;
  padding-top: 8px;
}

.insights-section h4 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.insights-section h5 {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.insights-section-lead {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
  max-width: 52rem;
}

.insights-ytd-categories {
  margin-top: 12px;
}

.insights-ytd-categories > h5 {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.expense-class-group {
  margin-top: 16px;
}

.expense-class-group h5 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}

.expense-class-hint {
  margin: 0 0 8px;
}

.monthly-breakdown-list {
  margin-top: 20px;
  display: grid;
  gap: 18px;
}

.monthly-breakdown-card {
  padding: 14px 0 4px;
  border-top: 1px solid var(--border);
}

.monthly-breakdown-header h4 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.monthly-breakdown-header .muted-note {
  margin: 0 0 8px;
}

.expense-breakdown-table thead th {
  vertical-align: bottom;
}

.expense-stack-cell {
  min-width: 160px;
  padding: 6px 8px !important;
}

.expense-cell {
  display: grid;
  gap: 6px;
}

.expense-cell-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f4f7f5;
  font-size: 12px;
  color: var(--muted);
}

.expense-cell-total strong {
  font-size: 15px;
}

.expense-cell-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.expense-subcell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.expense-subcell + .expense-subcell {
  border-left: 1px solid var(--border);
  border-top: none;
}

.expense-subcell strong {
  font-size: 14px;
  font-weight: 600;
}

.summary-item-expense .expense-cell {
  margin-top: 8px;
}

.summary-item-expense .expense-cell-total strong {
  font-size: 22px;
}

.summary-item-expense .expense-subcell strong {
  font-size: 16px;
}

.expense-tree {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.expense-tree-source {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.expense-tree-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
  background: #fffaf9;
}

.expense-tree-row strong {
  font-size: 16px;
}

.expense-tree-subs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
}

.expense-tree-subs .expense-subcell {
  padding-left: 18px;
}

.muted-note {
  color: var(--muted);
  font-size: 14px;
}

.opp-stat em,
.opp-scenario-save em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.amount-income {
  color: #1a7a4c;
}

.amount-expense {
  color: #b42318;
}

.opportunity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.opportunity-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
}

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

.opp-category {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.opp-header h4 {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 650;
}

.opp-confidence {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}

.opp-rationale {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.opportunity-card h5 {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.opp-stat {
  margin: 0;
  padding: 8px 10px;
  background: #f7f8f9;
  border-radius: 8px;
  font-size: 13px;
}

.opp-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.opp-stat strong {
  font-size: 15px;
}

.opp-monthly-table {
  max-height: 180px;
  overflow: auto;
}

.health-section .opp-monthly-table {
  max-height: none;
}

.health-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 14px 0 4px;
}

.health-verdict {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f7f8f9;
}

.health-verdict p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.health-verdict-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.health-verdict-stable {
  background: #eef6f1;
  border-color: #c5ddd0;
}

.health-verdict-ok {
  background: #f7f4ec;
  border-color: #e2d7b8;
}

.health-verdict-watch {
  background: #f8f1ea;
  border-color: #e4d0bc;
}

.health-verdict-risk {
  background: #f8eeee;
  border-color: #e3c8c6;
}

.health-rule-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 52rem;
}

.health-bucket-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-width: 420px;
}

.health-bucket-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.health-details {
  margin-top: 14px;
}

.health-details summary {
  cursor: pointer;
  width: fit-content;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
  list-style: none;
}

.health-details summary::-webkit-details-marker {
  display: none;
}

.health-details summary::before {
  content: "▸ ";
}

.health-details[open] summary::before {
  content: "▾ ";
}

.health-details-body {
  margin-top: 12px;
}

.opp-top-save {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: #1a7a4c;
}

.rule-compare-table {
  min-width: 720px;
}

.rule-compare-table thead th {
  text-align: center;
}

.rule-compare-table thead .matrix-sticky {
  text-align: left;
}

.rule-compare-table thead tr:first-child th[colspan] {
  border-bottom: 0;
  padding-bottom: 2px;
}

.rule-compare-table thead tr:last-child th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rule-compare-table .rule-ok {
  color: #1a7a4c;
  font-weight: 650;
}

.rule-compare-table .rule-miss {
  color: #b42318;
  font-weight: 650;
}

.opp-scenarios {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.opp-scenarios li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}

.opp-scenario-label {
  font-size: 14px;
  font-weight: 600;
}

.opp-scenario-save {
  font-size: 13px;
  color: #1a7a4c;
  font-weight: 600;
}

.summary-item ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.filters {
  margin: 14px 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.expense-class-overview {
  margin: 8px 0 6px;
  padding: 8px 0 18px;
  border-top: 0;
  border-bottom: 1px solid var(--section-line);
}

.expense-class-overview .import-result-title {
  margin-top: 0;
}

.expense-class-overview .import-result-title + .import-result-title,
.expense-class-overview .expense-source-grid + .import-result-title,
.expense-class-overview .expense-tree + .import-result-title {
  margin-top: 22px;
}

.expense-mix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 24px;
  margin: 8px 0 4px;
}

.expense-mix-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.expense-mix-track .mix-snapshot,
.expense-mix-track .chart-frame,
.expense-class-overview .chart-frame {
  max-width: none;
}

.expense-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}

.expense-source-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  display: grid;
  gap: 4px;
}

.expense-source-card span,
.expense-source-card em {
  font-size: 12px;
  color: var(--muted);
  font-style: normal;
}

.expense-source-card strong {
  font-size: 20px;
  font-weight: 700;
}

.expense-source-card-total {
  background: #fff3f1;
  border-color: #efc5bf;
}

.household-overview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.household-overview-bar .status-text {
  margin: 0;
  flex: 1 1 auto;
}

.household-overview-bar button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.account-browse-filters label {
  min-width: 160px;
  flex: 1 1 160px;
}

.account-browse-filters select {
  width: 100%;
}

.account-summary-wrap {
  margin: 14px 0 18px;
}

.account-summary-table {
  width: auto;
  min-width: 100%;
}

.account-summary-table th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.account-summary-table td {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  padding-top: 10px;
}

.account-txn-table {
  table-layout: fixed;
  width: 100%;
}

.account-txn-table th:nth-child(1),
.account-txn-table td:nth-child(1) {
  width: 7.5rem;
}

.account-txn-table th:nth-child(2),
.account-txn-table td:nth-child(2) {
  width: 8rem;
}

.account-txn-table th:nth-child(3),
.account-txn-table td:nth-child(3) {
  width: 7.5rem;
}

.account-txn-table th:nth-child(4),
.account-txn-table td:nth-child(4) {
  width: 11rem;
}

.account-txn-table input[type="date"],
.account-txn-table input[type="number"],
.account-txn-table select,
.account-txn-table textarea {
  width: 100%;
  max-width: 100%;
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
}

.account-txn-table textarea {
  min-height: 48px;
  resize: vertical;
}

.account-txn-table th:nth-child(5),
.account-txn-table td.account-txn-desc {
  width: auto;
  max-width: 14rem;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  font-size: 13px;
  color: var(--muted);
}

.account-txn-tabs {
  margin: 8px 0 14px;
}

.tab-total {
  margin: 12px 0 0;
  font-weight: 700;
}

label {
  display: grid;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 12px;
  font-weight: 500;
  cursor: pointer;
}

/* Keep Account / Account type / Upload only on one line, baseline-aligned. */
.filters-row {
  align-items: end;
}

.filters-row .checkbox-label {
  margin: 0 0 9px;
  align-items: center;
  white-space: nowrap;
}

.filters-row .form-actions {
  margin: 0 0 9px;
}

.insights-monthly-filters {
  align-items: center;
  flex-wrap: nowrap;
}

.insights-monthly-filters .inline-filter {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.insights-monthly-filters .inline-filter select {
  min-width: 110px;
}

.insights-monthly-filters #insightsMonthlyDetailBtn {
  flex-shrink: 0;
}

.import-upload-only-fields {
  flex-direction: column;
  align-items: stretch;
  max-width: 560px;
}

.import-upload-only-fields .import-upload-description {
  width: 100%;
}

.import-upload-only-fields textarea {
  min-height: 96px;
  width: 100%;
  resize: vertical;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.checkbox-label span {
  line-height: 1.4;
}

.field-with-info {
  display: grid;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  position: relative;
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
}

.info-icon-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.info-icon-btn:hover,
.info-icon-btn[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.info-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: min(320px, 80vw);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}

.info-popover p {
  margin: 0 0 8px;
  line-height: 1.4;
}

.info-popover p:last-child {
  margin-bottom: 0;
}

input,
textarea,
select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
}

td textarea[data-role="description-input"],
td textarea[data-role="parsed-description-input"] {
  width: 100%;
  min-height: 64px;
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

.parsed-amount-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.parsed-amount-sign {
  font-weight: 700;
  min-width: 0.75em;
}

td input[data-role="parsed-amount-input"] {
  width: 110px;
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

td input.input-invalid,
td textarea.input-invalid {
  border-color: #b91c1c;
  background: #fff5f5;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

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

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  background: #f7f8fa;
}

#parsedItemsFoot th,
#parsedItemsFoot td {
  border-bottom: 0;
  background: #f7f8fa;
  font-weight: 700;
}

.category-group-row td {
  background: #eef2f0;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.category-group-income td {
  background: var(--accent-soft);
  color: var(--income);
}

.category-group-expense td {
  background: #fdecea;
  color: var(--expense);
}

.category-group-movement td {
  background: #e8f0f4;
  color: #0f5f7a;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.form-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: #f3f5f7;
}

.table-inline-select {
  max-width: 120px;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.btn-linkish {
  background: transparent;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
}

.btn-linkish:hover {
  text-decoration: underline;
}

.status-text {
  margin: 10px 0 0;
  color: var(--muted);
}

.status-text.status-success {
  color: #0f766e;
  font-weight: 600;
}

.amount-income {
  color: var(--income);
  font-weight: 700;
}

.amount-expense {
  color: var(--expense);
  font-weight: 700;
}

.amount-credit {
  color: #0f766e;
  font-weight: 700;
}

.row-payment-credit td {
  background: #eef8f5;
}

.row-payment-credit:hover td {
  background: #e3f3ee;
}

.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f3f4f6;
  color: #4b5563;
  text-transform: lowercase;
}

.type-pill-income {
  background: var(--accent-soft);
  color: var(--income);
}

.type-pill-expense {
  background: #fdecea;
  color: var(--expense);
}

.type-pill-credit {
  background: #d1fae5;
  color: #065f46;
}

#parsedItemsWrap select[data-role="parsed-member-select"],
#parsedItemsWrap select[data-role="parsed-asset-select"],
#parsedItemsWrap select[data-role="parsed-category-select"] {
  min-width: 120px;
  max-width: 180px;
}

.btn-danger {
  background: #b91c1c;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger-panel {
  border: 1px solid #f1d5d5;
  background: #fff7f7;
  border-radius: 12px;
  padding: 16px 18px;
  max-width: 640px;
}

.reset-panels {
  display: grid;
  gap: 14px;
  max-width: 640px;
}

.reset-panels .danger-panel {
  max-width: none;
}

.danger-panel h3 {
  margin: 0 0 8px;
  color: #991b1b;
  font-family: "Fraunces", serif;
}

.danger-panel p {
  margin: 0 0 10px;
  color: #4b5563;
  line-height: 1.45;
}

.danger-emphasis {
  color: #991b1b !important;
  font-weight: 600;
}

.danger-panel label {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  font-size: 14px;
}

.danger-panel input {
  max-width: 280px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    max-height: 42vh;
    overflow: hidden;
  }

  .workspace {
    padding: 16px;
  }

  .workspace-title {
    font-size: 28px;
  }
}
