:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #68736f;
  --line: #dfe5e2;
  --surface: #ffffff;
  --canvas: #f4f6f4;
  --forest: #17352d;
  --green: #168568;
  --green-soft: #e8f4ef;
  --coral: #d75d4a;
  --coral-soft: #fbece8;
  --gold: #c38a2d;
  --shadow: 0 14px 40px rgba(24, 49, 40, 0.09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body.trend-preview-lock {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
textarea,
select,
[contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(22, 133, 104, 0.22);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(400px, 0.9fr);
  background: var(--surface);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: clamp(48px, 8vw, 128px);
  color: #f7fbf9;
  background: var(--forest);
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--forest);
  background: #b9dfcf;
  font-size: 27px;
  font-weight: 800;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.auth-brand h1 {
  margin: 28px 0 8px;
  font-size: clamp(48px, 7vw, 84px);
  line-height: 1;
  letter-spacing: 0;
}

.auth-brand p {
  margin: 0;
  color: #b9c9c3;
  font-size: 18px;
}

.auth-panel {
  width: min(420px, calc(100% - 48px));
  margin: auto;
}

.auth-panel h2 {
  margin: 0 0 30px;
  font-size: 30px;
}

label {
  display: grid;
  gap: 8px;
  color: #3d4844;
  font-size: 14px;
  font-weight: 600;
}

label + label {
  margin-top: 20px;
}

input,
select {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #cfd7d3;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

input:hover,
select:hover {
  border-color: #aab7b1;
}

.form-error {
  min-height: 22px;
  margin: 12px 0;
  color: #b94335;
  font-size: 13px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--forest);
  color: white;
  background: var(--forest);
}

.primary-button:hover {
  background: #244d41;
}

.full-button {
  width: 100%;
}

.auth-switch {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.auth-switch button {
  padding: 0 2px;
  border: 0;
  color: var(--green);
  background: transparent;
  font: inherit;
  font-weight: 700;
}

.app-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 224px;
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
  color: #f5faf8;
  background: var(--forest);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  font-size: 20px;
}

.main-nav {
  display: grid;
  gap: 6px;
  margin-top: 54px;
}

.nav-button {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 15px;
  border: 0;
  border-radius: 6px;
  color: #b9c9c3;
  background: transparent;
  text-align: left;
}

.nav-button .nav-icon {
  width: 20px;
  height: 20px;
  font-size: 20px;
  text-align: center;
}

.nav-icon,
.button-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button:hover,
.nav-button.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.sidebar-footer > span {
  display: block;
  max-width: 100%;
  margin-bottom: 6px;
  overflow: hidden;
  color: #dce8e3;
  font-size: 13px;
  text-overflow: ellipsis;
}

.text-button {
  padding: 4px 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 700;
}

.sidebar .text-button {
  color: #9fbbb0;
  font-size: 13px;
}

.workspace {
  height: 100%;
  min-height: 0;
  margin-left: 224px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 30;
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(24px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions .primary-button {
  display: flex;
  align-items: center;
  gap: 7px;
}

.month-control,
.month-control input {
  cursor: pointer;
}

.month-control input {
  width: 156px;
  height: 42px;
}

.content {
  width: min(1240px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 34px clamp(24px, 4vw, 54px) 64px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.view {
  display: none;
}

.view.active-view {
  display: block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  min-height: 142px;
  padding: 23px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-card > span,
.summary-card small {
  display: block;
  color: var(--muted);
}

.summary-card > span {
  font-size: 13px;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin: 13px 0 7px;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1;
}

.summary-card small {
  font-size: 12px;
}

.income-card {
  border-top: 3px solid var(--green);
}

.income-card strong {
  color: var(--green);
}

.expense-card {
  border-top: 3px solid var(--coral);
}

.expense-card strong {
  color: var(--coral);
}

.balance-card {
  border-top: 3px solid var(--gold);
}

.statistics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.recent-panel,
.category-panel,
.chart-panel {
  min-height: 390px;
  padding: 24px;
}

.recent-panel {
  min-height: 0;
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.transaction-list {
  display: grid;
}

.transaction-date-group {
  min-width: 0;
}

.transaction-date-group + .transaction-date-group {
  margin-top: 12px;
}

.transaction-date-heading {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: #65726d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.transaction-date-heading::after {
  min-width: 24px;
  height: 1px;
  flex: 1;
  background: var(--line);
  content: '';
}

.transaction-date-heading small {
  color: #87918d;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.transaction-date-rows {
  display: grid;
}

.transaction-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 68px;
  border-top: 1px solid #edf0ee;
}

.transaction-row:first-child {
  border-top: 0;
}

.transaction-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--coral);
  background: var(--coral-soft);
  font-size: 14px;
  font-weight: 800;
}

.transaction-row.income .transaction-icon {
  color: var(--green);
  background: var(--green-soft);
}

.transaction-main {
  min-width: 0;
}

.transaction-main strong,
.transaction-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-main strong {
  font-size: 14px;
}

.transaction-main small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.transaction-amount {
  color: var(--coral);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.income .transaction-amount {
  color: var(--green);
}

.transaction-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-button {
  min-width: 54px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #4e5b56;
  background: white;
}

.category-bars {
  display: grid;
  gap: 18px;
}

.category-bar-button {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 9px 2px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.category-bar-button:hover,
.legend-item:hover {
  color: var(--green);
}

.category-bar-button:hover .bar-fill {
  filter: brightness(0.85);
}

.category-bar-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 13px;
}

.category-bar-heading strong {
  font-size: 13px;
}

.bar-track {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf0ee;
}

.bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
}

.large-bars .bar-fill {
  background: var(--green);
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: #4c5753;
  font-size: 15px;
}

.empty-state span {
  font-size: 12px;
}

.records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}

.segmented-control button {
  min-width: 68px;
  height: 34px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
}

.segmented-control button.active {
  color: white;
  background: var(--forest);
}

.result-count {
  color: var(--muted);
  font-size: 13px;
}

.overview-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.overview-insights > div {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-left: 1px solid var(--line);
}

.overview-insights > div:first-child {
  border-left: 0;
}

.overview-insights span,
.budget-overview-values span {
  color: var(--muted);
  font-size: 12px;
}

.overview-insights strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-planning-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  margin-top: 18px;
}

.budget-overview-panel,
.quick-overview-panel,
.budget-settings-panel,
.quick-manager,
.security-panel,
.data-panel {
  padding: 24px;
}

.compact-heading {
  margin-bottom: 16px;
}

.budget-overview-values strong,
.budget-overview-values span {
  display: block;
}

.budget-overview-values strong {
  font-size: 19px;
}

.budget-overview-values span {
  margin-top: 6px;
}

.budget-track {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf0ee;
}

.budget-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

.budget-track span.over {
  background: var(--coral);
}

.quick-entry-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.quick-entry-list .empty-state {
  min-height: 74px;
  grid-column: 1 / -1;
}

.quick-entry-button {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fafbfa;
  text-align: left;
}

.quick-entry-button > span:first-child {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--coral);
  background: var(--coral-soft);
  font-size: 12px;
  font-weight: 800;
}

.quick-entry-button.income > span:first-child {
  color: var(--green);
  background: var(--green-soft);
}

.quick-entry-button strong,
.quick-entry-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-entry-button strong {
  font-size: 13px;
}

.quick-entry-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.record-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(120px, 0.75fr)) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.record-filters label,
.quick-entry-form label,
.password-form label,
.budget-form label {
  gap: 5px;
  font-size: 11px;
}

.record-filters label + label,
.quick-entry-form label + label,
.password-form label + label {
  margin-top: 0;
}

.record-filters input,
.record-filters select {
  height: 40px;
}

.record-search {
  position: relative;
}

.record-search svg {
  position: absolute;
  left: 12px;
  bottom: 11px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--muted);
}

