:root {
  color-scheme: light;
  --ivory: #f7f1e6;
  --warm: #fff9ef;
  --green: #123f32;
  --green-soft: #1d5747;
  --sage: #dde8d8;
  --gold: #b9904d;
  --ink: #25221d;
  --muted: #746d64;
  --border: #e5d8c3;
  --danger: #9b2c2c;
  --shadow: 0 14px 34px rgba(18, 63, 50, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top right, rgba(185, 144, 77, .12), transparent 28rem),
    var(--ivory);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }

button { cursor: pointer; }

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.panel,
.stat-card,
dialog {
  border: 1px solid var(--border);
  background: rgba(255, 249, 239, .97);
  box-shadow: var(--shadow);
}

.panel { border-radius: 20px; }

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--green);
  color: var(--warm);
  font-weight: 800;
  font-size: 1.6rem;
}

h1, h2, h3, p { margin-top: 0; }

h1, h2, h3 { color: var(--green); }

.brand h1 { margin-bottom: 4px; font-size: 1.35rem; }
.brand p { margin: 0; color: var(--muted); }

.stack { display: grid; gap: 16px; }

label {
  display: grid;
  gap: 7px;
  color: var(--green);
  font-weight: 700;
  font-size: .92rem;
}

input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(185, 144, 77, .15);
}

.primary, .ghost {
  min-height: 42px;
  border-radius: 11px;
  padding: 8px 15px;
  font-weight: 750;
}

.primary {
  border: 1px solid var(--green);
  background: var(--green);
  color: var(--warm);
}

.primary:hover { background: var(--green-soft); }

.ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--green);
}

.ghost:hover { background: var(--sage); }

.error { color: var(--danger); min-height: 1.5em; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
}

.topbar h1 { margin-bottom: 0; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--gold);
  font-size: .75rem;
  font-weight: 850;
  letter-spacing: .07em;
}

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

.stat-card {
  border-radius: 16px;
  padding: 19px;
}

.stat-card strong {
  display: block;
  color: var(--green);
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-card span { color: var(--muted); font-size: .9rem; }

.filters-panel, .table-panel { padding: 20px; margin-top: 18px; }

.filters {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(130px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
}

.filters .wide { min-width: 240px; }

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

.table-head h2 { margin-bottom: 4px; }
.table-head p { margin: 0; color: var(--muted); }

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: top;
}

th {
  color: var(--green);
  font-size: .83rem;
  white-space: nowrap;
}

tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(221, 232, 216, .42); }
tbody tr[data-status="new"] { font-weight: 700; }

.status-pill {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--sage);
  color: var(--green);
  white-space: nowrap;
  font-size: .78rem;
  font-weight: 800;
}

.cell-note {
  max-width: 290px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

dialog {
  width: min(980px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border-radius: 22px;
  color: var(--ink);
}

dialog::backdrop { background: rgba(16, 37, 31, .55); }

.detail {
  padding: 24px;
  overflow: auto;
  max-height: calc(100vh - 34px);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-grid section,
.content-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fffdf8;
}

dl {
  display: grid;
  grid-template-columns: 125px 1fr;
  gap: 8px 10px;
  margin: 0;
}

dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  line-height: 1.85;
}

.content-block { margin-top: 16px; }
.note-block { border-right: 4px solid var(--gold); }

.status-editor {
  display: flex;
  gap: 12px;
  align-items: end;
  margin: 18px 0;
}

.status-editor label { min-width: 220px; }

.events {
  margin: 0;
  padding-right: 20px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .filters .wide { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 16px, 1440px); padding-top: 12px; }
  .topbar { align-items: flex-start; }
  .stats { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr; }
  .filters .wide { grid-column: auto; min-width: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .status-editor { align-items: stretch; flex-direction: column; }
  .status-editor label { min-width: 0; }
  dl { grid-template-columns: 105px 1fr; }
}
