:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #d8e0e5;
  --text: #172026;
  --muted: #65727c;
  --accent: #1b6b75;
  --accent-2: #8f5a2a;
  --danger: #b33939;
  --income: #0f7b55;
  --expense: #a34833;
  --summary: #203b5c;
  --nav: #23323a;
  --nav-active: #1b6b75;
  --sidebar-bg: #18282a;
  --sidebar-text: #ffffff;
  --sidebar-muted: #8da3a6;
  --sidebar-link: #dce8e8;
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --brand-mark-bg: #f4c35a;
  --brand-mark-text: #172527;
  --shadow: 0 1px 2px rgba(20, 35, 45, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body[data-theme="light"] {
  --bg: #fbfcfc;
  --surface: #ffffff;
  --line: #e2e8e7;
  --text: #20282b;
  --muted: #6f7b7d;
  --accent: #287c74;
  --accent-2: #7d6630;
  --nav: #f5f8f7;
  --sidebar-bg: #f5f8f7;
  --sidebar-text: #1d2b2d;
  --sidebar-muted: #6b8082;
  --sidebar-link: #263739;
  --sidebar-active: rgba(31, 122, 112, 0.1);
  --brand-mark-bg: #ffe08c;
  --brand-mark-text: #203133;
}

body[data-theme="warm"] {
  --bg: #fbf8f1;
  --surface: #ffffff;
  --line: #e4dbcd;
  --text: #2a2520;
  --muted: #776d62;
  --accent: #8a6f38;
  --accent-2: #2f7a70;
  --sidebar-bg: #2d2a24;
  --sidebar-muted: #b7aa94;
  --sidebar-link: #efe8db;
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --brand-mark-bg: #f1c66b;
  --brand-mark-text: #2b241b;
}

body[data-theme="deep"] {
  --bg: #edf1f4;
  --surface: #ffffff;
  --line: #c8d5db;
  --text: #18222a;
  --muted: #5c6a72;
  --accent: #0b6f86;
  --accent-2: #7552b6;
  --sidebar-bg: #071a24;
  --sidebar-text: #f5fbff;
  --sidebar-muted: #87aabd;
  --sidebar-link: #d8edf6;
  --sidebar-active: rgba(81, 177, 205, 0.18);
  --brand-mark-bg: #68d5e5;
  --brand-mark-text: #061820;
}

body[data-theme="mint"] {
  --bg: #effcf6;
  --surface: #ffffff;
  --line: #bfe7d7;
  --text: #17332b;
  --muted: #557268;
  --accent: #008f72;
  --accent-2: #86642b;
  --sidebar-bg: #00443a;
  --sidebar-text: #f4fffb;
  --sidebar-muted: #9ddac9;
  --sidebar-link: #dcfff4;
  --sidebar-active: rgba(170, 255, 224, 0.18);
  --brand-mark-bg: #9bffd5;
  --brand-mark-text: #00352d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

body.auth-loading .layout,
body.auth-required .layout,
body.public-mode .layout {
  display: none;
}

body.auth-loading .landing-view,
body.auth-required .landing-view {
  display: none;
}

.landing-view {
  min-height: 100vh;
  background: #f7f7f3;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.landing-brand p,
.landing-brand strong {
  display: block;
  margin: 0;
}

.landing-brand p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.landing-brand strong {
  font-size: 20px;
}

.landing-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f4c35a;
  color: #172026;
  font-size: 22px;
  font-weight: 800;
}

.landing-actions,
.landing-cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.landing-seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 18px;
}

.landing-seo-links a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.landing-seo-links a:hover {
  text-decoration: underline;
}

.landing-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 36px;
  align-items: center;
  width: min(1120px, calc(100% - 32px));
  min-height: calc(100vh - 92px);
  margin: 0 auto;
  padding: 28px 0 70px;
}

.landing-copy h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.12;
  letter-spacing: 0;
}

.landing-copy p:not(.auth-eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.landing-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(32, 44, 40, 0.08);
}

.preview-bar {
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--accent), #f4c35a);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1.1fr repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  padding: 1px;
}

.preview-grid span,
.preview-grid strong,
.preview-grid em {
  min-height: 44px;
  padding: 12px;
  background: #fbfcfd;
  font-style: normal;
}

.preview-grid span {
  color: var(--accent);
  font-weight: 800;
  text-align: right;
}

.preview-grid em::before {
  content: "";
  display: block;
  width: 70%;
  height: 12px;
  margin-left: auto;
  border-radius: 999px;
  background: #dbe8e7;
}

.preview-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 150px;
  padding: 24px;
  background: #fbfcfd;
}

.preview-chart i {
  flex: 1;
  min-height: 28px;
  border-radius: 6px 6px 0 0;
  background: var(--accent);
}

