:root {
  --bg: #f3f0ea;
  --panel: #fffdf8;
  --ink: #24231f;
  --muted: #6f6a60;
  --line: #ded6c9;
  --accent: #c36c23;
  --green: #c2e4cd;
}

* {
  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;
}

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

.window {
  min-height: 100vh;
}

.titlebar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: #24231f;
  color: #fffdf8;
}

.titlebar > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.app-title {
  font-weight: 700;
}

.link-button,
.command-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.hidden {
  display: none;
}

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

.nav-pane {
  background: #312f2a;
  color: #f8f2e8;
  padding: 22px;
}

.nav-heading {
  margin: 18px 0 8px;
  color: #c9c0b3;
  font-size: 12px;
  text-transform: uppercase;
}

.nav-item {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: transparent;
  color: #f8f2e8;
  cursor: pointer;
}

.nav-item.selected,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-note {
  color: #d8d0c3;
  line-height: 1.4;
}

.content-pane {
  min-width: 0;
  padding: 26px;
}

.full-pane {
  max-width: 520px;
  margin: 0 auto;
  padding-top: 80px;
}

.login-panel,
.dialog-panel,
.list-panel,
.decision-panel,
.guide-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.login-form,
.decision-fields {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.primary-action,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.primary-action {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.command-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.guide-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.document-search-mount {
  margin-bottom: 18px;
  max-width: 720px;
}

.page-search {
  position: relative;
}

.page-search-label {
  margin-bottom: 6px;
}

.page-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.page-search-input {
  min-width: 0;
}

.page-search-clear {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.page-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(420px, 65vh);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(36, 35, 31, 0.18);
  padding: 6px;
}

.page-search-result {
  width: 100%;
  display: grid;
  gap: 3px;
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.page-search-result:hover,
.page-search-result.active {
  background: #f3eee5;
}

.page-search-result-title {
  font-weight: 700;
}

.page-search-result-snippet {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.page-search-result-snippet strong {
  color: var(--ink);
  font-weight: 800;
}

.page-search-empty {
  color: var(--muted);
  padding: 10px;
}

.search-target-highlight {
  outline: 3px solid rgba(195, 108, 35, 0.42);
  outline-offset: 4px;
  background: #fff4df;
  transition: background 0.2s ease, outline-color 0.2s ease;
}

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

.muted,
.table-hint {
  color: var(--muted);
}

.error-message {
  color: #9f2d20;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.metrics,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metrics > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metrics span,
.section-kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  font-size: 26px;
  margin: 6px 0;
}

.list-panel,
.decision-panel,
.detail-grid {
  margin-bottom: 20px;
}

.list-toolbar,
.sample-review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.sample-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search {
  width: 100%;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-grid th,
.data-grid td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.signal-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.signal-chip,
.signal-more {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  background: #ece5da;
  font-size: 12px;
}

.category-path {
  font-weight: 700;
}

.decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.notes-field {
  grid-column: 1 / -1;
}

.markdown-body {
  max-width: 980px;
  line-height: 1.6;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  border-bottom: 1px solid var(--line);
  margin: 24px 0 12px;
  padding-bottom: 8px;
}

.markdown-body h1:first-child {
  margin-top: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body .table-scroll {
  margin-bottom: 16px;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body code {
  background: #ece5da;
  border-radius: 4px;
  padding: 2px 5px;
}

.markdown-body a {
  color: var(--accent);
  font-weight: 700;
}

.table-scroll {
  overflow-x: auto;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
}

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

.markdown-body th {
  background: #ece5da;
}

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

  .nav-pane {
    display: none;
  }

  .command-bar,
  .guide-toolbar,
  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .sample-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-search-control {
    grid-template-columns: 1fr;
  }
}
