:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #687386;
  --line: #e3e9f1;
  --line-strong: #d8e0ea;
  --primary: #f47a20;
  --primary-dark: #bd4d09;
  --navy: #14213a;
  --navy-soft: #1d2b47;
  --success: #16835d;
  --warning: #a96305;
  --danger: #9a3232;
  --shadow-sm: 0 8px 24px rgba(23, 32, 51, 0.05);
  --shadow-md: 0 18px 50px rgba(23, 32, 51, 0.08);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px 14px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--navy) 0%, #111b30 100%);
  color: #fff;
  box-shadow: 8px 0 28px rgba(13, 23, 42, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 0 4px 8px;
}
.brand-logo-frame {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.08);
}
.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-copy { min-width: 0; }
.brand-copy strong,
.brand-copy span { display: block; }
.brand-copy strong {
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-copy span {
  margin-top: 2px;
  color: #aebad0;
  font-size: 12px;
}

.home-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-align: left;
  font-weight: 750;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.home-button:hover,
.home-button.active {
  border-color: rgba(244, 122, 32, 0.55);
  background: rgba(244, 122, 32, 0.18);
}
.home-button:active { transform: translateY(1px); }
.home-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffc394;
  font-size: 15px;
}

.search-box {
  display: grid;
  gap: 7px;
}
.search-label {
  padding: 0 2px;
  color: #aebad0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search-control {
  position: relative;
  display: block;
}
.search-control svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: #8795aa;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 10px 11px 10px 35px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.search-box input::placeholder { color: #7f8ca1; }
.search-box input:focus {
  border-color: rgba(244, 122, 32, 0.8);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(244, 122, 32, 0.16);
}

#navigation {
  min-height: 0;
  flex: 1;
  margin: 0 -5px;
  padding: 0 5px 18px;
  overflow-y: auto;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  scrollbar-width: thin;
}
#navigation::-webkit-scrollbar { width: 6px; }
#navigation::-webkit-scrollbar-track { background: transparent; }
#navigation::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.nav-group { margin-bottom: 14px; }
.nav-group-title {
  margin: 0 9px 5px;
  color: #7f8da5;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.nav-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 8px 10px 8px 12px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d5ddea;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, padding-left 0.16s ease;
}
.nav-item::before {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 3px;
  height: 0;
  border-radius: 99px;
  background: var(--primary);
  content: "";
  transform: translateY(-50%);
  transition: height 0.16s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  padding-left: 15px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-weight: 700;
}
.nav-item.active::before { height: 20px; }
.nav-empty {
  padding: 14px 10px;
  color: #92a0b5;
  font-size: 13px;
}

