/* Karaya — Moon Spirit (Creative Tech)
   Light mode default with explicit dark-mode support.
   Do not change class names. All original selectors preserved and enhanced.
   Fonts: Space Grotesk (UI), Space Mono (code).
*/
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=Space+Mono:wght@400;700&display=swap');

/* ------------------------------
   THEME TOKENS
   ------------------------------ */
:root {
    /* Core palette — Light */
    --bg: #F9FAFB;
    --bg2: #FFFFFF;
    --panel: #FFFFFF;
    --panel-2: #F3F4F6;
    --text: #111827;
    --muted: #6B7280;
    --brand: #6D28D9;
    /* link color */
    --border: #E5E7EB;
    --border-strong: #D1D5DB;
    --accent: #8B5CF6;
    /* primary CTA */
    --accent-contrast: #ffffff;
    --info: #3B82F6;
    --ok: #10B981;
    --warn: #F59E0B;
    --fail: #EF4444;

    /* Moon gradient */
    --grad-start: #3B82F6;
    /* blue */
    --grad-end: #8B5CF6;
    /* violet */

    /* Surfaces, focus, motion */
    --shadow-1: 0 1px 2px rgba(17, 24, 39, .06), 0 8px 24px rgba(17, 24, 39, .06);
    --shadow-2: 0 2px 6px rgba(17, 24, 39, .08), 0 16px 40px rgba(17, 24, 39, .10);
    --ring: 0 0 0 3px rgba(139, 92, 246, .32);
    --row-hover: #F3F4F6;

    /* Fields */
    --field-bg: #FFFFFF;
    --field-placeholder: #9CA3AF;

    /* Scrollbar */
    --scrollbar: #E5E7EB;
    --scrollbar-hover: #D1D5DB;

    /* Decorative */
    --glow-soft: 0 0 0 1px rgba(139, 92, 246, .15), 0 8px 24px rgba(59, 130, 246, .12);
    --pill-bg: linear-gradient(180deg, #F8FAFF 0%, #F1F5FF 100%);
    --chip-border: rgba(139, 92, 246, .35);

    --unipadding: 24px;

    --hpad: clamp(12px, 3vw, 18px);
    --vpad: clamp(12px, 2vw, 16px);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-1: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
    --shadow-2: 0 1px 1px rgba(0,0,0,.05), 0 12px 30px rgba(0,0,0,.10);
    --text-soft: color-mix(in srgb, var(--text) 84%, transparent);
    --link: var(--accent);
}

/* Explicit theme toggles */
[data-theme="light"] {
    color-scheme: light;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0B0F14;
    --bg2: #11161D;
    --panel: #151C26;
    --panel-2: #0F1520;
    --text: #E5E7EB;
    --muted: #9CA3AF;
    --brand: #A78BFA;
    --border: #223044;
    --border-strong: #314054;
    --accent: #A78BFA;
    --accent-contrast: #0B0F14;
    --info: #60A5FA;
    --ok: #34D399;
    --warn: #FBBF24;
    --fail: #F87171;
    --grad-start: #3B82F6;
    --grad-end: #A78BFA;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .30);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 20px 50px rgba(0, 0, 0, .40);
    --ring: 0 0 0 3px rgba(167, 139, 250, .28);
    --row-hover: #0F1520;
    --field-bg: #0C121A;
    --field-placeholder: #7C8AA0;
    --scrollbar: #1f2a3a;
    --scrollbar-hover: #2a3a55;
    --glow-soft: 0 0 0 1px rgba(167, 139, 250, .18), 0 10px 28px rgba(59, 130, 246, .18);
    --pill-bg: linear-gradient(180deg, #0F1520 0%, #121A28 100%);
    --chip-border: rgba(167, 139, 250, .45);
}

/* Respect system preference when no explicit data-theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --bg: #0B0F14;
        --bg2: #11161D;
        --panel: #151C26;
        --panel-2: #0F1520;
        --text: #E5E7EB;
        --muted: #9CA3AF;
        --brand: #A78BFA;
        --border: #223044;
        --border-strong: #314054;
        --accent: #A78BFA;
        --accent-contrast: #0B0F14;
        --info: #60A5FA;
        --ok: #34D399;
        --warn: #FBBF24;
        --fail: #F87171;
        --grad-start: #3B82F6;
        --grad-end: #A78BFA;
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .30);
        --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 20px 50px rgba(0, 0, 0, .40);
        --ring: 0 0 0 3px rgba(167, 139, 250, .28);
        --row-hover: #0F1520;
        --field-bg: #0C121A;
        --field-placeholder: #7C8AA0;
        --scrollbar: #1f2a3a;
        --scrollbar-hover: #2a3a55;
        --glow-soft: 0 0 0 1px rgba(167, 139, 250, .18), 0 10px 28px rgba(59, 130, 246, .18);
        --pill-bg: linear-gradient(180deg, #0F1520 0%, #121A28 100%);
        --chip-border: rgba(167, 139, 250, .45);
    }
}

/* ------------------------------
   BASE
   ------------------------------ */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body.app {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 "Space Grotesk", system-ui, Segoe UI, Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

::selection {
    background: rgba(139, 92, 246, .22);
}

a {
    color: var(--brand);
    text-decoration: none;
    transition: color .15s ease, text-decoration-color .15s ease, text-underline-offset .15s ease;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

h4 {
    margin: 0 0 6px 0;
}

select {
    min-width: 140px;
}

/* ------------------------------
   LAYOUT
   ------------------------------ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;              /* already pins to viewport bottom */
    width: 240px;
    display: flex;          /* NEW */
    flex-direction: column; /* NEW */
    background:
    radial-gradient(1200px 400px at -20% 0%, rgba(139, 92, 246, .08), transparent 50%),
    var(--bg2);
    border-right: 1px solid var(--border);
    padding: 16px;
    backdrop-filter: saturate(120%) blur(0.5px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.brand svg {
    /* color: var(--grad-start); */
    color: var(--text);
}

.logo {
    width: 20px;
    height: 20px;
    fill: var(--brand);
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, .25));
}

.brand-name {
    font-weight: 700;
    letter-spacing: .2px;
    /* background: linear-gradient(90deg, var(--grad-start), var(--grad-end)); */
    background: linear-gradient(180deg, var(--text), var(--grad-end));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-transform: none;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    flex: 1 1 auto;       /* NEW: take leftover height */
    min-height: 0;        /* NEW: allow child overflow calc */
    overflow-y: auto;     /* scroll inside nav only */
    padding-bottom: 8px;
}

.nav-group {
    margin: 10px 0 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
}

.nav-item {
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--text);
    transition: background .12s ease, color .12s ease, box-shadow .12s ease, transform .08s ease;
    border: 1px solid transparent;
}

.nav-spacer { flex: 1 1 auto; }

.nav-item.active,
.nav-item:hover {
    background: linear-gradient(180deg, rgba(139, 92, 246, .10), rgba(59, 130, 246, .08)), var(--panel);
    box-shadow: inset 2px 0 0 var(--accent), var(--shadow-1);
    border-color: var(--border);
}

.nav hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 3px 0;
}

.main {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(139, 92, 246, .06), transparent 60%),
        var(--bg2);
    backdrop-filter: saturate(140%) blur(6px);
    box-shadow: 0 1px 0 rgba(17, 24, 39, .02);
}

