:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #657067;
  --line: #dfe5dd;
  --green: #1f7a4f;
  --green-dark: #145f3c;
  --teal: #0b7285;
  --gold: #b88723;
  --red: #bd3b3b;
  --blue: #315aa6;
  --soft-green: #edf7f1;
  --soft-red: #fff0ef;
  --soft-gold: #fff6df;
  --shadow: 0 18px 44px rgba(23, 33, 28, 0.1);
  --glow: 0 0 0 1px rgba(255, 255, 255, 0.7), 0 20px 56px rgba(31, 122, 79, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 76% 8%, rgba(229, 185, 75, 0.2), transparent 26%),
    radial-gradient(circle at 20% 4%, rgba(11, 114, 133, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(31, 122, 79, 0.1), transparent 300px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.auth-locked .sidebar,
.auth-locked .shell {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 28% 18%, rgba(31, 122, 79, 0.18), transparent 30%),
    radial-gradient(circle at 78% 12%, rgba(229, 185, 75, 0.2), transparent 28%),
    rgba(245, 246, 243, 0.88);
  backdrop-filter: blur(12px);
}

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

.auth-card {
  width: min(460px, calc(100vw - 36px));
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(251, 252, 250, 0.9)),
    #fff;
  box-shadow: 0 28px 80px rgba(23, 33, 28, 0.22);
  animation: modalIn 0.2s ease both;
}

.auth-brand .brand-mark {
  animation: avatarPulse 3.6s ease-in-out infinite;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(237, 247, 241, 0.72);
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

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

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

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

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.auth-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  line-height: 1.5;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 26%),
    #17211c;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e5b94b;
  background-position: center;
  background-size: cover;
  color: #17211c;
  font-weight: 800;
  box-shadow: 0 0 0 0 rgba(229, 185, 75, 0.36);
  animation: avatarPulse 3.6s ease-in-out infinite;
}

.brand-mark.has-image {
  color: transparent;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #aeb9b1;
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  color: #d8e1da;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: inset 3px 0 0 #e5b94b;
}

.pending-float {
  position: relative;
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid rgba(229, 185, 75, 0.32);
  border-radius: 8px;
  text-align: left;
  color: #f8fff9;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(31, 122, 79, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 18px 32px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
  animation: pendingFloat 3.6s ease-in-out infinite;
}

.pending-float.hidden {
  display: none;
}

.pending-float-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e5b94b;
  color: #17211c;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 0 0 0 rgba(229, 185, 75, 0.45);
  animation: pendingPulse 1.8s ease-in-out infinite;
}

.pending-float-title,
.pending-float-meta {
  color: rgba(248, 255, 249, 0.74);
  font-size: 12px;
}

.pending-float strong {
  font-size: 24px;
  line-height: 1.1;
}

.pending-float-progress {
  position: absolute;
  inset: auto 12px 9px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.pending-float-progress::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e5b94b, #73d7a2, #0b7285);
  animation: pendingProgress 1.4s linear infinite;
}

@keyframes pendingFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes pendingPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(229, 185, 75, 0.42);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(229, 185, 75, 0);
  }
}