.preview-chart i:nth-child(1) { height: 42%; }
.preview-chart i:nth-child(2) { height: 58%; }
.preview-chart i:nth-child(3) { height: 72%; }
.preview-chart i:nth-child(4) { height: 86%; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: #f7f7f3;
}

.auth-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  background: #fff;
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 18px 50px rgba(32, 44, 40, 0.08);
}

.auth-panel h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.auth-eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 20px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

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

.auth-form.hidden {
  display: none;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 700;
}

.auth-form label span {
  font-size: 13px;
  color: var(--muted);
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fbfdfc;
}

.auth-form input:focus {
  outline: 3px solid rgba(27, 107, 117, 0.16);
  border-color: var(--accent);
  background: #fff;
}

.auth-back-button {
  color: var(--accent);
  margin-bottom: 18px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  display: grid;
  place-items: center;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--accent);
  background: rgba(27, 107, 117, 0.08);
}

.eye-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50% / 65%;
  transform: translate(-50%, -50%);
}

.eye-icon::before {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.password-toggle[aria-pressed="true"] .eye-icon::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  left: -5px;
  top: 5px;
  transform: rotate(-35deg);
}

.auth-form .primary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  justify-content: center;
}

.auth-link-button {
  color: var(--accent);
  justify-self: center;
  text-align: center;
}

