:root {
  --bg: #f7fbf7;
  --surface: #ffffff;
  --surface-strong: #e6f3e8;
  --text: #102018;
  --muted: #5f7167;
  --faint: #8ea197;
  --line: #cfe0d5;
  --line-soft: #e4eee7;
  --accent: #008f5a;
  --accent-dark: #006b45;
  --accent-ink: #053d2a;
  --accent-soft: #dff4e7;
  --fresh: #72d88c;
  --danger: #a64035;
  --shadow: 0 22px 70px rgba(0, 107, 69, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(223, 244, 231, 0.75) 0, rgba(247, 251, 247, 0) 320px),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 80px 1fr;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100svh;
  padding: 16px 10px;
  border-right: 1px solid var(--line-soft);
  background: rgba(247, 251, 247, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid var(--accent);
  background: var(--accent-ink);
  display: grid;
  place-items: center;
  color: var(--fresh);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
}

.nav-item {
  width: 56px;
  min-height: 56px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 4px;
  font-size: 12px;
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(0, 143, 90, 0.08);
}

.nav-item.bottom {
  margin-top: auto;
}

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

.top-bar {
  height: 74px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  background: #dff4e7;
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
  isolation: isolate;
}

.top-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("./assets/header-banner.jpg");
  background-size: cover;
  background-position: center 43%;
  opacity: 0.96;
  filter: saturate(1.12) contrast(1.02);
  pointer-events: none;
}

.top-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at center, rgba(247, 251, 247, 0.56) 0%, rgba(247, 251, 247, 0.34) 31%, rgba(247, 251, 247, 0.08) 66%),
    linear-gradient(90deg, rgba(0, 72, 45, 0.18), rgba(114, 216, 140, 0.04), rgba(0, 72, 45, 0.16)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(5, 61, 42, 0.08));
  pointer-events: none;
}

.top-bar > * {
  position: relative;
  z-index: 1;
}

.brand-title {
  margin: 0 auto;
  max-width: min(680px, calc(100vw - 150px));
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 12px;
}

.brand-title img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 14px rgba(0, 72, 45, 0.14));
}

.brand-title h1 {
  margin: 0;
  padding: 0;
  max-width: min(620px, calc(100vw - 150px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-family: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", Optima, system-ui, sans-serif;
  font-size: 29px;
  font-weight: 760;
  letter-spacing: 0;
  color: var(--accent-ink);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    0 2px 10px rgba(247, 251, 247, 0.96),
    0 8px 24px rgba(247, 251, 247, 0.86);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--accent);
  display: grid;
  place-items: center;
  justify-self: end;
  pointer-events: auto;
  border-radius: var(--radius);
  transition: background 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(0, 143, 90, 0.1);
}

.icon-button:active {
  transform: scale(0.94);
}

.mobile-only {
  visibility: hidden;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(360px, 1fr) minmax(340px, 1fr);
  min-height: calc(100svh - 74px);
}

.form-panel,
.records-panel,
.detail-panel,
.info-panel {
  min-width: 0;
  padding: 28px;
}

.form-panel,
.records-panel {
  border-right: 1px solid var(--line-soft);
}

.section-heading h2,
.records-header h2,
.info-panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
}

.section-heading p,
.records-header p,
.fine-print {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.form-flash {
  animation: form-flash 900ms ease;
}

@keyframes form-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 143, 90, 0);
  }
  28% {
    box-shadow: 0 0 0 5px rgba(0, 143, 90, 0.18);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 143, 90, 0);
  }
}

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

