.ledger-shell {
  min-height: calc(100vh - var(--nav-height));
  padding-bottom: 72px;
}

.ledger-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0 22px;
}

.ledger-head h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
}

.ledger-head p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.head-actions,
.trip-actions,
.entry-actions,
.panel-actions,
.memory-actions,
.moment-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.trip-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #d5ded8;
  border-left: 4px solid var(--forest);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.trip-select-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.trip-select-wrap > .icon {
  color: var(--forest);
}

.trip-select-wrap .select {
  min-height: 40px;
  border: 0;
  background: #f5f8f6;
  font-weight: 750;
}

.trip-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  color: #526158;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 650;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38a169;
  box-shadow: 0 0 0 4px rgba(56, 161, 105, 0.12);
}

.sync-pill.offline .sync-dot {
  background: #d88b27;
  box-shadow: 0 0 0 4px rgba(216, 139, 39, 0.14);
}

.quick-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #bbd8c9;
  border-radius: 9px;
  background: #f8fcf9;
  box-shadow: 0 10px 28px rgba(23, 107, 82, 0.08);
}

.quick-field {
  position: relative;
}

.quick-field > .icon {
  position: absolute;
  top: 50%;
  left: 15px;
  color: var(--forest);
  transform: translateY(-50%);
}

.quick-field .input {
  min-height: 52px;
  padding-left: 44px;
  border-color: #bed4c7;
  background: #fff;
  font-size: 15px;
}

.quick-hint {
  margin: 7px 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

.btn-voice.is-listening {
  color: #fff;
  background: #c84b45;
  animation: voicePulse 1.2s infinite;
}

@keyframes voicePulse {
  50% {
    box-shadow: 0 0 0 8px rgba(200, 75, 69, 0.12);
  }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--forest);
  border-radius: 7px;
  background: var(--forest-soft);
}

.metric:nth-child(2) .metric-icon {
  color: #a36412;
  background: #fff2df;
}

.metric:nth-child(3) .metric-icon {
  color: #2e668e;
  background: #e8f3fb;
}

.metric:nth-child(4) .metric-icon {
  color: #9c4f47;
  background: #fcecea;
}

.metric strong {
  display: block;
  margin-top: 13px;
  overflow: hidden;
  font-size: clamp(22px, 2.5vw, 30px);
  line-height: 1.1;
  text-overflow: ellipsis;
}

.metric small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.budget-track {
  height: 7px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ee;
}

.budget-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--forest);
  transition: width 300ms ease;
}

.budget-track.over span {
  background: #c84b45;
}

.workspace-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tab-button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 15px;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.tab-button:hover {
  color: var(--forest);
  background: #f3f8f5;
}

.tab-button.active {
  color: #fff;
  background: var(--forest);
  box-shadow: 0 6px 14px rgba(23, 107, 82, 0.2);
}