.top-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .2px;
}

.top-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.content {
    padding: 20px;
    max-width: 1800px;
}

/* ------------------------------
   CARDS
   ------------------------------ */
.card {
    background:
        radial-gradient(600px 180px at 0% -10%, rgba(59, 130, 246, .05), transparent 60%),
        var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow-1);
}

.card:hover {
    box-shadow: var(--shadow-2);
}

.card h3 {
    margin-top: 0;
}

.mt {
    margin-top: var(--unipadding);
}

/* ------------------------------
   GRIDS
   ------------------------------ */
.grid-1,
.grid-2,
.grid-3,
.grid-4,
.grid-5,
.grid-6,
.grid-7,
.grid-8 {
    display: grid;
    gap: var(--unipadding);
}

.grid-1 {
    grid-template-columns: repeat(1, 1fr);
    gap: 0;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

.grid-7 {
    grid-template-columns: repeat(7, 1fr);
}

.grid-8 {
    grid-template-columns: repeat(8, 1fr);
}

.grid-1-3,
.grid-3-1,
.grid-1-2-1,
.grid-2-1,
.grid-2-1-1,
.grid-1-2,
.grid-1-4-1-4-1-4,
.grid-1-4,
.grid-4-1 {
    display: grid;
    gap: var(--unipadding);
}

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

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

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

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

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

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

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

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

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

@media (max-width: 1199px) {

    .grid-1-3,
    .grid-3-1,
    .grid-1-2-1,
    .grid-2-1,
    .grid-1-2,
    .grid-1-4-1-4-1-4,
    .grid-1-4,
    .grid-4-1 {
        grid-template-columns: 1fr;
    }
}

/* Responsive grid downgrades */
@media (max-width: 1200px) {
    .grid-8 {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-7 {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {

    .grid-5,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .main {
        margin-left: 220px;
    }
}

@media (max-width: 768px) {

    .grid-3,
    .grid-2 {
        grid-template-columns: repeat(1, 1fr);
    }

    .sidebar {
        width: 200px;
    }

    .main {
        margin-left: 200px;
    }
}

@media (max-width: 560px) {
    .sidebar {
        position: static;
        width: auto;
        height: auto;
    }

    .grid-5,
    .grid-4 {
        grid-template-columns: repeat(1, 1fr);
    }

    .main {
        margin-left: 0;
    }
}

/* ------------------------------
   UTIL LAYOUT
   ------------------------------ */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

/* ------------------------------
   KPI
   ------------------------------ */
.kpi {
    color: var(--muted);
    font-size: 12px;
}

.kpi-val {
    font-size: 22px;
    font-weight: 800;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .2px;
}

.card.feat .kpi-val {
    font-size: 40px;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
}

.card.feat a.kpi-val {
    cursor: pointer;
    background: none;
    color: var(--accent);
    text-decoration: underline; /* Adds visual indicator for links */
    text-underline-offset: 6px;
    transition: text-decoration-color .15s ease, text-underline-offset .15s ease;
}

.card.feat a.kpi-val:hover {
    text-underline-offset: 8px; /* Slightly increases offset on hover for emphasis */
    text-decoration-color: var(--accent);
    opacity: .9;
}

.kpi-val span {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: normal;
}

/* ------------------------------
   TABLES
   ------------------------------ */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    position: sticky;
    top: 0;
    background: var(--bg2);
    z-index: 1;
    backdrop-filter: saturate(120%) blur(4px);
}

.table tr:hover td {
    background: var(--row-hover);
}

.table th code,
.table td code {
    max-width: 200px;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.table td.max-w a {
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.table td form {
    display: inline;
}

/* ------------------------------
   BUTTONS
   ------------------------------ */
.btn {
    /* clean, confident primary */
    background: var(--accent);
    color: var(--accent-contrast);
    border: 1px solid transparent;
    /* fallback */
    border: 1px solid color-mix(in srgb, var(--accent) 65%, transparent);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .1px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
    transition:
        background .15s ease,
        border-color .15s ease,
        box-shadow .15s ease,
        transform .06s ease,
        opacity .12s ease;
}

.btn:hover {
    background: color-mix(in srgb, var(--accent) 90%, black 30%);
    box-shadow: var(--shadow-2);
}

.btn:active {
    background: color-mix(in srgb, var(--accent) 80%, black 20%);
    transform: translateY(1px);
    box-shadow: var(--shadow-1);
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-color: color-mix(in srgb, var(--accent) 60%, black 20%);
}

.btn-secondary {
    background: linear-gradient(180deg, rgba(139, 92, 246, .10), rgba(59, 130, 246, .12)), var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: color-mix(in srgb, var(--panel) 90%, black 30%);
    opacity: .98;
    box-shadow: var(--shadow-2);
}

/* ------------------------------
   FORMS
   ------------------------------ */
input,
select,
input[type="checkbox"] {
    background: var(--field-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    min-width: 200px;
    max-width: 150px;
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease, transform .06s ease;
}

input::placeholder {
    color: var(--field-placeholder);
}

input:disabled,
select:disabled {
    opacity: .6;
    cursor: not-allowed;
}

input:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

input[type="checkbox"] {
    min-width: auto;
    cursor: pointer;
    transform: scale(1.2);
    accent-color: var(--accent);
}

input[type="checkbox"]:focus-visible {
    box-shadow: var(--ring);
}

textarea {
    background: var(--field-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
    font-family: "Space Grotesk", system-ui, Segoe UI, Roboto, Arial, sans-serif;
}

textarea::placeholder {
    color: var(--field-placeholder);
}

textarea:disabled,
select:disabled {
    opacity: .6;
    cursor: not-allowed;
}

textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.thin {
    width: 100%;
    min-width: 50px;
    max-width: 100px;
}

.wide {
    width: 100%;
    max-width: 600px;
}

.fullwidth {
    width: 100%;
}

input.thin,
textarea.thin,
select.thin {
    width: 100%;
    max-width: 100px;
}

input.wide,
textarea.wide,
select.wide {
    width: 100%;
    max-width: 600px;
}

input.fullwidth,
textarea.fullwidth,
select.fullwidth {
    width: 100%;
}

label {
    margin-right: 15px;
}

/* ------------------------------
   TABS
   ------------------------------ */
.tabs {
    display: flex;
    gap: 8px;
    margin: 12px 0 16px;
}

.tab {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    background: linear-gradient(180deg, rgba(139, 92, 246, .08), rgba(59, 130, 246, .06));
    transition: background .15s ease, border-color .15s ease, color .15s ease;
    cursor: pointer;
}

.tab.active,
.tab:hover {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
    box-shadow: none;
    transform: none;
}

.tabs.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tabs-left {
    display: flex;
    gap: 8px;
}

.tabs-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ------------------------------
   PLACEHOLDER / TEXT
   ------------------------------ */
.placeholder {
    color: var(--muted);
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--panel-2);
}

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

.card-link {
    display: block;
    text-decoration: none;
}

.site-card-title {
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: .2px;
}

.site-switch {
    margin: 10px 0 14px;
}

.site-name a {
    color: var(--text);
    text-decoration: none;
}

.site-name a:hover {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
}

/* ------------------------------
   PILLS AND CHIPS
   ------------------------------ */
.pill {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    margin: 2px 6px 0 0;
    background: var(--pill-bg);
    white-space: nowrap;
}

.pill.ok {
    border-color: var(--ok);
}

.pill.warn {
    border-color: var(--warn);
}

.pill.info {
    border-color: var(--info);
}

.sev-critical {
    background: rgba(239, 68, 68, .10);
    border-color: var(--fail);
}

.sev-major {
    background: rgba(245, 158, 11, .10);
    border-color: var(--warn);
}

.sev-minor {
    background: rgba(16, 185, 129, .10);
    border-color: var(--ok);
}

.sev-info {
    background: rgba(59, 130, 246, .10);
    border-color: var(--info);
}

.complete-icon {
    color: var(--text);
}

.missing-icon {
    color: var(--fail);
}

.queue-icon {
    color: var(--warn);
}

.small {
    font-size: 12px;
}

.large {
    font-size: 18px;
}

.chip-row {
    margin-top: 8px;
}

.chip-group .pill {
    margin-top: 6px;
}

.kpi-card .kpi-val {
    margin-top: 4px;
}

/* ------------------------------
   KEY-VALUE
   ------------------------------ */
dl.kv {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px 12px;
    margin: 12px 0;
}

dl.kv dt {
    color: var(--muted);
    font-weight: 700;
}

dl.kv dd {
    margin: 0;
}

/* ------------------------------
   PRE / CODE BLOCKS
   ------------------------------ */
.pre {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .02);
}

/* ------------------------------
   PROGRESS
   ------------------------------ */
.progress {
    background: var(--border);
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
}

.bar {
    height: 10px;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    width: 0;
    transition: width .3s ease;
}

/* ------------------------------
   LAYOUT CONTAINER
   ------------------------------ */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ------------------------------
   ALERTS
   ------------------------------ */
.alert {
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--panel-2);
}

.alert.error {
    background: rgba(255, 93, 93, .10);
    color: #ffcdcd;
    border: 1px solid rgba(255, 93, 93, .35);
}

/* ------------------------------
   FOCUS VISIBILITY
   ------------------------------ */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
.nav-item:focus-visible,
.tab:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-color: var(--accent);
}

/* ------------------------------
   SCROLLBAR (WebKit)
   ------------------------------ */
*::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

/* ------------------------------
   MOTION REDUCTION
   ------------------------------ */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* -------- Bell / Header -------- */
.notif-bell {
    position: relative;
    display: inline-block;
}

.notif-bell>button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background:
        radial-gradient(500px 140px at 0% -20%, rgba(59, 130, 246, .06), transparent 60%),
        var(--panel);
    color: var(--text);
    border-radius: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: border-color .12s ease, box-shadow .12s ease, transform .06s ease, background .12s ease;
}

.notif-bell>button:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-2);
}

