:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-strong: #e9eef2;
  --text: #17212b;
  --text-soft: #566473;
  --text-faint: #748290;
  --border: #dbe2e8;
  --border-strong: #b9c4ce;
  --border-thin: 1px;
  --border-accent: 3px;
  --radius-panel: 8px;
  --radius-control: 6px;
  --radius-compact: 4px;
  --shadow-control: 0 1px 2px rgba(23, 33, 43, 0.08);
  --shadow-panel: 0 1px 2px rgba(23, 33, 43, 0.06), 0 6px 18px rgba(23, 33, 43, 0.04);
  --shadow-chrome: 0 2px 12px rgba(23, 33, 43, 0.08);
  --shadow-raised: 0 12px 32px rgba(13, 25, 36, 0.2);
  --blue: #1769b8;
  --blue-hover: #11599d;
  --blue-soft: #eef6fd;
  --blue-strong: #dcecf9;
  --blue-border: #a8cbe7;
  --coral: #b33d38;
  --coral-hover: #96332f;
  --coral-soft: #fff3f1;
  --coral-strong: #f8dfdc;
  --coral-border: #e7aaa5;
  --green: #18794e;
  --green-hover: #12633f;
  --green-soft: #eef9f2;
  --green-strong: #d9f0e2;
  --green-border: #9fd1b2;
  --teal: #147d86;
  --teal-hover: #0f6970;
  --teal-soft: #edf9fa;
  --teal-strong: #d7f0f1;
  --teal-border: #94cdd1;
  --amber: #91600b;
  --amber-hover: #765006;
  --amber-soft: #fffbf3;
  --amber-strong: #f8edcf;
  --amber-border: #dfbd68;
  --graphite: #4e5b68;
  --graphite-hover: #3e4a56;
  --graphite-soft: #f2f5f7;
  --graphite-strong: #e3e8ec;
  --graphite-border: #bdc6ce;
  --red: var(--coral);
  --red-soft: var(--coral-soft);
  --on-blue: #ffffff;
  --sidebar-width: 216px;
  --topbar-height: 66px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10161b;
  --surface: #171e24;
  --surface-soft: #1d252c;
  --surface-strong: #27313a;
  --text: #edf2f5;
  --text-soft: #b0bbc4;
  --text-faint: #84919c;
  --border: #303a43;
  --border-strong: #4a5863;
  --shadow-control: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.26), 0 6px 18px rgba(0, 0, 0, 0.14);
  --shadow-chrome: 0 2px 14px rgba(0, 0, 0, 0.28);
  --shadow-raised: 0 12px 32px rgba(0, 0, 0, 0.42);
  --blue: #78b6ee;
  --blue-hover: #9ccbf3;
  --blue-soft: #182630;
  --blue-strong: #203743;
  --blue-border: #416b87;
  --coral: #f08a83;
  --coral-hover: #f4aaa5;
  --coral-soft: #302021;
  --coral-strong: #49292a;
  --coral-border: #7a4442;
  --green: #69ce98;
  --green-hover: #8bddae;
  --green-soft: #183126;
  --green-strong: #204735;
  --green-border: #3f7555;
  --teal: #65c7ce;
  --teal-hover: #88d7dc;
  --teal-soft: #162f33;
  --teal-strong: #1d4549;
  --teal-border: #3e7479;
  --amber: #e5b55f;
  --amber-hover: #efc77e;
  --amber-soft: #25241f;
  --amber-strong: #383321;
  --amber-border: #6f603b;
  --graphite: #aebac4;
  --graphite-hover: #cad2d8;
  --graphite-soft: #1c252c;
  --graphite-strong: #2a353e;
  --graphite-border: #47545f;
  --red: var(--coral);
  --red-soft: var(--coral-soft);
  --on-blue: #0d2231;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong,
th,
input[type="number"] {
  font-variant-numeric: tabular-nums;
}

h1 {
  margin-bottom: 1px;
  font-size: 19px;
  font-weight: 750;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  font-weight: 750;
  line-height: 1.3;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.35;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  overflow: visible;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.is-hidden {
  display: none !important;
}

.muted {
  color: var(--text-soft);
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: var(--border-thin) solid var(--border);
  background: var(--surface);
  padding: 16px 12px;
}

.brand-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  margin-bottom: 9px;
  padding: 4px 7px 15px;
  text-align: left;
  cursor: pointer;
}

