:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-elevated: #11182b;
  --surface: rgba(19, 27, 47, 0.92);
  --surface-strong: #171f35;
  --surface-muted: #202a42;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.16);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --income: #22c55e;
  --income-soft: rgba(34, 197, 94, 0.14);
  --expense: #fb7185;
  --expense-soft: rgba(251, 113, 133, 0.14);
  --danger: #fb7185;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --nav-height: 76px;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-viewport-height: 100dvh;
  --app-viewport-top: 0px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f9;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --surface-muted: #eef1f6;
  --text: #172033;
  --text-muted: #64748b;
  --line: rgba(71, 85, 105, 0.14);
  --shadow: 0 18px 45px rgba(30, 41, 59, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 88% -10%, var(--accent-soft), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 180ms ease, color 180ms ease;
}

body.is-reordering {
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

button,
select,
input[type="color"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 18px calc(var(--nav-height) + 36px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 78px;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.brand-button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 22%, rgba(0, 0, 0, .34));
  object-fit: cover;
  object-position: center;
}

.brand-logo.large {
  width: 62px;
  height: 62px;
  flex-basis: 62px;
  border-radius: 20px;
}

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

.brand-copy strong {
  overflow: hidden;
  font-size: 16px;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-chip,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.period-chip {
  display: inline-flex;
  max-width: 150px;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  overflow: hidden;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 14px;
  font-size: 18px;
}

.main-content {
  padding: 18px 0 0;
}

.tab-panel {
  animation: panel-in 220ms ease both;
}

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

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 2px 22px;
}

.section-heading h1,
.dialog-header h1 {
  margin: 2px 0 0;
  font-size: clamp(27px, 6.8vw, 38px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.section-heading p:not(.eyebrow) {
  max-width: 560px;
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.save-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--income-soft);
  color: var(--income);
  font-size: 11px;
  font-weight: 700;
  transition: opacity 160ms ease;
}

.save-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.save-badge.is-saving {
  opacity: 0.55;
}

.surface,
.balance-card,
.metric-card,
.category-card,
.section-total {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.balance-card {
  position: relative;
  display: grid;
  min-height: 176px;
  align-content: end;
  gap: 7px;
  margin-bottom: 14px;
  padding: 26px;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 32%, var(--surface-strong)), var(--surface-strong) 72%);
}

.balance-card::after {
  position: absolute;
  top: -85px;
  right: -62px;
  width: 220px;
  height: 220px;
  border: 1px solid color-mix(in srgb, white 15%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 28px color-mix(in srgb, white 3%, transparent), 0 0 0 60px color-mix(in srgb, white 2%, transparent);
  content: "";
}

.balance-card span,
.balance-card small {
  position: relative;
  z-index: 1;
  color: color-mix(in srgb, var(--text) 72%, var(--text-muted));
}

.balance-card strong {
  position: relative;
  z-index: 1;
  font-size: clamp(36px, 10vw, 54px);
  font-weight: 820;
  letter-spacing: -0.055em;
}

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

.capital-metric {
  grid-column: 1 / -1;
  background: linear-gradient(145deg, var(--accent-soft), var(--surface) 64%);
}

.capital-metric .metric-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.metric-card {
  display: grid;
  min-width: 0;
  gap: 7px;
  padding: 18px;
  border-radius: var(--radius-lg);
  color: var(--text);
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease;
}

.metric-card:active {
  transform: scale(0.985);
}

.metric-card span:not(.metric-icon) {
  color: var(--text-muted);
  font-size: 12px;
}

.metric-card strong {
  overflow: hidden;
  font-size: clamp(19px, 5.8vw, 28px);
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  font-size: 19px;
}

.income-metric {
  background: linear-gradient(145deg, var(--income-soft), var(--surface) 64%);
}

.income-metric .metric-icon {
  background: var(--income-soft);
  color: var(--income);
}

.expense-metric {
  background: linear-gradient(145deg, var(--expense-soft), var(--surface) 64%);
}

.expense-metric .metric-icon {
  background: var(--expense-soft);
  color: var(--expense);
}

.insights-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.insight-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
}

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

.insight-copy > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.insight-copy strong,
.insight-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-copy strong {
  font-size: 13px;
}

.insight-copy small {
  color: var(--text-muted);
  font-size: 10px;
}

.insight-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 850;
}

.ratio-icon {
  background: var(--expense-soft);
  color: var(--expense);
}

.insight-percent {
  align-self: center;
  font-size: 13px;
  font-weight: 800;
}

.progress-track {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 58%, white));
  transition: width 360ms cubic-bezier(.22, 1, .36, 1);
}