.field span {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field textarea,
.search-box {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input,
.field textarea {
  padding: 11px 12px;
  font-size: 15px;
}

.field textarea {
  resize: vertical;
  min-height: 86px;
}

.field input:focus,
.field textarea:focus,
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169, 120, 36, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.location-tools {
  display: grid;
  gap: 8px;
}

.location-tools .subtle-button {
  justify-self: start;
}

.location-tools p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.subtle-button,
.secondary-button,
.primary-button,
.photo-picker {
  min-height: 44px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 650;
}

.subtle-button,
.secondary-button,
.photo-picker {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

.primary-button {
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, #00a96b, #007a4f);
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 143, 90, 0.22);
}

.lookup-results {
  display: grid;
  gap: 6px;
}

.suggestion-results:not(:empty) {
  margin-top: 2px;
}

.lookup-result {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 10px;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
}

.lookup-result.is-muted {
  cursor: default;
  color: var(--muted);
}

.lookup-result strong {
  display: block;
  font-size: 13px;
}

.lookup-result small {
  color: var(--muted);
  line-height: 1.4;
}

.photo-picker input {
  display: none;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-chip {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--surface);
}

.photo-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-chip button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  display: grid;
  place-items: center;
}

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

.form-actions .primary-button {
  grid-column: 1 / -1;
}

.form-actions .secondary-button:not(.hidden) + .primary-button {
  grid-column: auto;
}

.records-header {
  display: grid;
  gap: 16px;
}

.search-box {
  height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.record-list {
  margin-top: 18px;
  display: grid;
  gap: 4px;
}

.record-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 10px;
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 12px;
  text-align: left;
  align-items: center;
}

.record-item:hover,
.record-item.selected {
  border-color: var(--line);
  background: var(--surface);
}

.record-item.selected {
  border-color: rgba(0, 143, 90, 0.45);
  box-shadow: inset 3px 0 0 var(--accent);
}

.record-thumb,
.thumb-placeholder {
  width: 74px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--accent-soft);
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.record-body {
  min-width: 0;
}

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

.record-body strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.record-body p,
.record-body small {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.record-body small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount {
  white-space: nowrap;
  font-size: 14px;
  color: var(--text);
}

.detail-panel {
  background: linear-gradient(180deg, #ffffff 0%, #eef8f0 100%);
}

.empty-detail {
  height: 100%;
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-detail svg {
  width: 44px;
  height: 44px;
  color: var(--accent);
}

.detail-accent-image {
  width: min(280px, 78%);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid rgba(0, 143, 90, 0.22);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.empty-detail h2 {
  margin: 16px 0 4px;
  color: var(--text);
  font-size: 20px;
}

.detail-card {
  display: grid;
  gap: 22px;
}

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

.detail-actions button,
.setting-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.detail-actions .danger,
.setting-row.danger {
  color: var(--danger);
}

.detail-title h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
  line-height: 1.08;
}

.detail-title p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-photos {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
}

.detail-photos img {
  width: 100%;
  height: 190px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--surface-strong);
}

.detail-photos img:first-child {
  height: 260px;
}

.detail-meta {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line-soft);
}

.meta-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  line-height: 1.5;
}

.meta-row span {
  color: var(--muted);
}

.info-panel {
  max-width: 920px;
  margin: 0 auto;
}

.stats-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #eef8f1 100%);
}

.stat-box strong {
  display: block;
  font-size: 28px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  color: var(--accent-dark);
}

.stat-box span {
  color: var(--muted);
  font-size: 13px;
}

.settings-list {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.setting-row {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  justify-content: space-between;
  padding: 0 16px;
  font-weight: 650;
}

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

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius);
  background: rgba(5, 61, 42, 0.94);
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: minmax(300px, 390px) minmax(360px, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line-soft);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .side-nav {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    height: calc(66px + env(safe-area-inset-bottom));
    padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-soft);
    border-right: 0;
    flex-direction: row;
    justify-content: space-around;
  }

  .brand-mark {
    display: none;
  }

  .nav-item {
    width: 64px;
    min-height: 52px;
    border-left: 0;
    border-top: 2px solid transparent;
  }

  .nav-item.active {
    border-top-color: var(--accent);
  }

  .nav-item.bottom {
    margin-top: 0;
  }

  .top-bar {
    height: 82px;
    padding: 0 14px;
    grid-template-columns: 32px minmax(0, 1fr) 32px;
  }

  .brand-title {
    max-width: calc(100vw - 92px);
    gap: 7px;
  }

  .brand-title img {
    width: 34px;
    height: 34px;
  }

  .brand-title h1 {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 21px;
    line-height: 1.05;
  }

  .mobile-only {
    visibility: visible;
  }

  .content-grid {
    display: block;
  }

  .form-panel,
  .records-panel,
  .detail-panel,
  .info-panel {
    padding: 24px 18px;
    border-right: 0;
  }

  .records-panel {
    border-top: 1px solid var(--line-soft);
  }

  .detail-panel {
    border-top: 1px solid var(--line-soft);
  }

  .field-grid,
  .lookup-row,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .record-item {
    grid-template-columns: 68px 1fr;
  }

  .record-thumb,
  .thumb-placeholder {
    width: 68px;
    height: 54px;
  }

  .record-item > .amount {
    grid-column: 2;
    justify-self: start;
  }

  .detail-title h2 {
    font-size: 28px;
  }

  .detail-photos,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-photos img,
  .detail-photos img:first-child {
    height: 220px;
  }

  .meta-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