.brand-mark,
.mobile-brand {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--blue);
  color: var(--on-blue);
  font-size: 18px;
  font-weight: 800;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 750;
}

.brand-copy small {
  color: var(--text-soft);
  font-size: 11px;
}

.desktop-nav {
  display: grid;
  gap: 4px;
}

.nav-item,
.quiet-button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.nav-item {
  color: var(--text-soft);
}

.nav-item .icon {
  color: var(--graphite);
}

.nav-item:hover,
.quiet-button:hover,
.sidebar-links a:hover,
.brand-button:hover {
  background: var(--blue-soft);
}

.nav-item:hover,
.quiet-button:hover {
  border-color: var(--blue-border);
}

.nav-item.is-active {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  box-shadow: inset var(--border-accent) 0 0 var(--blue);
  color: var(--blue);
  font-weight: 700;
}

.nav-item.is-active .icon {
  color: var(--blue);
}

.sidebar-links {
  display: grid;
  gap: 2px;
  margin-top: auto;
}

.sidebar-links a,
.related-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-control);
  color: var(--text-soft);
  padding: 8px 10px;
  text-decoration: none;
}

.sidebar-footer {
  display: grid;
  gap: 5px;
  border-top: var(--border-thin) solid var(--graphite-border);
  margin-top: 12px;
  padding-top: 9px;
}

.sidebar-footer > span {
  color: var(--text-faint);
  padding: 0 10px;
  font-size: 11px;
}

.workspace {
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  border-bottom: var(--border-thin) solid var(--border);
  background: var(--surface);
  padding: 9px 28px;
  box-shadow: var(--shadow-chrome);
}

.mobile-brand {
  display: none;
  cursor: pointer;
}

.topbar-heading {
  min-width: 0;
}

.topbar-heading p {
  overflow: hidden;
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.sync-state.is-ok .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.sync-state.is-error .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.main-content {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 26px 30px 56px;
}

.view {
  display: none;
  min-width: 0;
}

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

.notice,
.form-error {
  border: var(--border-thin) solid var(--red);
  border-radius: var(--radius-control);
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 12px;
  box-shadow: var(--shadow-control);
}

.notice {
  margin-bottom: 16px;
}

.section-title,
.page-heading {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-heading {
  align-items: center;
  margin: 0 0 18px;
}

.section-title {
  align-items: center;
  margin-bottom: 14px;
}

.section-title h2,
.section-title h3,
.page-heading h2 {
  margin: 0;
}

.section-kicker {
  margin: 0 0 2px;
  color: var(--graphite);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}

.record-workspace {
  border: var(--border-thin) solid var(--blue-border);
  border-top: var(--border-accent) solid var(--blue);
  border-radius: var(--radius-panel);
  background: var(--blue-soft);
  padding: 20px 24px 24px;
  box-shadow: var(--shadow-panel);
}

.record-title {
  border-bottom: var(--border-thin) solid var(--blue-border);
  margin-bottom: 17px;
  padding-bottom: 13px;
}

.record-title .section-kicker {
  color: var(--blue);
}

.cash-inline {
  min-width: 0;
  color: var(--text-soft);
  font-size: 12px;
  text-align: right;
}

.cash-inline strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--green);
  font-size: 18px;
  font-weight: 750;
}

.record-form {
  display: grid;
  max-width: 820px;
  gap: 16px;
}

.type-segment {
  display: grid;
  width: 220px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: var(--border-thin) solid var(--blue-border);
  border-radius: var(--radius-control);
  background: var(--surface);
  margin: 0;
  padding: 3px;
  box-shadow: var(--shadow-control);
}

.type-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-segment label {
  min-width: 0;
  border-radius: var(--radius-compact);
  color: var(--text-soft);
  padding: 7px 12px;
  text-align: center;
  cursor: pointer;
}

.type-segment input:checked + label {
  font-weight: 700;
}

#recordTypeExpense:checked + label,
#editTypeExpense:checked + label {
  background: var(--coral-strong);
  box-shadow: inset 0 0 0 var(--border-thin) var(--coral-border);
  color: var(--coral);
}

#recordTypeIncome:checked + label,
#editTypeIncome:checked + label {
  background: var(--green-strong);
  box-shadow: inset 0 0 0 var(--border-thin) var(--green-border);
  color: var(--green);
}

