/* ===== Theme variables =====
 * Default (no attribute) and explicit dark are identical.
 * Light theme is keyed off the data-theme attribute on <html>, set
 * before first paint by an inline snippet in base.html and toggled by
 * theme.js.
 */
:root,
:root[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #181b22;
    --surface-2: #1f232c;
    --border: #2a2f3a;
    --text: #e6e8ec;
    --text-muted: #9aa3b2;
    --link: #5aa9ff;
    --link-hover: #7cbcff;
    --accent: #d9534f;
    --accent-2: #ff7a73;
    --success: #2ecc71;
    --warn: #f5a623;
    --danger: #e74c3c;
    --info: #3498db;
    --code-bg: #11141a;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f0f2f6;
    --border: #d9dee6;
    --text: #1c2230;
    --text-muted: #5b6473;
    --link: #1f6feb;
    --link-hover: #1158c7;
    --accent: #d9534f;
    --accent-2: #b03a36;
    --success: #1e8e3e;
    --warn: #b78107;
    --danger: #c0392b;
    --info: #1f6feb;
    --code-bg: #f7f8fa;
    --shadow: 0 4px 16px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    color: var(--link);
    text-decoration: none;
}

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

/* ===== Site header / nav ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.site-header .header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.2px;
    text-decoration: none;
    line-height: 1;
}

.brand:hover {
    text-decoration: none;
    color: var(--text);
}

.brand-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: block;
    color: var(--accent);
}

.brand-name {
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a {
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.2;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.nav-links a.active {
    color: var(--text);
    background: var(--surface-2);
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.88rem;
    line-height: 1.2;
}

.icon-link:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.icon-link svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    display: block;
}

.toggle-btn {
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    height: 30px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.toggle-btn:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

/* ===== Layout / content ===== */
.container {
    max-width: 1000px;
    margin: 28px auto;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

h1, h2, h3 {
    color: var(--text);
    margin-top: 0;
}

h1 {
    color: var(--accent);
    font-size: 1.8rem;
}

h2 {
    font-size: 1.3rem;
}

h3 {
    font-size: 1.1rem;
}

/* Page header: title lockup on the left, download CTA pinned top-right. */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

/* Page title lockup: logo immediately to the left of the H1 text. */
.page-title {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.page-title-logo {
    height: 88px;
    width: auto;
    object-fit: contain;
    flex: 0 0 auto;
    display: block;
}

/* Download button: shares .cta-button base (blue), sized to match the
 * theme toggle so it sits cleanly with the GitHub link and toggle in
 * .header-actions. */
.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 5px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

p {
    color: var(--text);
}

ul {
    color: var(--text);
}

.muted {
    color: var(--text-muted);
}

.cta-button {
    display: inline-block;
    padding: 10px 18px;
    background: var(--link);
    color: #fff !important;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.15s ease;
}

.cta-button:hover {
    background: var(--link-hover);
    text-decoration: none;
}

/* ===== Client showcase (homepage screenshot box) ===== */
/* Two-column layout: left column gets the existing intro copy, right
 * column shows the desktop-client screenshot in a stylized box. The
 * layout collapses to a single column on narrow screens.
 */
.intro-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
    gap: 24px;
    align-items: start;
    margin-bottom: 12px;
}

.intro-text {
    min-width: 0;
}

.client-showcase {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 76px;
    max-width: 400px;
    width: 100%;
    margin-left: auto;
}

.client-showcase h3 {
    margin: 0;
    color: var(--accent);
    font-size: 1.05rem;
}

.client-showcase img {
    width: 100%;
    max-width: 400px;
    height: auto;
    display: block;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0f1115;
}

.client-showcase p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text);
}

.client-showcase ul {
    margin: 0;
    padding-left: 18px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.client-showcase ul li {
    margin-bottom: 2px;
}

.client-showcase .download-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.client-showcase .download-row .cta-button {
    padding: 8px 14px;
    font-size: 0.9rem;
}

.client-showcase .secondary-link {
    align-self: flex-start;
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 880px) {
    .intro-grid {
        grid-template-columns: 1fr;
    }

    .client-showcase {
        position: static;
    }
}

/* ===== Cards / structured scan results ===== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.card-title {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-id {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.kv-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 12px;
    font-size: 0.92rem;
}

.kv-grid .k {
    color: var(--text-muted);
}

.kv-grid .v {
    color: var(--text);
    word-break: break-word;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.6;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.badge.success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
    border-color: rgba(46, 204, 113, 0.35);
}

.badge.danger {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
    border-color: rgba(231, 76, 60, 0.35);
}

.badge.warn {
    background: rgba(245, 166, 35, 0.18);
    color: var(--warn);
    border-color: rgba(245, 166, 35, 0.35);
}

.badge.info {
    background: rgba(52, 152, 219, 0.15);
    color: var(--info);
    border-color: rgba(52, 152, 219, 0.35);
}

.badge.muted {
    background: var(--surface);
    color: var(--text-muted);
}

.severity-low {
    color: var(--success);
}

.severity-medium {
    color: var(--warn);
}

.severity-high {
    color: var(--danger);
}

.severity-critical {
    color: #fff;
    background: var(--danger);
    padding: 2px 8px;
    border-radius: 4px;
}

pre.code-block,
code.inline {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

pre.code-block {
    padding: 10px 12px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 8px 0 0;
    max-height: 260px;
}

code.inline {
    padding: 1px 6px;
    font-size: 0.9em;
}

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

table.data-table th,
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.92rem;
    vertical-align: top;
}

table.data-table thead th {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Forms ===== */
input[type=text],
input[type=number],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--link);
    box-shadow: 0 0 0 3px rgba(90, 169, 255, 0.18);
}