.auth-message {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.resend-form {
  margin-top: 24px;
}

.resend-form .ghost-button {
  width: 100%;
  justify-content: center;
  min-height: 42px;
  background: #fff;
  color: var(--accent);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.compact-button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

button:hover {
  filter: brightness(0.96);
}

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

.content {
  min-width: 0;
  padding: 34px;
  overflow-x: hidden;
}

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

.app-header h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header p,
.details-section p,
.section-heading p,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
}

.header-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-metrics span {
  border: 1px solid var(--line);
  padding: 6px 9px;
  border-radius: 6px;
  background: #fbfcfd;
}

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

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 28px 22px;
  border-right: 1px solid rgba(0, 0, 0, 0.12);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--brand-mark-bg);
  color: var(--brand-mark-text);
  font-size: 24px;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand-kicker {
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.storage-note {
  padding: 14px;
  border: 1px solid var(--sidebar-active);
  border-radius: 8px;
  color: var(--sidebar-link);
}

.storage-note span,
.storage-note strong,
.storage-note small {
  display: block;
}

.storage-note span {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.storage-note small {
  margin-top: 6px;
  color: var(--sidebar-muted);
  line-height: 1.4;
  word-break: break-all;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.auth-card .auth-back-button,
.auth-card .auth-link-button {
  color: var(--accent);
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-item,
.master-item {
  width: 100%;
  text-align: left;
  color: inherit;
  background: transparent;
  border-color: transparent;
}

.nav-item {
  min-height: 44px;
  padding: 13px 14px;
  border-radius: 8px;
  color: var(--sidebar-link);
}

.nav-item:hover,
.nav-item.active {
  background: var(--sidebar-active);
  border-color: var(--sidebar-active);
  color: var(--sidebar-text);
}

.master-subnav {
  display: grid;
  gap: 6px;
  margin-top: -4px;
  padding-left: 14px;
  border-left: 0;
}

.master-subitem {
  width: 100%;
  min-height: 34px;
  text-align: left;
  color: var(--sidebar-link);
  background: transparent;
  border-color: transparent;
  border-radius: 8px;
  padding: 8px 10px;
}

.master-subitem:hover,
.master-subitem.active {
  background: var(--sidebar-active);
  border-color: var(--sidebar-active);
  color: var(--sidebar-text);
}

.nav-status {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: var(--sidebar-muted);
}

.nav-status button {
  background: #fff;
  color: var(--text);
  border-color: #fff;
}

.workspace {
  display: grid;
  gap: 12px;
  overflow: visible;
  max-height: none;
  padding: 0;
}

.view-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.section-heading.inline {
  padding: 10px 10px 0;
}

h2,
h3 {
  margin: 0 0 10px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.panel-section,
.chart-block,
.details-section,
.table-section,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-section {
  padding: 12px;
  min-width: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.metric-card {
  padding: 12px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-card strong {
  display: block;
  font-size: 18px;
  white-space: nowrap;
}

.chart-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.chart-block {
  padding: 10px;
  min-width: 0;
}

.chart-block svg {
  width: 100%;
  height: 180px;
  display: block;
}

.toolbar {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

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

.tabs button {
  white-space: nowrap;
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tabs button:disabled {
  opacity: 0.45;
  cursor: default;
}

.guide-panel {
  display: grid;
  gap: 18px;
  line-height: 1.75;
}

.guide-panel p,
.guide-panel ol,
.guide-panel dl {
  margin-top: 0;
  color: var(--muted);
}

.guide-intro {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.guide-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guide-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  background: #fbfcfd;
  font-weight: 700;
  text-decoration: none;
}

.guide-nav a:hover {
  border-color: var(--accent);
}

.guide-section {
  padding-top: 4px;
}

.guide-section + .guide-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

.guide-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.guide-block h4,
.guide-faq dt {
  margin: 0 0 6px;
  color: var(--text);
}

.guide-faq {
  display: grid;
  gap: 8px;
}

.guide-faq dd {
  margin: 0 0 8px;
}

.info-tabs {
  padding-bottom: 2px;
}

.info-panel {
  line-height: 1.75;
}

.info-panel p {
  color: var(--muted);
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table th,
.info-table td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.info-table th {
  width: 170px;
  background: #eef5f6;
}

.settings-panel {
  max-width: 720px;
}

.settings-checkbox {
  justify-content: flex-start;
  gap: 10px;
}

.billing-panel {
  display: grid;
  gap: 16px;
}

.billing-notice {
  padding: 10px 12px;
  border: 1px solid #f0d28a;
  border-radius: 6px;
  background: #fff8e5;
  color: #73540f;
  font-size: 13px;
}

.limit-notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #f0d28a;
  border-radius: 6px;
  background: #fff8e5;
  color: #73540f;
  font-size: 13px;
}

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

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

.billing-plan-card {
  display: grid;
  gap: 12px;
  align-content: space-between;
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.billing-plan-card.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.billing-plan-card h4 {
  margin: 4px 0 8px;
}

.billing-plan-card p {
  margin: 0;
  color: var(--muted);
}

.billing-plan-spec {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
}

.billing-plan-spec div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.billing-plan-spec dt {
  color: var(--muted);
}

.billing-plan-spec dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.billing-plan-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.billing-plan-actions button {
  min-width: 0;
}

.billing-plan-note {
  font-size: 12px;
}

.billing-subscription-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.billing-subscription-card.scheduled {
  border-color: #f0d28a;
  background: #fffaf0;
}

.billing-subscription-card strong,
.billing-subscription-card p {
  display: block;
  margin: 0;
}

.billing-subscription-card p {
  margin-top: 4px;
  color: var(--muted);
}

.billing-subscription-card button {
  flex: 0 0 auto;
}

.window-label {
  align-self: center;
  min-width: 120px;
  text-align: center;
  color: var(--summary);
  font-weight: 700;
}

.small-tabs {
  margin-bottom: 10px;
}

.cashflow-mobile-panel {
  display: grid;
  gap: 10px;
}

.cashflow-single-panel.hidden,
.cashflow-multi-panel.hidden {
  display: none;
}

.cashflow-mobile-years {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cashflow-mobile-years button {
  flex: 0 0 72px;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: center;
}

.cashflow-mobile-years button.active {
  border-color: var(--accent);
  background: #eaf6f7;
  color: var(--accent);
  font-weight: 700;
}

.cashflow-mobile-years span,
.cashflow-mobile-years small {
  display: block;
}

.cashflow-mobile-years small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.cashflow-mobile-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.cashflow-mobile-selected strong,
.cashflow-mobile-selected span {
  display: block;
}

.cashflow-mobile-selected span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.cashflow-mobile-selected button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 10px;
}

.cashflow-mobile-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
}

.cashflow-mobile-summary button,
.cashflow-mobile-categories button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.cashflow-mobile-summary button {
  min-height: 68px;
  padding: 9px;
}

.cashflow-mobile-summary span,
.cashflow-mobile-summary strong {
  display: block;
}

.cashflow-mobile-summary span {
  color: var(--muted);
  font-size: 12px;
}

.cashflow-mobile-summary strong {
  margin-top: 5px;
  font-size: 15px;
}

.cashflow-mobile-summary .income strong,
.cashflow-mobile-categories .income small {
  color: var(--income);
}

.cashflow-mobile-summary .expense strong,
.cashflow-mobile-categories .expense small {
  color: var(--expense);
}

.cashflow-mobile-summary .negative strong {
  color: var(--danger);
}

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

.cashflow-mobile-categories h3 {
  margin: 4px 0 0;
  font-size: 14px;
}

.cashflow-mobile-categories button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
}

.cashflow-mobile-categories span,
.cashflow-mobile-categories small,
.cashflow-mobile-categories strong {
  display: block;
}

.cashflow-mobile-categories small {
  font-size: 11px;
}

.cashflow-mobile-categories strong {
  margin-top: 2px;
  font-size: 13px;
}

.cashflow-mobile-categories b {
  flex: 0 0 auto;
  font-size: 13px;
  text-align: right;
}

.cashflow-mobile-categories .expense b,
.cashflow-mobile-categories button.expense b {
  color: var(--expense);
}

.cashflow-mobile-categories .empty-note {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
}

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

.finance-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
}

#yearTable {
  table-layout: fixed;
  min-width: 1235px;
}

#yearTable col.item-col {
  width: 115px;
}

#yearTable col.year-col {
  width: 112px;
}

.finance-table th,
.finance-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: right;
  white-space: nowrap;
}

.finance-table th:first-child,
.finance-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  min-width: 190px;
  background: #f9fbfc;
  font-weight: 600;
}

.finance-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf4f6;
}

.finance-table thead th:first-child {
  z-index: 3;
}

#yearTable th:first-child,
#yearTable td:first-child {
  min-width: 115px;
}