.type-segment input:focus-visible + label {
  outline: 3px solid var(--blue);
  outline-offset: 1px;
}

.amount-field,
.field,
.date-field,
.category-field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--text-soft);
  font-size: 12px;
}

.amount-field {
  max-width: 520px;
  gap: 4px;
}

.amount-field > span:first-child {
  color: var(--blue);
  font-weight: 700;
}

.amount-input-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--blue-border);
  color: var(--text);
  padding: 1px 0 7px;
}

.amount-input-wrap > span {
  font-size: 28px;
  font-weight: 700;
}

.amount-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 42px;
  font-weight: 750;
  line-height: 1.15;
}

.amount-input-wrap:focus-within {
  border-color: var(--blue);
}

.amount-input-wrap input::placeholder {
  color: var(--text-faint);
  opacity: 0.55;
}

.field input,
.field select,
.date-field input,
.category-field select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-control);
  outline: 0;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
  box-shadow: var(--shadow-control);
}

.field-prominent input {
  min-height: 48px;
  font-size: 16px;
}

.field small {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 400;
}

.expected-line {
  display: flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: var(--border-thin) solid var(--blue-border);
  color: var(--text-soft);
}

.expected-area {
  min-width: 0;
}

.expected-suggestions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  color: var(--graphite);
  padding-top: 3px;
  font-size: 11px;
}

.expected-suggestions[hidden] {
  display: none;
}

.expected-suggestion-actions {
  display: flex;
  min-width: 0;
  flex: 1 1 190px;
  flex-wrap: wrap;
  gap: 2px 12px;
}

.expected-suggestions button {
  min-width: 0;
  min-height: 30px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  padding: 2px 0;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.expected-suggestions button:hover {
  text-decoration: underline;
}

.expected-label {
  min-width: 0;
  white-space: nowrap;
  font-weight: 650;
}

.expected-label small {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 400;
}

.expected-entry {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  color: var(--text-soft);
}

.expected-entry input {
  width: 112px;
  min-width: 0;
  min-height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 5px 0;
  font-size: 18px;
  font-weight: 700;
  text-align: right;
}

.expected-line:focus-within {
  border-bottom-color: var(--blue);
  box-shadow: 0 1px 0 var(--blue);
}

.field input:focus,
.field select:focus,
.date-field input:focus,
.category-field select:focus,
.search-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-strong), var(--shadow-control);
}

.amount-input-wrap input:focus-visible,
.expected-entry input:focus-visible,
.search-field input:focus-visible {
  outline: 0;
}

.record-detail-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(240px, 1.3fr);
  gap: 14px;
  align-items: end;
}

.comparison-box {
  display: flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  color: var(--text-soft);
  padding: 0 0 1px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.comparison-box.is-positive {
  color: var(--green);
}

.comparison-box.is-negative {
  color: var(--red);
}

.field-label {
  color: var(--text-soft);
  font-size: 12px;
}

.category-row {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.category-chips,
.preset-group,
.primary-presets {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.category-chips button,
.preset-group button,
.primary-presets button,
.theme-options button {
  min-height: 36px;
  border: var(--border-thin) solid var(--blue-border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-soft);
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: var(--shadow-control);
}

.category-chips button:hover,
.preset-group button:hover,
.primary-presets button:hover,
.category-chips button.is-active,
.theme-options button.is-active {
  border-color: var(--blue);
  background: var(--blue-strong);
  color: var(--blue);
}

.category-field select {
  width: 140px;
}

.record-options {
  border-top: var(--border-thin) solid var(--blue-border);
  padding-top: 2px;
}

.record-options[open] {
  border: var(--border-thin) solid var(--blue-border);
  border-left: var(--border-accent) solid var(--blue);
  border-radius: var(--radius-control);
  background: var(--blue-strong);
  padding: 0 12px 12px;
}

.record-options summary {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
  cursor: pointer;
}

.record-options summary small {
  overflow-wrap: anywhere;
  color: var(--blue);
  font-weight: 700;
  text-align: right;
}

.record-options-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 14px;
  align-items: end;
  padding-top: 12px;
}

.record-options-body .category-field {
  grid-column: 1 / -1;
}

.record-submit {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  font-size: 15px;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-control);
  padding: 8px 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-control);
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--on-blue);
}