@keyframes pendingProgress {
  from {
    transform: translateX(-115%);
  }
  to {
    transform: translateX(260%);
  }
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

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

.sidebar-note span {
  color: #aeb9b1;
  font-size: 12px;
}

.sidebar-note strong {
  margin-top: 4px;
}

.shell {
  margin-left: 244px;
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.1;
  font-weight: 850;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
}

.top-actions,
.form-actions,
.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-label {
  color: var(--muted);
  font-size: 14px;
}

.sync-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(31, 122, 79, 0.18);
  border-radius: 999px;
  background: rgba(31, 122, 79, 0.08);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select,
input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

.primary-button,
.ghost-button,
.danger-button,
.file-picker {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--green), #239568);
  color: #fff;
  box-shadow: 0 10px 22px rgba(31, 122, 79, 0.18);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.primary-button:hover {
  background: var(--green-dark);
  box-shadow: 0 14px 28px rgba(31, 122, 79, 0.24);
  transform: translateY(-1px);
}

.ghost-button,
.file-picker {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover,
.file-picker:hover {
  border-color: #b8c7bd;
  background: #f9fbf8;
}

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

.danger-button:hover {
  background: #fff7f7;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.metric-panel,
.panel,
.chart-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.78)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.metric-panel {
  padding: 18px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.metric-panel::after {
  content: "";
  position: absolute;
  inset: auto 14px 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, var(--green), var(--teal), var(--gold));
  opacity: 0.36;
  animation: progressSweep 3.8s ease-in-out infinite;
}

.metric-panel span,
.metric-panel small {
  color: var(--muted);
}

.metric-panel strong {
  display: block;
  margin: 8px 0;
  max-width: 100%;
  font-size: clamp(20px, 1.8vw, 30px);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: keep-all;
  background: linear-gradient(90deg, #17211c, #1f7a4f);
  -webkit-background-clip: text;
  color: transparent;
}

.metric-panel small {
  display: block;
  line-height: 1.45;
}

.chart-panel,
.panel {
  margin-top: 16px;
  padding: 18px;
}

.chart-panel {
  position: relative;
  overflow: hidden;
}

.chart-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(229, 185, 75, 0.1) 46%, transparent 68%);
  transform: translateX(-100%);
  animation: panelShimmer 7s ease-in-out infinite;
  pointer-events: none;
}

.money-effect {
  position: absolute;
  inset: 8px 20px auto auto;
  width: 120px;
  height: 80px;
  pointer-events: none;
  opacity: 0.8;
  z-index: 1;
}

.money-effect span {
  position: absolute;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(229, 185, 75, 0.18);
  color: var(--gold);
  font-weight: 900;
  animation: floatDollar 3.8s ease-in-out infinite;
}

.money-effect span:nth-child(1) {
  left: 4px;
  top: 34px;
}

.money-effect span:nth-child(2) {
  left: 44px;
  top: 10px;
  animation-delay: 0.7s;
}

.money-effect span:nth-child(3) {
  right: 4px;
  top: 40px;
  animation-delay: 1.4s;
}

@keyframes floatDollar {
  0%,
  100% {
    transform: translateY(8px) scale(0.92);
    opacity: 0.35;
  }
  50% {
    transform: translateY(-10px) scale(1.08);
    opacity: 1;
  }
}

@keyframes avatarPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(229, 185, 75, 0.28);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(229, 185, 75, 0);
  }
}

@keyframes progressSweep {
  0%,
  100% {
    transform: translateX(-8%);
  }
  50% {
    transform: translateX(8%);
  }
}

@keyframes softRise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-head p,
.section-head span {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section-head.compact {
  align-items: center;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented .period-tab {
  width: 48px;
  height: 36px;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.segmented .period-tab:last-child {
  border-right: 0;
}

.segmented .period-tab.active {
  background: var(--ink);
  color: #fff;
}

.period-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.range-select-label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.range-select-label select {
  height: 36px;
  min-width: 112px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.chart-point-hint {
  align-self: center;
  margin-top: 0 !important;
  padding: 8px 12px;
  border: 1px solid rgba(31, 122, 79, 0.18);
  border-radius: 999px;
  background: rgba(31, 122, 79, 0.08);
  color: var(--green) !important;
  font-weight: 700;
  white-space: nowrap;
}

canvas {
  width: 100%;
  min-height: 260px;
  display: block;
  border-radius: 8px;
  background: #fbfcfa;
}

.split-grid,
.submit-grid,
.settings-grid,
.table-grid,
.assets-layout {
  display: grid;
  gap: 16px;
}

.split-grid,
.submit-grid,
.settings-grid,
.assets-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
}

.split-grid {
  grid-template-columns: minmax(340px, 1.2fr) minmax(260px, 0.8fr) minmax(260px, 0.8fr);
}

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

.ledger-hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 8px 0 2px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(31, 122, 79, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(31, 122, 79, 0.12), rgba(229, 185, 75, 0.16), rgba(11, 114, 133, 0.1)),
    rgba(255, 255, 255, 0.72);
  box-shadow: var(--glow);
}

.ledger-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--teal));
  animation: progressSweep 3.4s ease-in-out infinite;
}