.tab-panel[hidden] {
  display: none !important;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.2fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 0;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.donut {
  position: relative;
  width: 126px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #edf1ee;
}

.donut::after {
  position: absolute;
  inset: 23px;
  display: grid;
  place-content: center;
  content: attr(data-total);
  color: var(--ink);
  border-radius: 50%;
  background: #fff;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  white-space: pre-line;
}

.legend {
  display: grid;
  gap: 8px;
  min-width: 0;
}

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

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

.legend-row span {
  overflow: hidden;
  color: #536159;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.trend-chart {
  min-height: 180px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 20px 18px 18px;
  overflow-x: auto;
}

.trend-column {
  min-width: 34px;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: 8px;
  height: 140px;
}

.trend-bar-wrap {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.trend-bar {
  width: min(28px, 80%);
  min-height: 4px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #4fa982, #176b52);
}

.trend-column:nth-child(3n + 2) .trend-bar {
  background: linear-gradient(180deg, #eeb66e, #d47a22);
}

.trend-column small {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.insight-list {
  display: grid;
  gap: 10px;
  padding: 16px 18px 18px;
}

.insight {
  padding: 11px 12px;
  border-left: 3px solid #7aa88f;
  border-radius: 0 6px 6px 0;
  background: #f5f9f6;
}

.insight.warning {
  border-left-color: #d68b32;
  background: #fff8ed;
}

.insight.danger {
  border-left-color: #c84b45;
  background: #fff4f3;
}

.insight strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.insight p {
  margin: 0;
  color: #5d6a62;
  font-size: 12px;
  line-height: 1.6;
}

.expense-panel {
  overflow: hidden;
}

.expense-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.expense-toolbar h2 {
  margin: 0 0 3px;
  font-size: 17px;
}

.expense-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.expense-filter {
  width: 140px;
  min-height: 38px;
}

.expense-list {
  display: grid;
}

.expense-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  gap: 13px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #edf1ee;
}

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

.expense-category-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--forest);
  border-radius: 8px;
  background: var(--forest-soft);
}

.expense-main {
  min-width: 0;
}

.expense-main strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-main p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.expense-amount strong {
  display: block;
  font-size: 15px;
}

.expense-amount small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

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

.row-actions .btn {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.expense-empty {
  padding: 44px 24px;
  color: var(--muted);
  text-align: center;
}

.moments-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.moment-composer {
  padding: 18px;
}

.moment-composer h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.moment-composer > p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 12px;
}

.prompt-chips {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.prompt-chip {
  flex: none;
  padding: 7px 10px;
  color: #536159;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}

.prompt-chip:hover {
  color: var(--forest);
  border-color: #b6d0c1;
  background: var(--forest-soft);
}

.moment-form-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
  margin-top: 12px;
}

.moment-form-grid .field {
  margin-bottom: 0;
}

.moment-media-preview {
  margin-top: 12px;
}

.moment-media-preview img,
.moment-media-preview video {
  width: 100%;
  max-height: 260px;
  border-radius: 7px;
  object-fit: cover;
}

.moment-media-preview audio {
  width: 100%;
}

.memory-map-panel {
  overflow: hidden;
}

.memory-map-panel .hand-route-shell {
  margin: 14px;
}

.moment-timeline {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.moment-day {
  padding-left: 20px;
  border-left: 2px solid #d7e4dc;
}

.moment-day-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 10px -27px;
}

.moment-day-dot {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--forest);
  box-shadow: 0 0 0 2px #bdd7c8;
}

.moment-day-head strong {
  font-size: 14px;
}

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

.moment-entry {
  position: relative;
  padding: 15px 46px 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.moment-entry + .moment-entry {
  margin-top: 9px;
}

.moment-entry.is-highlight {
  border-color: #eccb9e;
  background: #fffbf5;
}

.moment-time {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.moment-time .badge {
  padding: 3px 7px;
  font-size: 10px;
}

.moment-entry p {
  margin: 0;
  color: #344039;
  line-height: 1.75;
  white-space: pre-wrap;
}

.moment-entry img,
.moment-entry video {
  width: min(100%, 520px);
  max-height: 340px;
  margin-top: 12px;
  border-radius: 7px;
  object-fit: cover;
}

.moment-entry audio {
  width: min(100%, 520px);
  margin-top: 12px;
}

.moment-delete {
  position: absolute;
  top: 8px;
  right: 8px;
}

.memory-toolbar {
  display: grid;
  grid-template-columns: 150px 150px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.memory-toolbar .select {
  min-height: 40px;
}

.memory-draft-editor {
  margin-bottom: 16px;
  padding: 16px;
}

.memory-draft-editor label {
  display: block;
  margin-bottom: 8px;
  font-weight: 750;
}

.memory-draft-editor .textarea {
  min-height: 180px;
}

.memory-book {
  overflow: hidden;
  color: #25312a;
  border: 1px solid #d4ded7;
  border-radius: 8px;
  background: #fffdf9;
  box-shadow: 0 22px 60px rgba(23, 33, 27, 0.12);
}

.memory-cover {
  position: relative;
  min-height: 310px;
  display: grid;
  align-items: end;
  padding: 34px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(10, 24, 17, 0.1), rgba(10, 24, 17, 0.75)),
    #245a45;
  isolation: isolate;
}

.memory-cover-image {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.memory-cover::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: linear-gradient(180deg, rgba(15, 31, 23, 0.08), rgba(15, 31, 23, 0.78));
}

.memory-cover-content {
  position: relative;
  z-index: 1;
}

.memory-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.memory-cover h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1.02;
}

.memory-cover p {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
}

.memory-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid #e4e2dc;
  background: #fff;
}

.memory-summary div {
  padding: 20px 24px;
  border-right: 1px solid #e9e6df;
}

.memory-summary div:last-child {
  border-right: 0;
}

.memory-summary span {
  display: block;
  color: #7a7e76;
  font-size: 11px;
}

.memory-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.memory-content {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(250px, 0.75fr);
  gap: 32px;
  padding: 34px;
}

.memory-story h3,
.memory-highlights h3,
.memory-spend h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.memory-story-text {
  color: #47534b;
  line-height: 2;
  white-space: pre-wrap;
}

.memory-highlights {
  display: grid;
  gap: 12px;
}

.memory-highlight {
  padding: 15px;
  border-left: 3px solid #d88b27;
  background: #fff8ec;
}

.memory-highlight time {
  display: block;
  margin-bottom: 6px;
  color: #8b7559;
  font-size: 11px;
}

.memory-highlight p {
  margin: 0;
  color: #4f4c43;
  line-height: 1.7;
}

.memory-spend {
  grid-column: 1 / -1;
  padding-top: 24px;
  border-top: 1px solid #e7e3db;
}

.memory-spend-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.memory-spend-item {
  padding: 12px;
  border: 1px solid #e8e4dc;
  border-radius: 7px;
  background: #fff;
}

.memory-spend-item span {
  display: block;
  color: #7b7f78;
  font-size: 11px;
}

.memory-spend-item strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.memory-empty {
  padding: 36px;
  color: #747b75;
  text-align: center;
}

.empty-project {
  display: grid;
  place-items: center;
  min-height: 380px;
  padding: 40px 24px;
  border: 1px dashed #bdcbc2;
  border-radius: 8px;
  background:
    radial-gradient(circle at 15% 20%, rgba(232, 150, 58, 0.1), transparent 24%),
    #fff;
  text-align: center;
}

.empty-project > div {
  max-width: 500px;
}

.empty-project .empty-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: #fff;
  border-radius: 8px;
  background: var(--forest);
  box-shadow: 0 14px 28px rgba(23, 107, 82, 0.2);
}

