﻿        :root {
            --bg: #f5f8fd;
            --panel: #ffffff;
            --ink: #0f172a;
            --ink-muted: #64748b;
            --line: #e2e8f0;
            --line-strong: #cbd5e1;
            --accent: #1e3a8a;
            --accent-strong: #1d4ed8;
            --accent-soft: #eaf1ff;
            --user-bubble: #1e3a8a;
            --user-ink: #f8fbff;
            --assistant-bubble: #f8fbff;
            --assistant-ink: #0f172a;
            --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.08);
            --shadow-tiny: 0 2px 10px rgba(15, 23, 42, 0.06);
            --app-height: 100vh;
        }

        * {
            box-sizing: border-box;
        }

        :where(button, [role="button"], select, input:not(.attach-input), textarea, a):focus-visible {
            outline: 3px solid rgba(37, 99, 235, 0.32);
            outline-offset: 2px;
        }

        html {
            height: -webkit-fill-available;
        }

        body {
            margin: 0;
            font-family: "Manrope", sans-serif;
            color: var(--ink);
            background:
                radial-gradient(52rem 24rem at 12% -8%, #eaf1ff 0%, transparent 68%),
                radial-gradient(44rem 22rem at 96% -12%, #eff6ff 0%, transparent 70%),
                var(--bg);
            min-height: var(--app-height);
            height: var(--app-height);
            overflow: hidden;
            -webkit-text-size-adjust: 100%;
        }

        .layout {
            display: grid;
            grid-template-columns: 288px minmax(0, 1fr);
            min-height: var(--app-height);
            height: var(--app-height);
            position: relative;
            overflow: hidden;
        }

        .sidebar {
            background: #ffffff;
            border-right: 1px solid var(--line);
            padding: 20px 16px;
            display: flex;
            flex-direction: column;
            min-height: var(--app-height);
            height: var(--app-height);
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            box-shadow: 8px 0 32px rgba(15, 23, 42, 0.04);
            z-index: 6;
        }

        .sidebar-close {
            display: none;
            width: 30px;
            height: 30px;
            border: 1px solid #d5e0ee;
            border-radius: 9px;
            background: #f8fbff;
            color: #334155;
            font-size: 18px;
            line-height: 1;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            margin-left: auto;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 18px;
            color: #0f172a;
            font-weight: 800;
            letter-spacing: 0.01em;
        }

        .brand-dot {
            width: 30px;
            height: 30px;
            border-radius: 10px;
            background: linear-gradient(145deg, #1d4ed8, #1e3a8a);
            box-shadow: 0 10px 20px rgba(30, 58, 138, 0.25);
            position: relative;
        }

        .brand-dot::after {
            content: "RAM";
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #f8fbff;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.02em;
        }

        .new-chat {
            width: 100%;
            border: 1px solid #1e3a8a;
            background: linear-gradient(145deg, #1e3a8a, #1d4ed8);
            color: #eff6ff;
            padding: 11px 12px;
            border-radius: 12px;
            font-family: inherit;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
            box-shadow: 0 12px 24px rgba(30, 58, 138, 0.22);
        }

        .new-chat:hover {
            filter: brightness(1.04);
            transform: translateY(-1px);
        }

        .history-head {
            margin-top: 16px;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: #94a3b8;
            font-weight: 700;
        }

        .history-refresh {
            border: 1px solid var(--line);
            background: #f8fafc;
            color: #475569;
            border-radius: 8px;
            padding: 4px 8px;
            font-size: 11px;
            cursor: pointer;
            transition: 0.2s ease;
        }

        .history-refresh:hover {
            background: #f1f5f9;
            border-color: #cbd5e1;
        }

        .history-list {
            display: flex;
            flex-direction: column;
            gap: 7px;
            max-height: clamp(120px, 36vh, 320px);
            min-height: 120px;
            flex: 0 0 auto;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding-right: 2px;
            scrollbar-width: thin;
            scrollbar-color: #cbd5e1 transparent;
        }

        .history-list::-webkit-scrollbar {
            width: 6px;
        }

        .history-list::-webkit-scrollbar-thumb {
            background: #d6dfeb;
            border-radius: 999px;
        }

        .history-item {
            border: 1px solid var(--line);
            background: #ffffff;
            border-radius: 11px;
            padding: 8px 9px;
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 6px;
            align-items: start;
            transition: 0.2s ease;
        }

        .history-item.active {
            border-color: #bfdbfe;
            background: #f8fbff;
            box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.08);
        }

        .history-open {
            border: 0;
            background: transparent;
            text-align: left;
            padding: 0;
            margin: 0;
            cursor: pointer;
            color: #1e293b;
            font: inherit;
        }

        .history-title {
            font-size: 12px;
            font-weight: 600;
            line-height: 1.35;
            margin-bottom: 4px;
            word-break: break-word;
        }

        .history-meta {
            font-size: 10px;
            color: #94a3b8;
        }

        .history-delete {
            border: 1px solid #dbe3ef;
            background: #f8fafc;
            color: #64748b;
            border-radius: 8px;
            padding: 3px 6px;
            font-size: 10px;
            cursor: pointer;
            transition: 0.2s ease;
        }

        .history-delete:hover {
            border-color: #fecaca;
            background: #fff1f2;
            color: #b91c1c;
        }

        .history-empty {
            border: 1px dashed #cbd5e1;
            border-radius: 10px;
            padding: 11px;
            font-size: 11px;
            color: #64748b;
            background: #f8fafc;
        }

        .hint {
            margin-top: 14px;
            color: #64748b;
            font-size: 12px;
            line-height: 1.55;
        }

        .admin-link {
            display: inline-block;
            margin-top: 8px;
            font-size: 12px;
            color: #1d4ed8;
            text-decoration: none;
            border-bottom: 1px dashed #bfdbfe;
        }

        .admin-link:hover {
            color: #1e3a8a;
        }

        .admin-link-btn {
            appearance: none;
            border: 0;
            background: transparent;
            padding: 0;
            cursor: pointer;
            font-family: inherit;
            text-align: left;
        }

        body.finance-login-open {
            overflow: hidden;
        }

        .finance-login-modal {
            position: fixed;
            inset: 0;
            z-index: 95;
            background:
                radial-gradient(circle at 16% 0, rgba(30, 58, 138, 0.25), transparent 42%),
                radial-gradient(circle at 84% 0, rgba(14, 165, 233, 0.22), transparent 42%),
                rgba(15, 23, 42, 0.56);
            backdrop-filter: blur(3px);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 16px;
        }

        .finance-login-modal[hidden] {
            display: none;
        }

        .finance-login-card {
            width: min(460px, 100%);
            border: 1px solid rgba(203, 213, 225, 0.9);
            border-radius: 22px;
            background: linear-gradient(180deg, #ffffff, #f8fbff);
            padding: 18px;
            box-shadow: 0 26px 48px rgba(15, 23, 42, 0.26);
            position: relative;
            overflow: hidden;
        }

        .finance-login-card::before {
            content: "";
            position: absolute;
            inset: 0 auto auto 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, #1e3a8a, #0284c7);
        }

        .finance-login-head {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 6px;
        }

        .finance-login-eyebrow {
            margin: 0 0 6px;
            display: inline-flex;
            align-items: center;
            border-radius: 999px;
            padding: 3px 10px;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: #1d4ed8;
            background: #eaf1ff;
        }

        .finance-login-close {
            width: 34px;
            height: 34px;
            border: 1px solid #d6deeb;
            border-radius: 11px;
            background: #ffffff;
            color: #475569;
            font-size: 21px;
            line-height: 1;
            cursor: pointer;
            transition: 0.18s ease;
        }

        .finance-login-close:hover {
            color: #0f172a;
            background: #f8fafc;
            border-color: #c4d2e6;
        }

        .finance-login-title {
            margin: 0;
            font-size: 28px;
            font-weight: 800;
            color: #0f172a;
            line-height: 1.12;
            letter-spacing: -0.02em;
        }

        .finance-login-subtitle {
            margin: 8px 0 16px;
            font-size: 14px;
            color: #64748b;
            line-height: 1.45;
        }

        .finance-login-form {
            display: grid;
            gap: 11px;
        }

        .finance-login-field {
            display: grid;
            gap: 7px;
        }

        .finance-login-field label {
            margin: 0;
            font-size: 12px;
            font-weight: 700;
            color: #334155;
            letter-spacing: 0.03em;
            text-transform: uppercase;
        }

        .finance-login-field input {
            width: 100%;
            min-height: 46px;
            border: 1px solid #c9d5e8;
            border-radius: 12px;
            background: #ffffff;
            padding: 11px 12px;
            font-size: 15px;
            color: #0f172a;
            font-family: "Manrope", sans-serif;
            outline: none;
            transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
        }

        .finance-login-field input::placeholder {
            color: #94a3b8;
        }

        .finance-login-field input:focus {
            border-color: #60a5fa;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.17);
            background: #fbfdff;
        }

        .finance-login-meta {
            min-height: 20px;
            margin: 2px 0 0;
            font-size: 13px;
            color: #0f766e;
        }

        .finance-login-meta.is-error {
            color: #b42318;
        }

        .finance-login-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 4px;
        }

        .finance-login-cancel,
        .finance-login-submit {
            width: 100%;
            min-height: 46px;
            border-radius: 12px;
            font-family: inherit;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
        }

        .finance-login-cancel {
            border: 1px solid #d7e0ee;
            background: #ffffff;
            color: #334155;
        }

        .finance-login-submit {
            border: 1px solid #1e3a8a;
            background: linear-gradient(145deg, #1e3a8a, #1d4ed8);
            color: #eff6ff;
            box-shadow: 0 12px 24px rgba(30, 58, 138, 0.24);
        }

        .finance-login-cancel:hover,
        .finance-login-submit:hover {
            transform: translateY(-1px);
        }

        .finance-login-cancel:hover {
            border-color: #c8d4e7;
            background: #f8fafc;
        }

        .finance-login-submit:hover {
            filter: brightness(1.03);
        }

        .finance-login-cancel:disabled,
        .finance-login-submit:disabled,
        .finance-login-close:disabled {
            cursor: not-allowed;
            opacity: 0.65;
            transform: none;
            box-shadow: none;
        }

        @media (max-width: 640px) {
            .finance-login-modal {
                align-items: flex-end;
                padding: 10px;
            }

            .finance-login-card {
                width: 100%;
                border-radius: 20px;
                padding: 14px;
                max-height: 88vh;
                overflow: auto;
            }

            .finance-login-title {
                font-size: 24px;
            }

            .finance-login-subtitle {
                font-size: 13px;
            }

            .finance-login-actions {
                grid-template-columns: 1fr;
            }

            .finance-login-cancel {
                order: 2;
            }
        }

        .image-lab {
            margin-top: 12px;
            border: 1px solid #d9e2f0;
            border-radius: 16px;
            background: #f8fbff;
            padding: 12px;
            position: relative;
        }

        .image-lab-title {
            margin: 0 0 10px;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: #4b6281;
            font-weight: 800;
        }

        .image-lab-form {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .image-lab-body {
            position: relative;
        }

        .image-lab-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 7px;
        }

        .image-lab-field,
        .image-lab-textarea {
            width: 100%;
            border: 1px solid #cfdced;
            background: #ffffff;
            border-radius: 11px;
            padding: 8px 10px;
            font-size: 12px;
            color: #334155;
            font-family: "IBM Plex Mono", monospace;
            outline: none;
        }

        .image-lab-field:focus,
        .image-lab-textarea:focus {
            border-color: #93c5fd;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
        }

        .image-lab-textarea {
            min-height: 74px;
            resize: vertical;
            font-family: "Manrope", sans-serif;
        }

        .image-lab-files {
            display: flex;
            flex-wrap: wrap;
            gap: 7px;
        }

        .image-lab-upload {
            display: inline-block;
            font-size: 11px;
            border-radius: 10px;
            padding: 6px 9px;
        }

        .image-lab-filename {
            font-size: 11px;
            color: #64748b;
            line-height: 1.4;
        }

        .image-lab-run {
            border: 1px solid #1e40af;
            background: linear-gradient(145deg, #1e40af, #2563eb);
            color: #eff6ff;
            border-radius: 11px;
            padding: 9px 10px;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
        }

        .image-lab-run:disabled {
            opacity: 0.65;
            cursor: not-allowed;
            box-shadow: none;
        }

        .image-lab-status {
            margin-top: 8px;
            font-size: 12px;
            color: #475569;
            line-height: 1.45;
        }

        .image-lab-results {
            margin-top: 8px;
            display: grid;
            grid-template-columns: 1fr;
            gap: 8px;
        }

        .image-lab-gallery {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px;
        }

        .image-lab-gallery img {
            width: 100%;
            border-radius: 11px;
            border: 1px solid #d3e0f1;
            background: #f1f5f9;
            box-shadow: var(--shadow-tiny);
        }

        .image-lab-pre {
            margin: 0;
            padding: 9px;
            border: 1px solid #d6e1f0;
            border-radius: 10px;
            background: #ffffff;
            color: #334155;
            font-size: 11px;
            line-height: 1.45;
            max-height: 200px;
            overflow: auto;
            font-family: "IBM Plex Mono", monospace;
        }

        .image-lab-lock {
            display: none;
        }

        .image-lab.is-disabled .image-lab-body > *:not(.image-lab-lock) {
            filter: blur(3px);
            opacity: 0.86;
            user-select: none;
            pointer-events: none;
        }

        .image-lab.is-disabled .image-lab-lock {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 12px;
            border-radius: 10px;
            background: rgba(248, 251, 255, 0.42);
            backdrop-filter: saturate(1.1);
            text-align: center;
            z-index: 3;
        }

        .image-lab-lock-badge {
            border: 1px solid #d5e0ef;
            border-radius: 11px;
            padding: 9px 10px;
            background: rgba(255, 255, 255, 0.96);
            color: #475569;
            font-size: 12px;
            line-height: 1.4;
            max-width: 236px;
            box-shadow: var(--shadow-tiny);
        }

        .sidebar-profile {
            margin-top: auto;
            border-top: 1px solid var(--line);
            padding: 14px 4px 4px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .sidebar-avatar {
            width: 38px;
            height: 38px;
            border-radius: 999px;
            background: #e2e8f0;
            color: #334155;
            font-size: 12px;
            font-weight: 800;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .sidebar-user-name {
            font-size: 12px;
            font-weight: 700;
            color: #0f172a;
        }

        .sidebar-user-role {
            font-size: 11px;
            color: #64748b;
        }

