:root {
  --ink: #16201b;
  --muted: #738078;
  --line: #e4e8e2;
  --paper: #ffffff;
  --canvas: #f4f5f1;
  --green: #174d3a;
  --green-2: #236a50;
  --green-soft: #e8f0ec;
  --mint: #cfe8db;
  --orange: #e9874c;
  --orange-soft: #fff1e8;
  --blue: #6687c4;
  --shadow: 0 18px 45px rgba(32, 52, 42, 0.07);
  --sidebar: 244px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

body,
button,
input,
select,
textarea {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font-size: 14px;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  color: var(--green);
}

.boot-screen strong,
.boot-screen span {
  display: block;
}

.boot-screen strong {
  font-size: 20px;
}

.boot-screen span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.boot-mark,
.brand-mark {
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.boot-mark {
  width: 48px;
  height: 48px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 26px 18px 18px;
  background: #f8f9f6;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 25px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px 12px 12px 5px;
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: .02em;
}

.brand-copy small {
  margin-top: 2px;
  color: #9aa39e;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .18em;
}

.family-switcher {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  cursor: pointer;
  transition: .18s ease;
}

.family-switcher:hover {
  border-color: #c7d2cb;
  box-shadow: 0 7px 18px rgba(32, 52, 42, .06);
}

.family-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  background: #f2e2d2;
}

.family-switcher span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
}

.family-switcher span small {
  display: block;
  margin-bottom: 2px;
  color: #98a29c;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .08em;
}

.sidebar-label {
  padding: 0 12px 8px;
  color: #a1aaa5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .15em;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #6f7b74;
  cursor: pointer;
  text-align: left;
  transition: .18s ease;
}

.nav-item:hover {
  color: var(--green);
  background: #eef2ee;
}

.nav-item.active {
  color: var(--green);
  background: #e8efeb;
  font-weight: 700;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
}

.sidebar-foot {
  margin-top: auto;
}

.privacy-note {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #dbe5df;
  border-radius: 14px;
  background: #edf4f0;
}

.privacy-note strong {
  display: block;
  color: var(--green);
  font-size: 12px;
}

.privacy-note p {
  margin: 5px 0 0;
  color: #72817a;
  font-size: 10px;
  line-height: 1.6;
}

.main-panel {
  min-height: 100vh;
  margin-left: var(--sidebar);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px;
  background: rgba(244,245,241,.88);
  border-bottom: 1px solid rgba(222,226,220,.78);
  backdrop-filter: blur(18px);
}

.page-eyebrow {
  margin-bottom: 4px;
  color: #9aa39e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
}

.page-title {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.danger-btn,
.month-btn {
  min-height: 40px;
  border-radius: 11px;
  cursor: pointer;
  transition: .18s ease;
}

.icon-btn {
  width: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--paper);
}

.icon-btn:hover,
.ghost-btn:hover,
.month-btn:hover {
  border-color: #cbd4ce;
  background: #fafcf9;
}

.primary-btn,
.danger-btn,
.ghost-btn,
.month-btn {
  padding: 0 16px;
  font-weight: 600;
}

.primary-btn {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(23,77,58,.18);
}

.primary-btn:hover {
  background: #1e5c46;
  transform: translateY(-1px);
}

.ghost-btn,
.month-btn {
  border: 1px solid var(--line);
  background: var(--paper);
}

.danger-btn {
  border: 1px solid #f0cabc;
  background: #fff4f0;
  color: #a54d31;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.user-avatar {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ead6c7;
  color: #754d35;
  font-size: 12px;
  font-weight: 700;
}

.user-copy strong,
.user-copy small {
  display: block;
}

.user-copy strong {
  font-size: 12px;
}

.user-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.content {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 30px 38px 50px;
}

.welcome-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 23px;
}

.welcome-row h2 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -.04em;
}

.welcome-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.month-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-control strong {
  min-width: 90px;
  text-align: center;
  font-size: 13px;
}

.month-btn {
  min-height: 35px;
  padding: 0 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.summary-card,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 3px 18px rgba(35, 53, 43, .025);
}