.notif-bell>button:active {
    transform: translateY(1px);
    box-shadow: var(--shadow-1);
}

.notif-bell .badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    color: var(--accent-contrast);
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
    box-shadow: var(--glow-soft);
}

.notif-bell .badge.hidden {
    display: none;
}

/* -------- Drawer -------- */
.notif-bell .drawer {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 380px;
    max-height: 70vh;
    overflow: auto;
    background:
        radial-gradient(900px 260px at 100% -10%, rgba(139, 92, 246, .06), transparent 60%),
        var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-2);
    z-index: 60;
}

.notif-bell.open .drawer {
    display: block;
}

.drawer-head {
    position: sticky;
    top: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    font-weight: 800;
    letter-spacing: .2px;
}

.notif-list {
    list-style: none;
    margin: 0;
    padding: 8px;
}

.notif-list li {
    /* display: grid; */
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-2);
    margin: 8px 4px;
    transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .06s ease;
}

.notif-list li:hover {
    background: color-mix(in srgb, var(--panel-2) 88%, var(--grad-end) 12%);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-1);
}

.notif-list a {
    margin-left: 5px;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.notif-list a:hover {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
}

.notif-list time {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    align-self: center;
}

.notif-list .meta {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
}

/* -------- Status chips (started/finished/error/etc.) -------- */
.evt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--pill-bg);
    white-space: nowrap;
}