.ledger-hero p,
.ledger-hero h2 {
  margin: 0;
}

.ledger-hero p {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.ledger-hero h2 {
  margin-top: 4px;
  font-size: 28px;
}

.ledger-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 122, 79, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--green-dark);
  font-weight: 800;
  white-space: nowrap;
}

.ledger-sync-badge span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(31, 122, 79, 0.42);
  animation: avatarPulse 2.2s ease-in-out infinite;
}

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

.ledger-calendar-panel {
  max-width: 100%;
  overflow-x: auto;
}

.ledger-calendar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ledger-calendar-controls label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ledger-calendar-controls select {
  height: 36px;
  min-width: 96px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.month-nav-button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.month-nav-button:hover {
  border-color: #b8c7bd;
  background: #f9fbf8;
}

.calendar-weekdays,
.snapshot-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(132px, 1fr));
  gap: 8px;
  min-width: 980px;
}

.calendar-weekdays {
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  min-height: 164px;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(251, 252, 250, 0.86)),
    #fff;
  animation: softRise 0.24s ease both;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.calendar-day.has-data {
  border-color: rgba(31, 122, 79, 0.24);
  background:
    linear-gradient(180deg, rgba(237, 247, 241, 0.95), rgba(255, 246, 223, 0.34)),
    #fff;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px rgba(229, 185, 75, 0.62);
}

.calendar-day:not(.muted):hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(23, 33, 28, 0.1);
  border-color: rgba(31, 122, 79, 0.34);
}

.calendar-day.muted {
  min-height: 92px;
  background: rgba(255, 255, 255, 0.38);
  border-style: dashed;
  box-shadow: none;
}

.calendar-day-head,
.calendar-flow-pills,
.calendar-snapshot,
.ledger-flow-item {
  display: flex;
  align-items: center;
}

.calendar-day-head {
  justify-content: space-between;
}

.calendar-day-head strong {
  font-size: 20px;
}

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

.calendar-balance {
  color: var(--green-dark);
  font-size: clamp(13px, 0.9vw, 18px);
  font-weight: 900;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.calendar-flow-pills {
  gap: 6px;
  flex-wrap: wrap;
}

.calendar-flow-pills span {
  max-width: 100%;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.calendar-flow-pills .positive {
  background: rgba(31, 122, 79, 0.1);
  color: var(--green);
}

.calendar-flow-pills .negative {
  background: rgba(189, 59, 59, 0.1);
  color: var(--red);
}

.calendar-detail-button {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(31, 122, 79, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.calendar-detail-button:hover {
  background: rgba(31, 122, 79, 0.1);
}

.calendar-empty {
  color: var(--muted);
  font-size: 12px;
}

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

.ledger-flow-card {
  position: relative;
  overflow: hidden;
}

.ledger-flow-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--teal));
  opacity: 0.52;
  animation: progressSweep 3s ease-in-out infinite;
}

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

.ledger-flow-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(120px, auto);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 252, 250, 0.86);
  animation: softRise 0.22s ease both;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
}

.ledger-flow-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(23, 33, 28, 0.08);
}

.ledger-flow-item.income {
  border-color: #cfe4d6;
  background: linear-gradient(90deg, rgba(237, 247, 241, 0.95), rgba(255, 255, 255, 0.76));
}

.ledger-flow-item.expense {
  border-color: #f0cdca;
  background: linear-gradient(90deg, rgba(255, 240, 239, 0.92), rgba(255, 255, 255, 0.76));
}

.ledger-flow-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.ledger-flow-item.income .ledger-flow-icon {
  background: var(--green);
}

.ledger-flow-item.expense .ledger-flow-icon {
  background: var(--red);
}

.ledger-flow-item div:nth-child(2) {
  min-width: 0;
}

.ledger-flow-item strong,
.ledger-flow-item span {
  display: block;
  overflow-wrap: anywhere;
}