.summary-card {
  min-height: 148px;
  padding: 20px;
  border-radius: 17px;
}

.summary-card.primary {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.summary-card.primary::after {
  content: "";
  position: absolute;
  width: 145px;
  height: 145px;
  right: -48px;
  bottom: -74px;
  border: 28px solid rgba(255,255,255,.06);
  border-radius: 50%;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #8b958f;
  font-size: 11px;
  font-weight: 600;
}

.summary-card.primary .summary-head {
  color: rgba(255,255,255,.64);
}

.summary-icon {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #f1f4f1;
}

.summary-card.primary .summary-icon {
  background: rgba(255,255,255,.12);
}

.summary-value {
  margin-top: 19px;
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 700;
  letter-spacing: -.04em;
}

.summary-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  color: #9ba49f;
  font-size: 10px;
}

.summary-card.primary .summary-foot {
  color: rgba(255,255,255,.62);
}

.trend-up {
  color: #4d9a72;
  font-weight: 700;
}

.summary-card.primary .trend-up {
  color: #a7dfc4;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr);
  gap: 16px;
}

.panel {
  border-radius: 18px;
}

.panel-head {
  min-height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #edf0ec;
}

.panel-title {
  margin: 0;
  font-size: 14px;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: #919b95;
  font-size: 10px;
}

.text-btn {
  padding: 5px;
  border: 0;
  background: none;
  color: var(--green-2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.chart-wrap {
  padding: 20px 21px 18px;
}

.chart-summary {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
}

.chart-summary div {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #78847d;
  font-size: 10px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.green { background: var(--green); }
.dot.orange { background: var(--orange); }

.bar-chart {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 13px;
  padding-top: 8px;
  border-bottom: 1px solid #e8ebe7;
  background-image: linear-gradient(to top, #edf0ec 1px, transparent 1px);
  background-size: 100% 25%;
}

.bar-day {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  position: relative;
}

.bar {
  width: min(12px, 30%);
  min-height: 3px;
  border-radius: 5px 5px 1px 1px;
  transition: .2s ease;
}

.bar.income { background: #a6cab8; }
.bar.expense { background: var(--orange); }

.bar-day:hover .bar {
  filter: brightness(.92);
}

.bar-label {
  position: absolute;
  top: calc(100% + 9px);
  color: #9ba49f;
  font-size: 9px;
}

.budget-wrap {
  padding: 22px 20px;
}

.budget-overview {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid #edf0ec;
}

.budget-ring {
  --percent: 0;
  width: 108px;
  height: 108px;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--percent) * 1%), #e9ede9 0);
}

.budget-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: white;
}

.budget-ring span {
  position: relative;
  z-index: 1;
  font-size: 20px;
  font-weight: 700;
}

.budget-ring small {
  display: block;
  margin-top: -4px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 500;
}

.budget-copy strong {
  display: block;
  font-size: 18px;
}

.budget-copy span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.budget-list {
  display: grid;
  gap: 15px;
  margin-top: 20px;
}

.progress-row {
  display: grid;
  gap: 7px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
}

.progress-meta strong {
  font-size: 11px;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #edf0ec;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.progress-fill.warn { background: var(--orange); }
.progress-fill.over { background: #c85c45; }

.bottom-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  margin-top: 16px;
}

.transaction-list {
  padding: 4px 18px 12px;
}

.transaction-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1.25fr) minmax(80px, .7fr) 92px;
  align-items: center;
  gap: 12px;
  min-height: 67px;
  border-bottom: 1px solid #f0f2ef;
}

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

.category-badge {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 16px;
}

.transaction-main strong,
.transaction-main small,
.transaction-account,
.transaction-amount strong,
.transaction-amount small {
  display: block;
}

.transaction-main strong {
  overflow: hidden;
  color: #344039;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-main small,
.transaction-account,
.transaction-amount small {
  margin-top: 4px;
  color: #9aa39e;
  font-size: 9px;
}

.transaction-account {
  margin-top: 0;
}

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

.transaction-amount strong {
  font-size: 12px;
}

.transaction-amount.income strong { color: #2e845d; }

.account-list {
  display: grid;
  gap: 2px;
  padding: 11px 18px 17px;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.account-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
}

.account-copy {
  min-width: 0;
  flex: 1;
}

.account-copy strong,
.account-copy small {
  display: block;
}

.account-copy strong {
  font-size: 11px;
}

.account-copy small {
  margin-top: 3px;
  color: #a1aaa5;
  font-size: 9px;
}

.account-balance {
  font-size: 12px;
  font-weight: 700;
}

.section-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 16px;
}

.section-toolbar h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -.035em;
}

.section-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, 150px);
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.field,
.search-field {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid #dfe4df;
  border-radius: 11px;
  outline: none;
  background: #fbfcfa;
  color: var(--ink);
}