.record-search input {
  padding-left: 38px;
}

.record-custom-dates {
  display: contents;
}

.filter-reset-button {
  height: 40px;
  padding: 0 12px;
  border: 0;
  color: var(--green);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.period-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 0.45fr)) minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  margin-top: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.period-comparison span,
.period-comparison strong {
  display: block;
}

.period-comparison span,
.period-comparison p {
  color: var(--muted);
  font-size: 11px;
}

.period-comparison strong {
  margin-top: 4px;
  font-size: 15px;
}

.period-comparison p {
  margin: 0;
  text-align: right;
}

.records-panel {
  min-height: 440px;
  padding: 8px 24px;
}

.detailed-list .transaction-row {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  min-height: 76px;
}

.statistics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.income-chart-panel {
  grid-column: 1 / -1;
  min-height: 0;
}

.income-chart-panel .category-bars {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
}

.statistics-toolbar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.statistics-periods button {
  min-width: 64px;
}

.statistics-navigation {
  width: min(100%, 410px);
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  justify-self: center;
  gap: 8px;
}

.statistics-nav-button,
.statistics-recent-toggle {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #53605b;
  background: var(--surface);
}

.statistics-nav-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.statistics-nav-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.statistics-nav-button svg,
.statistics-recent-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.statistics-period-label {
  min-width: 0;
  text-align: center;
}

