:root {
  --canvas: #f3f5f2;
  --surface: #ffffff;
  --surface-muted: #f7f8f6;
  --line: #dfe4de;
  --line-strong: #cbd3ca;
  --text: #1e2721;
  --text-soft: #617066;
  --text-faint: #88928b;
  --accent: #16714a;
  --accent-strong: #0d5c3a;
  --accent-soft: #e8f4ed;
  --amber: #9b6618;
  --amber-soft: #fff3d9;
  --red: #a4403a;
  --red-soft: #fdecea;
  --gray-soft: #eef1ee;
  --focus: #2d82c7;
  --topbar-height: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  background: var(--canvas);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--canvas);
}

.auth-panel {
  width: min(100%, 390px);
  padding: 38px 36px 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(32, 48, 38, 0.09);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 750;
}

.brand-mark-small {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 15px;
  flex: 0 0 32px;
}

.auth-kicker,
.eyebrow {
  margin: 22px 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.auth-panel h1 {
  margin: 0 0 30px;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 720;
}

.auth-panel form {
  display: grid;
  gap: 9px;
}

.auth-panel label,
.select-label {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

.auth-panel input,
.filter-panel input,
.filter-panel select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}

.auth-panel input {
  padding: 0 12px;
  margin-bottom: 8px;
}

.auth-panel input:focus,
.filter-panel input:focus,
.filter-panel select:focus,
.global-search:focus-within {
  border-color: var(--focus);
}

.form-error {
  min-height: 20px;
  margin: 2px 0;
  color: var(--red);
  font-size: 13px;
  line-height: 1.45;
}

.password-rule {
  margin: -2px 0 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 680;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secondary-button {
  width: 100%;
  border: 1px solid var(--line-strong);
  color: var(--text-soft);
  background: var(--surface);
}

.secondary-button:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(300px, 680px) minmax(220px, 1fr);
  align-items: center;
  height: var(--topbar-height);
  padding: 0 22px;
  gap: 28px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.topbar-brand,
.account-area,
.reader-actions,
.reader-meta {
  display: flex;
  align-items: center;
}

.topbar-brand {
  min-width: 0;
  gap: 11px;
}

.topbar-brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.global-search {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  height: 40px;
  padding: 0 11px;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-muted);
}

.global-search svg,
.date-field svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.global-search input {
  min-width: 0;
  height: 38px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.global-search input::placeholder {
  color: var(--text-faint);
}

.global-search kbd {
  min-width: 22px;
  padding: 2px 6px;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
}

.account-area {
  justify-content: flex-end;
  min-width: 0;
  gap: 12px;
}

.account-copy {
  display: grid;
  min-width: 0;
  text-align: right;
}

.account-copy strong,
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 13px;
}

.account-copy span {
  color: var(--text-faint);
  font-size: 11px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-muted);
  border-color: var(--line);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(330px, 390px) minmax(470px, 1fr);
  height: calc(100vh - var(--topbar-height));
  min-height: 560px;
}

.filter-panel,
.record-panel,
.reader-panel {
  min-width: 0;
  height: 100%;
  overflow-y: auto;
}

.filter-panel {
  padding: 22px 18px 28px;
  background: var(--surface-muted);
  border-right: 1px solid var(--line);
}

.filter-section {
  padding: 0 0 22px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
}

.filter-section h2,
.select-label {
  display: block;
  margin: 0 0 11px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 720;
}

.department-list {
  display: grid;
  gap: 3px;
}

.department-group-label {
  padding: 10px 8px 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
}

.department-option {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 36px;
  padding: 6px 8px;
  gap: 8px;
  border-radius: 6px;
  color: var(--text-soft);
  cursor: pointer;
}

.department-option:hover {
  color: var(--text);
  background: var(--gray-soft);
}

.department-option.selected {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 680;
}

.department-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.department-option svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.department-option span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.department-option small {
  color: var(--text-faint);
  font-size: 10px;
}