.evt.started {
    border-color: var(--info);
}

.evt.finished {
    border-color: var(--ok);
}

.evt.queued,
.evt.running {
    border-color: var(--warn);
}

.evt.error,
.evt.failed {
    border-color: var(--fail);
}

/* Optional tiny dot in front */
.evt::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
    opacity: .85;
}

.evt.started::before {
    background: var(--info);
}

.evt.finished::before {
    background: var(--ok);
}

.evt.queued::before,
.evt.running::before {
    background: var(--warn);
}

.evt.error::before,
.evt.failed::before {
    background: var(--fail);
}

/* -------- Empty state -------- */
.notif-bell .muted {
    padding: 10px 14px;
}

/* -------- Toasts -------- */
.toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 70;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: 420px;
    padding: 12px 14px;
    border-radius: 12px;
    background:
        radial-gradient(800px 200px at 100% -30%, rgba(59, 130, 246, .08), transparent 60%),
        var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    animation: toast-in .18s ease-out both;
}

.toast.hide {
    animation: toast-out .15s ease-in forwards;
}

.toast strong {
    font-weight: 800;
    letter-spacing: .2px;
}

.toast a {
    color: var(--brand);
    font-weight: 700;
}

.toast .row {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
}

/* Variants by severity / status */
.toast.info {
    border-color: var(--info);
}