.ratio-track > span {
  background: linear-gradient(90deg, var(--income), var(--expense));
}

.insight-row.is-alert .insight-percent {
  color: var(--expense);
}

.chart-card,
.quick-card {
  margin-bottom: 16px;
  padding: 20px;
  border-radius: var(--radius-xl);
}

.card-heading,
.chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-heading h2 {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: -0.025em;
}

.segmented {
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
}

.segment {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.segment.active {
  background: var(--surface-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
  color: var(--text);
}

.chart-wrap {
  position: relative;
  min-height: 290px;
  margin-top: 18px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 290px !important;
}

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

.soft-button,
.primary,
.secondary,
.text-button,
.danger-text {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 15px;
  border-radius: 14px;
  font-weight: 730;
  transition: transform 110ms ease, filter 140ms ease, background 140ms ease;
}

.soft-button:active,
.primary:active,
.secondary:active,
.text-button:active {
  transform: scale(0.98);
}

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

.expense-soft {
  background: var(--expense-soft);
  color: var(--expense);
}

.primary {
  background: var(--accent);
  box-shadow: 0 9px 24px color-mix(in srgb, var(--accent) 24%, transparent);
  color: white;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text);
}

.text-button,
.danger-text {
  background: transparent;
  color: var(--text-muted);
}

.danger-text {
  width: 100%;
  margin-top: 10px;
  color: var(--danger);
}

.compact {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
}

.wide {
  width: 100%;
}

.section-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
}

.section-total span {
  color: var(--text-muted);
  font-size: 13px;
}

.section-total strong {
  font-size: 22px;
  letter-spacing: -0.035em;
}

.income-total {
  border-color: color-mix(in srgb, var(--income) 34%, var(--line));
  background: linear-gradient(135deg, var(--income-soft), var(--surface) 70%);
}

.expense-total {
  border-color: color-mix(in srgb, var(--expense) 34%, var(--line));
  background: linear-gradient(135deg, var(--expense-soft), var(--surface) 70%);
}

.capital-total {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
}

.transfer-main-button {
  margin-bottom: 14px;
}

.capital-list,
.transfer-list {
  display: grid;
  gap: 10px;
}

.capital-list:not(:empty) {
  margin-bottom: 16px;
}

.capital-account-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--accent-soft), var(--surface) 68%);
  box-shadow: var(--shadow);
}

.capital-account-head,
.capital-account-actions,
.capital-account-meta,
.transfer-row {
  display: flex;
  min-width: 0;
  align-items: center;
}

.capital-account-head {
  justify-content: space-between;
  gap: 12px;
}

.capital-account-title {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.capital-account-title strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capital-account-title small,
.capital-account-meta,
.available-note,
.muted-empty,
.transfer-row small {
  color: var(--text-muted);
  font-size: 11px;
}

.capital-account-balance {
  font-size: 24px;
  font-weight: 820;
  letter-spacing: -.04em;
}

.capital-account-actions {
  flex: 0 0 auto;
  gap: 6px;
}

.capital-account-actions button {
  min-height: 36px;
  padding: 7px 10px;
}

.capital-account-meta {
  flex-wrap: wrap;
  gap: 7px 12px;
}

.account-progress {
  display: grid;
  gap: 6px;
}

.account-progress > div {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 10px;
}

.transfer-history-card {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius-lg);
}

.transfer-list {
  margin-top: 14px;
}

.transfer-row {
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

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

.transfer-route {
  display: grid;
  min-width: 0;
  gap: 3px;
}

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

.transfer-amount {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.muted-empty {
  margin: 14px 0 0;
}

.category-list {
  display: grid;
  gap: 12px;
}

.category-card {
  position: relative;
  padding: 15px;
  border-radius: var(--radius-lg);
  transition: opacity 130ms ease, transform 130ms ease, border-color 130ms ease;
}

.category-card.is-dragging {
  z-index: 3;
  opacity: 0.56;
  transform: scale(0.99);
}

.category-card.drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.category-card.over-limit {
  border-color: color-mix(in srgb, var(--expense) 65%, var(--line));
  background: linear-gradient(145deg, var(--expense-soft), var(--surface) 62%);
}

.category-topline {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
}

.drag-handle,
.delete-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
}

.drag-handle {
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: grab;
  font-size: 20px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.delete-button {
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
}

.delete-button:active {
  background: var(--expense-soft);
  color: var(--expense);
}

.category-name-input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 760;
  outline: 0;
}

.category-name-input::placeholder {
  color: var(--text-muted);
  font-weight: 560;
}

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

.field-block {
  display: grid;
  min-width: 0;
  gap: 6px;
}

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

.field-block > span,
.control > span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 680;
}