.simple-table {
  min-width: 720px;
}

.simple-table th:first-child,
.simple-table td:first-child {
  min-width: 120px;
}

.simple-table th.checkbox-cell,
.simple-table td.checkbox-cell {
  min-width: 34px;
}

#eventTable {
  table-layout: fixed;
  min-width: 760px;
}

#eventTable col.event-year-col {
  width: 78px;
}

#eventTable col.event-target-col {
  width: 120px;
}

#eventTable col.event-age-col {
  width: 64px;
}

#eventTable col.event-title-col {
  width: 190px;
}

#eventTable col.event-amount-col {
  width: 120px;
}

#eventTable th:first-child,
#eventTable td:first-child {
  position: static;
  min-width: 0;
  width: auto;
}

#eventTable th,
#eventTable td {
  overflow: hidden;
  text-overflow: ellipsis;
}

#eventTable th:nth-child(1),
#eventTable td:nth-child(1),
#eventTable th:nth-child(3),
#eventTable td:nth-child(3),
#eventTable th:nth-child(5),
#eventTable td:nth-child(5) {
  text-align: right;
}

#eventTable th:nth-child(2),
#eventTable td:nth-child(2),
#eventTable th:nth-child(4),
#eventTable td:nth-child(4),
#eventTable th:nth-child(6),
#eventTable td:nth-child(6) {
  text-align: left;
}

#eventTable th:nth-child(6),
#eventTable td:nth-child(6) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.year-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 700;
}

.amount-link {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: inherit;
  text-align: right;
  cursor: pointer;
}

.amount-link:hover,
.amount-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.member-name-cell {
  vertical-align: middle;
  padding-left: 18px;
}

.member-event-text {
  margin-top: 3px;
  color: var(--accent-2);
  font-size: 0.86rem;
  line-height: 1.35;
  white-space: normal;
}

.sub-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
}

.compact-heading {
  align-items: center;
  padding-bottom: 8px;
}

.compact-heading h4 {
  margin: 0;
}

.sub-heading h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.sub-heading p {
  margin: 0;
  color: var(--muted);
}

.drilldown-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 12px;
}

.drilldown-grid.single {
  grid-template-columns: 1fr;
}

.cashflow-drilldown-mobile-list {
  display: none;
}

.cashflow-drilldown-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.cashflow-drilldown-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfc;
}

.cashflow-drilldown-card-head span {
  color: var(--summary);
  font-weight: 700;
}

.cashflow-drilldown-card-head strong {
  text-align: right;
}

.cashflow-drilldown-card dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.cashflow-drilldown-card dl div {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #eef3f5;
}

.cashflow-drilldown-card dl div:first-child {
  border-top: 0;
}

.cashflow-drilldown-card dt {
  color: var(--muted);
  font-size: 12px;
}

.cashflow-drilldown-card dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.cashflow-drilldown-card .cashflow-bonus-line {
  display: block;
}

@media (max-width: 1100px) {
  .drilldown-grid {
    grid-template-columns: 1fr;
  }
}

.row-income td:first-child {
  color: var(--income);
}

.row-expense td:first-child {
  color: var(--expense);
}

.row-summary td:first-child,
.row-summary td {
  font-weight: 700;
}

.row-event td {
  color: var(--accent-2);
  white-space: normal;
}

.row-age td {
  background: #fbfcfd;
  color: var(--muted);
}

.row-age td:first-child {
  color: var(--summary);
}

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

.cashflow-bonus-line {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.details-section {
  padding: 12px;
}

.compact {
  margin-top: 10px;
}

.compact-section {
  padding-bottom: 0;
}

.monthly {
  min-width: 760px;
}

.sub-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sub-panel h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.event-editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 12px;
  align-items: start;
}

.parameter-editor-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 12px;
  align-items: start;
}

