:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171a1d;
  --panel-2: #1f2327;
  --text: #f3f0e8;
  --muted: #a7adb3;
  --line: #30363c;
  --accent: #58c7b7;
  --accent-2: #d8a657;
  --danger: #eb6f72;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #ffffff;
  --panel-2: #ede9de;
  --text: #1d2329;
  --muted: #5d6670;
  --line: #d9d2c2;
  --accent: #087b72;
  --accent-2: #9b5f00;
  --danger: #b4232f;
  --shadow: 0 18px 45px rgba(72, 57, 34, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

code {
  font-family: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topnav a,
button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.topnav a,
button {
  min-height: 38px;
  padding: 8px 12px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  padding: 0;
}

.theme-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-icon-moon,
:root[data-theme="light"] .theme-icon-sun {
  display: none;
}

:root[data-theme="light"] .theme-icon-moon {
  display: block;
}

.text-button {
  color: var(--accent);
}

.app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 2vw, 28px) 28px;
}

.search-pane,
.document-page {
  min-width: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

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

.summary-strip strong,
.summary-strip span {
  display: block;
}

.summary-strip strong {
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
}

.summary-strip span {
  color: var(--muted);
  font-size: 0.86rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(130px, 0.55fr) minmax(220px, 1fr) minmax(130px, 0.45fr);
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 9px 11px;
}

.results-bar,
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
}

.status-line {
  min-height: 24px;
  color: var(--muted);
}

.policy-list {
  display: grid;
  gap: 10px;
}

.policy-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.policy-item.is-active {
  border-color: var(--accent);
}

.policy-open {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 0;
  padding: 15px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.policy-open:hover {
  background: var(--panel-2);
}

.policy-title {
  color: var(--text);
  font-weight: 800;
}

.policy-path,
.policy-description,
.policy-meta {
  overflow-wrap: anywhere;
}

.policy-path {
  color: var(--accent);
  font-size: 0.9rem;
}

.policy-description {
  color: var(--muted);
}

.policy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.policy-meta span,
.platform-list span {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}

.search-hit {
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent-2) 54%, transparent);
  color: var(--text);
  padding: 0 2px;
}

.policy-page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.policy-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.back-link {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--accent);
  text-decoration: none;
}

.detail-kicker {
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.empty-detail,
.detail-header,
.detail-section,
.detail-actions,
.registry-grid {
  padding: 18px;
}

.empty-detail h1,
.detail-header h1,
.page-heading h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  line-height: 1.1;
}

.empty-detail p,
.page-heading p,
.detail-subtitle {
  color: var(--muted);
}

.detail-header {
  border-bottom: 1px solid var(--line);
}

.detail-header .text-button {
  float: right;
}

.detail-subtitle {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.registry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.registry-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
}

.registry-grid dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.registry-grid dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-section {
  border-bottom: 1px solid var(--line);
}

.detail-section h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.detail-section p {
  margin: 0 0 12px;
  color: var(--muted);
}

.platform-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  overflow-wrap: anywhere;
}

.pager {
  justify-content: center;
}

.pager span {
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  transform: translateY(20px);
  opacity: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.document-page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.page-heading {
  margin-bottom: 20px;
}

.file-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: minmax(220px, 1fr) minmax(130px, 0.45fr);
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .summary-strip,
  .filters,
  .registry-grid {
    grid-template-columns: 1fr;
  }

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