:root {
  --red: #c0392b;
  --orange: #e67e22;
  --yellow: #f39c12;
  --green: #27ae60;
  --blue: #2980b9;
  --purple: #8e44ad;
  --dark: #1a1a2e;
  --mid: #2d2d44;
  --panel: #f4f6f8;
  --border: #dde1e7;
  --text: #1c1c2e;
  --muted: #6b7280;
  --white: #ffffff;
  --font: 'Courier New', Courier, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: #f0f2f5;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* HEADER */
#site-header {
  background: var(--dark);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.site-logo {
  font-family: var(--font);
  font-size: 18px;
  font-weight: bold;
  color: white;
  letter-spacing: -0.5px;
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo span { color: #e74c3c; }

#search-box {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid #444;
  border-radius: var(--radius);
  background: #2d2d44;
  color: white;
  font-size: 14px;
  font-family: var(--sans);
}

#search-box::placeholder { color: #888; }
#search-box:focus { outline: none; border-color: var(--blue); }

.header-tagline {
  font-size: 11px;
  color: #aaa;
  font-family: var(--font);
  flex-shrink: 0;
}

/* LAYOUT */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
}

@media(max-width:768px) {
  .page-wrapper { grid-template-columns: 1fr; padding: 8px; }
}

/* SIDEBAR */
#sidebar {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0;
  height: fit-content;
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}

.sidebar-cat {
  border-bottom: 1px solid var(--border);
}

.sidebar-cat-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 14px 6px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  user-select: none;
}

.sidebar-cat-title .arrow { transition: transform 0.2s; font-size: 10px; }
.sidebar-cat.open .arrow { transform: rotate(90deg); }

.sidebar-links { display: none; }
.sidebar-cat.open .sidebar-links { display: block; }

.sidebar-links a {
  display: block;
  padding: 6px 14px 6px 20px;
  font-size: 13px;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-links a:hover,
.sidebar-links a.active {
  background: #eef4fb;
  border-left-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
}

/* MAIN CONTENT */
#main-content { min-width: 0; }

/* HOME GRID */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.cat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
}

.cat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.cat-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.cat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.cat-card h3 { font-size: 14px; font-weight: 700; }
.cat-card p { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.pill:hover { background: #dde1e7; }

/* TOPIC PAGE */
.topic-page { background: white; border-radius: var(--radius); border: 1px solid var(--border); }

.topic-header {
  padding: 16px 20px;
  border-bottom: 3px solid var(--blue);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-header h1 { font-size: 22px; font-weight: 800; }
.topic-header .meta { font-size: 12px; color: var(--muted); font-family: var(--font); }

.breadcrumb {
  padding: 8px 20px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.breadcrumb a { color: var(--blue); }

.topic-body { padding: 16px 20px; }

/* SECTIONS */
.section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-header {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-body {
  padding: 12px 14px;
  font-size: 14px;
}

/* Section color themes */
.sec-immediate .section-header { background: #fde8e8; color: #c0392b; border-bottom: 1px solid #f5c6c6; }
.sec-questions .section-header { background: #fef3cd; color: #856404; border-bottom: 1px solid #fae7a0; }
.sec-investigations .section-header { background: #e8f4fd; color: #1a6fa8; border-bottom: 1px solid #bee3f8; }
.sec-management .section-header { background: #e8f8ef; color: #1d6f42; border-bottom: 1px solid #a8dfc0; }
.sec-escalation .section-header { background: #f3e8fd; color: #6f3fa8; border-bottom: 1px solid #d6b8f5; }
.sec-prescribing .section-header { background: #fff0e8; color: #a84f00; border-bottom: 1px solid #f5c9a0; }
.sec-redflags .section-header { background: #c0392b; color: white; }
.sec-checklist .section-header { background: #2d2d44; color: white; }

/* LIST STYLES */
.section-body ul { padding-left: 18px; }
.section-body ul li { margin-bottom: 4px; }
.section-body ol { padding-left: 18px; }
.section-body ol li { margin-bottom: 4px; }

.checklist { list-style: none; padding-left: 0; }
.checklist li { padding: 4px 0; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.checklist li::before { content: '☐'; font-size: 16px; line-height: 1.2; flex-shrink: 0; color: var(--muted); }
.checklist li.done { text-decoration: line-through; color: var(--muted); }
.checklist li.done::before { content: '☑'; color: var(--green); }

/* ALERT BOXES */
.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.alert-red { background: #fde8e8; border-left: 4px solid #c0392b; color: #7b1c1c; }
.alert-orange { background: #fff3e0; border-left: 4px solid #e67e22; color: #7b3d00; }
.alert-green { background: #e8f8ef; border-left: 4px solid #27ae60; color: #1a4d2e; }
.alert-blue { background: #e8f4fd; border-left: 4px solid #2980b9; color: #0d3c6e; }

/* DOSE TABLE */
.dose-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dose-table th { background: var(--panel); font-weight: 700; text-align: left; padding: 6px 10px; border: 1px solid var(--border); }
.dose-table td { padding: 6px 10px; border: 1px solid var(--border); vertical-align: top; }
.dose-table tr:nth-child(even) td { background: #fafbfc; }

/* SEARCH RESULTS */
#search-results {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.search-result-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item h4 { font-size: 15px; color: var(--blue); margin-bottom: 2px; }
.search-result-item p { font-size: 12px; color: var(--muted); }
.search-result-item .badge { font-size: 11px; background: var(--panel); padding: 1px 6px; border-radius: 20px; color: var(--muted); margin-left: 6px; }

/* HOME PAGE */
.home-hero {
  background: var(--dark);
  color: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  font-family: var(--font);
}

.home-hero h2 { font-size: 20px; margin-bottom: 6px; }
.home-hero h2 span { color: #e74c3c; }
.home-hero p { font-size: 13px; color: #aaa; }

.stats-bar {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.stat { font-size: 12px; }
.stat strong { color: #4ecdc4; font-size: 18px; display: block; }

/* BACK BUTTON */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--panel);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.back-btn:hover { background: var(--border); text-decoration: none; }

/* UTILITY */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.bold { font-weight: 700; }
.mono { font-family: var(--font); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }

/* CATEGORY COLOR ACCENTS */
.accent-red { background: #fde8e8; }
.accent-orange { background: #fff3e0; }
.accent-blue { background: #e8f4fd; }
.accent-green { background: #e8f8ef; }
.accent-purple { background: #f3e8fd; }
.accent-yellow { background: #fef9e7; }
.accent-teal { background: #e8f8f5; }
.accent-pink { background: #fde8f3; }
.accent-dark { background: #eaecef; }
.accent-indigo { background: #ede7f6; }

.icon-red { background: #c0392b; color: white; }
.icon-orange { background: #e67e22; color: white; }
.icon-blue { background: #2980b9; color: white; }
.icon-green { background: #27ae60; color: white; }
.icon-purple { background: #8e44ad; color: white; }
.icon-yellow { background: #f39c12; color: white; }
.icon-teal { background: #16a085; color: white; }
.icon-pink { background: #e91e63; color: white; }
.icon-dark { background: #2d2d44; color: white; }
.icon-indigo { background: #5c6bc0; color: white; }

@media(max-width:480px) {
  .topic-header h1 { font-size: 18px; }
  .page-wrapper { padding: 6px; gap: 8px; }
}
