:root {
    --sidebar: #111827;
    --sidebar-hover: #1f2937;
    --sidebar-active: #2563eb;

    --background: #f8fafc;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --panel-raised: #ffffff;
    --border: #e5e7eb;

    --text: #111827;
    --muted: #6b7280;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --topbar-bg: rgba(255, 255, 255, 0.96);
    --mobile-header-bg: rgba(255, 255, 255, 0.97);
    --input-bg: #ffffff;
    --menu-hover: #f1f5f9;

    --focus-ring: rgba(37, 99, 235, 0.10);

    --status-loading-bg: #eff6ff;
    --status-loading-text: #1d4ed8;
    --status-success-bg: #ecfdf3;
    --status-success-text: #047857;
    --status-error-bg: #fef2f2;
    --status-error-text: #b91c1c;

    --sidebar-width: 240px;
    --topbar-height: 72px;
    --mobile-header-height: 64px;

    --content-width: 1080px;

    color-scheme: light;
}

html[data-theme="dark"] {
    --sidebar: #0b1220;
    --sidebar-hover: #172033;
    --sidebar-active: #2563eb;

    --background: #0f172a;
    --panel: #111827;
    --panel-soft: #0f172a;
    --panel-raised: #172033;
    --border: #263244;

    --text: #e5edf7;
    --muted: #94a3b8;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;

    --topbar-bg: rgba(15, 23, 42, 0.94);
    --mobile-header-bg: rgba(15, 23, 42, 0.96);
    --input-bg: #111827;
    --menu-hover: #172033;

    --focus-ring: rgba(59, 130, 246, 0.18);

    --status-loading-bg: rgba(37, 99, 235, 0.16);
    --status-loading-text: #93c5fd;
    --status-success-bg: rgba(5, 150, 105, 0.16);
    --status-success-text: #6ee7b7;
    --status-error-bg: rgba(220, 38, 38, 0.16);
    --status-error-text: #fca5a5;

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]):not([data-theme="dark"]) {
        --sidebar: #0b1220;
        --sidebar-hover: #172033;
        --sidebar-active: #2563eb;

        --background: #0f172a;
        --panel: #111827;
        --panel-soft: #0f172a;
        --panel-raised: #172033;
        --border: #263244;

        --text: #e5edf7;
        --muted: #94a3b8;

        --primary: #3b82f6;
        --primary-hover: #60a5fa;

        --topbar-bg: rgba(15, 23, 42, 0.94);
        --mobile-header-bg: rgba(15, 23, 42, 0.96);
        --input-bg: #111827;
        --menu-hover: #172033;

        --focus-ring: rgba(59, 130, 246, 0.18);

        --status-loading-bg: rgba(37, 99, 235, 0.16);
        --status-loading-text: #93c5fd;
        --status-success-bg: rgba(5, 150, 105, 0.16);
        --status-success-text: #6ee7b7;
        --status-error-bg: rgba(220, 38, 38, 0.16);
        --status-error-text: #fca5a5;

        color-scheme: dark;
    }
}


/* =========================================================
   BASE
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
}

body {
    margin: 0;
    min-width: 0;
    min-height: 100vh;

    background: var(--background);
    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}


body,
.habios-topbar,
.habios-mobile-header,
.workflow-card,
.workflow-panel,
.form-field input {
    transition:
        background-color 160ms ease,
        color 160ms ease,
        border-color 160ms ease;
}


/* =========================================================
   APPLICATION SHELL
   ========================================================= */

.habios-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);

    width: 100%;
    min-height: 100vh;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

.habios-sidebar {
    position: fixed;
    z-index: 50;

    inset: 0 auto 0 0;

    width: var(--sidebar-width);
    height: 100vh;

    padding: 22px 16px;

    overflow-y: auto;

    background: var(--sidebar);
    color: white;
}

.habios-sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.habios-brand {
    padding: 4px 10px 24px;

    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.habios-brand small {
    display: block;

    margin-top: 3px;

    color: #94a3b8;

    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
}


/* =========================================================
   SIDEBAR NAVIGATION
   ========================================================= */

.habios-nav {
    display: grid;
    gap: 6px;
}

.habios-nav a {
    display: flex;
    align-items: center;

    min-height: 44px;

    padding: 0 12px;

    border-radius: 9px;

    color: #cbd5e1;

    font-size: 14px;
    font-weight: 700;

    text-decoration: none;

    transition:
        background 120ms ease,
        color 120ms ease;
}

.habios-nav a:hover {
    background: var(--sidebar-hover);
    color: white;
}

.habios-nav a.active {
    background: rgba(37, 99, 235, 0.28);
    color: white;
}


/* =========================================================
   SIDEBAR CLOSE BUTTON
   DESKTOP HIDDEN
   ========================================================= */

.habios-sidebar-close {
    display: none;

    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    align-items: center;
    justify-content: center;

    margin-top: -3px;

    border: 0;
    border-radius: 8px;

    background: transparent;
    color: #cbd5e1;

    font-size: 30px;
    font-weight: 300;
    line-height: 1;
}

.habios-sidebar-close:hover {
    background: var(--sidebar-hover);
    color: white;
}


/* =========================================================
   MAIN APPLICATION AREA
   ========================================================= */

.habios-main {
    grid-column: 2;

    width: 100%;
    min-width: 0;
}


/* =========================================================
   DESKTOP TOP BAR
   ========================================================= */

.habios-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: var(--topbar-height);

    padding: 0 32px;

    border-bottom: 1px solid var(--border);

    background: var(--topbar-bg);
}