label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* ===== Dashboard KPI strip ===== */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
}

.kpi {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
}

.kpi-num {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

.kpi-danger {
    border-color: rgba(231, 76, 60, 0.45);
}

.kpi-danger .kpi-num {
    color: var(--danger);
}

.kpi-warn {
    border-color: rgba(245, 166, 35, 0.45);
}

.kpi-warn .kpi-num {
    color: var(--warn);
}

.chart-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    margin: 18px 0;
}

.chart-card h2 {
    margin-top: 0;
}

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

.issue {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    background: var(--surface);
}

.issue-critical {
    border-left: 4px solid var(--danger);
}

.issue-warning {
    border-left: 4px solid var(--warn);
}

.issue-info {
    border-left: 4px solid var(--info);
}

.issue-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Empty state ===== */
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .site-header .header-inner {
        padding: 0 14px;
        gap: 10px;
        height: 52px;
    }

    .brand-name {
        font-size: 0.95rem;
    }

    .brand-icon {
        width: 20px;
        height: 20px;
        flex: 0 0 20px;
    }

    .nav-links {
        gap: 6px;
    }

    .nav-links a {
        padding: 5px 8px;
        font-size: 0.88rem;
    }

    .icon-link-label {
        display: none;
    }

    .icon-link {
        padding: 6px 8px;
    }

    .toggle-btn,
    .download-button {
        height: 29px;
        padding: 5px 8px;
        font-size: 0.82rem;
    }

    .header-actions {
        gap: 6px;
    }

    .container {
        margin: 16px 12px;
        padding: 18px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .page-title {
        gap: 10px;
    }

    .page-title-logo {
        height: 64px;
    }

    .page-header {
        gap: 12px;
    }
}

@media (max-width: 420px) {
    .nav-links a:not(.active) {
        padding: 5px 6px;
    }
}

/* Header Download button: blue, compact, aligned with theme toggle */
.site-header .header-actions .download-button,
.site-header .header-actions .cta-button.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 5px 10px;
    border-radius: 6px;
    background: var(--link);
    color: #fff !important;
    border: 1px solid var(--link);
    box-shadow: none;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
}

.site-header .header-actions .download-button:hover,
.site-header .header-actions .cta-button.download-button:hover {
    background: var(--link-hover);
    border-color: var(--link-hover);
    color: #fff !important;
    text-decoration: none;
}

@media (max-width: 720px) {
    .site-header .header-actions .download-button,
    .site-header .header-actions .cta-button.download-button {
        height: 29px;
        padding: 5px 8px;
        font-size: 0.82rem;
    }
}

/* ===== Site footer ===== */
.site-footer {
    margin-top: 40px;
    padding: 22px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.site-footer .footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.site-footer .footer-brand strong {
    color: var(--text);
}

.site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.site-footer .footer-links a {
    color: var(--text-muted);
}

.site-footer .footer-links a:hover {
    color: var(--text);
    text-decoration: underline;
}

.site-footer .footer-home-link {
    font-weight: 600;
    color: var(--link);
}

.site-footer .footer-home-link:hover {
    color: var(--link-hover);
}

@media (max-width: 720px) {
    .site-footer .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== Documentation page ===== */
.docs-layout {
    max-width: 1180px;
    margin: 28px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.docs-sidebar {
    position: sticky;
    top: 76px;
    align-self: start;
}

.docs-sidebar-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 14px;
    box-shadow: var(--shadow);
}

.docs-sidebar-title {
    margin: 0 0 8px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
}

.docs-toc {
    display: flex;
    flex-direction: column;
}

.docs-toc a {
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.3;
    border-left: 2px solid transparent;
}

.docs-toc a:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    border-left-color: var(--link);
}

.docs-content {
    margin: 0;
    max-width: none;
}

.docs-content section {
    margin-top: 28px;
    scroll-margin-top: 80px;
}

.docs-content section:first-of-type {
    margin-top: 8px;
}

.docs-content h2 {
    margin-top: 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-size: 1.35rem;
}

.docs-content h3 {
    margin-top: 18px;
    color: var(--text);
}

.docs-content table.data-table {
    margin-top: 8px;
}

.docs-header {
    margin-bottom: 12px;
}

.docs-header h1 {
    margin-bottom: 6px;
}

@media (max-width: 880px) {
    .docs-layout {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        position: static;
    }

    .docs-toc {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .docs-toc a {
        padding: 4px 8px;
        font-size: 0.85rem;
        border-left: none;
        border: 1px solid var(--border);
    }
}