.toast.success {
    border-color: var(--ok);
}

.toast.warn {
    border-color: var(--warn);
}

.toast.error {
    border-color: var(--fail);
}

.toast.started {
    border-color: var(--info);
}

.toast.finished {
    border-color: var(--ok);
}

.toast.running {
    border-color: var(--warn);
}

/* Progress accent bar on top */
.toast::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    opacity: .9;
}

/* Close button (optional if you render one) */
.toast .close {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.toast .close:hover {
    color: var(--text);
}

/* -------- Animations -------- */
@keyframes toast-in {
    from {
        transform: translateY(8px) scale(.98);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    to {
        transform: translateY(6px) scale(.98);
        opacity: 0;
    }
}

/* -------- Inline icon helpers (Tabler) -------- */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.icon.info {
    color: var(--info);
}

.icon.success {
    color: var(--ok);
}

.icon.warn {
    color: var(--warn);
}

.icon.error {
    color: var(--fail);
}

/* -------- Compact breakpoint -------- */
@media (max-width: 560px) {
    .notif-bell .drawer {
        width: min(92vw, 380px);
    }

    .toasts {
        right: 10px;
        left: 10px;
        bottom: 10px;
    }

    .toast {
        max-width: 100%;
    }
}

/* -------- Focus visibility -------- */
.notif-bell>button:focus-visible,
.toast .close:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-color: var(--accent);
}

/* -------- Motion reduction -------- */
@media (prefers-reduced-motion: reduce) {

    .toast,
    .toast.hide {
        animation: none !important;
    }

    .notif-bell>button,
    .notif-list li {
        transition: none !important;
    }
}

/* -------- Optional utility classes for JS hooks -------- */
.hidden {
    display: none !important;
}

.nowrap {
    white-space: nowrap;
}

/* -------- Subtle skeleton for loading within drawer (optional) -------- */
.skel {
    display: inline-block;
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg,
            color-mix(in srgb, var(--panel-2) 70%, white 30%),
            color-mix(in srgb, var(--panel) 70%, white 30%),
            color-mix(in srgb, var(--panel-2) 70%, white 30%));
    background-size: 200% 100%;
    animation: skel 1.2s ease-in-out infinite;
}