.input-shell {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-muted);
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.input-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-shell input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.input-affix {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.comment-input {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: var(--surface-muted);
  color: var(--text);
}

.comment-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-error {
  border-color: var(--expense) !important;
  box-shadow: 0 0 0 3px var(--expense-soft) !important;
}

.percent-error-message,
.form-error {
  margin: 2px 0 0;
  color: var(--expense);
  font-size: 11px;
  line-height: 1.35;
}

.limit-warning {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  color: var(--expense);
  font-size: 11px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  min-height: 230px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}

.empty-state > span {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--surface-muted);
  font-size: 23px;
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state h2 {
  color: var(--text);
  font-size: 17px;
}

.empty-state p {
  font-size: 13px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  min-height: 0;
  border: 0;
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 12px;
  padding: 19px;
  border-radius: var(--radius-lg);
}

.hero-info {
  align-items: center;
  padding: 23px;
  background: linear-gradient(145deg, var(--accent-soft), var(--surface) 66%);
}

.info-card h2,
.info-card p {
  margin: 0;
}

.info-card h2 {
  margin-bottom: 6px;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.info-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.52;
}

.info-card button {
  margin-top: 12px;
}

.install-status {
  display: block;
  margin-top: 10px;
  color: var(--income);
  font-size: 10px;
  font-weight: 760;
}

.info-icon,
.settings-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.info-icon {
  width: 42px;
  height: 42px;
}

.creator-card {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 30px 20px 8px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.creator-card strong {
  color: var(--text);
  font-size: 17px;
}

.creator-card a {
  color: var(--accent);
  text-decoration: none;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: max(12px, calc((100vw - 920px) / 2 + 12px));
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: max(12px, calc((100vw - 920px) / 2 + 12px));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: var(--nav-height);
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.nav-item {
  display: grid;
  min-width: 0;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 5px 3px;
  border-radius: 18px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
}

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

.nav-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  font-size: 20px;
  font-weight: 780;
}

dialog {
  padding: 0;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.50);
  color: var(--text);
}

dialog:not([open]) {
  display: none;
}

dialog::backdrop {
  background: rgba(3, 7, 18, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet-dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: min(88vh, 860px);
  overflow: hidden;
  border-radius: 28px;
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h1 {
  font-size: 26px;
}

.dialog-footer {
  border-top: 1px solid var(--line);
}

.dialog-footer > span {
  color: var(--text-muted);
  font-size: 12px;
}

.settings-body {
  max-height: calc(min(88vh, 860px) - 146px);
  padding: 6px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.settings-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-section-title {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 16px;
}

.settings-icon {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.settings-section-title h2,
.settings-section-title p {
  margin: 0;
}

.settings-section-title h2 {
  font-size: 15px;
}

.settings-section-title p,
.settings-note {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

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

.control {
  display: grid;
  min-width: 0;
  gap: 6px;
}

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

.control input,
.control select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: var(--surface-muted);
  color: var(--text);
}

.control input:focus,
.control select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.color-control input {
  padding: 5px;
}

.security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
}

.security-row + .security-row {
  border-top: 1px solid var(--line);
}

.security-row > div:first-child {
  display: grid;
  gap: 3px;
}

.security-row strong {
  font-size: 13px;
}

.security-row small {
  color: var(--text-muted);
  font-size: 11px;
}

.small-dialog {
  width: min(420px, calc(100vw - 24px));
  border-radius: 24px;
}

.form-dialog form {
  display: grid;
  max-height: min(88vh, 720px);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.dialog-scroll {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.account-dialog-body {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.available-note {
  margin: -5px 0 0;
}

.install-steps {
  padding: 22px 20px;
}

.install-steps > p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.install-steps ol {
  display: grid;
  gap: 17px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.install-steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
}

.install-steps li > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 850;
}

.install-steps li p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.pin-dialog-body {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.lock-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 28rem),
    var(--bg);
}

.auth-screen {
  position: fixed;
  z-index: 110;
  inset: 0;
  display: grid;
  padding: max(22px, calc(env(safe-area-inset-top) + 14px)) 22px max(22px, calc(env(safe-area-inset-bottom) + 14px));
  overflow-x: hidden;
  overflow-y: auto;
  place-items: center;
  background:
    radial-gradient(circle at 50% -8%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 31rem),
    radial-gradient(circle at 10% 90%, color-mix(in srgb, var(--income) 8%, transparent), transparent 24rem),
    radial-gradient(circle at 92% 88%, color-mix(in srgb, var(--expense) 7%, transparent), transparent 22rem),
    var(--bg);
}

.auth-card {
  position: relative;
  display: grid;
  width: min(100%, 440px);
  gap: 22px;
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface-strong) 94%, var(--accent) 6%), var(--surface));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .36), inset 0 1px 0 rgba(255, 255, 255, .035);
}

.auth-card::before {
  position: absolute;
  top: 0;
  right: 22%;
  left: 22%;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 75%, white), transparent);
  content: '';
}

