:root {
  --ink: #1f2925;
  --muted: #66736d;
  --faint: #8d9893;
  --line: #dce2de;
  --line-strong: #bdc9c3;
  --surface: #ffffff;
  --surface-soft: #f5f7f5;
  --green: #167a68;
  --green-dark: #0d594c;
  --green-soft: #e7f3ee;
  --blue-soft: #eaf1f8;
  --blue: #315f88;
  --amber-soft: #fff4df;
  --amber: #9b6513;
  --red-soft: #faece9;
  --red: #a34739;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--surface-soft); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--surface-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
.document-body:focus-visible {
  outline: 3px solid rgb(22 122 104 / 20%);
  outline-offset: 2px;
}

.is-hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
}

.topbar-inner,
main {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font-size: 14px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--muted);
  font-size: 13px;
}

.topnav a { color: inherit; text-decoration: none; }
.topnav a:hover { color: var(--green); }

.current-user {
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main { padding: 34px 0 56px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.kicker,
.access-kicker {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
}

h1,
h2,
p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.page-summary {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.page-summary strong { color: var(--ink); font-size: 24px; }

.access-state {
  padding: 54px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.access-state h2 { margin: 0; font-size: 24px; }

.access-state > p:not(.access-kicker) {
  max-width: 620px;
  margin: 12px 0 22px;
  color: var(--muted);
  line-height: 1.7;
}

.primary-command,
.filterbar button,
.quiet-command,
.download-command,
.pagination button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--green);
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
  cursor: pointer;
}

.records-workbench {
  display: grid;
  min-height: 680px;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.record-index {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.filterbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.search-field { min-width: 0; }

.filterbar input,
.filterbar select {
  width: 100%;
  height: 38px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

.filterbar .quiet-command,
.quiet-command,
.pagination button {
  border-color: var(--line-strong);
  color: var(--ink);
  background: #fff;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.record-list { flex: 1; min-height: 0; }

.record-row {
  display: block;
  width: 100%;
  min-height: 112px;
  padding: 15px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.record-row:hover { background: var(--surface-soft); }

.record-row.is-active {
  box-shadow: inset 3px 0 var(--green);
  background: var(--green-soft);
}

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

.record-date { color: var(--muted); font-size: 11px; }

.record-row strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-participants {
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-label {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 10px;
  font-weight: 700;
}

.status-label[data-status="approved"] { color: var(--green-dark); background: var(--green-soft); }
.status-label[data-status="stale"] { color: var(--amber); background: var(--amber-soft); }
.status-label[data-status="revoked"] { color: var(--red); background: var(--red-soft); }

.loading-row,
.empty-state {
  padding: 42px 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.pagination {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.pagination button { min-height: 34px; padding: 0 10px; font-size: 11px; }

.record-detail { min-width: 0; background: var(--surface); }

.detail-placeholder {
  display: grid;
  min-height: 680px;
  place-content: center;
  justify-items: center;
  color: var(--faint);
}

.placeholder-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  background: var(--surface-soft);
  font-size: 20px;
}

.detail-placeholder h2 { margin: 0; font-size: 15px; font-weight: 600; }

.detail-content { min-width: 0; }

.detail-head {
  display: flex;
  min-height: 152px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 28px 22px;
  border-bottom: 1px solid var(--line);
}

.detail-labels {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.detail-head h2 {
  max-width: 900px;
  margin: 12px 0 13px;
  font-size: 23px;
  line-height: 1.35;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.detail-meta div { display: flex; gap: 5px; }
.detail-meta dt { color: var(--faint); }
.detail-meta dd { margin: 0; }

.document-toolbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 28px;
  border-bottom: 1px solid var(--line);
}

.document-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.document-tabs button {
  min-width: 92px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.document-tabs button.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgb(30 45 38 / 10%);
  font-weight: 680;
}

.download-command { min-height: 36px; }

.document-info {
  min-height: 35px;
  padding: 10px 28px 7px;
  color: var(--muted);
  font-size: 10px;
}

.document-body {
  width: 100%;
  min-height: 430px;
  max-height: 70vh;
  margin: 0;
  padding: 12px 28px 36px;
  overflow: auto;
  border: 0;
  color: #29332f;
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.85;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 15px;
  border-radius: 6px;
  color: #fff;
  background: #28342f;
  box-shadow: 0 12px 30px rgb(20 31 26 / 20%);
  font-size: 12px;
}

.toast.is-error { background: var(--red); }

.unlock-dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(25 38 32 / 24%);
}

.unlock-dialog::backdrop {
  background: rgb(25 38 32 / 48%);
  backdrop-filter: blur(3px);
}

.unlock-form {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.unlock-kicker,
.unlock-form h2,
.unlock-meeting,
.unlock-hint {
  margin: 0;
}

.unlock-kicker {
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
}

.unlock-form h2 {
  margin-top: -10px;
  font-size: 23px;
}

.unlock-meeting {
  margin-top: -9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.unlock-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.unlock-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

.unlock-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.unlock-actions button {
  min-height: 40px;
}

@media (max-width: 900px) {
  .topbar-inner,
  main { width: min(100% - 28px, 760px); }

  .topnav a:first-child,
  .current-user { display: none; }

  main { padding-top: 24px; }

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

  .record-index {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .record-list { max-height: 360px; overflow: auto; }
  .record-detail { min-height: 540px; }
  .detail-placeholder { min-height: 540px; }
}

@media (max-width: 560px) {
  .topbar-inner { min-height: 56px; }
  .brand { font-size: 13px; }
  .topnav { gap: 10px; font-size: 11px; }

  .page-head { align-items: center; }
  h1 { font-size: 25px; }

  .filterbar { grid-template-columns: minmax(0, 1fr) auto; }

  .filterbar .quiet-command { grid-column: 1 / -1; }

  .detail-head {
    min-height: 0;
    padding: 20px 18px;
  }

  .detail-head .quiet-command { display: none; }
  .detail-head h2 { font-size: 19px; }

  .document-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px 18px;
  }

  .document-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .document-tabs button { min-width: 0; }
  .download-command { width: 100%; }
  .document-info { padding-inline: 18px; }
  .document-body { padding: 10px 18px 30px; font-size: 13px; }

  .unlock-form { padding: 22px 18px; }

  .unlock-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .unlock-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
