:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --line: #e5e9ef;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1677ff;
    --primary-dark: #0958d9;
    --danger-bg: #fff2f0;
    --danger-text: #b42318;
    --sidebar: #111827;
    --sidebar-text: #d1d5db;
    --radius: 10px;
    --shadow: 0 6px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        "PingFang SC",
        "Microsoft YaHei",
        Arial,
        sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input { font: inherit; }

.ai-app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
}

.ai-sidebar {
    min-height: 100vh;
    padding: 22px 16px;
    background: var(--sidebar);
    color: #fff;
}

.ai-sidebar-brand,
.ai-login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-sidebar-brand span,
.ai-login-brand span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: #9ca3af;
}

.ai-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.ai-nav {
    display: grid;
    gap: 6px;
    margin-top: 30px;
}

.ai-nav a {
    padding: 11px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
}

.ai-nav a:hover,
.ai-nav a.active {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}

.ai-nav a[aria-disabled="true"] {
    opacity: .55;
    cursor: default;
}

.ai-main {
    min-width: 0;
    padding: 28px;
}

.ai-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.ai-topbar h1 {
    margin: 0;
    font-size: 26px;
}

.ai-topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.ai-btn {
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.ai-btn:hover { border-color: #b8c3d1; }

.ai-btn-primary {
    width: 100%;
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.ai-btn-primary:hover { background: var(--primary-dark); }

.ai-btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text);
}

.ai-scope-card {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin-bottom: 18px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.ai-scope-card span {
    color: var(--muted);
    font-size: 13px;
}

.ai-scope-card strong {
    margin-right: 12px;
    font-size: 13px;
}

.ai-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.ai-stat-card,
.ai-panel,
.ai-login-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.ai-stat-card {
    min-height: 142px;
    padding: 18px;
}

.ai-stat-card span {
    color: var(--muted);
    font-size: 14px;
}

.ai-stat-card strong {
    display: block;
    margin: 14px 0;
    font-size: 32px;
}

.ai-stat-card small { color: #9ca3af; }

.ai-panel {
    margin-top: 18px;
    padding: 20px;
}

.ai-panel h2 {
    margin: 0 0 6px;
    font-size: 18px;
}

.ai-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.ai-status-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.ai-status-list div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.ai-status-list span { color: var(--muted); }

.ai-module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ai-module-card {
    min-height: 180px;
    display: flex;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
}

.ai-module-card.is-live {
    transition:
        transform .18s ease,
        border-color .18s ease,
        box-shadow .18s ease;
}

.ai-module-card.is-live:hover {
    transform: translateY(-2px);
    border-color: #b7d6ff;
    box-shadow: 0 9px 26px rgba(15, 23, 42, .09);
}

.ai-module-card.is-disabled { opacity: .62; }

.ai-module-icon {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: #eef5ff;
    color: var(--primary);
    font-weight: 800;
}

.ai-module-content {
    min-width: 0;
    flex: 1;
}

.ai-module-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ai-module-title-row h2 {
    margin: 0;
    font-size: 18px;
}

.ai-module-content p {
    min-height: 48px;
    margin: 12px 0 16px;
    color: var(--muted);
    line-height: 1.7;
}

.ai-module-content > strong {
    color: var(--primary);
    font-size: 13px;
}

.ai-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.ai-tag-live {
    background: #ecfdf3;
    color: #027a48;
}

.ai-breadcrumb {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
}

.ai-breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.ai-flow-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.ai-flow-line span {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafbfc;
    font-size: 13px;
}

.ai-flow-line b { color: #9ca3af; }

.ai-login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.ai-login-shell { width: min(420px, 100%); }

.ai-login-brand { margin-bottom: 18px; }

.ai-login-card { padding: 24px; }

.ai-login-card h1 { margin: 0 0 6px; }

.ai-login-card > p {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.ai-login-card label {
    display: grid;
    gap: 7px;
    margin-bottom: 16px;
}

.ai-login-card label span {
    font-size: 13px;
    font-weight: 600;
}

.ai-login-card input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #cfd7e3;
    border-radius: 8px;
    outline: none;
}

.ai-login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 119, 255, .10);
}

.ai-alert {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
}

.ai-alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.ai-error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.ai-error-card {
    width: min(560px, 100%);
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.ai-error-card h1 { margin: 0 0 12px; }

.ai-error-card p {
    margin: 0;
    color: var(--muted);
}

@media (max-width: 980px) {
    .ai-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-module-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .ai-app {
        display: block;
    }

    .ai-sidebar {
        min-height: auto;
    }

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

    .ai-main {
        padding: 18px;
    }
}
/* =========================================================
   A02-HF01 - Sysvoo AI Chat Shell
   ========================================================= */

.ai-chat-page {
    overflow: hidden;
}

.ai-chat-app {
    grid-template-columns: 260px minmax(0, 1fr);
    height: 100vh;
    min-height: 100vh;
}

.ai-chat-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 16px;
}

.ai-chat-new-button {
    margin-top: 22px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    background: rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition:
        background .18s ease,
        border-color .18s ease;
}

.ai-chat-new-button:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .25);
}

