:root {
  color-scheme: light;
  --ink: #16211c;
  --muted: #68736f;
  --line: #d9dedb;
  --panel: #ffffff;
  --page: #f4f6f3;
  --accent: #276b53;
  --accent-strong: #174c3a;
  --gold: #b8872d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(39, 107, 83, 0.16), transparent 36rem),
    linear-gradient(180deg, #0f1714 0, #16211c 22rem, var(--page) 22rem);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 20, 0.88);
  color: white;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  font-weight: 720;
}

h2 {
  font-size: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px 32px 0;
  background: rgba(15, 23, 20, 0.88);
}

.tab {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.72);
  min-height: 38px;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.tab-panel {
  display: none;
  padding: 24px 32px 40px;
}

.tab-panel.active {
  display: block;
}

.finder {
  display: grid;
  gap: 18px;
}

.finder-hero {
  color: white;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
  min-height: 180px;
}

.finder-hero h2 {
  font-size: clamp(34px, 6vw, 66px);
  line-height: 1;
  max-width: 920px;
}

.hero-orbit {
  position: relative;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(184, 135, 45, 0.24), transparent 38%),
    rgba(255, 255, 255, 0.04);
}

.hero-orbit span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 78px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
  font-weight: 720;
}

.hero-orbit span:nth-child(1) {
  left: 72px;
  top: 18px;
}

.hero-orbit span:nth-child(2) {
  right: 12px;
  top: 112px;
}

.hero-orbit span:nth-child(3) {
  left: 12px;
  top: 112px;
}

.finder-search {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.finder-search h2 {
  font-size: 28px;
}

.results-panel,
.panel,
.flow-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.flow-panel {
  background: #101a16;
  border-color: rgba(255, 255, 255, 0.1);
  color: white;
  overflow: hidden;
}

.flow-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.flow-badge {
  align-self: start;
  border: 1px solid rgba(184, 135, 45, 0.42);
  border-radius: 999px;
  color: #f0cf8e;
  font-size: 13px;
  font-weight: 720;
  padding: 6px 10px;
}

.flow-canvas {
  display: grid;
  grid-template-columns: repeat(6, minmax(180px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.flow-node {
  position: relative;
  min-height: 170px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    #14221d;
  padding: 16px;
}

.flow-node::after {
  content: "";
  position: absolute;
  right: -15px;
  top: 50%;
  width: 14px;
  height: 1px;
  background: rgba(255, 255, 255, 0.28);
}

.flow-node:last-child::after {
  display: none;
}

.flow-node span {
  color: #f0cf8e;
  font-size: 12px;
  font-weight: 800;
}

.flow-node strong {
  display: block;
  font-size: 17px;
  margin: 16px 0 8px;
}

.flow-node p {
  color: rgba(255, 255, 255, 0.66);
  font-size: 14px;
  line-height: 1.45;
}

.flow-node.decision {
  border-color: rgba(184, 135, 45, 0.45);
}

.flow-node.sop {
  border-color: rgba(75, 153, 122, 0.48);
}

.flow-node.route {
  border-color: rgba(129, 160, 203, 0.48);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
}

.library-panel {
  grid-column: 1 / -1;
}

form {
  display: grid;
  gap: 12px;
}

.search-form {
  margin-top: 18px;
}

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

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 10px 12px;
}

button,
.button-link {
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 720;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
}

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

button.secondary {
  background: #e8eeeb;
  color: var(--accent-strong);
}

.status,
.muted {
  color: var(--muted);
  font-size: 14px;
}

.results {
  margin-top: 18px;
}

.documents,
.areas {
  display: grid;
  gap: 10px;
}

.document,
.area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  padding: 14px;
}

.document a:first-child {
  display: grid;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.document-actions {
  display: flex;
  gap: 8px;
}

#find-tab .admin-only {
  display: none;
}

.area-form {
  grid-template-columns: minmax(160px, 240px) minmax(0, 1fr) auto;
  margin-bottom: 16px;
}

.document span,
.area span {
  color: var(--muted);
  font-size: 14px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1 {
  margin: 4px 0 22px;
}

@media (max-width: 820px) {
  .topbar,
  .tabs,
  .tab-panel {
    padding-left: 18px;
    padding-right: 18px;
  }

  .finder-hero {
    grid-template-columns: 1fr;
  }

  .hero-orbit {
    display: none;
  }

  .admin-grid,
  .search-row,
  .area-form,
  .document,
  .area {
    grid-template-columns: 1fr;
  }

  .finder-search {
    padding: 22px;
  }

  .document-actions {
    display: grid;
  }
}