.auth-brand {
  display: grid;
  justify-items: center;
  text-align: center;
}

.auth-logo-frame {
  display: grid;
  width: 120px;
  height: 120px;
  margin-bottom: 17px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 38px;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 64%),
    var(--surface-muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 20px 42px rgba(0, 0, 0, .22);
}

.auth-brand-logo {
  width: 92px;
  height: 92px;
  flex-basis: 92px;
  border-radius: 28px;
  box-shadow: 0 18px 38px color-mix(in srgb, var(--accent) 28%, rgba(0, 0, 0, .48));
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card h1 {
  margin-top: 7px;
  font-size: 30px;
  letter-spacing: -.045em;
}

.auth-subtitle,
.auth-privacy,
.code-sent-hint {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-subtitle {
  max-width: 330px;
  margin-top: 9px !important;
}

.auth-stage {
  display: grid;
  gap: 12px;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  background: var(--line);
  content: '';
}

.google-auth-button {
  position: relative;
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .86);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
  color: #182033;
  font-weight: 820;
}

.google-auth-button:hover {
  background: #f7f9ff;
}

.google-auth-button:focus-visible {
  outline: 3px solid color-mix(in srgb, #4285f4 48%, transparent);
  outline-offset: 3px;
}

.google-auth-button:disabled {
  cursor: wait;
  opacity: .62;
}

.google-mark {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 10px;
  place-items: center;
  border: 1px solid rgba(66, 133, 244, .18);
  border-radius: 8px;
  background: #f8fbff;
  color: #4285f4;
  font-size: 14px;
  font-weight: 900;
}

.verification-panel {
  justify-items: stretch;
  text-align: center;
}

.verification-panel h2 {
  margin: 0;
  font-size: 20px;
}

.verification-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--income) 45%, transparent);
  border-radius: 18px;
  background: var(--income-soft);
  color: var(--income);
  font-size: 24px;
  font-weight: 900;
}

.auth-inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.otp-input {
  font-size: 22px !important;
  font-weight: 800;
  letter-spacing: .22em;
  text-align: center;
}

.auth-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--expense-soft);
}