.ai-chat-new-icon {
    font-size: 18px;
    line-height: 1;
}

.ai-chat-nav {
    margin-top: 14px;
}

.ai-chat-history {
    min-height: 0;
    flex: 1;
    margin-top: 22px;
    overflow-y: auto;
}

.ai-chat-history-title {
    margin-bottom: 8px;
    padding: 0 10px;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
}

.ai-chat-history-empty {
    padding: 10px;
    color: #6b7280;
    font-size: 13px;
}

.ai-chat-sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, .09);
}

.ai-chat-scope-mini {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.ai-chat-scope-mini span {
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .08);
    color: #9ca3af;
    font-size: 11px;
}

.ai-chat-logout {
    border: 0;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 12px;
}

.ai-chat-logout:hover {
    color: #fff;
}

.ai-chat-main {
    position: relative;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.ai-chat-topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
}

.ai-chat-model-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-model-label {
    color: var(--muted);
    font-size: 13px;
}

.ai-chat-model-select {
    min-width: 150px;
    height: 36px;
    padding: 0 32px 0 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
}

.ai-chat-model-select:focus {
    border-color: #8dbbff;
    box-shadow: 0 0 0 3px rgba(22, 119, 255, .08);
}

.ai-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
}

.ai-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #22c55e;
}

.ai-chat-messages {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 36px 28px 190px;
}

.ai-chat-welcome {
    width: min(820px, 100%);
    margin: 11vh auto 0;
    text-align: center;
}

.ai-chat-welcome-logo {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.ai-chat-welcome h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: -.03em;
}

.ai-chat-welcome > p {
    max-width: 680px;
    margin: 14px auto 0;
    color: var(--muted);
    line-height: 1.75;
    font-size: 14px;
}

.ai-chat-starter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 28px;
}

.ai-chat-starter {
    min-height: 96px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition:
        transform .16s ease,
        border-color .16s ease,
        box-shadow .16s ease;
}

.ai-chat-starter:hover {
    transform: translateY(-1px);
    border-color: #c8d7ed;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

.ai-chat-starter strong {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
}

.ai-chat-starter span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.ai-chat-composer-shell {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding:
        26px
        max(24px, calc((100% - 860px) / 2))
        18px;
    background:
        linear-gradient(
            to bottom,
            rgba(255,255,255,0),
            rgba(255,255,255,.94) 26%,
            #fff 58%
        );
}

.ai-chat-composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    min-height: 58px;
    padding: 8px;
    border: 1px solid #d8dee8;
    border-radius: 18px;
    background: #fff;
    box-shadow:
        0 10px 30px rgba(15, 23, 42, .08),
        0 1px 3px rgba(15, 23, 42, .04);
}

.ai-chat-composer:focus-within {
    border-color: #b7cdf0;
    box-shadow:
        0 0 0 3px rgba(22, 119, 255, .06),
        0 10px 30px rgba(15, 23, 42, .08);
}

.ai-chat-composer-tools {
    display: flex;
    align-items: flex-end;
}

.ai-chat-tool-button,
.ai-chat-send {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
}

.ai-chat-tool-button {
    background: #f3f5f8;
    color: #4b5563;
    font-size: 21px;
}

.ai-chat-tool-button:hover {
    background: #e9edf3;
}

.ai-chat-input {
    width: 100%;
    min-height: 40px;
    max-height: 180px;
    padding: 9px 5px;
    border: 0;
    resize: none;
    outline: none;
    background: transparent;
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
}

.ai-chat-input::placeholder {
    color: #9ca3af;
}

.ai-chat-send {
    background: #111827;
    color: #fff;
    font-size: 19px;
    font-weight: 700;
}

.ai-chat-send:hover:not(:disabled) {
    background: #000;
}

.ai-chat-send:disabled {
    background: #d8dde5;
    cursor: not-allowed;
}

.ai-chat-composer-note {
    margin-top: 8px;
    text-align: center;
    color: #9ca3af;
    font-size: 11px;
}

@media (max-width: 900px) {
    .ai-chat-app {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .ai-chat-starter-grid {
        grid-template-columns: 1fr;
    }

    .ai-chat-welcome {
        margin-top: 5vh;
    }
}

@media (max-width: 680px) {
    .ai-chat-app {
        display: block;
    }

    .ai-chat-sidebar {
        display: none;
    }

    .ai-chat-main {
        height: 100dvh;
    }

    .ai-chat-topbar {
        padding: 0 14px;
    }

    .ai-chat-messages {
        padding:
            24px
            14px
            180px;
    }

    .ai-chat-composer-shell {
        padding:
            22px
            12px
            12px;
    }

    .ai-chat-model-label {
        display: none;
    }

    .ai-chat-model-select {
        min-width: 120px;
    }
}