.status-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.status-control button {
  min-height: 32px;
  padding: 4px 6px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.status-control button.selected {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #b7d9c6;
  font-weight: 700;
}

.date-field {
  display: grid;
  grid-template-columns: 18px 38px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  margin-top: 8px;
}

.date-field label {
  color: var(--text-faint);
  font-size: 11px;
}

.filter-panel input,
.filter-panel select {
  height: 36px;
  padding: 0 8px;
  font-size: 12px;
}

.filter-panel select {
  appearance: auto;
}

.record-panel {
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.record-panel-head {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 15px 18px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.record-panel-head .eyebrow {
  margin: 0 0 4px;
}

.record-panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 680;
}

.loading-label {
  color: var(--text-faint);
  font-size: 11px;
}

.record-list {
  display: grid;
}

.record-item {
  position: relative;
  width: 100%;
  min-height: 132px;
  padding: 16px 42px 16px 18px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.record-item:hover {
  background: var(--surface-muted);
}

.record-item.selected {
  background: #edf6f0;
  box-shadow: inset 3px 0 0 var(--accent);
}

.record-item h3 {
  margin: 8px 0 7px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 700;
}

.record-item p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-item-top,
.record-item-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.record-item-top {
  color: var(--text-faint);
  font-size: 11px;
}

.record-item-tags {
  margin-top: 10px;
}

.record-item .chevron {
  position: absolute;
  top: 53px;
  right: 16px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.35;
}

.tag {
  color: var(--text-soft);
  background: var(--gray-soft);
}

.tag.shared {
  color: #70530e;
  background: #f6edcf;
}

.status-badge.confirmed {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.status-badge.pending {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge.expired {
  color: var(--red);
  background: var(--red-soft);
}

.status-badge.history {
  color: var(--text-soft);
  background: var(--gray-soft);
}

.empty-state,
.reader-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 360px;
  padding: 32px;
  color: var(--text-faint);
  text-align: center;
}

.empty-state svg,
.reader-empty svg {
  width: 34px;
  height: 34px;
  margin-bottom: 13px;
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state strong,
.reader-empty strong {
  color: var(--text-soft);
  font-size: 14px;
}

.empty-state span,
.reader-empty span {
  margin-top: 5px;
  font-size: 12px;
}

.reader-panel {
  background: var(--surface);
}

.reader-toolbar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  min-height: 104px;
  padding: 19px 28px 17px;
  gap: 18px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
}

.reader-title-block {
  min-width: 0;
}

.reader-title-block h1 {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.35;
  font-weight: 730;
}

.reader-meta {
  flex-wrap: wrap;
  gap: 7px;
  color: var(--text-faint);
  font-size: 11px;
}

.reader-actions {
  gap: 4px;
}

.markdown-body {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 34px 44px 90px;
  color: #2a322c;
  font-size: 14px;
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--text);
  line-height: 1.4;
}

.markdown-body h1 {
  margin: 0 0 24px;
  font-size: 25px;
}

.markdown-body h2 {
  margin: 38px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 19px;
}

.markdown-body h3 {
  margin: 28px 0 10px;
  font-size: 16px;
}

.markdown-body h4 {
  margin: 22px 0 8px;
  font-size: 14px;
}

.markdown-body p {
  margin: 9px 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
}

.markdown-body li {
  margin: 5px 0;
}

.markdown-body blockquote {
  margin: 16px 0;
  padding: 9px 14px;
  color: var(--text-soft);
  background: var(--surface-muted);
  border-left: 3px solid #95b7a2;
}

.markdown-body blockquote p {
  margin: 3px 0;
}

.markdown-body .table-wrap {
  width: 100%;
  margin: 18px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.markdown-body table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.55;
}

.markdown-body th,
.markdown-body td {
  padding: 9px 11px;
  vertical-align: top;
  text-align: left;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.markdown-body th:last-child,
.markdown-body td:last-child {
  border-right: 0;
}

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

.markdown-body th {
  color: var(--text);
  background: var(--surface-muted);
  font-weight: 700;
}

.markdown-body code {
  padding: 2px 5px;
  color: #8a3b2f;
  background: #f7efec;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.markdown-body pre {
  margin: 16px 0;
  padding: 14px;
  overflow-x: auto;
  color: #eef4ef;
  background: #27322b;
  border-radius: 6px;
}

.markdown-body pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.markdown-body a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

mark {
  padding: 0 2px;
  color: inherit;
  background: #ffe4a6;
  border-radius: 2px;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 26px;
  max-width: min(90vw, 480px);
  padding: 11px 15px;
  color: #ffffff;
  background: #27322b;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(22, 31, 25, 0.24);
  transform: translateX(-50%);
  font-size: 13px;
}

.filter-scrim {
  position: fixed;
  z-index: 39;
  inset: 0;
  background: rgba(25, 34, 28, 0.42);
}

.mobile-only {
  display: none;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 230px minmax(280px, 1fr) 180px;
    gap: 18px;
  }

  .workspace {
    grid-template-columns: 220px 340px minmax(420px, 1fr);
  }

  .account-copy span {
    display: none;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-height: 58px;
  }

  .mobile-only {
    display: inline-grid;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: auto;
    min-height: var(--topbar-height);
    padding: 9px 12px;
    gap: 10px;
  }

  .topbar-brand {
    gap: 6px;
  }

  .topbar-brand .brand-mark,
  .topbar-brand strong {
    display: none;
  }

  .global-search {
    height: 38px;
  }

  .global-search kbd,
  .account-copy {
    display: none;
  }

  .workspace {
    display: block;
    height: calc(100vh - var(--topbar-height));
    min-height: 0;
  }

  .filter-panel {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 330px);
    height: 100vh;
    padding: 16px 18px 28px;
    box-shadow: 16px 0 40px rgba(26, 37, 30, 0.14);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .filter-panel.open {
    transform: translateX(0);
  }

  .mobile-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    margin-bottom: 16px;
  }

  .record-panel,
  .reader-panel {
    width: 100%;
    height: 100%;
    border: 0;
  }

  .record-panel.mobile-hidden,
  .reader-panel.mobile-hidden {
    display: none;
  }

  .record-panel-head {
    min-height: 70px;
    padding: 12px 16px;
  }

  .record-item {
    min-height: 124px;
    padding-left: 16px;
  }

  .reader-toolbar {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    min-height: 90px;
    padding: 12px 10px;
    gap: 6px;
  }

  .reader-title-block h1 {
    font-size: 16px;
  }

  .reader-meta {
    font-size: 10px;
  }

  .reader-actions {
    gap: 0;
  }

  .markdown-body {
    padding: 24px 18px 72px;
    font-size: 14px;
  }

  .markdown-body h1 {
    font-size: 22px;
  }

  .markdown-body h2 {
    margin-top: 32px;
    font-size: 18px;
  }

  .auth-panel {
    padding: 30px 24px;
  }
}

@media (max-width: 430px) {
  .global-search input::placeholder {
    color: transparent;
  }

  .global-search input:focus::placeholder {
    color: var(--text-faint);
  }

  .auth-shell {
    place-items: start center;
    padding-top: 11vh;
  }

  .auth-panel {
    width: 100%;
  }
}

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