:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #6b7672;
  --line: #dbe3df;
  --green: #1f6f5b;
  --green-dark: #165443;
  --green-soft: #e6f3ee;
  --red: #b73e35;
  --red-soft: #fae9e7;
  --blue: #2f6797;
  --blue-soft: #e8f0f7;
  --shadow: 0 18px 46px rgba(35, 45, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(244, 247, 242, 0.92), rgba(232, 238, 234, 0.92)),
    url("data:image/svg+xml,%3Csvg width='1000' height='700' viewBox='0 0 1000 700' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1000' height='700' fill='%23eef3ef'/%3E%3Cg fill='none' stroke='%23d4ded8' stroke-width='2' opacity='.9'%3E%3Cpath d='M90 110h820M90 210h820M90 310h820M90 410h820M90 510h820'/%3E%3Cpath d='M170 70v520M390 70v520M700 70v520'/%3E%3C/g%3E%3Cg fill='%23ffffff' opacity='.72'%3E%3Crect x='150' y='145' width='180' height='44' rx='4'/%3E%3Crect x='430' y='345' width='250' height='44' rx='4'/%3E%3Crect x='720' y='445' width='150' height='44' rx='4'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

button,
input {
  font: inherit;
  font-size: 16px;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(940px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 128px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1;
}

.total-pill {
  display: inline-grid;
  align-items: center;
  min-width: 150px;
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--green-dark);
  font-size: 22px;
  text-align: right;
  overflow-wrap: anywhere;
}

.entry-panel,
.records-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.entry-panel {
  margin-top: 24px;
  padding: 18px;
}

.entry-form {
  display: grid;
  grid-template-columns: 160px minmax(220px, 1fr) 150px auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
}

input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

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

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

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.small-button {
  min-height: 46px;
  border-radius: 7px;
  font-weight: 850;
}

.primary-button {
  min-width: 88px;
  padding: 0 18px;
  background: var(--green);
  color: #fff;
}

.secondary-button {
  background: var(--blue);
  color: #fff;
}

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

.ghost-button {
  min-width: 72px;
  padding: 0 14px;
  background: #edf2ef;
  color: var(--ink);
}

.status {
  margin: 14px 0 0;
  padding: 11px 14px;
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 850;
}

.bottom-nav {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(720px, calc(100% - 24px));
  margin: 0 auto;
  padding: 10px;
  border: 1px solid rgba(219, 227, 223, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(23, 33, 31, 0.18);
  backdrop-filter: blur(14px);
}

.nav-button {
  display: grid;
  place-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  border-radius: 7px;
  background: #edf2ef;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.1;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 21px;
  line-height: 1;
}

.nav-copy {
  background: var(--blue);
  color: #fff;
}

.nav-refresh {
  background: var(--green);
  color: #fff;
}

.nav-delete {
  background: var(--red-soft);
  color: var(--red);
}

.records-panel {
  margin-top: 16px;
  overflow: hidden;
}

.records-head,
.record-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr) 140px 96px;
  gap: 12px;
  align-items: center;
}

.records-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.record-row {
  min-height: 62px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

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

.record-date {
  color: var(--muted);
  font-weight: 750;
}

.record-content {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.record-amount {
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 900;
  text-align: right;
  overflow-wrap: anywhere;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.small-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  background: #edf2ef;
  color: var(--ink);
  font-size: 17px;
}

.small-button.delete {
  background: var(--red-soft);
  color: var(--red);
}

.empty-state {
  padding: 48px 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 940px);
    padding-top: 18px;
    padding-bottom: 112px;
  }

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

  .total-pill {
    min-width: 116px;
    font-size: 18px;
  }

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

  input[type="date"] {
    font-size: 16px;
    text-align: left;
  }

  .form-actions {
    display: grid;
  }

  input {
    font-size: 16px;
  }

  .records-head {
    display: none;
  }

  .record-row {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: start;
    min-height: 88px;
    padding: 14px;
  }

  .record-date {
    grid-column: 1;
    grid-row: 1;
    font-size: 13px;
  }

  .record-amount {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-width: 96px;
    font-size: 17px;
  }

  .record-content {
    grid-column: 1;
    grid-row: 2;
  }

  .record-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 4px;
  }
}