.auth-privacy {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.small-dialog-card {
  display: grid;
}

.compact-dialog-header h1 {
  max-width: 280px;
  font-size: 18px;
  line-height: 1.2;
}

.dialog-description {
  margin: 0;
  padding: 20px 20px 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.conflict-actions {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.account-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
}

.account-summary > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.account-summary small {
  color: var(--text-muted);
  font-size: 10px;
}

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

.sync-status {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-align: right;
}

.sync-status.is-synced {
  color: var(--income);
}

.sync-status.is-error {
  color: var(--expense);
}

.lock-card {
  display: grid;
  width: min(100%, 390px);
  gap: 13px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lock-card .brand-logo {
  margin-bottom: 10px;
}

.lock-card h1,
.lock-card p {
  margin: 0;
}

.lock-card h1 {
  font-size: 27px;
  letter-spacing: -0.04em;
}

.lock-card > p {
  margin-bottom: 8px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  z-index: 120;
  right: 50%;
  bottom: calc(var(--nav-height) + 28px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  transform: translateX(50%);
  animation: toast-in 180ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(50%, 8px); }
  to { opacity: 1; transform: translate(50%, 0); }
}

@media (max-width: 460px) {
  .auth-screen {
    padding-right: 14px;
    padding-left: 14px;
  }

  .auth-card {
    gap: 18px;
    padding: 22px;
    border-radius: 28px;
  }

  .auth-logo-frame {
    width: 104px;
    height: 104px;
    margin-bottom: 14px;
    border-radius: 32px;
  }

  .auth-brand-logo {
    width: 80px;
    height: 80px;
    flex-basis: 80px;
    border-radius: 24px;
  }

  .auth-card h1 {
    font-size: 27px;
  }
}

@media (max-width: 620px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    touch-action: manipulation;
  }

  .app-shell {
    position: fixed;
    top: var(--app-viewport-top);
    right: 0;
    bottom: auto;
    left: 0;
    display: grid;
    width: 100%;
    height: var(--app-viewport-height);
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    margin: 0;
    padding: var(--app-safe-top) 12px max(var(--app-safe-bottom), 10px);
    overflow: hidden;
  }

  .topbar {
    position: relative;
    top: auto;
    min-height: 66px;
    padding: 8px 0 10px;
  }

  .main-content {
    min-height: 0;
    padding: 14px 0 18px;
    overflow-x: hidden;
    overflow-y: auto;
    overflow-anchor: none;
    overscroll-behavior: contain;
    scroll-behavior: auto;
    scrollbar-width: none;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .main-content::-webkit-scrollbar {
    display: none;
  }

  .bottom-nav {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    min-height: 70px;
    margin: 10px 0 0;
    padding: 6px;
    border-radius: 22px;
    box-shadow: 0 -10px 34px rgba(0, 0, 0, .22);
  }

  .nav-item {
    font-size: 9px;
  }

  .nav-icon {
    width: 24px;
    height: 24px;
    font-size: 18px;
  }

  .form-dialog {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 28px 28px 0 0;
  }

  .form-dialog form {
    max-height: calc(var(--app-viewport-height) - var(--app-safe-top));
  }

  .account-money-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.keyboard-open .bottom-nav {
    display: none;
  }

  body.keyboard-open .main-content {
    padding-bottom: 14px;
  }

  input,
  select,
  textarea,
  .input-shell input,
  .category-name-input,
  .comment-input {
    font-size: 16px !important;
    line-height: 1.25;
    scroll-margin-block: 100px;
  }

  .brand-copy small {
    display: none;
  }

  .period-chip {
    max-width: 108px;
  }

  .overview-heading {
    align-items: center;
  }

  .chart-heading {
    display: grid;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  .chart-wrap,
  .chart-wrap canvas {
    height: 260px !important;
    min-height: 260px;
  }

  .sheet-dialog {
    width: 100vw;
    height: calc(var(--app-viewport-height) - var(--app-safe-top));
    max-width: none;
    max-height: calc(var(--app-viewport-height) - var(--app-safe-top));
    grid-template-rows: auto minmax(0, 1fr) auto;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 28px 28px 0 0;
  }

  .sheet-dialog[open] {
    display: grid;
  }

  .settings-body {
    min-height: 0;
    max-height: none;
    padding-right: 16px;
    padding-left: 16px;
    overflow-x: hidden;
  }

  .settings-section,
  .settings-section-title,
  .settings-section-title > div,
  .security-row,
  .security-row > div,
  .inline-actions,
  .control,
  .control-grid,
  .action-grid {
    min-width: 0;
    max-width: 100%;
  }

  .control-grid,
  .action-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .control.full {
    grid-column: auto;
  }

  .action-grid button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

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

  .security-row .inline-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .settings-section-title p,
  .settings-note,
  .security-row small {
    overflow-wrap: anywhere;
  }

  .account-summary {
    display: grid;
  }

  .sync-status {
    text-align: left;
  }

  .dialog-footer {
    padding-bottom: max(14px, var(--app-safe-bottom));
  }

  .insights-card {
    grid-template-columns: 1fr;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 620px) and (display-mode: standalone) {
    :root {
      --app-safe-top: max(env(safe-area-inset-top, 0px), 44px);
      --app-safe-bottom: max(env(safe-area-inset-bottom, 0px), 10px);
    }
  }
}

@media (max-width: 390px) {
  .metric-grid,
  .quick-actions,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .control.full {
    grid-column: auto;
  }

  .section-heading {
    gap: 10px;
  }

  .section-heading h1 {
    font-size: 28px;
  }

  .category-fields {
    grid-template-columns: 1fr;
  }

  .field-block.full {
    grid-column: auto;
  }
}

@media (min-width: 760px) {
  .main-content {
    padding-top: 30px;
  }

  .balance-card {
    min-height: 210px;
  }

  .category-fields.expense-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-fields.expense-fields .field-block.full {
    grid-column: 1 / -1;
  }
}

.offline-page {
  display: grid;
  min-height: 100vh;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  place-items: center;
}

.offline-card {
  width: min(100%, 390px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.offline-card img {
  display: block;
  margin: 0 auto 18px;
  border-radius: 22px;
}

.offline-card h1 {
  margin: 5px 0 8px;
}

.offline-card > p:not(.eyebrow) {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.offline-card a.primary {
  text-decoration: none;
}

@media print {
  body {
    background: white;
    color: black;
  }

  .topbar,
  .bottom-nav,
  dialog,
  .quick-card,
  .section-heading button,
  .drag-handle,
  .delete-button {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .tab-panel {
    display: block !important;
  }

  .surface,
  .category-card,
  .balance-card,
  .metric-card,
  .section-total {
    break-inside: avoid;
    box-shadow: none;
  }
}