.habios-topbar strong {
    font-size: 16px;
    font-weight: 750;
}

.habios-topbar span {
    color: var(--text);

    font-size: 15px;
    font-weight: 500;
}


/* =========================================================
   MOBILE HEADER
   DESKTOP HIDDEN
   ========================================================= */

.habios-mobile-header {
    display: none;
}

.habios-menu-button {
    display: none;
}


/* =========================================================
   MOBILE OVERLAY
   ========================================================= */

.habios-sidebar-overlay {
    display: none;
}


/* =========================================================
   CONTENT
   ========================================================= */

.habios-content {
    width: 100%;
    max-width: var(--content-width);

    margin: 0 auto;

    padding: 40px 32px 64px;
}


/* =========================================================
   PAGE HEADINGS
   ========================================================= */

.page-eyebrow {
    margin-bottom: 7px;

    color: var(--primary);

    font-size: 12px;
    font-weight: 800;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-title {
    margin: 0;

    font-size: 38px;
    font-weight: 750;

    line-height: 1.12;
    letter-spacing: -0.04em;
}

.page-description {
    max-width: 650px;

    margin: 10px 0 28px;

    color: var(--muted);

    font-size: 15px;
    line-height: 1.6;
}


/* =========================================================
   WORKFLOW CARDS
   ========================================================= */

.workflow-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 16px;
}

.workflow-card {
    min-width: 0;

    padding: 22px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: var(--panel);

    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04);
}

.workflow-card h2 {
    margin: 0 0 7px;

    font-size: 17px;
    font-weight: 750;

    line-height: 1.3;
}

.workflow-card p {
    margin: 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.5;
}

.workflow-card button {
    min-height: 42px;

    margin-top: 18px;
    padding: 0 15px;

    border: 0;
    border-radius: 8px;

    background: var(--primary);
    color: white;

    font-weight: 700;

    transition: background 120ms ease;
}

.workflow-card button:hover {
    background: var(--primary-hover);
}


/* =========================================================
   WORKFLOW PANEL
   ========================================================= */

.workflow-panel {
    margin-top: 24px;

    padding: 28px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: var(--panel);
}

.workflow-panel h2 {
    margin: 0 0 8px;

    font-size: 22px;
    line-height: 1.3;
}

.workflow-panel > p {
    margin: 0 0 24px;

    color: var(--muted);

    line-height: 1.6;
}

.workflow-panel h3 {
    margin: 28px 0 16px;

    font-size: 17px;
}


/* =========================================================
   FORMS
   ========================================================= */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 16px;
}

.form-field {
    display: grid;

    gap: 7px;

    margin-bottom: 16px;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 13px;
    font-weight: 700;
}

.form-field input {
    width: 100%;
    min-height: 44px;

    padding: 10px 12px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--input-bg);
    color: var(--text);

    outline: none;

    transition:
        border-color 120ms ease,
        box-shadow 120ms ease;
}

.form-field input:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px var(--focus-ring);
}


/* =========================================================
   PRIMARY ACTION
   ========================================================= */

.primary-action {
    min-height: 44px;

    padding: 0 18px;

    border: 0;
    border-radius: 8px;

    background: var(--primary);
    color: #ffffff;

    font-weight: 700;

    transition:
        background 120ms ease,
        opacity 120ms ease;
}

.primary-action:hover {
    background: var(--primary-hover);
}

.primary-action:disabled {
    cursor: wait;
    opacity: 0.65;
}


/* =========================================================
   STATUS MESSAGES
   ========================================================= */

.form-message {
    display: none;

    margin: 16px 0;
    padding: 12px 14px;

    border-radius: 8px;

    font-size: 13px;
    font-weight: 700;
}

.form-message.loading,
.form-message.success,
.form-message.error {
    display: block;
}

.form-message.loading {
    background: var(--status-loading-bg);
    color: var(--status-loading-text);
}

.form-message.success {
    background: var(--status-success-bg);
    color: var(--status-success-text);
}