@keyframes skel {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* -------- Row state colors if you show per-run status inline -------- */
.row-status.running {
    color: var(--warn);
}

.row-status.finished {
    color: var(--ok);
}

.row-status.started {
    color: var(--info);
}

.row-status.failed {
    color: var(--fail);
}

/* lightweight meters for pillar scores */
.meter {
    background: var(--bg);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
}

.meter>span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
}

.meta-row {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

.kv {
    font-size: .8rem;
    color: var(--muted);
}

.mini {
    font-size: .85rem;
}

.atglance {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 48px;
}

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

/* Utilities */
.tiny {
    font-size: 12px;
    line-height: 1.2;
}

.small {
    font-size: 13px;
    line-height: 1.35;
}

/* safe if already defined */
.mt-xxs {
    margin-top: 4px;
}

/* Inline icon rows */
.icon-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

/* Pills: size variant */
.pill.tiny {
    padding: 1px 6px;
    font-size: 11px;
    line-height: 1.2;
    border-radius: 999px;
}

/* Buttons: size variant */
.btn.tiny {
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1.2;
}

/* Tighten table cells flagged as tiny */
td.tiny,
th.tiny {
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
}

/* Optional: reduce spacing inside grid cells for dense model columns */
.table td .icon-row+.mt-xxs {
    margin-top: 2px;
}

/* Insights add-ons */
.chart-wrap {
    width: 100%;
    height: 220px;
}

#tavTrend {
    width: 100%;
    height: 100%;
}

.spark {
    display: inline-block;
    border-radius: 8px;
}

.spark path {
    stroke: currentColor;
    opacity: .9;
}

.pos {
    color: var(--ok);
}

.neg {
    color: var(--fail);
}

/* Drawer */
.issue-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 0;
    background: var(--panel);
    box-shadow: var(--shadow-2);
    overflow: auto;
    transition: width .2s ease;
    z-index: 1000;
    color: var(--text);
}

.issue-drawer.open {
    width: 520px;
}

.issue-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 999;
}

.no-scroll {
    overflow: hidden;
}

.issue-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.issue-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.issue-drawer-meta {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    background: var(--panel);
}

.issue-drawer-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-strong);
    background: var(--panel);
}

/* Code block uses themed surfaces */
.code {
    background: var(--panel-2);
    color: var(--text);
    padding: 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow: auto;
    box-shadow: var(--shadow-1);
}

/* Chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--chip-border);
    border-radius: 14px;
    text-decoration: none;
    font-size: 12px;
    background: var(--pill-bg);
    color: var(--text);
}

.click-row {
    cursor: pointer;
}

.issue-drawer-section h5 {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}
#d_current_wrap .code {
  background: var(--panel-2);
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 4px;
}

/* === Admin form refinement only === */

.api-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm, 12px);
}

.api-form label {
    font-size: 13px;
    color: var(--text);
    display: flex;
    flex-direction: column;
}

.api-form input[type="checkbox"] {
    width: auto;
    margin-right: 6px;
    vertical-align: middle;
}

.api-form .btn {
    align-self: flex-start;
}

.api-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* message block */
#adminMsg {
    margin-top: var(--space-md, 16px);
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
}

#adminMsg.error {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* Onboarding Module */
.onboard-card {
    background: radial-gradient(800px 200px at 0% -10%, rgba(139, 92, 246, .08), transparent 60%), var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-2);
    color: var(--text);
    margin-bottom: 20px;
    margin-top: 20px;
}

.onboard-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 4px;
    margin-top: 0;
}

.onboard-sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 16px;
}

.onboard-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 16px;
}

.onboard-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    transition: background .15s ease, border-color .15s ease;
}