.statistics-period-label strong,
.statistics-period-label span {
  display: block;
}

.statistics-period-label strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statistics-date-range {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.statistics-recent {
  position: relative;
}

.statistics-recent-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
}

.statistics-recent-toggle.active {
  border-color: var(--forest);
  color: var(--forest);
  background: var(--green-soft);
}

.statistics-recent-menu {
  position: absolute;
  z-index: 6;
  top: calc(100% + 7px);
  right: 0;
  width: 184px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.statistics-recent-menu > span {
  display: block;
  padding: 7px 10px 5px;
  color: var(--muted);
  font-size: 11px;
}

.statistics-recent-menu button {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.statistics-recent-menu button:hover,
.statistics-recent-menu button.active {
  background: var(--green-soft);
}

.statistics-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.statistics-metric {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.statistics-metric > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.statistics-metric > strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: 20px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.income-metric {
  border-left-color: var(--green);
}

.income-metric strong {
  color: var(--green);
}

.expense-metric {
  border-left-color: var(--coral);
}

.expense-metric strong {
  color: var(--coral);
}

.balance-metric {
  border-left-color: var(--gold);
}

.trend-panel {
  margin-top: 18px;
  padding: 24px;
}

.trend-heading {
  align-items: flex-start;
}

.trend-insights {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.trend-selection {
  min-width: 118px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.trend-selection[hidden] {
  display: none;
}

#expense-trend-selection-amount {
  margin-left: 6px;
}

.trend-chart-body {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 8px;
}

.trend-y-axis {
  height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 0 1px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.trend-plot {
  position: relative;
  height: 240px;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.trend-plot * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.trend-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.trend-grid-line {
  stroke: #e3e8e5;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.trend-average-line {
  stroke: var(--gold);
  stroke-dasharray: 5 5;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.trend-area {
  fill: rgba(215, 93, 74, 0.1);
}

.trend-line {
  fill: none;
  stroke: var(--coral);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.trend-point {
  position: absolute;
  width: 7px;
  height: 7px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 1px var(--coral);
  transform: translate(-50%, -50%);
}

.trend-point.zero {
  width: 5px;
  height: 5px;
  opacity: 0.35;
}

.trend-point.peak {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 0 2px rgba(215, 93, 74, 0.24);
}

.trend-selection-line,
.trend-selection-marker {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.trend-selection-line {
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(215, 93, 74, 0.58);
  transform: translateX(-50%);
}

.trend-selection-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(215, 93, 74, 0.16);
  transform: translate(-50%, -50%);
}

.trend-selection-marker::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--coral);
}

.trend-plot.selecting .trend-selection-line,
.trend-plot.selecting .trend-selection-marker {
  opacity: 1;
}

.trend-plot.dense .trend-point {
  width: 3px;
  height: 3px;
  border: 0;
  box-shadow: none;
}

.trend-plot.dense .trend-point.peak {
  width: 8px;
  height: 8px;
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--coral);
}

.trend-x-axis {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.chart-panel {
  min-height: 450px;
}

.donut-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(12px, 2vw, 30px);
  min-height: 315px;
}

.donut {
  width: min(100%, 210px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: auto;
  border-radius: 50%;
  background: #edf0ee;
}

.donut svg,
.donut > div {
  grid-area: 1 / 1;
}

.donut svg {
  width: 100%;
  height: 100%;
}

.donut path {
  cursor: pointer;
}

.donut path:hover {
  filter: brightness(0.88);
}

.donut path:focus-visible {
  outline: none;
  stroke: white;
  stroke-width: 4;
}

.donut > div {
  width: 62%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: white;
  z-index: 1;
  pointer-events: none;
}

.donut strong,
.donut span {
  display: block;
  text-align: center;
}

.donut strong {
  max-width: 94px;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
}

.donut span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend {
  display: grid;
  gap: 14px;
}

.legend-item {
  width: 100%;
  padding: 4px 2px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.personal-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(420px, 1.28fr);
  gap: 18px;
}

.account-panel,
.category-manager {
  padding: 24px;
}

.personal-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.feedback-panel {
  margin-top: 18px;
  padding: 24px;
}

.section-count {
  color: var(--muted);
  font-size: 12px;
}

.settings-launch-row {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.settings-launch-row strong,
.settings-launch-row span {
  display: block;
}

.settings-launch-row strong {
  font-size: 14px;
}

.settings-launch-row span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.settings-launch-row button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.budget-form p {
  margin: 10px 0 20px;
  color: var(--muted);
  font-size: 12px;
}

.money-input {
  position: relative;
}

.money-input b {
  position: absolute;
  left: 13px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-50%);
}

.money-input input {
  padding-left: 32px;
}

.quick-manager-list {
  display: grid;
  margin-bottom: 18px;
  border-top: 1px solid var(--line);
}

.quick-manager-row {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.quick-manager-row strong,
.quick-manager-row span {
  display: block;
}

.quick-manager-row strong {
  font-size: 13px;
}

.quick-manager-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.compact-icon-button {
  flex: 0 0 auto;
  color: #89928f;
}

.quick-entry-form {
  display: grid;
  grid-template-columns: 1fr 0.65fr 0.9fr 0.8fr;
  align-items: end;
  gap: 12px;
}

.quick-entry-form .quick-note {
  grid-column: 1 / -2;
}

.quick-entry-form button {
  height: 46px;
}

.password-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
}

.password-form label:first-child {
  grid-column: 1 / -1;
}

.password-form .form-error {
  grid-column: 1 / -1;
  margin: 0;
}

.password-form button {
  grid-column: 2;
  justify-self: end;
}

.settings-dialog-content {
  padding: 26px;
}

.quick-entry-dialog {
  width: min(680px, calc(100% - 28px));
}

.password-dialog {
  width: min(460px, calc(100% - 28px));
}

.feedback-dialog {
  width: min(560px, calc(100% - 28px));
}

.feedback-content-field {
  margin-top: 24px;
}

.feedback-content-field textarea {
  width: 100%;
  min-height: 180px;
  padding: 13px;
  resize: vertical;
  border: 1px solid #cfd7d3;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.65;
}

.feedback-content-field textarea:hover {
  border-color: #aab7b1;
}

.feedback-form-meta {
  min-height: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-form-meta .form-error {
  min-height: 0;
  margin: 0;
}

.feedback-form > .dialog-actions {
  margin-top: 12px;
}

.dialog-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.quick-entry-dialog .quick-manager-list {
  max-height: min(30vh, 230px);
  margin-bottom: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.quick-entry-dialog .quick-manager-list .empty-state {
  min-height: 82px;
}

.quick-entry-dialog .quick-entry-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.quick-entry-dialog .quick-entry-form .quick-note {
  grid-column: 1 / -1;
}

.quick-entry-dialog > .settings-dialog-content > .dialog-actions {
  margin-top: 20px;
}

.password-dialog-form {
  display: block;
}

.password-dialog-fields {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.password-dialog-fields label {
  gap: 6px;
}

.password-dialog-form .form-error {
  min-height: 18px;
  margin: 8px 0 0;
}

.password-dialog-form > .dialog-actions {
  margin-top: 20px;
}

.delete-account-warning {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid #edc0b8;
  border-radius: 6px;
  color: #87382e;
  background: var(--coral-soft);
}

.delete-account-warning strong {
  display: block;
  font-size: 14px;
}

.delete-account-warning p {
  margin: 6px 0 0;
  color: #71443d;
  font-size: 12px;
  line-height: 1.7;
}

.delete-account-dialog .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.data-action-row {
  min-height: 67px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--line);
}

.data-action-row strong,
.data-action-row span {
  display: block;
}

.data-action-row strong {
  font-size: 13px;
}

.data-action-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.data-action-row button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.import-preview {
  padding: 13px;
  border: 1px solid #c9ddd5;
  border-radius: 6px;
  background: var(--green-soft);
}

.import-preview p {
  margin: 0 0 12px;
  color: #38564b;
  font-size: 12px;
  line-height: 1.6;
}

.account-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 24px;
}

.account-avatar {
  position: relative;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--forest);
  cursor: pointer;
  font-size: 20px;
  font-family: inherit;
  font-weight: 800;
}

.account-avatar:disabled {
  cursor: wait;
  opacity: 0.62;
}

.account-avatar-initial,
.account-avatar img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
}

.account-avatar-initial {
  display: grid;
  place-items: center;
}

.account-avatar img {
  object-fit: cover;
}

.account-avatar-edit {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: rgba(18, 40, 34, 0.82);
}

.account-avatar-edit svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
}

.account-meta strong,
.account-meta > span {
  display: block;
}

.account-meta strong {
  max-width: 220px;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-meta > span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.account-details {
  margin: 0;
  border-top: 1px solid var(--line);
}

.account-details > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.account-details dt {
  color: var(--muted);
}

.account-details dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.category-editor + .category-editor {
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.category-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 14px;
}

.category-editor-count {
  color: var(--muted);
  font-size: 12px;
}

.category-editor-meta {
  display: flex;
  align-items: center;
  gap: 9px;
}

.category-add-button {
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.category-add-button .button-icon {
  width: 15px;
  height: 15px;
}

.category-tags {
  min-height: 76px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}

.category-summary-tag {
  height: 32px;
  max-width: 130px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d7dfdb;
  border-radius: 6px;
  color: #3e4b46;
  background: #f8faf9;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-sort-list {
  max-height: min(46vh, 420px);
  display: grid;
  gap: 6px;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #a8b2ae transparent;
  scrollbar-width: thin;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.category-sort-list::-webkit-scrollbar {
  width: 8px;
}

.category-sort-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: #a8b2ae;
  background-clip: padding-box;
}

.category-sort-item {
  min-width: 0;
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border: 1px solid #d7dfdb;
  border-radius: 6px;
  color: #3e4b46;
  background: #f8faf9;
  font-size: 13px;
  cursor: default;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  will-change: transform;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.category-sort-item * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.category-sort-item:focus-visible {
  outline: 3px solid rgba(22, 133, 104, 0.22);
  outline-offset: 2px;
}

.category-sort-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-drag-handle {
  width: fit-content;
  max-width: 100%;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  cursor: grab;
  touch-action: none;
}

.category-drag-handle:active {
  cursor: grabbing;
}

.category-delete-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: #89928f;
  background: transparent;
}

.category-drag-indicator svg,
.category-delete-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.category-drag-indicator {
  width: 20px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #89928f;
}

.category-delete-button:hover {
  color: var(--coral);
  background: var(--coral-soft);
}

.category-drag-source {
  border-color: #b9d8ce;
  border-style: dashed;
  background: #eff6f3;
  box-shadow: inset 0 0 0 1px rgba(22, 133, 104, 0.05);
  pointer-events: none;
}

.category-drag-source > * {
  visibility: hidden;
}

.category-drag-preview {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  border-color: #91cbb7;
  background: var(--surface);
  box-shadow: 0 5px 12px rgba(23, 53, 45, 0.12);
  cursor: grabbing;
  will-change: transform;
  contain: paint;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  opacity: 1;
  transition: box-shadow 120ms ease, border-color 120ms ease;
}

.category-drag-preview-active {
  border-color: #68b79d;
  box-shadow: 0 16px 34px rgba(23, 53, 45, 0.23);
}

.category-drag-preview-active .category-drag-indicator {
  color: var(--green);
}

.category-drag-preview-dropping {
  box-shadow: 0 6px 14px rgba(23, 53, 45, 0.12);
}

body.category-dragging,
body.category-dragging * {
  cursor: grabbing !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

.export-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 18px;
  padding: 22px 24px;
}

.export-panel h2 {
  margin: 0;
  font-size: 18px;
}

.export-action {
  display: flex;
  align-items: center;
  gap: 22px;
}

.export-action strong,
.export-action span {
  display: block;
}

.export-action strong {
  font-size: 13px;
}

.export-action span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.export-action button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#personal-view.active-view {
  min-height: calc(100vh - 210px);
  display: flex;
  flex-direction: column;
}

.personal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 34px;
}

.footer-logout {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  border: 0;
  color: #b94335;
  background: transparent;
  font-weight: 700;
}

.button-icon {
  width: 18px;
  height: 18px;
}

.legend-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-item span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item strong {
  white-space: nowrap;
}

.entry-dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-dialog::backdrop {
  background: rgba(13, 25, 21, 0.56);
}

.transaction-entry-dialog {
  width: min(560px, calc(100% - 28px));
}

.field-label-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-label-actions button {
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  color: var(--green);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.entry-dialog-actions {
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.category-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.category-back-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 0;
  border: 0;
  color: var(--forest);
  background: transparent;
  font-weight: 700;
}

.category-back-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.category-page-range {
  color: var(--muted);
  font-size: 12px;
}

.category-page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin: 20px 0 18px;
}

.category-page-heading h2 {
  margin: 0;
  font-size: 23px;
  overflow-wrap: anywhere;
}

.category-detail-summary {
  max-width: 100%;
  color: var(--coral);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.category-detail-summary.income {
  color: var(--green);
}

.category-page-records {
  min-height: 240px;
}

.avatar-crop-dialog {
  width: min(460px, calc(100% - 28px));
}

.category-dialog {
  width: min(520px, calc(100% - 28px));
}

.category-dialog-fields {
  display: grid;
  gap: 10px;
  margin: 25px 0 4px;
}

.category-dialog-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.category-dialog-add-row button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.category-sort-heading {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.category-sort-heading span {
  color: var(--muted);
  font-size: 12px;
}

.category-dialog .form-error {
  margin-bottom: 4px;
}

.avatar-crop-stage {
  position: relative;
  width: min(100%, 340px);
  aspect-ratio: 1;
  margin: 24px auto 18px;
  overflow: hidden;
  background: #16201d;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.avatar-crop-stage:active {
  cursor: grabbing;
}

.avatar-crop-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.avatar-crop-mask {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(8, 18, 15, 0.5);
  pointer-events: none;
}

.avatar-zoom-control {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  margin: 0 auto 24px;
}

.avatar-zoom-control svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
}

.avatar-zoom-control input[type="range"] {
  width: 100%;
  margin: 0;
  padding: 0;
  accent-color: var(--forest);
}

.avatar-crop-actions {
  margin-top: 0;
}

.entry-dialog > form {
  padding: 26px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 23px;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #53605b;
  background: white;
  font-size: 23px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.type-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 25px 0;
}

.type-switch button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: white;
  font-weight: 700;
}

.type-switch button.expense.active {
  color: var(--coral);
  border-color: #e4a59a;
  background: var(--coral-soft);
}

.type-switch button[data-entry-type="income"].active {
  color: var(--green);
  border-color: #91cbb7;
  background: var(--green-soft);
}

.amount-field {
  margin-bottom: 20px;
}

.amount-field > div {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 68px;
  padding: 0 18px;
  border: 1px solid #cfd7d3;
  border-radius: 6px;
}

.amount-field b {
  font-size: 25px;
}

.amount-field input {
  height: 60px;
  padding: 0;
  border: 0;
  font-size: 30px;
  font-weight: 800;
}

.amount-field input:focus-visible {
  outline: 0;
}

.form-row {
  width: auto;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.form-row label + label {
  margin-top: 0;
}

.entry-dialog label,
.form-row > label {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.entry-dialog input,
.entry-dialog select {
  min-width: 0;
  max-width: 100%;
}

.date-input-wrap input[type="date"] {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.date-input-wrap {
  position: relative;
  width: 100%;
  height: 46px;
  min-width: 0;
  display: block;
  overflow: hidden;
  border: 1px solid #cfd7d3;
  border-radius: 6px;
  background: var(--surface);
}

.date-input-wrap:hover {
  border-color: #aab7b1;
}

.date-input-wrap:focus-within {
  outline: 3px solid rgba(22, 133, 104, 0.22);
  outline-offset: 2px;
}

.date-input-display {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 13px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}

.date-input-icon {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #596660;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

label small {
  color: var(--muted);
  font-weight: 400;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.action-spacer {
  flex: 1;
}

.secondary-button {
  border: 1px solid var(--line);
  color: #45504c;
  background: white;
}

.danger-button {
  border: 1px solid #edc0b8;
  color: #b94335;
  background: var(--coral-soft);
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 100;
  min-width: 180px;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 6px;
  color: white;
  background: #26332e;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -16px);
  transition: opacity 160ms ease, transform 160ms ease;
  text-align: center;
  font-size: 13px;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-nav {
  display: none;
}

@media (max-width: 980px) {
  .statistics-grid,
  .personal-grid,
  .personal-settings-grid {
    grid-template-columns: 1fr;
  }

  .record-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .record-search {
    grid-column: span 2;
  }

  .recent-panel,
  .category-panel,
  .chart-panel,
  .account-panel,
  .category-manager {
    min-height: 0;
  }

  .statistics-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .category-sort-list {
    padding-right: 16px;
  }

  body {
    padding-bottom: 0;
  }

  .auth-screen {
    display: block;
    min-height: 100vh;
    background: white;
  }

  .auth-brand {
    min-height: 220px;
    padding: 38px 28px;
    justify-content: flex-end;
  }

  .auth-brand h1 {
    margin: 18px 0 5px;
    font-size: 42px;
  }

  .auth-brand p {
    font-size: 15px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 21px;
  }

  .auth-panel {
    width: min(100% - 40px, 440px);
    padding: 28px 0 40px;
  }

  .auth-panel h2 {
    margin-bottom: 24px;
    font-size: 24px;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    margin-left: 0;
  }

  .topbar {
    min-height: 68px;
    gap: 12px;
    padding: 10px 16px;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .topbar .eyebrow,
  .topbar-actions .primary-button {
    display: none;
  }

  .month-control input {
    width: 132px;
    height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .content {
    padding: 20px 16px calc(88px + env(safe-area-inset-bottom));
  }

  .overview-insights {
    grid-template-columns: 1fr;
  }

  .overview-insights > div {
    padding: 11px 4px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .overview-insights > div:first-child {
    border-top: 0;
  }

  .overview-planning-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
  }

  .record-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 0;
    background: transparent;
  }

  .record-search {
    grid-column: 1 / -1;
  }

  .filter-reset-button {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
  }

  .period-comparison {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 14px 4px;
  }

  .period-comparison p {
    grid-column: 1 / -1;
    text-align: left;
  }

  .statistics-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 8px;
  }

  .statistics-periods {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .statistics-periods button {
    min-width: 0;
    padding: 0 6px;
  }

  .statistics-navigation {
    width: 100%;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    justify-self: stretch;
    gap: 5px;
  }

  .statistics-nav-button,
  .statistics-recent-toggle {
    height: 42px;
  }

  .statistics-period-label strong {
    font-size: 13px;
  }

  .statistics-date-range {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .statistics-recent-toggle {
    width: 42px;
    justify-content: center;
    padding: 0;
  }

  .statistics-recent-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .statistics-recent-menu {
    width: 174px;
  }

  .statistics-metric {
    padding: 15px 16px;
  }

  .statistics-metric > strong {
    font-size: 18px;
  }

  .trend-panel {
    padding: 20px 16px;
  }

  .trend-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .trend-insights {
    justify-content: flex-start;
  }

  .trend-y-axis,
  .trend-plot {
    height: 210px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .summary-card {
    min-height: 116px;
    padding: 17px;
  }

  .summary-card strong {
    margin-top: 11px;
    font-size: 23px;
  }

  .balance-card {
    grid-column: 1 / -1;
  }

  .recent-panel {
    margin-top: 12px;
  }

  .recent-panel,
  .category-panel,
  .chart-panel,
  .account-panel,
  .category-manager,
  .budget-overview-panel,
  .quick-overview-panel,
  .budget-settings-panel,
  .quick-manager,
  .security-panel,
  .data-panel {
    padding: 19px 16px;
  }

  .quick-entry-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-entry-form .quick-note {
    grid-column: 1 / -1;
  }

  .quick-entry-form button {
    grid-column: 1 / -1;
  }

  .records-panel {
    padding: 6px 14px;
  }

  .income-chart-panel .category-bars {
    grid-template-columns: 1fr;
  }

  .detailed-list .transaction-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .transaction-actions {
    display: grid;
    justify-items: end;
  }

  .donut-layout {
    grid-template-columns: 1fr;
  }

  .donut {
    max-width: 190px;
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    height: 66px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: white;
  }

  .mobile-nav button {
    min-width: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    border: 0;
    color: #78837f;
    background: transparent;
  }

  .mobile-nav button.active {
    color: var(--green);
  }

  .mobile-nav .nav-icon {
    width: 20px;
    height: 20px;
  }

  .mobile-nav small {
    font-size: 10px;
  }

  .mobile-nav .mobile-add {
    width: 48px;
    height: 48px;
    align-self: center;
    justify-self: center;
    border-radius: 50%;
    color: white;
    background: var(--forest);
  }

  .mobile-nav .mobile-add:disabled {
    cursor: default;
    opacity: 0.38;
  }

  .mobile-nav .mobile-add .nav-icon {
    width: 25px;
    height: 25px;
  }

  .personal-footer {
    padding-top: 28px;
  }

  .footer-logout {
    width: 100%;
    justify-content: center;
    min-height: 46px;
    border: 1px solid #edc0b8;
    border-radius: 6px;
    background: var(--coral-soft);
  }

  .export-panel {
    display: block;
    padding: 19px 16px;
  }

  .export-action {
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-top: 20px;
  }
}

@media (max-width: 420px) {
  .summary-card strong {
    font-size: 20px;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .quick-entry-list,
  .record-filters,
  .quick-entry-form,
  .password-form {
    grid-template-columns: 1fr;
  }

  .quick-entry-dialog .quick-entry-form {
    grid-template-columns: 1fr;
  }

  .record-search,
  .quick-entry-form .quick-note,
  .quick-entry-form button,
  .password-form label:first-child,
  .password-form .form-error,
  .password-form button {
    grid-column: 1;
  }

  .password-form button {
    width: 100%;
  }

  .form-row label + label {
    margin-top: 0;
  }

  .entry-dialog > form {
    padding: 21px 18px;
  }

  .export-action {
    display: grid;
    grid-template-columns: 1fr;
  }

  .export-action button {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