.sidebar-footer {
  display: grid;
  gap: 3px;
  flex: 0 0 auto;
  padding: 12px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: #a8b3c6;
  font-size: 11px;
  line-height: 1.4;
}
.sidebar-footer small { color: #748199; }

.main-panel { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  min-height: 72px;
  gap: 14px;
  padding: 13px 28px;
  border-bottom: 1px solid rgba(222, 229, 239, 0.92);
  background: rgba(243, 246, 250, 0.9);
  backdrop-filter: blur(18px);
}
.topbar-copy { min-width: 0; }
.topbar h1 {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(19px, 2vw, 23px);
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eyebrow {
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.menu-button {
  display: none;
  width: 40px;
  height: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.menu-button span {
  display: block;
  height: 2px;
  margin: 4px 0;
  border-radius: 99px;
  background: var(--text);
}
.source-badge {
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.content-area {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 30px 44px;
}
.loading-card,
.error-card {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.error-card {
  border-color: #f1cccc;
  color: var(--danger);
}

.hero-card {
  padding: clamp(26px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 88% 18%, rgba(244, 122, 32, 0.26), transparent 28%),
    linear-gradient(135deg, #14213a 0%, #213759 72%, #314865 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.hero-card h2 {
  max-width: 760px;
  margin: 9px 0 12px;
  font-size: clamp(28px, 3.6vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.025em;
}
.hero-card p {
  max-width: 760px;
  margin: 0;
  color: #cad4e2;
  line-height: 1.68;
}
.hero-label {
  color: #ffc293;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 28px;
}
.stat-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.stat-value {
  display: block;
  font-size: 26px;
  font-weight: 850;
  line-height: 1;
}
.stat-label {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 12px;
}
.section-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.document-card {
  display: flex;
  min-height: 190px;
  flex-direction: column;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 7px 20px rgba(23, 32, 51, 0.035);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.document-card:hover {
  border-color: #efbd99;
  box-shadow: 0 14px 30px rgba(23, 32, 51, 0.075);
  transform: translateY(-2px);
}
.document-card h3 {
  margin: 9px 0 7px;
  font-size: 16px;
  line-height: 1.35;
}
.document-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.document-card button {
  margin-top: auto;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: var(--panel-soft);
  color: var(--primary-dark);
  text-align: left;
  font-size: 12px;
  font-weight: 800;
}
.category-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  overflow: hidden;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-pill { background: #fff0e4; color: #a4440a; }
.status-pill {
  margin-top: 9px;
  background: #eef3f8;
  color: #64748b;
}
.status-pill.warning { background: #fff3d8; color: var(--warning); }
.status-pill.success { background: #e6f6ef; color: var(--success); }

.doc-layout {
  display: flex;
  max-width: 980px;
  flex-direction: column;
  gap: 12px;
  margin: 0 auto;
}
.doc-panel {
  min-width: 0;
  padding: clamp(26px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-width: 800px;
  margin: 0 auto 22px;
}
.doc-source {
  order: -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px 12px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 5px 18px rgba(23, 32, 51, 0.035);
}
.doc-source strong {
  grid-row: 1 / span 2;
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
}
.doc-source code {
  display: block;
  overflow: hidden;
  color: var(--primary-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.markdown {
  max-width: 800px;
  margin: 0 auto;
  color: #2b374a;
  font-size: 15px;
  line-height: 1.74;
}
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  color: var(--text);
  line-height: 1.25;
  scroll-margin-top: 96px;
}
.markdown h1 {
  margin: 0 0 22px;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.025em;
}
.markdown h2 {
  margin: 34px 0 13px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  font-size: 22px;
  letter-spacing: -0.015em;
}
.markdown h3 {
  margin: 25px 0 9px;
  font-size: 18px;
}
.markdown h4 {
  margin: 20px 0 7px;
  font-size: 16px;
}
.markdown p { margin: 0 0 14px; }
.markdown ul,
.markdown ol { padding-left: 23px; }
.markdown li { margin: 6px 0; }
.markdown a {
  color: #ad4709;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.markdown blockquote {
  margin: 19px 0;
  padding: 12px 15px;
  border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0;
  background: #fff8f2;
  color: #596477;
}
.markdown code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}
.markdown pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 12px;
  background: #111a28;
  color: #e7edf7;
}
.markdown pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}
.table-wrap {
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.markdown th,
.markdown td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.markdown th {
  background: #f6f8fb;
  color: var(--text);
}
.markdown tr:last-child td { border-bottom: 0; }

.overlay { display: none; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .document-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0;
    width: min(88vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: block; flex: 0 0 auto; }
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(10, 18, 31, 0.54);
  }
  .overlay.show { display: block; }
  .topbar {
    min-height: 64px;
    padding: 10px 15px;
  }
  .topbar h1 { font-size: 18px; }
  .eyebrow { font-size: 9px; }
  .source-badge { display: none; }
  .content-area { padding: 18px 14px 36px; }
  .document-grid,
  .stats-grid { grid-template-columns: 1fr; }
  .hero-card { padding: 25px 20px; }
  .doc-panel { padding: 23px 18px 30px; }
  .doc-source {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .doc-source strong { grid-row: auto; }
  .doc-source code { white-space: normal; overflow-wrap: anywhere; }
  .markdown { font-size: 14.5px; }
  .markdown h1 { font-size: 28px; }
  .markdown h2 { font-size: 20px; }
}

@media (max-width: 480px) {
  .section-heading { align-items: start; flex-direction: column; }
  .stat-card { padding: 15px; }
  .document-card { min-height: 176px; }
}