.onboard-step:hover {
    background: color-mix(in srgb, var(--panel-2) 85%, var(--grad-end) 15%);
    border-color: var(--border-strong);
}

.step-icon {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    color: var(--accent-contrast);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glow-soft);
}

.step-text strong {
    display: block;
    margin-bottom: 2px;
    font-weight: 700;
}

.step-text p {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
}

.onboard-btn {
    background: var(--accent);
    color: var(--accent-contrast);
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease;
}

.onboard-btn:hover {
    background: color-mix(in srgb, var(--accent) 85%, black 20%);
}

@media (max-width: 600px) {
    .onboard-step {
        flex-direction: column;
        align-items: stretch;
    }

    .step-icon {
        align-self: flex-start;
    }
}

.onboard-btn:disabled {
    opacity: 0.5;
    cursor: default;
    background: color-mix(in srgb, var(--accent) 60%, var(--bg) 40%);
    box-shadow: none;
}

.onboard-btn:disabled:hover {
    background: color-mix(in srgb, var(--accent) 60%, var(--bg) 40%);
}

.prose {
    max-width: 900px;
}

/* ===== Help Center (scoped) ===== */
.helpdoc * { box-sizing: border-box; }
.helpdoc .container { max-width: 1200px; margin: 0 auto; padding: 0 var(--hpad); }

/* Topbar */
.helpdoc-topbar {
  display: grid; grid-template-columns: 1fr auto; align-items: end;
  gap: 16px; margin: 8px 0 14px;
}
.helpdoc-title { font-size: clamp(20px, 3vw, 28px); line-height: 1.15; margin: 0; }
.helpdoc-breadcrumb { font-size: 12px; }
.helpdoc-breadcrumb .muted { color: var(--muted); margin-right: 6px; }
.helpdoc-breadcrumb a { color: var(--link); text-decoration: none; }
.helpdoc-breadcrumb a:hover { text-decoration: underline; }

.helpdoc-search {
  position: relative; display: flex; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 10px 6px 36px; box-shadow: var(--shadow-1);
}
.helpdoc-search svg { position: absolute; left: 10px; width: 18px; height: 18px; fill: var(--muted); }
.helpdoc-search input {
  background: transparent; border: 0; outline: 0; width: 260px;
  color: var(--text); font-size: 14px;
}

/* Layout: two-column with sticky sidebar */
.helpdoc-layout {
  display: grid; grid-template-columns: 290px 1fr; gap: 20px;
}

/* Sidebar */
.helpdoc-sidebar {
  position: sticky; top: 12px; align-self: start;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--vpad); box-shadow: var(--shadow-1);
  max-height: calc(100dvh - 24px); overflow: auto;
}

.helpdoc-nav { display: grid; gap: 14px; }
.nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: 12px; }
.nav-group-label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 2px 2px 0;
  margin-bottom: 5px;
}

.nav-item, .nav-subitem {
  display: block; text-decoration: none; color: var(--text);
  padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: background .12s, border-color .12s, color .12s;
  margin-bottom: 5px;
}
.nav-item:hover, .nav-subitem:hover { background: linear-gradient(180deg, rgba(139,92,246,.08), rgba(59,130,246,.06)); border-color: var(--border); }
.nav-item.active, .nav-subitem.active {
  background: linear-gradient(180deg, rgba(139,92,246,.12), rgba(59,130,246,.10));
  box-shadow: inset 2px 0 0 var(--accent);
  border-color: var(--border);
}

.nav-subgroup { margin-left: 8px; display: grid; gap: 4px; }
.nav-subitem { font-size: 13px; color: var(--text-soft); text-transform: none; }
.nav-subitem.active { color: var(--text); }

/* Quick links as chips */
.nav-quick .chip {
  display: inline-block; margin: 4px 6px 0 0; padding: 4px 10px;
  font-size: 12px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); text-decoration: none; background: var(--panel);
}
.nav-quick .chip:hover { border-color: var(--accent); }

/* Article */
.helpdoc-article {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: clamp(14px, 2vw, 22px);
  box-shadow: var(--shadow-1);
}
.helpdoc-article section { margin: 0 0 28px; }
.helpdoc-article p { line-height: 1.65; margin: 8px 0; color: var(--text); }
.helpdoc-article ul, .helpdoc-article ol { margin: 10px 0 10px 20px; }
.helpdoc-article li { margin: 4px 0; }
.helpdoc-article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px; background: color-mix(in srgb, var(--panel) 80%, var(--accent) 4%);
  border: 1px solid var(--border); border-radius: 6px; padding: 0 5px;
}

