/* ==========================================================================
   EBsoft HMS — Build Guide
   Design language: clinical-systems documentation. A deep chart-navy
   sidebar, a paper-cool content surface, one teal accent used the way a
   monitor readout uses it — for signal, not decoration. Numbers are used
   only where the content is genuinely sequential (setup steps).
   ========================================================================== */

:root {
    --navy: #101c33;
    --navy-2: #16233d;
    --bg: #f3f5f8;
    --surface: #ffffff;
    --text: #1b2230;
    --muted: #5b6472;
    --border: #dfe3ea;
    --accent: #0f6e5c;
    --accent-soft: #e4f2ee;
    --warn: #b5651d;
    --warn-soft: #fbf0e4;
    --code-bg: #101923;
    --code-text: #d9e4ea;
    --code-key: #7fd1b9;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--navy);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: #fff;
}

.brand-pulse {
    width: 46px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}
.brand-pulse svg {
    width: 100%;
    height: 100%;
}
.brand-pulse polyline {
    fill: none;
    stroke: var(--code-key);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brand-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.brand-text em {
    font-style: normal;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.01em;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    height: 2px;
    margin: 0 7px;
    background: #fff;
}

/* ---------- Layout ---------- */

.layout {
    max-width: 1240px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 0;
}

/* ---------- Sidebar ---------- */

.sidebar {
    background: var(--navy-2);
    color: rgba(255, 255, 255, 0.86);
    padding: 32px 20px 40px;
    min-height: calc(100vh - 64px);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-group { margin-bottom: 28px; }

.nav-group-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.4);
    margin: 0 0 10px 10px;
}

.sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar a {
    display: block;
    padding: 7px 10px;
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 0.92rem;
    border-left: 2px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar a.active {
    background: rgba(15, 110, 92, 0.28);
    color: #fff;
    border-left-color: var(--code-key);
    font-weight: 500;
}

.sidebar-meta {
    margin-top: 8px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
}
.sidebar-meta p { margin: 0 0 6px 10px; }

/* ---------- Content ---------- */

.content {
    background: var(--surface);
    padding: 48px 56px 64px;
    min-width: 0;
}

.content > article > *:first-child { margin-top: 0; }

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent);
    margin: 0 0 6px;
}

h1 {
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 600;
    margin: 0 0 10px;
    letter-spacing: -0.01em;
}

.lede {
    font-size: 1.08rem;
    color: var(--muted);
    max-width: 62ch;
    margin: 0 0 36px;
}

h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    margin: 44px 0 14px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}
.content > article > h2:first-of-type { border-top: none; margin-top: 8px; }

h3 {
    font-family: var(--font-display);
    font-size: 1.06rem;
    font-weight: 600;
    margin: 28px 0 10px;
}

p { max-width: 72ch; margin: 0 0 16px; }
ul, ol { max-width: 72ch; padding-left: 22px; margin: 0 0 16px; }
li { margin-bottom: 6px; }

a { color: var(--accent); }

strong { font-weight: 600; }

code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: var(--accent-soft);
    color: #0b4a3d;
    padding: 0.1em 0.4em;
    border-radius: 4px;
}

pre {
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.86rem;
    line-height: 1.55;
    padding: 18px 20px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 0 0 20px;
}
pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

.filename {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--muted);
    margin: 0 0 -12px;
    display: block;
}

/* ---------- Tables ---------- */

table {
    width: 100%;
    max-width: 760px;
    border-collapse: collapse;
    margin: 0 0 28px;
    font-size: 0.92rem;
}
th, td {
    text-align: left;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.76rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

/* ---------- Callouts ---------- */

.note, .warn {
    max-width: 72ch;
    padding: 14px 18px;
    border-radius: 8px;
    margin: 0 0 22px;
    font-size: 0.94rem;
}
.note { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.warn { background: var(--warn-soft); border-left: 3px solid var(--warn); }
.note p, .warn p { margin: 0; max-width: none; }

/* ---------- Vitals strip (overview page only) ---------- */

.vitals {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 0 40px;
}
.vital {
    padding: 16px 18px;
    border-right: 1px solid var(--border);
    background: var(--surface);
}
.vital:last-child { border-right: none; }
.vital-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 6px;
}
.vital-value {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

/* ---------- Module cards ---------- */

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin: 0 0 30px;
}
.module-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.module-card h4 {
    font-family: var(--font-display);
    font-size: 0.98rem;
    margin: 0 0 6px;
}
.module-card p {
    font-size: 0.86rem;
    color: var(--muted);
    margin: 0;
}
.module-card .count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent);
}

/* ---------- Steps ---------- */

.steps { counter-reset: step; list-style: none; padding: 0; max-width: 72ch; }
.steps > li {
    position: relative;
    padding-left: 44px;
    margin-bottom: 22px;
}
.steps > li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--navy-2);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.steps h3 { margin: 2px 0 6px; }

/* ---------- Page nav ---------- */

.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.page-nav-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    max-width: 45%;
}
.page-nav-link.next { text-align: right; margin-left: auto; }
.page-nav-dir {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
}
.page-nav-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text);
}

.sitefooter {
    grid-column: 1 / -1;
    text-align: center;
    padding: 26px 20px 40px;
    font-size: 0.78rem;
    color: var(--muted);
    max-width: 1240px;
    margin: 0 auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
    .nav-toggle { display: flex; }

    .layout { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }

    .content { padding: 32px 22px 48px; }

    .vitals { grid-template-columns: repeat(2, 1fr); }
    .vital:nth-child(2) { border-right: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .sidebar { transition: none; }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
