.ai-insight-trigger {
    border: 0;
    background: linear-gradient(135deg, #635bff, #00a7c7);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 14px rgba(60, 84, 220, .22);
    transition: transform .18s ease, box-shadow .18s ease;
}

.ai-smart-robot {
    position: relative;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 15px;
    color: #fff;
    background: linear-gradient(145deg, rgba(255,255,255,.28), rgba(255,255,255,.1));
    border: 1px solid rgba(255,255,255,.32);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 8px 22px rgba(8,25,72,.18);
}

.ai-smart-robot i {
    font-size: 23px;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.18));
}

.ai-smart-robot.is-compact {
    width: 27px;
    height: 27px;
    border-radius: 9px;
    box-shadow: none;
}

.ai-smart-robot.is-compact i { font-size: 15px; }

.ai-robot-pulse {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #62ffca;
    box-shadow: 0 0 0 3px rgba(98,255,202,.18);
}

.ai-insight-trigger .ai-smart-robot {
    background: transparent;
    border: 0;
    width: 29px;
    height: 29px;
}

.ai-insight-trigger:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(60, 84, 220, .3);
}

.financial-ai-button {
    margin-inline-start: auto;
    border: 1px solid rgba(255, 255, 255, .55);
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border-radius: 999px;
    padding: 7px 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.financial-ai-button:hover {
    background: #fff;
    color: #3159d9;
}

.filter-card-header.ai-insight-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-insight-modal .modal-dialog {
    max-width: 1180px;
}

.ai-insight-modal .modal-content {
    border: 0;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(22, 35, 68, .25);
}

.ai-insight-modal .modal-header {
    border: 0;
    padding: 20px 24px;
    color: #fff;
    background:
        radial-gradient(circle at 90% 0, rgba(255, 255, 255, .22), transparent 30%),
        linear-gradient(135deg, #172554, #3b5ccc 55%, #00a7c7);
}

.ai-insight-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-insight-title-mark {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, .16);
    font-size: 19px;
}

.ai-insight-subtitle {
    opacity: .78;
    font-size: 14px;
    font-weight: 600;
}

#aiInsightLanguage {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    font-weight: 700;
    border-color: rgba(255, 255, 255, .65);
    background-color: rgba(255, 255, 255, .12);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

#aiInsightLanguage option {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    background: #3459c4;
}

.ai-insight-modal .modal-body {
    background: #f6f8fc;
    padding: 22px;
    max-height: calc(100vh - 135px);
    overflow-y: auto;
}

.ai-language-picker {
    min-height: 360px;
    display: grid;
    place-content: center;
    justify-items: center;
    text-align: center;
    color: #23355f;
}

.ai-language-picker-icon {
    margin-bottom: 18px;
    padding: 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, #3159d9, #00a7c7);
}

.ai-language-picker h5 {
    margin-bottom: 4px;
    font-weight: 800;
}

.ai-language-picker p {
    margin-bottom: 20px;
    color: #72809a;
    font-size: 18px;
}

.ai-language-picker-actions {
    display: flex;
    gap: 12px;
}

.ai-language-picker-actions .btn {
    min-width: 140px;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 700;
}

.ai-insight-modal.is-arabic #aiInsightContent {
    direction: rtl;
    text-align: right;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.75;
}

.ai-insight-modal.is-arabic .ai-insight-answer {
    direction: rtl;
    text-align: right;
}

.ai-insight-modal.is-arabic .ai-card-heading,
.ai-insight-modal.is-arabic .ai-insight-title {
    flex-direction: row;
    text-align: right;
}

.ai-insight-modal.is-arabic .ai-insight-table th {
    text-align: right;
}

.ai-insight-modal.is-arabic .ai-card-heading h6 {
    font-size: 20px;
}

.ai-insight-modal.is-arabic .ai-card-heading small,
.ai-insight-modal.is-arabic .ai-insight-metric small {
    font-size: 16px;
    font-weight: 600;
}

.ai-insight-modal.is-arabic .ai-key-value-row span,
.ai-insight-modal.is-arabic .ai-insight-facts-list,
.ai-insight-modal.is-arabic .ai-insight-chip {
    font-size: 17px;
}

.ai-insight-modal.is-arabic .ai-key-value-row strong,
.ai-insight-modal.is-arabic .ai-insight-answer {
    font-size: 18px;
}

.ai-insight-modal.is-arabic .ai-insight-answer {
    line-height: 2;
    font-weight: 600;
}

.ai-insight-modal.is-arabic .ai-insight-table {
    font-size: 15px;
}

.ai-insight-modal.is-arabic .ai-status,
.ai-insight-modal.is-arabic .ai-medical-tags span,
.ai-insight-modal.is-arabic .ai-insight-warning {
    font-size: 15px;
}

