:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --ink: #14231c;
  --muted: #66756d;
  --line: #dce5df;
  --green: #597722;
  --green-dark: #43591a;
  --green-soft: #e9efd6;
  --gold: #b98935;
  --shadow: 0 16px 45px rgba(27, 56, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(89, 119, 34, 0.14), transparent 30rem),
    var(--bg);
  font-family: "Quicksand", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input, select { font: inherit; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: linear-gradient(145deg, #6f8f2b, #43591a);
  font-family: "Quicksand", sans-serif;
  font-size: 22px;
  box-shadow: 0 7px 18px rgba(89, 119, 34, 0.24);
}

.brand-logo {
  height: 42px;
  width: auto;
  display: block;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: 0.01em; }
.brand small { color: var(--muted); margin-top: 1px; }

.topbar-meta { display: flex; align-items: center; gap: 18px; }
.environment-badge, .status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.environment-badge { padding: 7px 11px; color: #78591f; background: #fff1cf; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.page-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 60px; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.compact-hero { align-items: center; }
.hero h1 { margin: 5px 0 8px; font-family: "Quicksand", sans-serif; font-size: clamp(32px, 5vw, 52px); line-height: 1.06; font-weight: 500; }
.hero-copy { margin: 0; max-width: 700px; color: var(--muted); font-size: 16px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }

.primary-button, .secondary-button, .text-button, .copy-button, .danger-button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-button, .secondary-button { padding: 11px 17px; }
.primary-button { color: white; background: var(--green); box-shadow: 0 7px 18px rgba(89, 119, 34, 0.18); }
.secondary-button { color: var(--green-dark); background: var(--green-soft); }
.text-button { color: var(--green); padding: 9px 6px; }
.copy-button { padding: 6px 9px; color: var(--green); background: transparent; }
.danger-button { padding: 11px 17px; color: white; background: #b3261e; box-shadow: 0 7px 18px rgba(179, 38, 30, 0.18); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.danger-button:hover { transform: translateY(-1px); background: #8c1d18; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 16px; margin-bottom: 20px; }
.metric-card {
  min-height: 145px;
  padding: 23px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { font-family: "Quicksand", sans-serif; font-size: 44px; font-weight: 500; }
.metric-card .metric-date { font-family: inherit; font-size: clamp(18px, 2.4vw, 28px); font-weight: 650; }

.panel { margin-top: 20px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-heading h2 { margin: 0; font-family: "Quicksand", sans-serif; font-size: 26px; font-weight: 500; }
.panel-heading p:not(.eyebrow) { color: var(--muted); margin: 7px 0 0; }
.result-count, .timestamp { color: var(--muted); font-size: 13px; }

.event-chip-list { display: flex; flex-wrap: wrap; gap: 10px; }
.event-chip { display: inline-flex; align-items: center; gap: 10px; padding: 8px 10px 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); }
.event-chip strong { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 12px; }

.filter-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0 24px; }
.search-field { flex: 1; }
.filter-bar input, .filter-bar select, .event-filter select {
  width: 100%;
  height: 43px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.filter-bar input:focus, .filter-bar select:focus, .event-filter select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(89, 119, 34, 0.1); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 12px; letter-spacing: 0.05em; text-align: left; text-transform: uppercase; }
td { padding: 16px 14px; border-bottom: 1px solid #e9efeb; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbfa; }
.document-link { display: block; margin-bottom: 6px; font-weight: 750; text-decoration: none; }
.document-link:hover { color: var(--green); }
.subtle-id { color: var(--muted); font-size: 12px; }
.status-badge { padding: 6px 9px; color: var(--green-dark); background: var(--green-soft); }
.status-discovered { color: #74551c; background: #fff1cf; }
.status-archived { color: #5c6460; background: #edf0ee; }
.row-arrow { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--green); background: var(--green-soft); text-decoration: none; }

.empty-state { padding: 58px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin: 10px 0 5px; }
.empty-state p { margin: 0; }
.empty-icon { font-size: 34px; color: var(--green); }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 27px; color: var(--muted); font-size: 14px; }
.breadcrumb a { color: var(--green); text-decoration: none; }
.title-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.project-code { color: var(--green-dark); font-weight: 700; }
.project-code-badge { padding: 5px 9px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-weight: 700; letter-spacing: 0.02em; }
.document-hero { align-items: center; padding-bottom: 8px; }
.document-hero h1 { font-size: clamp(31px, 4.5vw, 48px); }
.id-line { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.id-line code { overflow-wrap: anywhere; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.8fr); gap: 20px; }
.detail-grid .panel { margin: 0; }
.context-copy { white-space: pre-wrap; line-height: 1.7; }
.muted-copy { color: var(--muted); }
.metadata-panel dl { margin: 16px 0 0; }
.metadata-panel dl > div { padding: 11px 0; border-bottom: 1px solid var(--line); }
.metadata-panel dt { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.metadata-panel dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; }

.timeline-panel { margin-top: 20px; }
.timeline-heading { align-items: flex-end; }
.event-filter { min-width: 245px; }
.timeline { list-style: none; margin: 0; padding: 3px 0 3px 26px; border-left: 2px solid var(--green-soft); }
.timeline-item { position: relative; padding: 0 0 18px 24px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker { position: absolute; left: -33px; top: 18px; width: 14px; height: 14px; border: 3px solid var(--surface); border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.event-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.event-card header { display: flex; justify-content: space-between; gap: 20px; }
.event-card time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.event-type { color: var(--green-dark); font-weight: 800; }
.session-label { margin-left: 9px; color: var(--muted); font-size: 12px; }
.user-label { margin-left: 9px; padding: 2px 9px; border-radius: 999px; color: #78591f; background: #fff1cf; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.user-label-missing { color: #5c6460; background: #edf0ee; }
.event-summary { margin: 13px 0; line-height: 1.55; white-space: pre-wrap; }
.event-card footer { margin-top: 12px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }

.json-details { margin-top: 10px; }
.json-details summary { cursor: pointer; color: var(--green); font-size: 13px; font-weight: 700; }
.json-details pre { max-height: 430px; overflow: auto; padding: 14px; border-radius: 10px; color: #d8f3e3; background: #12251c; font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.metadata-json { margin-top: 16px; }

.tasks-panel { margin-top: 20px; }
.task-board { display: grid; gap: 10px; }
.dashboard-task { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.task-check { flex: 0 0 auto; color: var(--green); font-size: 16px; line-height: 1.4; }
.dashboard-task.completed .task-check { color: #9aa7a0; }
.task-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.task-title { font-weight: 700; }
.dashboard-task.completed .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { color: var(--muted); font-size: 12px; }

.sources-panel { margin-top: 20px; }
.source-board { display: grid; gap: 10px; }
.dashboard-source { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); text-decoration: none; }
.dashboard-source:hover { border-color: var(--green); }
.source-name { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.source-open { flex: 0 0 auto; color: var(--green); font-size: 13px; font-weight: 700; }

.footer { padding: 24px 20px 35px; color: var(--muted); text-align: center; font-size: 12px; }
.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; }

.modal-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(18, 34, 25, 0.42); z-index: 50; }
.modal-overlay[hidden] { display: none; }
.modal { width: min(440px, calc(100% - 40px)); padding: 26px; border-radius: 16px; background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28); }
.modal h2 { margin: 0 0 10px; font-family: "Quicksand", sans-serif; font-size: 25px; font-weight: 500; }
.modal p { margin: 0 0 12px; color: var(--muted); line-height: 1.55; }
.modal .modal-note { color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 820px) {
  .clock { display: none; }
  .page-shell { width: min(100% - 24px, 1240px); padding-top: 28px; }
  .metric-grid, .detail-grid { grid-template-columns: 1fr; }
  .wide-metric { grid-column: auto; }
  .hero, .timeline-heading { align-items: flex-start; flex-direction: column; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .event-filter { width: 100%; min-width: 0; }
  .document-heading { align-items: flex-start; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 14px; }
  .environment-badge { display: none; }
  .panel, .metric-card { padding: 18px; border-radius: 14px; }
  .event-card header { flex-direction: column; gap: 7px; }
  th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4) { display: none; }
}


.structure-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.structure-list li { padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px; background: var(--surface-soft); font-size: 14px; }
.structure-list strong { color: var(--green-dark); font-weight: 700; }