.ledger-flow-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.ledger-flow-amount {
  min-width: 0;
  text-align: right;
}

.ledger-flow-amount strong {
  color: var(--green-dark);
  font-size: clamp(14px, 1vw, 18px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.ledger-flow-amount small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ledger-flow-item.expense .ledger-flow-amount strong {
  color: var(--red);
}

.ledger-archive {
  grid-column: 1 / -1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 33, 28, 0.42);
  backdrop-filter: blur(8px);
}

.modal-backdrop.hidden {
  display: none;
}

.ledger-modal {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 48px));
  overflow-y: auto;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 252, 250, 0.92)),
    #fff;
  box-shadow: 0 28px 80px rgba(23, 33, 28, 0.28);
  animation: modalIn 0.18s ease both;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.ledger-modal-body,
.ledger-detail-section {
  display: grid;
  gap: 12px;
}

.ledger-detail-section h3 {
  margin: 6px 0 0;
  font-size: 16px;
}

.ledger-detail-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 252, 250, 0.88);
}

.ledger-detail-card.income {
  border-color: #cfe4d6;
  background: var(--soft-green);
}

.ledger-detail-card.expense {
  border-color: #f0cdca;
  background: var(--soft-red);
}

.ledger-detail-card.snapshot {
  border-color: rgba(31, 122, 79, 0.22);
}

.ledger-detail-card-head,
.ledger-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.ledger-detail-card-head strong,
.ledger-detail-row strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.ledger-detail-row span {
  color: var(--muted);
  white-space: nowrap;
}

.text-button.neutral {
  color: var(--green);
  font-weight: 800;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.rank-list,
.income-list,
.pending-list {
  display: grid;
  gap: 10px;
}

.asset-tree {
  display: grid;
  gap: 14px;
}

.asset-type {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(251, 252, 250, 0.92)),
    #fbfcfa;
  overflow: hidden;
  animation: softRise 0.24s ease both;
}

.asset-type-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: linear-gradient(90deg, #eef7f1, #f8f4e8);
}

.asset-type-head h3 {
  margin: 0;
  font-size: 17px;
}

.asset-main {
  border-top: 1px solid var(--line);
}

.asset-main summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
}

.asset-main summary::marker {
  color: var(--green);
}

.asset-main-title {
  display: grid;
  gap: 3px;
}

.asset-main-title small {
  color: var(--muted);
  font-size: 12px;
}

.asset-main-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.icon-add-button {
  width: 28px;
  height: 28px;
  border: 1px solid #cfe4d6;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft-green);
  color: var(--green);
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
}

.icon-add-button:hover {
  background: var(--green);
  color: #fff;
}

.inline-asset-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin: 0 14px 12px;
  padding: 10px;
  border: 1px solid #cfe4d6;
  border-radius: 8px;
  background: #f7fbf8;
}

.inline-asset-form input {
  width: 100%;
}

.asset-sub-list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.asset-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.asset-sub-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.asset-sub-row > div:last-child {
  margin-left: auto;
  text-align: right;
}

.rank-row,
.income-row,
.pending-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
  animation: softRise 0.22s ease both;
}

.pending-card {
  box-shadow: 0 8px 24px rgba(23, 33, 28, 0.06);
}

.rank-row {
  display: grid;
  grid-template-columns: 34px 38px 1fr auto;
  gap: 10px;
  align-items: center;
}

.rank-row:hover,
.asset-sub-row:hover,
.income-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(23, 33, 28, 0.08);
}

.rank-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7eee9;
  color: var(--green);
  font-weight: 800;
}

.asset-avatar,
.settings-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e7eee9;
  background-position: center;
  background-size: cover;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.asset-avatar.has-image,
.settings-avatar.has-image {
  color: transparent;
}

.rank-name,
.income-source {
  font-weight: 700;
}

.rank-meta,
.income-meta,
.pending-meta {
  color: var(--muted);
  font-size: 13px;
}

.income-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.income-row.positive {
  background: var(--soft-green);
  border-color: #cfe4d6;
}

