:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #202426;
  --muted: #66706d;
  --line: #d8ddd8;
  --accent: #226b64;
  --accent-2: #8b4f2f;
  --danger: #a43d3d;
  --shadow: 0 18px 40px rgba(24, 34, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  filter: brightness(0.94);
}

button.ghost {
  background: #e6ece8;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.subtle {
  min-height: 34px;
  padding: 0 12px;
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 22px clamp(18px, 4vw, 42px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1,
.view-head h2 {
  letter-spacing: 0;
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.45rem, 2.4vw, 2.25rem);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 3px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100vh - 92px);
}

.sidebar {
  align-content: start;
  background: #26302f;
  display: grid;
  gap: 6px;
  padding: 18px;
}

.nav-item {
  background: transparent;
  color: #dfe7e2;
  min-height: 44px;
  text-align: left;
  width: 100%;
}

.nav-item.active,
.nav-item:focus-visible {
  background: #f7fbf8;
  color: #17201e;
  outline: 0;
}

.workspace {
  min-width: 0;
  padding: clamp(18px, 3vw, 34px);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.view-head {
  align-items: start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.view-head h2 {
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  max-width: 760px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.stat,
.panel,
.notice,
.record-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  font-size: 1.85rem;
  font-weight: 850;
}

.stat p {
  color: var(--muted);
  margin: 2px 0 0;
}

.two-column {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
}

.panel,
.notice {
  padding: 18px;
}

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

.panel-head h3,
.notice h3 {
  margin: 0;
}

.stacked-form,
.entry-form {
  display: grid;
  gap: 14px;
}

.entry-form {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
  padding: 16px;
}

label {
  color: #3a4441;
  display: grid;
  font-size: 0.9rem;
  font-weight: 750;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #cbd4cf;
  border-radius: 7px;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input[type="file"] {
  cursor: pointer;
  padding: 8px;
}

.file-field {
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed #b5c3bd;
  border-radius: 8px;
  padding: 12px;
}

.file-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.wide {
  grid-column: 1 / -1;
}

.entry-form button {
  align-self: end;
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-card {
  box-shadow: none;
  padding: 14px;
}

.record-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  background: #e8f1ee;
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 850;
  line-height: 1;
  padding: 7px 9px;
  text-transform: uppercase;
}

.delete-btn {
  background: transparent;
  border: 1px solid #e5c8c8;
  color: var(--danger);
  min-height: 32px;
  padding: 0 10px;
}

.record-card h3 {
  font-size: 1.05rem;
  margin: 10px 0 8px;
}

.record-card dl {
  display: grid;
  gap: 6px 12px;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0 0 8px;
}

.record-card dt {
  color: var(--muted);
  font-weight: 800;
}

.record-card dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-card p {
  margin: 0;
  white-space: pre-wrap;
}

.attachment-link {
  align-items: center;
  color: var(--accent);
  display: inline-flex;
  font-weight: 800;
  gap: 6px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.notice {
  max-width: 880px;
}

.notice p {
  margin-bottom: 0;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-auto-flow: column;
    overflow-x: auto;
    padding: 10px;
  }

  .nav-item {
    white-space: nowrap;
  }

  .stats-grid,
  .two-column,
  .entry-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .view-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .stats-grid,
  .two-column,
  .entry-form {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

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

  .topbar-actions,
  .sidebar,
  form,
  .delete-btn,
  .notice {
    display: none !important;
  }

  .topbar {
    position: static;
  }

  .app-shell,
  .two-column,
  .stats-grid {
    display: block;
  }

  .workspace {
    padding: 16px 0;
  }

  .view {
    display: block;
    break-after: page;
  }

  .record-card,
  .stat,
  .panel {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 12px;
  }
}