.event-detail-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.event-detail-card .sub-heading {
  padding-bottom: 0;
}

.detail-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-card-heading h5 {
  margin: 0;
  font-size: 13px;
}

.secondary-heading {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.compact-form-grid {
  gap: 10px;
}

.event-editor-actions {
  justify-content: flex-end;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.summary-strip span,
.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafb;
  color: var(--text);
  white-space: nowrap;
}

.summary-pill.negative {
  border-color: #f0c0a2;
  background: #fff0e7;
  color: #8a3b13;
}

.actual-sheet-panel {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.actual-sheet-salary-grid {
  display: grid;
  grid-template-columns: minmax(123px, 1fr);
  gap: 4px;
  min-width: 135px;
}

.actual-sheet-salary-grid label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.actual-sheet-salary-grid .table-input {
  width: 100%;
  min-width: 0;
}

#actualSheetTable {
  min-width: 1240px;
}

#actualSheetTable th:first-child,
#actualSheetTable td:first-child {
  width: 77px;
  min-width: 77px;
  max-width: 88px;
}

#actualSheetTable th:nth-child(2),
#actualSheetTable td:nth-child(2) {
  width: 180px;
  min-width: 180px;
  max-width: 210px;
  white-space: normal;
  overflow-wrap: anywhere;
}

#actualSheetTable th:nth-child(5),
#actualSheetTable td:nth-child(5) {
  width: 144px;
  min-width: 144px;
  max-width: 165px;
}

#actualSheetTable th:nth-child(7),
#actualSheetTable td:nth-child(7) {
  width: 165px;
  min-width: 165px;
  max-width: 180px;
}

#actualSheetTable .note-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

#actualTable th:nth-child(2),
#actualTable td:nth-child(2) {
  width: 150px;
  min-width: 150px;
  max-width: 170px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.admin-stripe-id {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.link-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 10px;
}

.link-panel label {
  flex: 1 1 320px;
  min-width: 240px;
}

.link-panel p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.candidate-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 2px;
}

.candidate-toolbar label {
  display: grid;
  gap: 4px;
  min-width: 220px;
  color: var(--muted);
  font-size: 12px;
}

.income-table {
  min-width: 860px;
}

.income-period-form {
  display: grid;
  gap: 10px;
}

.income-period-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.income-period-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  min-width: 160px;
}

.income-period-toolbar select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #fff;
  color: var(--text);
}

.income-period-table {
  min-width: 960px;
}

.income-period-table th:first-child,
.income-period-table td:first-child {
  min-width: 140px;
}

.table-input {
  width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 7px;
  text-align: right;
}

.amount-input-wrap {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  width: 100%;
}

.amount-input-wrap input,
.amount-input-wrap .table-input {
  width: 100%;
}

.amount-calculator-button {
  grid-column: auto !important;
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  text-align: center;
}

.note-input {
  width: 220px;
  text-align: left;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  color: var(--muted);
}

.pager button {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.pager button:disabled {
  opacity: 0.45;
  cursor: default;
}

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

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

.form-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  min-width: 0;
}

.form-grid input,
.form-grid select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #fff;
  color: var(--text);
}

.inline-fields {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding-top: 20px;
}

.form-grid input[type="checkbox"] {
  width: auto;
}