.primary-button:hover {
  border-color: var(--blue-hover);
  background: var(--blue-hover);
}

.secondary-button {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue);
}

.danger-button {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

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

.button-link {
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: var(--border-thin) solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--shadow-control);
}

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

.text-button {
  border: 0;
  border-radius: var(--radius-compact);
  background: transparent;
  color: var(--blue);
  padding: 4px;
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.today-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: var(--border-thin) solid var(--border);
  border-radius: var(--radius-panel);
  margin-top: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}

.today-metric {
  min-width: 0;
  border-left: var(--border-thin) solid var(--border);
  padding: 15px 18px;
}

.today-metric:nth-of-type(1) {
  background: var(--coral-soft);
  box-shadow: inset 0 var(--border-accent) 0 var(--coral);
}

.today-metric:nth-of-type(2) {
  background: var(--surface);
  box-shadow: inset 0 var(--border-accent) 0 var(--blue-border);
}

.today-metric:nth-of-type(3) {
  background: var(--green-soft);
  box-shadow: inset 0 var(--border-accent) 0 var(--green);
}

.today-metric:nth-of-type(4) {
  background: var(--graphite-soft);
  box-shadow: inset 0 var(--border-accent) 0 var(--graphite-border);
}

.today-metric:first-of-type {
  border-left: 0;
}

.today-metric span,
.today-metric strong {
  display: block;
}

.today-metric span {
  color: var(--text-soft);
  font-size: 11px;
}

.today-metric strong {
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

#todayExpense {
  color: var(--coral);
}

#todayCash {
  color: var(--green);
}

.records-band {
  overflow: hidden;
  border: var(--border-thin) solid var(--blue-border);
  border-radius: var(--radius-panel);
  margin-top: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}

.records-band > .section-title {
  border-bottom: var(--border-thin) solid var(--blue-border);
  margin-bottom: 0;
  background: var(--blue-soft);
  padding: 11px 14px;
}

.transaction-list,
.mobile-record-list {
  display: grid;
}

.transaction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-top: var(--border-thin) solid var(--border);
  padding: 12px 8px;
}

.transaction-row:has(.amount-expense) {
  border-left: var(--border-accent) solid var(--coral-border);
}

.transaction-row:has(.amount-income) {
  border-left: var(--border-accent) solid var(--green-border);
}

.transaction-row:first-child {
  border-top: 0;
}

.transaction-main,
.transaction-main > div {
  min-width: 0;
}

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

.transaction-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-main small {
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.transaction-values {
  min-width: 0;
  text-align: right;
}

.transaction-values strong,
.transaction-values small {
  display: block;
  white-space: nowrap;
}

.transaction-values small {
  color: var(--text-soft);
}

.amount-income,
.comparison-positive {
  color: var(--green) !important;
}

.amount-expense,
.comparison-negative {
  color: var(--red) !important;
}

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

.row-action {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: var(--radius-compact);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.row-action:hover {
  background: var(--surface-strong);
  color: var(--blue);
}

.row-action.delete:hover {
  background: var(--red-soft);
  color: var(--red);
}

.empty-state {
  color: var(--text-soft);
  padding: 22px 8px;
  text-align: center;
}

.section-band {
  min-width: 0;
  border: var(--border-thin) solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  padding: 18px 20px;
  box-shadow: var(--shadow-panel);
}

.ledger-section {
  border-color: var(--blue-border);
  border-top: var(--border-accent) solid var(--blue);
  background: var(--blue-soft);
}

[data-view="ledger"] .section-kicker {
  color: var(--blue);
}

.ledger-filters,
.filter-row {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.search-field {
  display: flex;
  min-width: min(280px, 100%);
  min-height: 42px;
  flex: 1 1 260px;
  align-items: center;
  gap: 8px;
  border: var(--border-thin) solid var(--blue-border);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: 0 10px;
  box-shadow: var(--shadow-control);
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.compact-field {
  width: 138px;
}

.ledger-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  border-bottom: var(--border-thin) solid var(--blue-border);
  margin: 14px 0 0;
  padding: 0 0 10px;
  color: var(--text-soft);
  font-size: 12px;
}

.ledger-stats strong {
  color: var(--text);
}

.ledger-stats span:first-child strong {
  color: var(--blue);
}

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

.ledger-section .table-scroll {
  border: var(--border-thin) solid var(--blue-border);
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: var(--shadow-control);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  min-width: 0;
  border-bottom: var(--border-thin) solid var(--border);
  padding: 10px 11px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--graphite-soft);
  color: var(--graphite);
  font-size: 11px;
}

.data-table tbody tr:hover {
  background: var(--blue-soft);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table td.note-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.align-right {
  text-align: right !important;
}

.mobile-record-list {
  display: none;
}

.type-badge,
.health-badge,
.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: var(--radius-compact);
  background: var(--surface-strong);
  color: var(--text-soft);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
}

.type-badge.income,
.health-badge.is-ok {
  background: var(--green-strong);
  color: var(--green);
}

.type-badge.expense,
.health-badge.is-error {
  background: var(--coral-strong);
  color: var(--red);
}

[data-view="analytics"] .section-kicker {
  color: var(--teal);
}

[data-view="analytics"] .section-band {
  border-color: var(--teal-border);
  border-top: var(--border-accent) solid var(--teal);
  background: var(--teal-soft);
}

[data-view="analytics"] .section-title h3 {
  color: var(--teal);
}

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

.period-column {
  min-width: 0;
  border-left: var(--border-thin) solid var(--teal-border);
  padding: 3px 18px;
}

.period-column:first-child {
  border-left: 0;
  padding-left: 0;
}

.period-column:last-child {
  padding-right: 0;
}

.period-column h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--teal);
}