.income-row.negative {
  background: var(--soft-red);
  border-color: #f0cdca;
}

.income-panel,
.expense-panel {
  min-width: 0;
}

.income-row.positive .income-meta,
.amount-positive {
  color: var(--green);
  font-weight: 800;
}

.income-row.negative .income-meta,
.amount-negative {
  color: var(--red);
  font-weight: 800;
}

.bar {
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e4ebe6, #f2e9cd);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--teal), var(--gold));
  animation: progressGlow 2.8s ease-in-out infinite;
}

@keyframes progressGlow {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.35) brightness(1.08);
  }
}

@keyframes panelShimmer {
  0%,
  72% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.sync-hint {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  margin: 12px 0 2px;
  border: 1px solid #cfe4d6;
  border-radius: 8px;
  background: var(--soft-green);
  color: #355442;
  line-height: 1.5;
}

.sync-hint strong {
  color: var(--green);
}

.sync-hint span {
  color: #496354;
}

.upload-row {
  margin: 14px 0;
}

#imageInput,
#profileAvatarInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

#assetAvatarInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

#imageName {
  color: var(--muted);
}

.pending-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.pending-source {
  padding: 10px;
  margin: 10px 0;
  border-radius: 8px;
  background: #eef3ef;
  color: #425046;
  white-space: pre-wrap;
}

.record-editor {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 0.9fr 0.9fr 0.65fr 0.65fr minmax(210px, 1.2fr);
  gap: 8px;
  margin: 8px 0;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.record-preview {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.record-preview.neutral {
  background: #eef3ef;
  color: #425046;
}

.record-preview.positive {
  background: var(--soft-green);
  color: var(--green);
}

.record-preview.negative {
  background: var(--soft-red);
  color: var(--red);
}

.record-preview.warning {
  background: var(--soft-gold);
  color: #7b550c;
}

.pending-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 13px;
}

td:last-child,
th:last-child {
  text-align: right;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 4px;
}

.rates-form {
  display: grid;
  gap: 14px;
  max-width: 360px;
}

.rates-form label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 0;
}

.profile-form {
  display: grid;
  gap: 14px;
}

.profile-preview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.settings-avatar {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  font-size: 18px;
}

.profile-preview input {
  width: 100%;
  margin-top: 8px;
}

.asset-avatar-list {
  display: grid;
  gap: 10px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.asset-avatar-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.asset-avatar-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.integration-box {
  color: var(--muted);
  line-height: 1.6;
}

code {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: #eef3ef;
  color: var(--blue);
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(23, 33, 28, 0.96);
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1020px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px;
  }

  .nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .sidebar-note {
    display: none;
  }

  .shell {
    margin-left: 0;
    padding: 18px;
  }

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

  .split-grid,
  .submit-grid,
  .settings-grid,
  .assets-layout,
  .ledger-layout {
    grid-template-columns: 1fr;
  }

  .ledger-flow-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 660px) {
  .sidebar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    grid-template-columns: repeat(5, minmax(58px, 1fr));
  }

  .nav-item {
    text-align: center;
    padding: 10px 8px;
  }

  .topbar,
  .section-head {
    display: grid;
  }

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

  .record-editor {
    grid-template-columns: 1fr 1fr;
  }

  .record-preview,
  .sync-hint,
  .inline-asset-form {
    grid-column: 1 / -1;
  }

  .ledger-hero {
    display: grid;
  }

  .ledger-sync-badge {
    justify-content: center;
    white-space: normal;
  }

  .ledger-calendar-controls {
    justify-content: flex-start;
  }

  .ledger-calendar-controls label,
  .ledger-calendar-controls select {
    flex: 1 1 130px;
  }

  .ledger-calendar-panel {
    overflow-x: auto;
  }

  .calendar-weekdays,
  .snapshot-calendar {
    min-width: 980px;
  }

  .ledger-flow-item {
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: flex-start;
  }

  .ledger-flow-amount {
    grid-column: 2;
    text-align: left;
  }

  .inline-asset-form {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}