.ai-insight-modal.is-arabic .ai-insight-policy {
    font-size: 15px;
    font-weight: 600;
}

.ai-insight-modal.is-arabic .ai-insight-title {
    font-size: 21px;
}

.ai-insight-modal .ai-key-value-row strong,
.ai-insight-modal .ai-insight-metric strong,
.ai-insight-modal .ai-insight-table td,
.ai-insight-modal .ai-medical-tags span {
    unicode-bidi: plaintext;
}

.ai-insight-loading {
    min-height: 360px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #54627b;
}

.ai-insight-orbit {
    width: 58px;
    height: 58px;
    margin: 0 auto 16px;
    border: 4px solid #dce5ff;
    border-top-color: #506ff1;
    border-radius: 50%;
    animation: aiInsightSpin .8s linear infinite;
}

@keyframes aiInsightSpin {
    to { transform: rotate(360deg); }
}

.ai-insight-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.ai-insight-metric {
    background: #fff;
    border: 1px solid #e3e9f4;
    border-radius: 16px;
    padding: 14px;
}

.ai-insight-metric small {
    color: #72809a;
    display: block;
    margin-bottom: 7px;
}

.ai-insight-metric strong {
    color: #1d2c4d;
    font-size: 20px;
}

.ai-insight-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, .75fr);
    gap: 16px;
}

.ai-summary-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ai-half-card { min-width: 0; }

.ai-insight-card {
    background: #fff;
    border: 1px solid #e3e9f4;
    border-radius: 17px;
    padding: 18px;
    margin-bottom: 16px;
}

.ai-card-heading {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 14px;
}

.ai-card-heading h6 {
    margin: 0 0 2px;
    font-size: 19px;
}

.ai-card-heading small {
    color: #8692a8;
    font-size: 14px;
    font-weight: 600;
}

.ai-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3f5ed7;
    background: #edf2ff;
}