.empty-project h2 {
  margin: 0 0 8px;
}

.empty-project p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.ocr-status {
  display: none;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  color: #536159;
  border: 1px solid #d6e3da;
  border-radius: 7px;
  background: #f5faf7;
  font-size: 13px;
}

.ocr-status.show {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid #c9d9cf;
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.receipt-preview {
  display: none;
  margin-top: 12px;
}

.receipt-preview.show {
  display: block;
}

.receipt-preview img {
  max-width: 220px;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
}

.currency-note {
  margin-top: -10px;
  color: var(--muted);
  font-size: 12px;
}

.modal.wide {
  width: min(720px, 100%);
}

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

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

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: #47544c;
  font-size: 13px;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--forest);
}

@media (max-width: 1050px) {
  .analytics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .insight-panel {
    grid-column: 1 / -1;
  }

}

@media (max-width: 760px) {
  .ledger-head {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 24px;
  }

  .head-actions {
    width: 100%;
  }

  .head-actions .btn {
    flex: 1;
  }

  .trip-strip {
    grid-template-columns: 1fr;
  }

  .trip-meta {
    justify-content: flex-start;
  }

  .quick-entry {
    grid-template-columns: 1fr;
  }

  .entry-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .entry-actions .btn {
    padding-inline: 8px;
  }

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

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

  .insight-panel {
    grid-column: auto;
  }

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

  .row-actions {
    grid-column: 2 / -1;
    justify-content: flex-end;
  }

  .memory-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .memory-actions {
    grid-column: 1 / -1;
  }

  .memory-content {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .memory-spend {
    grid-column: auto;
  }

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

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

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

@media (max-width: 520px) {
  .metrics-grid {
    gap: 8px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 22px;
  }

  .tab-button {
    gap: 5px;
    padding-inline: 7px;
    font-size: 12px;
  }

  .category-chart {
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 12px;
    padding: 15px;
  }

  .donut {
    width: 105px;
  }

  .donut::after {
    inset: 20px;
    font-size: 12px;
  }

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

  .memory-cover {
    min-height: 260px;
    padding: 24px;
  }

  .memory-summary {
    grid-template-columns: 1fr;
  }

  .memory-summary div {
    border-right: 0;
    border-bottom: 1px solid #e9e6df;
  }

  .memory-summary div:last-child {
    border-bottom: 0;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-nav,
  .ledger-head,
  .trip-strip,
  .workspace-tabs,
  .memory-toolbar,
  .memory-draft-editor,
  .toast,
  .modal-backdrop {
    display: none !important;
  }

  .ledger-shell {
    padding: 0;
  }

  .page-container {
    width: 100%;
  }

  .memory-book {
    border: 0;
    box-shadow: none;
  }
}