.field:focus,
.search-field:focus {
  border-color: #87a697;
  box-shadow: 0 0 0 3px rgba(35,106,80,.08);
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 105px minmax(180px, 1.3fr) minmax(120px, .8fr) 110px 115px 108px;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
}

.table-head {
  min-height: 44px;
  background: #fafbf9;
  border-bottom: 1px solid var(--line);
  color: #9aa39e;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
}

.table-row {
  min-height: 68px;
  border-bottom: 1px solid #edf0ec;
  font-size: 11px;
}

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

.table-date {
  color: var(--muted);
}

.table-merchant {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.table-merchant .category-badge {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
}

.table-merchant span {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.money-expense { font-weight: 700; }
.money-income { color: #2e845d; font-weight: 700; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.row-action {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #dde4de;
  border-radius: 8px;
  background: #fff;
  color: #59665f;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.row-action.edit:hover {
  border-color: #a9c1b5;
  background: #f2f7f4;
  color: var(--green);
}

.row-action.delete {
  border-color: #f0d8cf;
  color: #a84d33;
}

.row-action.delete:hover {
  background: #fff0eb;
}

.empty-state {
  padding: 70px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state b {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.budget-grid,
.accounts-grid,
.family-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

.budget-card,
.account-card,
.member-card,
.report-card,
.settings-card {
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 17px;
}

.budget-card-head,
.account-card-head,
.member-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.category-title .category-badge {
  width: 36px;
  height: 36px;
}

.budget-card-value {
  margin: 22px 0 12px;
  font-size: 23px;
  font-weight: 700;
}

.budget-card-value small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.budget-card-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
  font-size: 9px;
}

.account-card {
  position: relative;
  min-height: 170px;
  overflow: hidden;
}

.account-card::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -46px;
  width: 105px;
  height: 105px;
  border: 22px solid currentColor;
  border-radius: 50%;
  opacity: .045;
}

.account-card .account-icon {
  width: 42px;
  height: 42px;
  font-size: 18px;
}

.account-card-name {
  margin-top: 20px;
  color: var(--muted);
  font-size: 10px;
}

.account-card-balance {
  margin-top: 5px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.03em;
}

.report-layout {
  display: grid;
  grid-template-columns: 1.5fr .8fr;
  gap: 16px;
}

.report-card {
  min-height: 340px;
}

.report-card h3,
.settings-card h3 {
  margin: 0;
  font-size: 14px;
}

.donut-layout {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 32px 10px 12px;
}

.donut {
  --segments: conic-gradient(#174d3a 0 32%, #e9874c 32% 55%, #6687c4 55% 72%, #d3ac62 72% 86%, #9a79b0 86%);
  width: 180px;
  height: 180px;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--segments);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: #fff;
}

.donut-label {
  position: relative;
  z-index: 1;
  text-align: center;
}

.donut-label strong,
.donut-label small {
  display: block;
}

.donut-label strong {
  font-size: 17px;
}

.donut-label small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.legend {
  min-width: 180px;
  display: grid;
  gap: 13px;
}

.legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 10px;
}

.legend-row strong {
  font-size: 11px;
}

.insight-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.insight {
  padding: 14px;
  border-radius: 12px;
  background: #f7f9f6;
}

.insight strong {
  display: block;
  font-size: 11px;
}

.insight p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.member-card-head {
  align-items: flex-start;
}

.member-profile {
  display: flex;
  align-items: center;
  gap: 11px;
}

.member-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e9ddd4;
  color: #765541;
  font-size: 12px;
  font-weight: 700;
}