.ai-card-icon.green { color: #087c64; background: #e5faf4; }
.ai-card-icon.purple { color: #6941c6; background: #f1ebff; }
.ai-card-icon.cyan { color: #067a95; background: #e3f8fc; }

.ai-insight-card h6 {
    color: #23355f;
    font-weight: 800;
    margin-bottom: 12px;
}

.ai-insight-answer {
    color: #26344f;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.9;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    direction: ltr;
    text-align: left;
}

.ai-insight-answer p {
    margin: 0 0 14px;
}

.ai-insight-answer p:last-child {
    margin-bottom: 0;
}

.ai-key-value-table {
    border: 1px solid #e6ebf4;
    border-radius: 12px;
    overflow: hidden;
}

.ai-key-value-row {
    display: grid;
    grid-template-columns: minmax(130px, .9fr) minmax(0, 1.3fr);
    gap: 14px;
    padding: 9px 11px;
    border-bottom: 1px solid #e9edf5;
    align-items: center;
}

.ai-key-value-row:last-child { border-bottom: 0; }
.ai-key-value-row span { color: #53617b; font-size: 15px; font-weight: 600; }
.ai-key-value-row strong { color: #172b52; font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }

.ai-section-label {
    color: #53637f;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin: 14px 0 8px;
}

.ai-medical-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.ai-medical-tags span {
    padding: 5px 9px;
    border-radius: 999px;
    background: #fff4e7;
    color: #8a5717;
    font-size: 11px;
}

.ai-insight-facts-list {
    display: grid;
    gap: 8px;
    font-size: 13px;
}

.ai-insight-facts-list div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px dashed #e2e7f0;
    padding-bottom: 7px;
}

.ai-insight-facts-list span {
    color: #77839a;
}

.ai-insight-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-insight-chip {
    border: 1px solid #d7def0;
    background: #f8faff;
    color: #3651a3;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 14px;
    font-weight: 600;
}

.ai-insight-chip:hover {
    background: #eaf0ff;
}

.ai-insight-chat {
    display: flex;
    gap: 9px;
    margin-top: 12px;
}

.ai-insight-chat textarea {
    min-height: 46px;
    max-height: 120px;
    resize: vertical;
    border-radius: 13px;
    font-size: 16px;
    font-weight: 600;
}

.ai-insight-chat button {
    border-radius: 13px;
    min-width: 48px;
}

.ai-voice-button {
    color: #3d58c5;
    background: #edf2ff;
    border: 1px solid #d9e2fb;
}

.ai-voice-button.is-recording {
    color: #fff;
    background: #e5484d;
    border-color: #e5484d;
    animation: aiVoicePulse 1s ease-in-out infinite;
}

@keyframes aiVoicePulse {
    50% { box-shadow: 0 0 0 7px rgba(229,72,77,.16); }
}

.ai-insight-table-wrap {
    max-height: 330px;
    overflow: auto;
    border: 1px solid #e3e9f4;
    border-radius: 12px;
}

.ai-insight-table {
    width: 100%;
    font-size: 12px;
}

.ai-insight-table th {
    position: sticky;
    top: 0;
    background: #edf2ff;
    color: #334a86;
    z-index: 1;
}

.ai-insight-table th,
.ai-insight-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #e6ebf4;
    vertical-align: top;
    text-align: left;
    white-space: nowrap;
}

.ai-insight-table tbody tr:nth-child(even) { background: #fafbfe; }
.ai-insight-table tbody tr:hover { background: #f1f5ff; }
.ai-result-value { color: #2358c9; font-weight: 700; }

.ai-status {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 800;
}

.ai-status.is-complete { color: #087c64; background: #e5faf4; }
.ai-status.is-partial { color: #8a5717; background: #fff4e7; }
.ai-status.is-pending { color: #687386; background: #eef1f6; }

.ai-empty-state {
    border: 1px dashed #cfd8e8;
    background: #fafcff;
    color: #7c8799;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.ai-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.ai-filter-field {
    display: grid;
    gap: 6px;
}

.ai-filter-field > span {
    color: #52617d;
    font-size: 12px;
    font-weight: 700;
}

.ai-check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    color: #53617b;
    font-size: 12px;
}

.ai-setup-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.ai-setup-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    padding: 9px 16px;
}

.ai-error-robot {
    display: inline-flex;
    margin-bottom: 15px;
    background: #d93c51;
    border-radius: 16px;
}

.ai-insight-warning {
    background: #fff8e7;
    color: #785d18;
    border: 1px solid #f3df9d;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 600;
    margin-top: 10px;
}

.ai-insight-policy {
    color: #77839a;
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
}

@media (max-width: 800px) {
    .ai-insight-grid { grid-template-columns: 1fr; }
    .ai-summary-row { grid-template-columns: 1fr; }
    .ai-filter-grid { grid-template-columns: 1fr; }
    .ai-insight-modal .modal-body { padding: 14px; }
}

.test-catalog-ai-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 0;
    border-radius: 12px;
    padding: 9px 16px;
    color: #fff;
    background: linear-gradient(135deg, #3049a8, #34bdd4);
    box-shadow: 0 8px 20px rgba(56, 100, 190, .22);
    font-weight: 700;
}

.test-catalog-ai-button:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(56, 100, 190, .3);
}

.test-data-actions {
    white-space: nowrap;
}

.ai-print-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 10px;
    padding: 6px 11px;
    color: #fff;
    background: rgba(255, 255, 255, .12);
    font-weight: 700;
}

.ai-print-button:hover {
    color: #23355f;
    background: #fff;
}

.ai-chat-conversation {
    display: grid;
    gap: 12px;
    max-height: 360px;
    overflow-y: auto;
    margin: 12px 0;
    padding: 4px 6px;
    scrollbar-width: thin;
}

.ai-chat-conversation:empty {
    display: none;
}

.ai-chat-message {
    width: min(82%, 760px);
    padding: 11px 14px;
    border-radius: 15px;
    border: 1px solid #dce5f3;
    background: #f7f9fd;
    color: #253552;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.75;
}

.ai-chat-message.is-user {
    justify-self: end;
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #4269df, #3151bd);
    border-bottom-right-radius: 5px;
}

.ai-insight-modal.is-arabic .ai-chat-message.is-user {
    justify-self: start;
    border-bottom-right-radius: 15px;
    border-bottom-left-radius: 5px;
}

.ai-chat-message.is-assistant {
    justify-self: start;
    border-bottom-left-radius: 5px;
}

.ai-insight-modal.is-arabic .ai-chat-message.is-assistant {
    justify-self: end;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 5px;
}

.ai-chat-message.is-error {
    justify-self: center;
    color: #9c2f2f;
    border-color: #f2c5c5;
    background: #fff2f2;
}

.ai-chat-message-label {
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 800;
    opacity: .72;
}

.ai-chat-message-content p {
    margin: 0 0 7px;
    white-space: pre-wrap;
}

.ai-chat-message-content p:last-child {
    margin-bottom: 0;
}

.ai-chat-typing {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.ai-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7182a5;
    animation: ai-chat-dot 1.1s infinite ease-in-out;
}

.ai-chat-typing span:nth-child(2) { animation-delay: .15s; }
.ai-chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes ai-chat-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ai-test-notes {
    display: grid;
    gap: 8px;
}

.ai-test-notes > div {
    padding: 9px 11px;
    border: 1px solid #e4eaf4;
    border-radius: 9px;
    background: #fafcff;
    unicode-bidi: plaintext;
}

@media (max-width: 800px) {
    .ai-chat-message {
        width: 94%;
    }

    .test-catalog-ai-button {
        width: 100%;
        justify-content: center;
    }
}