.form-grid button {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.form-actions button {
  grid-column: auto;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.bulk-actions span {
  color: var(--muted);
  font-size: 13px;
}

.checkbox-col,
.checkbox-cell {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
  white-space: nowrap;
}

.checkbox-col input,
.checkbox-cell input {
  width: 16px;
  height: 16px;
}

#parameterTable th.checkbox-col,
#parameterTable td.checkbox-cell,
#eventMasterTable th.checkbox-col,
#eventMasterTable td.checkbox-cell {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  left: 0;
  text-align: center;
}

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

.section-note {
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.life-plan-timeline-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.life-plan-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.life-plan-tabs button {
  min-height: 36px;
  padding: 8px 14px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.life-plan-tabs button:hover,
.life-plan-tabs button.active {
  border-color: #b9d9dc;
  background: #e9f6f7;
  color: var(--primary);
}

.parameter-search {
  margin-bottom: 10px;
}

.event-timeline-panel {
  margin: 0 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.timeline-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.timeline-toolbar label {
  min-width: 180px;
}

.timeline-toolbar select {
  min-height: 38px;
}

.template-summary {
  flex: 1 1 260px;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fafb;
  color: var(--muted);
  font-size: 13px;
}

.template-summary.has-warning {
  border-color: #f0c0a2;
  background: #fff7ed;
  color: #8a3b13;
}

.timeline-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.event-timeline {
  display: grid;
  grid-template-columns: 72px repeat(var(--timeline-years), minmax(72px, 1fr));
  min-width: max(800px, calc(72px + var(--timeline-years) * 72px));
  align-items: stretch;
}

.timeline-head,
.timeline-year {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.timeline-label,
.timeline-lane-label {
  position: sticky;
  left: 0;
  z-index: 3;
  border-right: 1px solid var(--line);
}

.timeline-lane-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 62px;
  padding: 8px 6px;
  background: #fff;
}

.timeline-lane-label strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.timeline-lane-label small {
  color: var(--muted);
  font-size: 11px;
}

.timeline-lane-label .timeline-out-of-range {
  width: fit-content;
  padding: 2px 6px;
  border: 1px solid #f0c0a2;
  border-radius: 999px;
  background: #fff7ed;
  color: #8a3b13;
  font-weight: 700;
}

.timeline-lane {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--timeline-years), minmax(72px, 1fr));
  grid-template-rows: repeat(var(--timeline-rows), 28px);
  grid-auto-flow: column;
  min-height: 62px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-cell {
  position: relative;
  grid-row: 1 / -1;
  min-height: 100%;
  padding: 0;
  border: 0;
  border-right: 1px solid #eef2f1;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: copy;
}

.timeline-cell:hover,
.timeline-cell:focus-visible {
  background: #f1f7f8;
  outline: 2px solid rgba(25, 118, 130, 0.22);
  outline-offset: -2px;
}

.timeline-cell-age {
  position: absolute;
  top: 3px;
  left: 4px;
  z-index: 0;
  color: #9aa8ae;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.timeline-item {
  position: relative;
  z-index: 1;
  align-self: center;
  min-width: 0;
  min-height: 24px;
  margin: 2px 4px;
  padding: 3px 8px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.timeline-item-labels {
  display: grid;
  grid-template-columns: repeat(var(--timeline-item-years), minmax(0, 1fr));
  align-items: center;
  width: 100%;
  min-width: 0;
  pointer-events: none;
}

.timeline-item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-item.parameter-income {
  background: #e8f5ee;
  border-color: #b7ddc7;
  color: #1d6b42;
}

.timeline-item.parameter-expense {
  background: #fff0e7;
  border-color: #f0c0a2;
  color: #8a3b13;
}

.timeline-item.event-point {
  background: #eaf1fb;
  border-color: #b7cdee;
  color: #1d4e89;
}

.timeline-no-item,
.timeline-empty {
  grid-column: 1 / -1;
  align-self: center;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

#parameterTable tbody tr[data-parameter-key] {
  cursor: pointer;
}

#parameterTable tbody tr[data-parameter-key]:hover td {
  background: #f3f8fa;
}

.copy-button {
  padding: 4px 8px;
  background: #fff;
  color: var(--accent);
  border-color: var(--line);
}

.danger-button {
  background: #fff;
  color: var(--danger);
  border-color: #d9a3a3;
}

.member-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.member-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  white-space: nowrap;
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.member-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.member-tab small {
  font-size: 11px;
  opacity: 0.86;
}

.add-tab {
  border-style: dashed;
}

.list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.list button {
  text-align: left;
  color: var(--text);
  background: #f8fafb;
  border-color: var(--line);
}

.list small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 360px;
  background: #172026;
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.help-chat-open {
  position: fixed;
  right: 20px;
  bottom: 82px;
  z-index: 28;
  min-width: 84px;
  min-height: 42px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(20, 35, 45, 0.16);
}

body.public-mode .help-chat,
body.public-mode .help-chat-open,
body.auth-required .help-chat,
body.auth-required .help-chat-open,
body.auth-loading .help-chat,
body.auth-loading .help-chat-open {
  display: none !important;
}

.help-chat {
  position: fixed;
  right: 20px;
  bottom: 136px;
  z-index: 29;
  display: grid;
  grid-template-rows: auto minmax(160px, 1fr) auto auto;
  width: min(380px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(20, 35, 45, 0.18);
  overflow: hidden;
}

.help-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #eef5f6;
}

.help-chat-head strong,
.help-chat-head span {
  display: block;
}

.help-chat-head span {
  color: var(--muted);
  font-size: 12px;
}

.help-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.help-chat-toggle input {
  width: 16px;
  height: 16px;
}

.help-chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
}

.help-chat-message {
  max-width: 90%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfd;
}

.help-chat-message.user {
  justify-self: end;
  border-color: var(--accent);
  background: #e7f2f3;
}

.help-chat-message p {
  margin: 0;
  line-height: 1.6;
}

.help-chat-actions,
.help-chat-topics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.help-chat-topics {
  margin: 0;
  padding: 0 12px 10px;
}

.help-chat-actions button,
.help-chat-topics button {
  min-height: 30px;
  padding: 5px 8px;
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 12px;
}

.help-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.help-chat-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 24, 30, 0.42);
}

