:root {
  color-scheme: light dark;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;

  --bg: #f3f5f5;
  --surface: #ffffff;
  --surface-muted: #f7f8f8;
  --text: #172024;
  --text-muted: #5d696e;
  --border: #d5dcde;
  --border-strong: #b8c2c5;
  --accent: #176b78;
  --accent-hover: #125763;
  --primary: #176b78;
  --primary-hover: #125763;
  --primary-text: #ffffff;
  --focus: #176b78;
  --focus-halo: rgba(23, 107, 120, .22);
  --important-bg: #fff5df;
  --important-border: #d9bd7f;
  --important-text: #6f5319;
  --danger-bg: #fff0f0;
  --danger-border: #d5a0a0;
  --danger-text: #742828;
  --code-bg: #edf1f1;
  --shadow: 0 8px 24px rgba(25, 38, 43, .045);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181b;
    --surface: #182125;
    --surface-muted: #1d282c;
    --text: #edf2f3;
    --text-muted: #aab6ba;
    --border: #344247;
    --border-strong: #4a5a60;
    --accent: #79c4ce;
    --accent-hover: #9bdae2;
    --primary: #2f6f78;
    --primary-hover: #377f89;
    --primary-text: #ffffff;
    --focus: #79c4ce;
    --focus-halo: rgba(121, 196, 206, .28);
    --important-bg: #382d17;
    --important-border: #66542b;
    --important-text: #efd18d;
    --danger-bg: #3a2020;
    --danger-border: #6f3b3b;
    --danger-text: #f0b4b4;
    --code-bg: #243136;
    --shadow: 0 8px 24px rgba(0, 0, 0, .16);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:where(a, button, input):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--focus-halo);
}

.page-shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}
.page-shell.narrow { width: min(620px, calc(100% - 32px)); }

.card, .article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.hero { margin-top: 12vh; }
.eyebrow {
  display: block;
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
h1, h2, h3 { line-height: 1.2; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.85rem, 5vw, 2.65rem); margin: 0 0 12px; }
h2 { margin: 0; font-size: 1.3rem; }
h3 { margin-top: 1.6em; }
p { line-height: 1.6; }
.hint { color: var(--text-muted); }

.app-header { display: flex; align-items: center; margin-bottom: 26px; }
.brand-link {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  border-radius: 5px;
}
.brand-link:hover { color: var(--accent); }
.brand-link .eyebrow { margin-bottom: 2px; }
.brand-title { display: block; font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; }
.page-intro { margin: 8px 0 22px; }
.page-intro.compact { margin-bottom: 16px; }
.page-intro p:last-child { margin-bottom: 0; }
.content-section { margin-top: 30px; }
.section-heading { margin-bottom: 13px; }
.section-heading .eyebrow { margin-bottom: 5px; }

.section-grid, .topic-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.section-card, .topic-card, .article-link, .search-result {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.section-card, .topic-card {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  min-height: 78px;
  border-radius: 12px;
  padding: 17px 18px;
}
.topic-card { flex-direction: column; align-items: flex-start; gap: 8px; }
.section-card strong, .topic-card strong { font-size: 1.08rem; overflow-wrap: anywhere; }
.topic-card span { color: var(--text-muted); font-size: .88rem; }
.breadcrumb-line {
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.article-list, .search-results { display: grid; gap: 9px; }
.article-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 56px;
  border-radius: 11px;
  padding: 13px 16px;
}
.article-link strong { min-width: 0; overflow-wrap: anywhere; }
.article-link .breadcrumb-line { margin-left: auto; text-align: right; }
.section-card:hover, .topic-card:hover, .article-link:hover, .search-result:hover,
.section-card:focus-visible, .topic-card:focus-visible, .article-link:focus-visible, .search-result:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.important-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  flex: none;
  border: 1px solid var(--important-border);
  border-radius: 999px;
  background: var(--important-bg);
  padding: 4px 8px;
  color: var(--important-text);
  font-size: .76rem;
  font-weight: 700;
}
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.breadcrumbs a { color: var(--accent); text-underline-offset: 3px; }
.breadcrumbs [aria-current="page"] { color: var(--text-muted); }
.empty-state { margin-top: 24px; }
.empty-state p:last-child { margin-bottom: 0; }