.period-values {
  display: grid;
  gap: 8px;
}

.period-values div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.period-values span {
  color: var(--text-soft);
}

.period-values strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
  margin-top: 16px;
}

.chart-section {
  min-height: 310px;
}

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

#categoryChart {
  display: block;
  width: 170px;
  height: 170px;
}

.legend-list {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.legend-row + .legend-row {
  border-top: var(--border-thin) solid var(--teal-border);
  padding-top: 7px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-compact);
}

.chart-wrap {
  position: relative;
  min-height: 220px;
}

#cashflowChart {
  display: block;
  width: 100%;
  height: 220px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-soft);
}

.chart-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 18px;
  border-top: var(--border-thin) solid var(--teal-border);
  margin-top: 6px;
  padding-top: 9px;
  color: var(--text-soft);
  font-size: 11px;
}

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

.checkpoint-item {
  min-width: 0;
  border: var(--border-thin) solid var(--amber-border);
  border-top: var(--border-accent) solid var(--amber);
  border-radius: var(--radius-panel);
  background: var(--amber-soft);
  padding: 14px 18px 16px;
  box-shadow: var(--shadow-panel);
}

.checkpoint-item header,
.checkpoint-item footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.checkpoint-item header {
  color: var(--text-soft);
  font-size: 12px;
}

.checkpoint-item > strong {
  display: block;
  margin: 5px 0 10px;
  overflow-wrap: anywhere;
  color: var(--green);
  font-size: 26px;
}

.checkpoint-item footer {
  border-top: var(--border-thin) solid var(--amber-border);
  padding-top: 9px;
  color: var(--text-soft);
  font-size: 11px;
}

.actual-plan-note {
  border: var(--border-thin) solid var(--amber-border);
  border-left: var(--border-accent) solid var(--amber);
  border-radius: var(--radius-control);
  margin: 14px 0;
  background: var(--amber-soft);
  color: var(--text-soft);
  padding: 10px 12px;
  box-shadow: var(--shadow-control);
}

.actual-plan-note strong {
  color: var(--text);
}

.plan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.plan-aside {
  display: grid;
  gap: 14px;
}

[data-view="plan"] .section-kicker,
[data-view="plan"] .section-title h3 {
  color: var(--amber);
}

.plan-timeline-band,
.plan-totals-band,
.plan-assumptions-band {
  border-color: var(--amber-border);
  border-top: var(--border-accent) solid var(--amber);
  background: var(--amber-soft);
}

.check-field {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: normal;
}

.check-field input {
  accent-color: var(--amber);
}

.timeline {
  display: grid;
}

.timeline-day {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  border-top: var(--border-thin) solid var(--amber-border);
  padding: 12px 0;
}

.timeline-day:first-child {
  border-top: 0;
}

.timeline-date {
  color: var(--text-soft);
  font-size: 11px;
}

.timeline-date strong {
  display: block;
  color: var(--amber);
  font-size: 15px;
}

