:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --amber: #d97706;
  --bg: #f4f6f8;
  --surface: #fff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem 1.25rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.brand-mark {
  width: 36px; height: 36px;
  background: var(--teal);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700;
}
.brand-lg { justify-content: center; margin-bottom: 0.5rem; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  padding: 0.55rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active {
  color: var(--teal-dark);
  background: #ecfdf5;
  border-left-color: var(--teal);
  font-weight: 500;
}

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search { position: relative; flex: 1; max-width: 420px; }
.search input {
  width: 100%;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  background: var(--bg);
}
.search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
}
.search-results.hidden { display: none; }
.search-results a {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.search-results a:hover { background: #f8fafc; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}
.role-badge {
  background: #ecfdf5;
  color: var(--teal-dark);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.logout-link { color: var(--muted); text-decoration: none; margin-left: 0.25rem; }

.content { padding: 1.5rem 2rem 3rem; max-width: 960px; }

.page-title { margin: 0 0 0.5rem; font-size: 1.75rem; font-weight: 700; }
.page-lead { color: var(--muted); margin: 0 0 1.5rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
  border-color: #99f6e4;
}
.card-icon { font-size: 1.75rem; display: block; margin-bottom: 0.5rem; }
.card h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.card-link { display: inline-block; margin-top: 0.75rem; color: var(--teal); font-size: 0.85rem; font-weight: 500; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.panel h3 { margin: 0 0 1rem; font-size: 1rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.table a { color: var(--teal-dark); }

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--teal); text-decoration: none; }
.breadcrumb span { margin: 0 0.35rem; }

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.chip {
  display: inline-block;
  background: #ecfdf5;
  color: var(--teal-dark);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.78rem;
  margin-right: 0.35rem;
}
.chip-muted { background: #f1f5f9; color: var(--muted); }

.markdown h1, .markdown h2, .markdown h3 { margin-top: 1.5rem; }
.markdown table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.92rem; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; }
.markdown th { background: #ecfdf5; text-align: left; }
.markdown pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.markdown blockquote {
  border-left: 4px solid var(--amber);
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  background: #fffbeb;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; justify-content: center; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ecfdf5 0%, #f4f6f8 50%, #fffbeb 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.login-sub { text-align: center; color: var(--muted); margin: 0 0 1.5rem; }
.login-form label { display: block; margin-bottom: 1rem; font-size: 0.88rem; font-weight: 500; }
.login-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

#editor, .EasyMDEContainer { margin-bottom: 1rem; }

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0 0.5rem; }
  .content { padding: 1rem; }
}
