:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f9fbff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #3454d1;
  --brand-dark: #162d9a;
  --brand-soft: #eef2ff;
  --success: #0f766e;
  --warning: #b45309;
  --draft: #475569;
  --planned: #7c3aed;
  --shadow: 0 24px 70px rgba(15, 23, 42, .08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(52, 84, 209, .14), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%);
}

a { color: inherit; text-decoration: none; }
code {
  padding: .12rem .35rem;
  border-radius: 7px;
  background: #eef2ff;
  color: var(--brand-dark);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(20px);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  box-shadow: 0 18px 40px rgba(52,84,209,.28);
}
.brand strong { display: block; line-height: 1.1; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }

.side-nav { display: grid; gap: 8px; }
.side-nav a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #334155;
  font-size: 14px;
}
.side-nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.side-nav span:last-child { color: var(--muted); }

.sidebar-card {
  margin-top: 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}
.sidebar-card p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.eyebrow, .pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.eyebrow { color: var(--brand); }
.pill {
  padding: 8px 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.main-content {
  width: min(var(--max), calc(100vw - 340px));
  margin: 0 auto;
  padding: 46px 28px 80px;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 28px;
  align-items: end;
  padding: 42px;
  border: 1px solid rgba(226,232,240,.78);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.74);
  box-shadow: var(--shadow);
}
.hero h1 {
  max-width: 780px;
  margin: 18px 0 12px;
  font-size: clamp(44px, 6vw, 76px);
  line-height: .92;
  letter-spacing: -.06em;
}
.hero p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}
.hero-panel {
  padding: 24px;
  border-radius: 22px;
  color: white;
  background: linear-gradient(135deg, #0f172a, #334155);
}
.hero-panel strong { display: block; font-size: 56px; line-height: 1; letter-spacing: -.05em; }
.hero-panel span { display: block; margin-top: 8px; color: #cbd5e1; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 14px;
  margin: 24px 0;
}
.search-box, .select-box {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.78);
}
.search-box span, .select-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
input, select {
  width: 100%;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
  font: inherit;
}

.category-list { display: grid; gap: 24px; }
.category-section {
  scroll-margin-top: 30px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.82);
}
.category-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.category-header h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.category-header p { max-width: 760px; margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.count-badge {
  flex: 0 0 auto;
  height: fit-content;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.sop-card {
  position: relative;
  display: flex;
  min-height: 230px;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.sop-card:hover {
  transform: translateY(-4px);
  border-color: rgba(52,84,209,.34);
  box-shadow: 0 22px 50px rgba(15,23,42,.10);
}
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tag {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}
.tag.status-ready { background: #ccfbf1; color: var(--success); }
.tag.status-in-progress { background: #fef3c7; color: var(--warning); }
.tag.status-draft { background: #e2e8f0; color: var(--draft); }
.tag.status-planned { background: #ede9fe; color: var(--planned); }
.sop-card h3 { margin: 0 0 10px; font-size: 20px; line-height: 1.18; letter-spacing: -.025em; }
.sop-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 22px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
}
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.6);
}

.detail-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 80px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.back-link {
  display: inline-flex;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  color: var(--brand-dark);
  font-weight: 800;
}
.topbar-label { color: var(--muted); font-weight: 700; }
.detail-card {
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow);
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.detail-card h1 {
  margin: 0 0 16px;
  font-size: clamp(36px, 5vw, 64px);
  line-height: .98;
  letter-spacing: -.055em;
}
.detail-summary {
  max-width: 760px;
  margin: 0 0 34px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.7;
}
.content-section {
  padding: 24px 0;
  border-top: 1px solid var(--line);
}
.content-section h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: -.03em; }
.content-section p { margin: 0; color: #475569; font-size: 16px; line-height: 1.75; }
.not-found { text-align: center; }
.not-found p { color: var(--muted); }

@media (max-width: 1040px) {
  .page-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-content { width: min(var(--max), 100%); }
  .hero { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .sidebar, .main-content { padding: 20px; }
  .side-nav { grid-template-columns: 1fr; }
  .hero { padding: 28px; }
  .toolbar { grid-template-columns: 1fr; }
  .category-header { display: grid; }
  .card-grid { grid-template-columns: 1fr; }
  .sop-card { min-height: auto; }
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
}