.member-profile strong,
.member-profile small {
  display: block;
}

.member-profile strong {
  font-size: 12px;
}

.member-profile small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.role-pill {
  padding: 5px 8px;
  border-radius: 99px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 8px;
  font-weight: 700;
}

.member-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 23px;
  padding-top: 15px;
  border-top: 1px solid #edf0ec;
  color: var(--muted);
  font-size: 9px;
}

.owner-member-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.member-remove {
  width: 100%;
  margin-top: 13px;
  padding: 9px 10px;
  border: 1px solid #f0d8cf;
  border-radius: 9px;
  background: #fff8f5;
  color: #a84d33;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.member-remove:hover {
  background: #fff0eb;
}

.invite-card {
  min-height: 170px;
  display: grid;
  place-items: center;
  border: 1px dashed #b9c8c0;
  border-radius: 17px;
  background: #f8faf8;
  color: var(--green);
  cursor: pointer;
}

.invite-card span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin: 0 auto 9px;
  border-radius: 50%;
  background: var(--green-soft);
  font-size: 20px;
}

.invite-card strong {
  font-size: 11px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-card p {
  margin: 7px 0 19px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.settings-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  min-height: 60px;
  border-top: 1px solid #edf0ec;
}

.settings-line strong,
.settings-line small {
  display: block;
}

.settings-line strong {
  font-size: 11px;
}

.settings-line small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.status-good {
  color: #2e845d;
  font-size: 10px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 27, 21, .5);
  backdrop-filter: blur(8px);
}

.modal {
  width: min(520px, 100%);
  max-height: min(760px, calc(100vh - 34px));
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(12, 30, 21, .25);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 22px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.close-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: #f3f5f2;
  cursor: pointer;
}

.modal-body {
  padding: 22px;
}

.modal-help {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.ledger-list {
  display: grid;
  gap: 9px;
}

.ledger-option {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.ledger-option:hover {
  border-color: #b9c9c0;
  background: #fafcf9;
}

.ledger-option.active {
  border-color: #a5bfb2;
  background: var(--green-soft);
}

.ledger-option-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.ledger-option > span:nth-child(2) {
  min-width: 0;
}

.ledger-option strong,
.ledger-option small {
  display: block;
}

.ledger-option strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.ledger-option b {
  color: var(--green);
  text-align: center;
}

.ledger-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.code-input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .18em;
}

.invite-link {
  overflow: hidden;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f9f6;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 12px;
  background: #f1f3f0;
}

.type-switch label {
  position: relative;
}

.type-switch input {
  position: absolute;
  opacity: 0;
}

.type-switch span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.type-switch input:checked + span {
  background: #fff;
  color: var(--green);
  box-shadow: 0 2px 7px rgba(28,46,36,.08);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-group {
  display: grid;
  gap: 7px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  color: #657169;
  font-size: 10px;
  font-weight: 700;
}

.amount-input {
  height: 64px;
  padding: 0 16px;
  border: 1px solid #dfe4df;
  border-radius: 13px;
  outline: none;
  font-size: 27px;
  font-weight: 700;
}

.amount-input:focus {
  border-color: #87a697;
  box-shadow: 0 0 0 4px rgba(35,106,80,.08);
}

textarea.field {
  min-height: 78px;
  padding-top: 11px;
  resize: vertical;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 16px;
  border-radius: 12px;
  background: #173f31;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 11px;
  animation: toast-in .24s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, .9fr) 1.1fr;
  background: #f5f6f2;
}

.login-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 36px clamp(28px, 5vw, 72px);
  background: #fff;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.login-brand .brand-mark {
  width: 36px;
  height: 36px;
}

.login-form-wrap {
  width: min(390px, 100%);
  margin: auto;
}

.login-form-wrap h1 {
  margin: 0;
  font-size: 31px;
  letter-spacing: -.045em;
}