/* Section headers with anchor buttons */
.helpdoc-sectionhead {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px dashed var(--border); padding-bottom: 6px; margin-bottom: 10px;
}
.helpdoc-sectionhead h3 { margin: 0; font-size: clamp(16px, 2.2vw, 20px); }
.helpdoc-anchor {
  border: 1px solid var(--border); background: var(--panel);
  border-radius: 6px; font-size: 12px; padding: 2px 8px; cursor: pointer;
  color: var(--text-soft);
}
.helpdoc-anchor:hover { color: var(--text); border-color: var(--accent); }
.helpdoc-anchor.copied { background: linear-gradient(180deg, rgba(139,92,246,.12), rgba(59,130,246,.10)); }

/* Search feedback */
.is-hidden { display: none !important; }
.is-highlight { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-radius: var(--radius-sm); }

/* Definition list & FAQ */
.helpdoc-kv { margin: 8px 0; }
.helpdoc-kv dt { font-weight: 700; margin-top: 10px; }
.helpdoc-kv dd { margin-left: 0; color: var(--text-soft); }

.helpdoc-faq summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.helpdoc-faq + .helpdoc-faq { border-top: 1px solid var(--border); }

/* Responsive polish */
@media (max-width: 1120px) {
  .helpdoc-layout { grid-template-columns: 260px 1fr; }
  .helpdoc-search input { width: 220px; }
}
@media (max-width: 860px) {
  .helpdoc-layout { grid-template-columns: 1fr; }
  .helpdoc-sidebar { position: static; max-height: none; }
  .helpdoc-search input { width: 100%; }
  .helpdoc-topbar { grid-template-columns: 1fr; align-items: start; }
}

/* Ensure all composite grids collapse */
@media (max-width: 1199px) {
  .grid-1-3,
  .grid-3-1,
  .grid-1-2-1,
  .grid-2-1,
  .grid-2-1-1,            /* ADDED */
  .grid-1-2,
  .grid-1-4-1-4-1-4,
  .grid-1-4,
  .grid-4-1 {
    grid-template-columns: 1fr;
  }
}

/* Toggle open state via hidden checkbox */
#navCheck:checked ~ .sidebar {
  transform: translateX(0);
}

/* Backdrop to close menu */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 999; /* under .sidebar */
}
#navCheck:checked ~ .nav-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Hamburger button */
.hamburger {
  display: none;                 /* only shown on mobile via media query */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 36px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  box-shadow: var(--shadow-1);
  margin-right: 8px;
}
.hamburger span {
  display: block;
  width: 18px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .15s ease, opacity .15s ease;
}
.hamburger span + span { margin-top: 4px; }

/* Optional: animate hamburger when open */
#navCheck:checked ~ .main .topbar .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
#navCheck:checked ~ .main .topbar .hamburger span:nth-child(2) { opacity: 0; }
#navCheck:checked ~ .main .topbar .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Accessibility: update aria-expanded when possible via :checked */
#navCheck:checked ~ .main .topbar .hamburger[aria-expanded] { aria-expanded: true; }

/* Help Center: ensure sidebar can overlay on mobile too */
@media (max-width: 860px) {
  .helpdoc-layout { grid-template-columns: 1fr; }
  .helpdoc-sidebar { position: static; max-height: none; }
}

/* Minor fix: make sticky table headers play nice on small screens */
@media (max-width: 560px) {
  .table th, .table td { padding: 8px; }
  .table th { position: sticky; top: 0; }
}

/* Mobile nav: off-canvas */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 320px);
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 1000;
  }
  .main { margin-left: 0; }
  /* Show hamburger */
  .hamburger { display: inline-flex; }
}

/* Minor fix: make sticky table headers play nice on small screens */
@media (max-width: 560px) {
    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        contain: inline-size; /* avoids page-wide reflow */
        border-radius: 12px;  /* optional polish */
    }

    /* Let columns size naturally; wrapper handles overflow */
    .table-wrap > .table {
        width: max-content;       /* expand to content width */
        min-width: 100%;          /* but not smaller than container */
        border-collapse: separate;/* preserves sticky header appearance */
    }
}
