:root {
  --ink: #25312d;
  --muted: #66736c;
  --paper: #fffaf0;
  --panel: rgba(255, 253, 246, 0.9);
  --line: rgba(48, 61, 55, 0.18);
  --sage: #8fb59f;
  --sage-dark: #527868;
  --coral: #e88975;
  --sun: #e7bf62;
  --shadow: 0 18px 50px rgba(73, 75, 63, 0.16);
  color-scheme: light;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 250, 240, 0.62), rgba(255, 250, 240, 0.82)),
    url("./assets/travel-journal-bg.png") center top / cover fixed,
    #f8efe0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 2px 16px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--sage-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.05rem, 7vw, 4rem);
  line-height: 0.98;
}

h2 {
  font-size: 1.15rem;
}

.header-actions,
.form-actions,
.expense-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.mini-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 253, 246, 0.82);
  box-shadow: 0 8px 22px rgba(73, 75, 63, 0.1);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.35rem;
}

.mini-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
}

.destination-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(15px);
  padding: 10px;
}

.destination-actions {
  display: flex;
  gap: 8px;
}

.sync-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.82);
  box-shadow: 0 10px 28px rgba(73, 75, 63, 0.1);
  backdrop-filter: blur(15px);
  padding: 12px 14px;
}

.sync-panel strong {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
}

.sync-controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto;
  gap: 8px;
}

.trip-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.trip-tab {
  display: grid;
  gap: 2px;
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
  text-align: left;
}

.trip-tab strong,
.trip-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-tab span {
  color: var(--muted);
  font-size: 0.82rem;
}

.trip-tab.active {
  border-color: rgba(82, 120, 104, 0.45);
  background: rgba(234, 246, 235, 0.86);
}

.mobile-trip-select {
  display: none;
}

.app-layout {
  display: grid;
  gap: 16px;
}

.entry-row {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(15px);
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 16px;
  color: #fff;
  background: var(--sage-dark);
  box-shadow: 0 10px 22px rgba(82, 120, 104, 0.24);
  white-space: nowrap;
}

.ghost-button {
  color: var(--sage-dark);
  border-color: rgba(82, 120, 104, 0.3);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: none;
}

.danger-button {
  color: #b34d42;
  border-color: rgba(179, 77, 66, 0.3);
}

.count-pill {
  border: 1px solid rgba(82, 120, 104, 0.3);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--sage-dark);
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-block {
  min-width: 0;
  border: 1px dashed rgba(48, 61, 55, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  padding: 12px;
}

.stat-block span,
label span {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-block strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  line-height: 1.16;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.pie-card {
  display: grid;
  place-items: center;
  min-height: 220px;
}

canvas {
  width: min(220px, 100%);
  height: auto;
}

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

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(56px, 0.75fr) minmax(120px, 1.25fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-item strong {
  color: var(--ink);
  font-weight: 700;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.expense-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(48, 61, 55, 0.2);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(82, 120, 104, 0.65);
  box-shadow: 0 0 0 4px rgba(143, 181, 159, 0.18);
}


.budget-input-wrap {
  position: relative;
  display: block;
  margin-top: 6px;
}

.budget-input-wrap span {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink);
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  font-weight: 800;
  pointer-events: none;
}

.budget-input-wrap input {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 0 0 0 24px;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.budget-input-wrap input:focus {
  box-shadow: inset 0 -2px 0 rgba(82, 120, 104, 0.38);
}

.overspent {
  color: #b34d42;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-select {
  max-width: 150px;
}

.expense-list {
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 2px;
}

.expense-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.category-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(232, 137, 117, 0.18);
  margin-top: 4px;
}

.expense-title-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.expense-title-line strong,
.expense-title-line span,
.expense-main p,
.expense-main small {
  overflow-wrap: anywhere;
}

.expense-title-line span {
  flex: 0 1 auto;
  text-align: right;
  color: var(--sage-dark);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.expense-main p,
.expense-main small {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
}

.empty-state {
  border: 1px dashed rgba(48, 61, 55, 0.24);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.44);
  text-align: center;
}

@media (max-width: 900px) {
  .entry-row {
    grid-template-columns: 1fr;
  }

  .expense-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  body {
    background-attachment: scroll;
  }

  .page-shell {
    width: min(100% - 20px, 560px);
    padding-top: 18px;
  }

  .app-header {
    align-items: flex-start;
  }

  .destination-nav {
    grid-template-columns: 1fr;
  }

  .destination-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .sync-panel,
  .sync-controls {
    grid-template-columns: 1fr;
  }

  .trip-tabs {
    display: none;
  }

  .mobile-trip-select {
    display: block;
  }

  .panel {
    padding: 15px;
  }

  .stats-grid,
  .form-row,
  .chart-layout {
    grid-template-columns: 1fr;
  }

  .chart-layout {
    justify-items: center;
  }

  .category-legend {
    width: 100%;
  }

  .legend-item {
    grid-template-columns: 12px minmax(56px, 0.7fr) minmax(118px, 1.3fr);
  }

  .expense-title-line {
    display: grid;
  }

  .filter-select {
    max-width: 132px;
  }
}

@media (max-width: 420px) {
  .panel-heading {
    align-items: flex-start;
  }

  .primary-button,
  .ghost-button {
    padding: 0 12px;
  }

  .destination-actions {
    grid-template-columns: 1fr;
  }

  .expense-item {
    grid-template-columns: 14px minmax(0, 1fr);
  }

  .expense-actions {
    grid-column: 2;
  }
}