.login-form-wrap > p {
  margin: 10px 0 28px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 15px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  border-radius: 12px;
  background: #f1f3f0;
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tabs button.active {
  background: #fff;
  color: var(--green);
  box-shadow: 0 2px 10px rgba(34, 62, 48, .08);
}

.login-form .primary-btn {
  min-height: 46px;
  margin-top: 4px;
}

.auth-note {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
  text-align: center;
}

.login-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff0eb;
  color: #aa4e33;
  font-size: 10px;
}

.login-foot {
  color: #9ca59f;
  font-size: 9px;
  text-align: center;
}

.login-visual {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 50px;
  background: var(--green);
  color: #fff;
}

.login-visual::before,
.login-visual::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 50%;
}

.login-visual::before {
  width: 580px;
  height: 580px;
  right: -240px;
  top: -220px;
}

.login-visual::after {
  width: 380px;
  height: 380px;
  left: -160px;
  bottom: -170px;
}

.login-quote {
  position: relative;
  z-index: 1;
  width: min(470px, 100%);
}

.login-quote .quote-mark {
  font-family: Georgia, serif;
  color: #88b9a2;
  font-size: 76px;
  line-height: .7;
}

.login-quote h2 {
  margin: 22px 0 14px;
  font-size: clamp(27px, 3.2vw, 42px);
  line-height: 1.25;
  letter-spacing: -.04em;
}

.login-quote p {
  color: rgba(255,255,255,.62);
  font-size: 12px;
  line-height: 1.8;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1180px) {
  :root { --sidebar: 210px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr 1fr; }
  .budget-grid,
  .accounts-grid,
  .family-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .main-panel { margin-left: 0; padding-bottom: 72px; }
  .topbar {
    height: 66px;
    padding: 0 17px;
  }
  .page-eyebrow,
  .user-copy,
  .top-actions .icon-btn { display: none; }
  .page-title { font-size: 18px; }
  .user-chip { padding-left: 7px; }
  .content { padding: 22px 16px 32px; }
  .welcome-row { align-items: flex-start; }
  .welcome-row h2 { font-size: 24px; }
  .month-control { display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .search-field { grid-column: 1 / -1; }
  .table-head { display: none; }
  .table-row {
    grid-template-columns: minmax(0, 1fr) auto 82px;
    gap: 8px;
    min-height: 72px;
    padding: 0 14px;
  }
  .table-date,
  .table-category,
  .table-account { display: none; }
  .budget-grid,
  .accounts-grid,
  .family-grid { grid-template-columns: 1fr 1fr; }
  .report-layout,
  .settings-grid { grid-template-columns: 1fr; }
  .donut-layout { gap: 20px; }
  .donut { width: 145px; height: 145px; }
  .donut::after { inset: 29px; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 80;
    height: 68px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px 8px max(7px, env(safe-area-inset-bottom));
    background: rgba(255,255,255,.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
  }
  .mobile-nav button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    background: none;
    color: #8b958f;
    font-size: 8px;
  }
  .mobile-nav button b {
    font-size: 16px;
    font-weight: 500;
  }
  .mobile-nav button.active { color: var(--green); }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}

@media (max-width: 560px) {
  .top-actions .user-chip { margin-left: 0; }
  .primary-btn .btn-label { display: none; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 130px; }
  .dashboard-grid { display: block; }
  .dashboard-grid > * + * { margin-top: 15px; }
  .bar-chart { gap: 6px; }
  .transaction-row {
    grid-template-columns: 38px minmax(0,1fr) 78px;
    gap: 8px;
  }
  .transaction-account { display: none; }
  .budget-grid,
  .accounts-grid,
  .family-grid { grid-template-columns: 1fr; }
  .section-toolbar { align-items: flex-start; }
  .section-toolbar h2 { font-size: 22px; }
  .owner-member-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .search-field { grid-column: auto; }
  .donut-layout {
    flex-direction: column;
    align-items: flex-start;
  }
  .legend { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }
  .modal-body { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: .001ms !important;
  }
}