.calculator-modal,
.choice-modal {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  padding: 14px;
}

.choice-modal.wide {
  width: min(760px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 28px));
  overflow: auto;
}

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

.choice-actions button {
  min-height: 42px;
}

.template-preview-body {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  min-width: 0;
  overflow-x: auto;
}

.template-preview-body h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.template-warning {
  padding: 8px 10px;
  border: 1px solid #f0c0a2;
  border-radius: 7px;
  background: #fff7ed;
  color: #8a3b13;
  font-size: 13px;
}

.template-plan-summary {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fafb;
  color: var(--text);
  font-size: 13px;
}

.template-plan-summary.has-skip {
  border-color: #d8c1a4;
  background: #fbf6ef;
  color: #7b5536;
}

.template-confirm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 4px 2px;
  color: var(--text);
  font-size: 13px;
}

.template-confirm input {
  width: auto;
  margin: 0;
}

.template-range-status {
  color: var(--muted);
  font-weight: 700;
}

.template-range-status.out-of-range {
  color: #8a3b13;
  background: #fff7ed;
}

.duplicate-row td {
  background: #fff7ed;
}

#templatePreviewModal.skip-duplicates .duplicate-row td {
  background: #f6f2ed;
  color: #9a6a45;
  text-decoration: line-through;
}

#templatePreviewModal.skip-duplicates .duplicate-row td:last-child {
  text-decoration: none;
}

.modal-actions {
  margin-top: 14px;
}

.calculator-display {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 18px;
  text-align: right;
}

.calculator-error {
  min-height: 20px;
  padding-top: 4px;
  color: var(--danger);
  font-size: 12px;
}