.article-card { width: min(860px, 100%); min-width: 0; }
.article-header { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.article-header .important-badge { margin-bottom: 12px; }
.article-header h1 { margin-bottom: 0; }
.article-body { min-width: 0; padding-top: 8px; overflow-wrap: anywhere; line-height: 1.65; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4,
.article-body h5, .article-body h6 { margin-top: 1.55em; margin-bottom: .55em; }
.article-body p, .article-body ul, .article-body ol, .article-body blockquote,
.article-body pre, .article-body table { margin-top: 1em; margin-bottom: 1em; }
.article-body img { display: block; max-width: 100%; height: auto; margin: 20px auto; border-radius: 9px; }
/* Let the table scroll locally instead of forcing the page or crushing every column. */
.article-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  overscroll-behavior-x: contain;
}
.article-body th, .article-body td {
  min-width: 9rem;
  max-width: 26rem;
  border: 1px solid var(--border-strong);
  padding: 8px 11px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.article-body th { background: var(--surface-muted); font-weight: 700; }
.article-body blockquote {
  margin-left: 0;
  padding-left: 16px;
  border-left: 4px solid var(--border-strong);
  color: var(--text-muted);
}
.article-body pre {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--code-bg);
  padding: 14px;
  overscroll-behavior-x: contain;
}
.article-body code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.article-body :not(pre) > code { padding: 1px 4px; border-radius: 4px; background: var(--code-bg); }
.article-body a { text-underline-offset: 3px; }

.employee-search { display: grid; gap: 8px; margin: 0 0 26px; }
.employee-search label { font-weight: 750; }
.employee-search-row { display: flex; gap: 10px; }
.employee-search input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface);
  padding: 13px 15px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.employee-search input::placeholder { color: var(--text-muted); opacity: 1; }
.employee-search button {
  min-height: 48px;
  border: 1px solid var(--primary);
  border-radius: 11px;
  background: var(--primary);
  padding: 11px 18px;
  color: var(--primary-text);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.employee-search button:hover { background: var(--primary-hover); }
.search-result {
  display: grid;
  gap: 5px;
  min-width: 0;
  border-radius: 11px;
  padding: 15px 16px;
}
.search-result strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.search-excerpt { color: var(--text-muted); line-height: 1.5; overflow-wrap: anywhere; }
.search-error {
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  background: var(--danger-bg);
  padding: 12px 14px;
  color: var(--danger-text);
}
.article-attachments { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.article-attachments h2 { margin-bottom: 12px; }
.attachment-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.attachment-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  min-width: 0;
}
.attachment-list a { min-width: 0; overflow-wrap: anywhere; font-weight: 700; text-underline-offset: 3px; }
.attachment-meta { flex: none; color: var(--text-muted); font-size: .86rem; }

@media (max-width: 700px) {
  .page-shell { width: calc(100% - 20px); padding-top: 18px; padding-bottom: 36px; }
  .card, .article-card { padding: 16px; border-radius: 12px; }
  .hero { margin-top: 8vh; }
  .app-header { margin-bottom: 20px; }
  .section-grid, .topic-list { grid-template-columns: 1fr; }
  .section-card, .topic-card { min-height: 58px; padding: 15px 16px; }
  .article-link { align-items: flex-start; flex-direction: column; gap: 5px; }
  .article-link .breadcrumb-line { margin-left: 0; text-align: left; }
  .article-body th, .article-body td { min-width: 10rem; }
}
@media (max-width: 560px) {
  .employee-search-row { flex-direction: column; }
  .employee-search button { width: 100%; }
  .attachment-list li { align-items: flex-start; flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .section-card, .topic-card, .article-link, .search-result { transition: none; }
}
