:root {
  --bg: #f7f7f2;
  --surface: #ffffff;
  --ink: #18211f;
  --muted: #63706b;
  --line: #d9ded7;
  --accent: #1f6f65;
  --accent-dark: #154c46;
  --danger: #a33a32;
  --warning: #956b16;
  --info: #255f91;
  --shadow: 0 16px 40px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.5;
}

a {
  color: var(--accent-dark);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 242, 0.95);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.nav a,
.session-pill,
.button,
button {
  border-radius: 8px;
}

.nav a {
  padding: 0.45rem 0.65rem;
  color: var(--ink);
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: #e7ede9;
}

.session-pill {
  border: 1px solid var(--line);
  padding: 0.4rem 0.65rem;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  margin-left: auto;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
}

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

.panel,
.login-panel {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.login-panel {
  width: min(460px, 100%);
  margin: 12vh auto 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-head h1,
.panel h1,
.panel h2,
.login-panel h1 {
  margin: 0;
  line-height: 1.15;
}

.page-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button,
button {
  display: inline-flex;
  min-height: 2.4rem;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--accent);
  padding: 0.45rem 0.75rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary,
button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.danger,
button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.button:hover,
button:hover {
  filter: brightness(0.96);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.span-4 {
  grid-column: span 4;
}

.span-6 {
  grid-column: span 6;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 9rem;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.search-row {
  margin: 0 0 1rem;
}

.picture-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  cursor: pointer;
}

.picture-filter input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.meta-list {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0.5rem 1rem;
  margin: 1rem 0;
}

.meta-list dt {
  color: var(--muted);
  font-weight: 700;
}

.meta-list dd {
  margin: 0;
}

.meta-list .meta-divider {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

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

.flash {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--surface);
}

.flash.success {
  border-color: #9ac9a4;
  color: #235c2d;
}

.flash.error {
  border-color: #d89a94;
  color: var(--danger);
}

.role-badge,
.relation-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  background: #e7ede9;
  color: var(--accent-dark);
  font-size: 0.82rem;
}

.relation-row {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
}

.relation-row:first-of-type {
  padding-top: 0;
}

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

pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: #f2f4f0;
}

.tree-selection-table td {
  min-width: 10rem;
  height: 3rem;
}

.tree-selection-table th,
.tree-selection-table td {
  border-right: 1px solid var(--line);
}

.tree-selection-table th:last-child,
.tree-selection-table td:last-child {
  border-right: 0;
}

.tree-selection-table [data-tree-selected-cell] {
  font-weight: 700;
}

.tree-cell-list {
  display: grid;
  gap: 0.25rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagination-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.print-only {
  display: none;
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    order: 3;
    margin-left: 0;
  }

  .nav.open {
    display: flex;
  }

  .session-pill {
    margin-left: 0;
  }

  .page-head {
    flex-direction: column;
  }

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

  .span-4,
  .span-6,
  .span-8,
  .span-12 {
    grid-column: auto;
  }

  .meta-list {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
    color: #000;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  }

  .topbar,
  .page-actions,
  .inline-actions,
  .search-row,
  .flash,
  form,
  .no-print {
    display: none !important;
  }

  .shell {
    width: auto;
    margin: 0;
  }

  .panel,
  .table-wrap {
    border-color: #000;
    box-shadow: none;
  }

  .print-only {
    display: block;
  }
}


/* Member pictures sit immediately after Notes in the information panel. */
.member-pictures {
  min-width: 0;
}

.picture-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 1rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.picture-gallery li {
  min-width: 0;
  max-width: 180px;
  break-inside: avoid;
}

.picture-thumbnail {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.picture-thumbnail img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: contain;
}

.picture-thumbnail:hover,
.picture-thumbnail:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.picture-help {
  margin: 0;
  font-size: 0.85rem;
}


.record-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e4f4e8;
  color: #166534;
  vertical-align: middle;
}

.record-status svg {
  width: 22px;
  height: 22px;
}