.calculator-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.calculator-keys button {
  min-height: 38px;
}

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

  .layout {
    grid-template-columns: 1fr;
  }

  .app-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 12px;
    padding: 12px;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
  }

  .nav-group {
    display: flex;
    gap: 8px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .brand {
    gap: 10px;
    min-width: 0;
  }

  .brand > div {
    min-width: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand h1 {
    font-size: 21px;
    overflow-wrap: anywhere;
  }

  .user-note {
    display: flex;
    align-items: center;
    gap: 8px 10px;
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .user-note span,
  .user-note strong,
  .user-note small {
    display: inline;
  }

  .user-note span {
    flex: 0 0 auto;
  }

  .user-note strong {
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-note small {
    margin: 0;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-note .link-button {
    min-height: 32px;
    margin-left: auto;
    padding: 4px 0;
    white-space: nowrap;
  }

  .nav-item,
  .master-subitem {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    white-space: nowrap;
  }

  .master-subnav {
    display: flex;
    flex: 1 0 100%;
    gap: 8px;
    margin: 0;
    padding-left: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .nav-status {
    display: none;
  }

  .content {
    padding: 18px 12px 28px;
  }

  .workspace {
    max-height: none;
  }

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

  .event-editor-grid,
  .parameter-editor-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 720px) {
  html {
    scroll-padding-top: 12px;
  }

  body {
    min-width: 0;
  }

  .landing-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .landing-main {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 18px 16px 28px;
  }

  .landing-copy h1 {
    font-size: 34px;
  }

  .landing-preview {
    min-height: 260px;
    padding: 14px;
  }

  .app-nav {
    position: static;
    z-index: 20;
    gap: 10px;
    padding: 10px 12px 12px;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }

  .brand {
    align-items: center;
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand h1 {
    font-size: 21px;
    line-height: 1.1;
  }

  .brand-kicker,
  .eyebrow {
    font-size: 11px;
  }

  .user-note {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 10px;
    margin: 4px 0 0;
    padding: 9px 10px;
    font-size: 12px;
  }

  .user-note span {
    grid-column: 1 / -1;
  }

  .user-note strong,
  .user-note small {
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-note .link-button {
    margin-left: 0;
  }

  .nav-group {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .nav-item,
  .master-subitem {
    flex: 0 0 auto;
    width: auto;
    text-align: center;
    white-space: nowrap;
  }

  .master-subnav {
    flex: 1 0 100%;
    order: 99;
    margin: 0;
    padding: 0 0 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .master-subnav::-webkit-scrollbar {
    display: none;
  }

  .content {
    padding: 14px 10px 24px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }

  .app-header h2 {
    font-size: 22px;
    line-height: 1.25;
  }

  .header-metrics {
    width: 100%;
    justify-content: flex-start;
  }

  .header-metrics span {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
  }

  .view-panel {
    gap: 10px;
  }

  .panel-section,
  .details-section,
  .table-section,
  .metric-card {
    border-radius: 6px;
  }

  .panel-section {
    padding: 10px;
  }

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

  .section-heading,
  .section-heading.inline,
  .sub-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .section-heading.inline {
    padding: 8px 8px 0;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions button,
  .timeline-toolbar button {
    width: 100%;
  }

  .tabs,
  .life-plan-tabs,
  .member-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .tabs button,
  .life-plan-tabs button,
  .member-tab {
    flex: 0 0 auto;
  }

  .summary-strip {
    gap: 6px;
  }

  .summary-strip span {
    flex: 1 1 140px;
    justify-content: center;
  }

  .drilldown-grid {
    display: none;
  }

  .cashflow-drilldown-mobile-list {
    display: grid;
    gap: 8px;
  }

  .cashflow-mobile-summary {
    grid-template-columns: 1fr 1fr;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .info-table th,
  .info-table td {
    display: block;
    width: 100%;
  }

  .help-chat {
    right: 10px;
    bottom: 126px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 146px);
  }

  .help-chat-open {
    right: 10px;
    bottom: 72px;
  }

  .table-wrap {
    margin-left: -10px;
    margin-right: -10px;
    padding: 0 10px 2px;
    border-radius: 0;
  }

  .finance-table th,
  .finance-table td {
    padding: 6px 7px;
    font-size: 13px;
  }

  .simple-table {
    min-width: 680px;
  }

  #yearTable {
    min-width: 1090px;
  }

  #yearTable col.item-col {
    width: 108px;
  }

  #yearTable col.year-col {
    width: 98px;
  }

  #yearTable th:first-child,
  #yearTable td:first-child {
    min-width: 108px;
  }

  #eventTable {
    min-width: 660px;
  }

  #eventTable col.event-year-col {
    width: 70px;
  }

  #eventTable col.event-target-col {
    width: 96px;
  }

  #eventTable col.event-age-col {
    width: 56px;
  }

  #eventTable col.event-title-col {
    width: 164px;
  }

  #actualSheetTable {
    min-width: 1040px;
  }

  .timeline-toolbar {
    align-items: stretch;
  }

  .timeline-toolbar label,
  .template-summary {
    flex: 1 1 100%;
    min-width: 0;
  }

  .event-timeline {
    grid-template-columns: 64px repeat(var(--timeline-years), minmax(62px, 1fr));
    min-width: max(640px, calc(64px + var(--timeline-years) * 62px));
  }

  .timeline-lane-label {
    padding: 7px 5px;
  }

  .timeline-lane-label strong {
    font-size: 12px;
  }

  .timeline-lane-label small {
    font-size: 10px;
  }

  .timeline-item {
    min-height: 26px;
    margin: 2px 3px;
    padding: 4px 6px;
    font-size: 11px;
  }

  .event-detail-card {
    padding: 10px;
  }

  .summary-strip span,
  .summary-pill {
    white-space: normal;
  }

  .link-panel label,
  .candidate-toolbar label {
    flex-basis: 100%;
    min-width: 0;
  }

  .choice-modal.wide {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
  }
}

@media (max-width: 480px) {
  .landing-copy h1 {
    font-size: 30px;
  }

  .landing-actions,
  .landing-cta-row {
    width: 100%;
  }

  .landing-actions button,
  .landing-cta-row button {
    width: 100%;
  }

  .app-nav {
    gap: 10px;
    padding: 10px 12px 12px;
  }

  .nav-group {
    gap: 6px;
  }

  .nav-item,
  .master-subitem {
    min-height: 38px;
    padding: 9px 10px;
    font-size: 13px;
  }

  .master-subnav {
    gap: 8px;
  }

  .content {
    padding: 12px 8px 22px;
  }

  .app-header h2 {
    font-size: 20px;
  }

  .header-metrics span,
  .summary-strip span,
  .summary-pill {
    font-size: 12px;
  }

  .panel-section {
    padding: 8px;
  }

  .table-wrap {
    margin-left: -8px;
    margin-right: -8px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .finance-table th,
  .finance-table td {
    padding: 5px 6px;
    font-size: 12px;
  }

  .form-grid input,
  .form-grid select {
    min-height: 36px;
    padding: 6px 7px;
  }

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

  #yearTable {
    min-width: 1015px;
  }

  #yearTable col.item-col {
    width: 100px;
  }

  #yearTable col.year-col {
    width: 91px;
  }

  #yearTable th:first-child,
  #yearTable td:first-child {
    min-width: 100px;
  }

  .event-timeline {
    grid-template-columns: 58px repeat(var(--timeline-years), minmax(56px, 1fr));
    min-width: max(590px, calc(58px + var(--timeline-years) * 56px));
  }
}