.form-message.error {
    background: var(--status-error-bg);
    color: var(--status-error-text);
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {

    .habios-content {
        padding-left: 24px;
        padding-right: 24px;
    }

    .page-title {
        font-size: 34px;
    }

}


/* =========================================================
   MOBILE APPLICATION SHELL
   ========================================================= */

@media (max-width: 767px) {

    body.habios-menu-open {
        overflow: hidden;
    }


    /* -----------------------------------------
       SHELL
       ----------------------------------------- */

    .habios-shell {
        display: block;

        min-height: 100vh;
    }

    .habios-main {
        width: 100%;
        min-width: 0;
    }


    /* -----------------------------------------
       MOBILE HEADER
       ----------------------------------------- */

    .habios-mobile-header {
        position: sticky;
        z-index: 40;

        top: 0;

        display: grid;
        grid-template-columns: 1fr auto 44px;
        align-items: center;

        width: 100%;
        min-height: var(--mobile-header-height);

        padding: 0 16px;

        border-bottom: 1px solid var(--border);

        background: var(--mobile-header-bg);

        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .habios-mobile-brand {
        min-width: 0;

        font-size: 20px;
        font-weight: 800;

        letter-spacing: -0.03em;
    }

    .habios-mobile-section {
        margin-right: 8px;

        color: var(--muted);

        font-size: 13px;
        font-weight: 700;
    }


    /* -----------------------------------------
       MOBILE MENU BUTTON
       ----------------------------------------- */

    .habios-menu-button {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        gap: 4px;

        width: 44px;
        height: 44px;

        padding: 0;

        border: 0;
        border-radius: 9px;

        background: transparent;
    }

    .habios-menu-button:hover {
        background: var(--menu-hover);
    }

    .habios-menu-button span {
        display: block;

        width: 20px;
        height: 2px;

        border-radius: 999px;

        background: var(--text);
    }


    /* -----------------------------------------
       HIDE DESKTOP TOPBAR
       ----------------------------------------- */

    .habios-topbar {
        display: none;
    }


    /* -----------------------------------------
       MOBILE DRAWER
       ----------------------------------------- */

    .habios-sidebar {
        position: fixed;
        z-index: 100;

        inset: 0 auto 0 0;

        width: min(82vw, 300px);
        height: 100dvh;

        padding: 22px 16px;

        transform: translateX(-105%);

        box-shadow:
            12px 0 30px rgba(15, 23, 42, 0.18);

        transition:
            transform 180ms ease;
    }

    .habios-sidebar.mobile-open {
        transform: translateX(0);
    }

    .habios-sidebar-close {
        display: flex;
    }

    .habios-brand {
        padding-right: 0;
    }


    /* -----------------------------------------
       MOBILE OVERLAY
       ----------------------------------------- */

    .habios-sidebar-overlay {
        position: fixed;
        z-index: 90;

        inset: 0;

        display: block;

        visibility: hidden;

        background: rgba(15, 23, 42, 0.48);

        opacity: 0;

        transition:
            opacity 180ms ease,
            visibility 180ms ease;
    }

    .habios-sidebar-overlay.visible {
        visibility: visible;
        opacity: 1;
    }


    /* -----------------------------------------
       CONTENT
       ----------------------------------------- */

    .habios-content {
        width: 100%;
        max-width: none;

        margin: 0;

        padding:
            28px
            20px
            48px;
    }


    /* -----------------------------------------
       HEADINGS
       ----------------------------------------- */

    .page-eyebrow {
        margin-bottom: 6px;

        font-size: 11px;
    }

    .page-title {
        max-width: 100%;

        font-size: clamp(
            34px,
            10vw,
            42px
        );

        line-height: 1.08;
        letter-spacing: -0.045em;
    }

    .page-description {
        max-width: 100%;

        margin-top: 12px;
        margin-bottom: 24px;

        font-size: 15px;
        line-height: 1.55;
    }


    /* -----------------------------------------
       WORKFLOW
       ----------------------------------------- */

    .workflow-grid {
        grid-template-columns: 1fr;

        gap: 14px;
    }

    .workflow-card {
        padding: 20px;
    }

    .workflow-card h2 {
        font-size: 18px;
    }

    .workflow-card p {
        font-size: 14px;
    }

    .workflow-card button {
        width: 100%;
        min-height: 46px;

        margin-top: 18px;
    }


    /* -----------------------------------------
       PANELS
       ----------------------------------------- */

    .workflow-panel {
        margin-top: 20px;

        padding: 20px;

        border-radius: 12px;
    }

    .workflow-panel h2 {
        font-size: 20px;
    }

    .workflow-panel h3 {
        margin-top: 24px;
    }


    /* -----------------------------------------
       FORMS
       ----------------------------------------- */

    .form-grid {
        grid-template-columns: 1fr;

        gap: 0;
    }

    .form-field.full-width {
        grid-column: auto;
    }

    .form-field input {
        min-height: 48px;

        font-size: 16px;
    }

    .primary-action {
        width: 100%;
        min-height: 48px;
    }

}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 420px) {

    .habios-mobile-header {
        grid-template-columns: 1fr auto 44px;

        padding-left: 14px;
        padding-right: 10px;
    }

    .habios-mobile-brand {
        font-size: 19px;
    }

    .habios-mobile-section {
        font-size: 12px;
    }

    .habios-content {
        padding:
            24px
            18px
            44px;
    }

    .page-title {
        font-size: 36px;
    }

}