.timeline-events {
  display: grid;
  gap: 8px;
}

.timeline-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.timeline-event div {
  min-width: 0;
}

.timeline-event small {
  display: block;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.definition-list {
  display: grid;
  margin: 0;
}

.definition-list div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-top: var(--border-thin) solid var(--border);
  padding: 9px 0;
}

.definition-list div:first-child {
  border-top: 0;
}

.definition-list dt {
  color: var(--text-soft);
}

.definition-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-weight: 700;
}

.risk-band {
  border-color: var(--amber-border);
  border-top: var(--border-accent) solid var(--amber);
  background: var(--amber-soft);
}

.risk-value {
  display: block;
  color: var(--red);
  font-size: 23px;
}

.risk-band p {
  margin: 5px 0 0;
  color: var(--text-soft);
}

.assumption-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 19px;
  color: var(--text-soft);
}

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

[data-view="data"] .section-kicker,
[data-view="data"] .section-title h3 {
  color: var(--graphite);
}

.data-layout .section-band {
  border-color: var(--graphite-border);
  border-top: var(--border-accent) solid var(--graphite);
  background: var(--graphite-soft);
}

.data-status-band {
  box-shadow: inset var(--border-accent) 0 0 var(--green-border), var(--shadow-panel);
}

.data-exports-band {
  box-shadow: inset var(--border-accent) 0 0 var(--blue-border), var(--shadow-panel);
}

.export-list {
  display: grid;
}

.export-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: var(--border-thin) solid var(--graphite-border);
  border-radius: 0;
  padding: 10px 2px;
  text-decoration: none;
}

.export-list a:first-child {
  border-top: 0;
}

.export-list a:hover {
  background: var(--graphite-strong);
  color: var(--graphite-hover);
}

.export-list strong,
.export-list small {
  display: block;
}

.export-list small {
  color: var(--text-soft);
}

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

.related-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border-top: var(--border-thin) solid var(--graphite-border);
  margin-top: 14px;
  padding-top: 12px;
}

.entry-dialog {
  width: min(600px, calc(100vw - 30px));
  max-height: min(760px, calc(100dvh - 30px));
  overflow: hidden;
  border: var(--border-thin) solid var(--blue-border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow-raised);
}

.entry-dialog::backdrop {
  background: rgba(0, 0, 0, 0.44);
}

.dialog-shell {
  display: flex;
  max-height: inherit;
  flex-direction: column;
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
}

.dialog-header {
  border-top: var(--border-accent) solid var(--blue);
  border-bottom: var(--border-thin) solid var(--blue-border);
  background: var(--blue-soft);
  padding-top: 12px;
}

.dialog-header .section-kicker {
  color: var(--blue);
}

.dialog-header h2 {
  margin: 0;
}

.dialog-body {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding: 18px;
}

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

.dialog-footer {
  border-top: var(--border-thin) solid var(--border);
  background: var(--graphite-soft);
}

.dialog-footer > div {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(380px, calc(100vw - 32px));
  transform: translateY(16px);
  border: var(--border-thin) solid var(--blue-border);
  border-left: var(--border-accent) solid var(--blue);
  border-radius: var(--radius-control);
  background: #25313a;
  color: #ffffff;
  opacity: 0;
  padding: 10px 13px;
  pointer-events: none;
  box-shadow: var(--shadow-raised);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1080px) {
  :root {
    --sidebar-width: 196px;
  }

  .main-content {
    padding-right: 22px;
    padding-left: 22px;
  }

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

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

@media (max-width: 900px) {
  :root {
    --topbar-height: 60px;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    margin-left: 0;
  }

  .topbar {
    padding: 8px 14px;
  }

  .mobile-brand {
    display: grid;
    width: 32px;
    height: 32px;
    margin-right: 9px;
    font-size: 16px;
  }

  .main-content {
    padding: 16px 16px calc(92px + env(safe-area-inset-bottom));
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top: var(--border-thin) solid var(--blue-border);
    background: var(--surface);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-chrome);
  }

  .mobile-nav button {
    display: grid;
    min-width: 0;
    min-height: 48px;
    place-items: center;
    gap: 1px;
    border: var(--border-thin) solid transparent;
    border-radius: var(--radius-control);
    background: transparent;
    color: var(--text-soft);
    padding: 4px 1px;
  }

  .mobile-nav button .icon {
    width: 19px;
    height: 19px;
  }

  .mobile-nav button small {
    font-size: 10px;
  }

  .mobile-nav button.is-active {
    border-color: var(--blue-border);
    background: var(--blue-soft);
    box-shadow: inset 0 var(--border-accent) 0 var(--blue);
    color: var(--blue);
    font-weight: 700;
  }

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

@media (max-width: 700px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .record-workspace {
    padding: 16px 16px 18px;
  }

  .amount-input-wrap input {
    font-size: 36px;
  }

  .record-detail-grid,
  .record-options-body {
    grid-template-columns: 1fr;
  }

  .record-detail-grid {
    gap: 4px;
  }

  .record-detail-grid .comparison-box {
    min-height: 32px;
  }

  .record-options-body .category-field {
    grid-column: auto;
  }

  .date-field {
    width: 150px;
  }

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

  .today-metric:nth-of-type(3) {
    border-left: 0;
  }

  .today-metric:nth-of-type(n + 3) {
    border-top: var(--border-thin) solid var(--border);
  }

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

  .period-column,
  .period-column:first-child,
  .period-column:last-child {
    border-top: var(--border-thin) solid var(--border);
    border-left: 0;
    padding: 13px 0;
  }

  .period-column:first-child {
    border-top: 0;
    padding-top: 0;
  }

  .plan-aside {
    grid-template-columns: 1fr;
  }

  .desktop-table-wrap {
    display: none;
  }

  .mobile-record-list {
    display: grid;
  }

  .mobile-record-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    border-top: var(--border-thin) solid var(--border);
    padding: 12px 8px;
  }

  .mobile-record-card:has(.amount-expense) {
    border-left: var(--border-accent) solid var(--coral-border);
  }

  .mobile-record-card:has(.amount-income) {
    border-left: var(--border-accent) solid var(--green-border);
  }

  .mobile-record-card:first-child {
    border-top: 0;
  }

  .mobile-record-card > div {
    min-width: 0;
  }

  .mobile-record-card strong,
  .mobile-record-card small {
    display: block;
    overflow-wrap: anywhere;
  }

  .mobile-record-card small {
    color: var(--text-soft);
  }

  .mobile-record-card .card-value {
    text-align: right;
  }

  .mobile-record-card .row-actions {
    grid-column: 1 / -1;
    justify-self: end;
  }

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

  .ledger-filters .search-field,
  .ledger-filters .secondary-button {
    grid-column: 1 / -1;
  }

  .compact-field {
    width: auto;
  }

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

  .responsive-title {
    align-items: stretch;
    flex-direction: column;
  }

  .entry-dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - env(safe-area-inset-top));
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  }

  .dialog-footer {
    padding-bottom: calc(13px + env(safe-area-inset-bottom));
  }

  .toast {
    right: 14px;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .topbar-actions .sync-state {
    display: none;
  }

  .main-content {
    padding-top: 8px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .record-workspace {
    padding: 12px 14px 14px;
  }

  .record-title {
    align-items: flex-start;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  .record-form {
    gap: 8px;
  }

  .cash-inline {
    max-width: 130px;
  }

  .type-segment {
    width: 100%;
  }

  .type-segment label {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .primary-presets button {
    min-height: 34px;
  }

  .amount-input-wrap input {
    font-size: 32px;
  }

  .amount-input-wrap {
    padding-bottom: 4px;
  }

  .field-prominent input {
    min-height: 44px;
  }

  .expected-line {
    min-height: 38px;
  }

  .expected-entry input {
    min-height: 38px;
  }

  .record-options summary {
    min-height: 36px;
  }

  .record-submit {
    min-height: 46px;
  }

  .category-row {
    align-items: stretch;
    flex-direction: column;
  }

  .category-field select,
  .date-field {
    width: 100%;
  }

  .today-metric {
    padding: 13px 12px;
  }

  .today-metric strong {
    font-size: 16px;
  }

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

  .transaction-row .row-actions {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .section-band {
    padding: 16px 13px;
  }

  .category-chart-layout {
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 10px;
  }

  #categoryChart {
    width: 120px;
    height: 120px;
  }

  .checkpoint-item > strong {
    font-size: 23px;
  }

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

  .dialog-footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .dialog-footer > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
