.tp-chatbot {
    --tp-chat-green: #188a57;
    --tp-chat-green-dark: #106640;
    --tp-chat-ink: #1d2923;
    --tp-chat-muted: #65736c;
    --tp-chat-line: #dce5df;
    --tp-chat-surface: #ffffff;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1080;
    color: var(--tp-chat-ink);
    font-family: inherit;
}

.tp-chatbot-trigger {
    position: relative;
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--tp-chat-green);
    box-shadow: none;
    font-size: 20px;
    transition: background-color 160ms ease, transform 160ms ease;
}

.tp-chatbot-lock-badge {
    position: absolute;
    right: -2px;
    bottom: -1px;
    width: 19px;
    height: 19px;
    display: grid;
    place-items: center;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #37443d;
    color: #fff;
    font-size: 8px;
}

.tp-chatbot-trigger:hover,
.tp-chatbot-trigger:focus-visible {
    background: transparent;
    color: var(--tp-chat-green-dark);
    outline: none;
    transform: translateY(-2px) scale(1.04);
}

.tp-chatbot-trigger.is-locked {
    background: transparent;
}

.tp-chatbot-trigger-label {
    position: absolute;
    top: 50%;
    right: calc(100% + 8px);
    z-index: 2;
    padding: 7px 10px;
    border: 1px solid var(--tp-chat-line);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(31, 48, 39, 0.16);
    color: var(--tp-chat-ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(5px, -50%);
    visibility: hidden;
    transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.tp-chatbot-trigger:hover .tp-chatbot-trigger-label,
.tp-chatbot-trigger:focus-visible .tp-chatbot-trigger-label {
    opacity: 1;
    transform: translate(0, -50%);
    visibility: visible;
}

.tp-chatbot-animated-icon,
.tp-chatbot-lottie {
    width: 100%;
    height: 100%;
    display: block;
}

.tp-chatbot-animated-icon {
    position: relative;
    overflow: visible;
    border-radius: 0;
}

.tp-chatbot-lottie {
    opacity: 0;
    transition: opacity 180ms ease;
}

.tp-chatbot-lottie.is-ready {
    opacity: 1;
}

.tp-chatbot-lottie svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
    filter: drop-shadow(0 7px 7px rgba(31, 48, 39, 0.2));
}

.tp-chatbot-trigger:focus-visible .tp-chatbot-lottie svg {
    filter:
        drop-shadow(0 7px 7px rgba(31, 48, 39, 0.2))
        drop-shadow(0 0 4px rgba(24, 138, 87, 0.72));
}

.tp-chatbot-lottie-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

.tp-chatbot-lottie-fallback[hidden] {
    display: none;
}

.tp-chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 106px;
    width: min(370px, calc(100vw - 28px));
    height: min(540px, calc(100vh - 110px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid var(--tp-chat-line);
    border-radius: 8px;
    background: var(--tp-chat-surface);
    box-shadow: 0 18px 50px rgba(31, 48, 39, 0.24);
    transform-origin: bottom right;
}

.tp-chatbot-panel[hidden] {
    display: none;
}

.tp-chatbot-header {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--tp-chat-line);
    background: #f4f8f5;
}

.tp-chatbot-avatar {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    display: grid;
    place-items: center;
    border-radius: 0;
    border: 0;
    background: transparent;
    color: var(--tp-chat-green);
}

.tp-chatbot-heading {
    min-width: 0;
    flex: 1;
}

.tp-chatbot-heading strong,
.tp-chatbot-heading span {
    display: block;
}

.tp-chatbot-heading strong {
    font-size: 15px;
    line-height: 1.25;
}

.tp-chatbot-heading span {
    margin-top: 2px;
    color: var(--tp-chat-muted);
    font-size: 12px;
}

.tp-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tp-chatbot-header-button,
.tp-chatbot-close {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #526159;
}

.tp-chatbot-header-button:hover,
.tp-chatbot-header-button:focus-visible,
.tp-chatbot-header-button.is-active,
.tp-chatbot-close:hover,
.tp-chatbot-close:focus-visible {
    background: #e4ece7;
    color: var(--tp-chat-ink);
    outline: none;
}

.tp-chatbot-header-button[hidden] {
    display: none;
}

.tp-chatbot-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    background: #fbfcfb;
    scrollbar-width: thin;
}

.tp-chatbot-message {
    width: fit-content;
    max-width: 88%;
    margin-bottom: 10px;
    padding: 9px 11px;
    border: 1px solid var(--tp-chat-line);
    border-radius: 8px;
    background: #fff;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14px;
}

.tp-chatbot-message.is-assistant {
    white-space: normal;
}

.tp-chatbot-message p {
    margin: 0 0 8px;
}

.tp-chatbot-message p:last-child,
.tp-chatbot-message ul:last-child,
.tp-chatbot-message ol:last-child {
    margin-bottom: 0;
}

.tp-chatbot-message ul,
.tp-chatbot-message ol {
    margin: 4px 0 10px;
    padding-left: 20px;
}

.tp-chatbot-message li + li {
    margin-top: 4px;
}

.tp-chatbot-message-heading {
    color: var(--tp-chat-green-dark);
    font-weight: 700;
}

.tp-chatbot-chart {
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--tp-chat-line);
}

.tp-chatbot-artifact-preview {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid var(--tp-chat-line);
    border-radius: 6px;
    background: #f5f8f6;
    font-size: 11px;
}

.tp-chatbot-artifact-preview span {
    color: var(--tp-chat-muted);
    text-align: right;
}

.tp-chatbot-chart-title {
    display: block;
    margin-bottom: 9px;
    font-size: 13px;
}

.tp-chatbot-doughnut {
    width: 82px;
    height: 82px;
    display: grid;
    place-items: center;
    margin: 4px auto 12px;
    border-radius: 50%;
}

.tp-chatbot-doughnut span {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    font-size: 16px;
    font-weight: 700;
}

.tp-chatbot-chart-list {
    display: grid;
    gap: 7px;
}

.tp-chatbot-chart-row {
    display: grid;
    grid-template-columns: minmax(70px, 1fr) minmax(68px, 1.4fr) 24px;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.tp-chatbot-chart-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-chatbot-chart-track {
    height: 7px;
    overflow: hidden;
    border-radius: 4px;
    background: #e5ebe7;
}

.tp-chatbot-chart-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--tp-chat-green);
}

.tp-chatbot-download {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--tp-chat-green);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.tp-chatbot-download:hover,
.tp-chatbot-download:focus-visible {
    background: var(--tp-chat-green-dark);
    color: #fff;
    outline: none;
}

.tp-chatbot-download.is-excel {
    background: #176b45;
}

.tp-chatbot-download.is-excel:hover,
.tp-chatbot-download.is-excel:focus-visible {
    background: #0f5033;
}

.tp-chatbot-related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.tp-chatbot-related-links a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--tp-chat-green-dark);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.tp-chatbot-related-links a:hover,
.tp-chatbot-related-links a:focus-visible {
    text-decoration: underline;
    outline: none;
}

.tp-chatbot-data-time {
    display: block;
    margin-top: 9px;
    color: #7b8881;
    font-size: 10px;
}

.tp-chatbot-message.is-user {
    margin-left: auto;
    border-color: var(--tp-chat-green);
    background: var(--tp-chat-green);
    color: #fff;
}

.tp-chatbot-message.is-error {
    border-color: #efc8c4;
    background: #fff3f2;
    color: #9a2f25;
}

.tp-chatbot-typing {
    color: var(--tp-chat-muted);
    font-style: italic;
}

.tp-chatbot-message.is-streaming {
    min-width: 32px;
    min-height: 34px;
    white-space: pre-wrap;
}

.tp-chatbot-message.is-streaming::after {
    width: 6px;
    height: 15px;
    display: inline-block;
    margin-left: 3px;
    background: var(--tp-chat-green);
    content: '';
    vertical-align: -2px;
    animation: tp-chatbot-cursor 800ms steps(1) infinite;
}

.tp-chatbot-message.is-streaming.is-awaiting::after {
    display: none;
}

.tp-chatbot-waiting-dots {
    height: 16px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tp-chatbot-waiting-status {
    display: block;
    margin-bottom: 5px;
    color: var(--tp-chat-muted);
    font-size: 12px;
    line-height: 1.35;
}

.tp-chatbot-waiting-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tp-chat-green);
    animation: tp-chatbot-waiting-dot 1s ease-in-out infinite;
}

.tp-chatbot-waiting-dots i:nth-child(2) {
    animation-delay: 140ms;
}

.tp-chatbot-waiting-dots i:nth-child(3) {
    animation-delay: 280ms;
}

@keyframes tp-chatbot-cursor {
    50% { opacity: 0; }
}

@keyframes tp-chatbot-waiting-dot {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .tp-chatbot-message.is-streaming::after,
    .tp-chatbot-waiting-dots i {
        animation: none;
    }
}

.tp-chatbot-suggestions {
    display: grid;
    gap: 7px;
    margin: 4px 0 14px;
}

.tp-chatbot-alerts {
    display: grid;
    gap: 6px;
    margin: 2px 0 12px;
}

.tp-chatbot-alert {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 8px 9px;
    border-left: 3px solid #4783a5;
    border-radius: 4px;
    background: #eef6fa;
    color: #315a70;
    font-size: 12px;
    line-height: 1.35;
}

.tp-chatbot-alert.is-warning {
    border-left-color: #ca8618;
    background: #fff8e9;
    color: #745217;
}

.tp-chatbot-alert.is-danger {
    border-left-color: #bd4c42;
    background: #fff1ef;
    color: #82362f;
}

.tp-chatbot-suggestion {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #bfd5c7;
    border-radius: 6px;
    background: #f6faf7;
    color: #24583e;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

.tp-chatbot-suggestion:hover,
.tp-chatbot-suggestion:focus-visible {
    border-color: var(--tp-chat-green);
    background: #eaf5ee;
    color: var(--tp-chat-green-dark);
    outline: none;
}

.tp-chatbot-history {
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    background: #fbfcfb;
}

.tp-chatbot-history[hidden] {
    display: none;
}

.tp-chatbot-history-list {
    display: grid;
    gap: 6px;
}

.tp-chatbot-history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: stretch;
    border: 1px solid var(--tp-chat-line);
    border-radius: 6px;
    background: #fff;
}

.tp-chatbot-history-open {
    min-width: 0;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    color: var(--tp-chat-ink);
    text-align: left;
}

.tp-chatbot-history-open strong,
.tp-chatbot-history-open span,
.tp-chatbot-history-open small {
    display: block;
}

.tp-chatbot-history-open strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-chatbot-history-open span {
    margin-top: 3px;
    overflow: hidden;
    color: var(--tp-chat-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-chatbot-history-open small {
    margin-top: 4px;
    color: #829087;
    font-size: 11px;
}

.tp-chatbot-history-open:hover,
.tp-chatbot-history-open:focus-visible {
    background: #f1f7f3;
    outline: none;
}

.tp-chatbot-history-delete {
    width: 36px;
    border: 0;
    border-left: 1px solid var(--tp-chat-line);
    border-radius: 0 6px 6px 0;
    background: transparent;
    color: #87948c;
}

.tp-chatbot-history-delete:hover,
.tp-chatbot-history-delete:focus-visible {
    background: #fff0ee;
    color: #a63b30;
    outline: none;
}

.tp-chatbot-history-empty {
    padding: 32px 18px;
    color: var(--tp-chat-muted);
    text-align: center;
    font-size: 13px;
}

.tp-chatbot-history-empty.is-error {
    color: #9a2f25;
}

.tp-chatbot-lock {
    height: 100%;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 12px;
    padding: 28px;
    text-align: center;
}

.tp-chatbot-lock i {
    font-size: 27px;
    color: #6b7770;
}

.tp-chatbot-lock p {
    margin: 0;
    color: var(--tp-chat-muted);
}

.tp-chatbot-lock a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 6px;
    background: var(--tp-chat-green);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

.tp-chatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--tp-chat-line);
    background: #fff;
}

.tp-chatbot-input {
    min-height: 42px;
    max-height: 112px;
    flex: 1;
    resize: none;
    border: 1px solid #cbd7cf;
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--tp-chat-ink);
    line-height: 1.35;
    font: inherit;
}

.tp-chatbot-input:focus {
    border-color: var(--tp-chat-green);
    outline: 3px solid rgba(24, 138, 87, 0.12);
}

.tp-chatbot-send {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: var(--tp-chat-green);
    color: #fff;
}

.tp-chatbot-stop {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: #37443d;
    color: #fff;
}

.tp-chatbot-stop[hidden],
.tp-chatbot-send[hidden] {
    display: none;
}

.tp-chatbot-message-actions {
    display: flex;
    gap: 3px;
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid var(--tp-chat-line);
}

.tp-chatbot-message-action {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #78857e;
    font-size: 11px;
}

.tp-chatbot-message-action:hover,
.tp-chatbot-message-action:focus-visible,
.tp-chatbot-message-action.is-active {
    background: #e7f1eb;
    color: var(--tp-chat-green-dark);
    outline: none;
}

.tp-chatbot-stopped {
    display: block;
    margin-top: 6px;
    color: var(--tp-chat-muted);
    font-size: 10px;
}

.tp-chatbot-send:disabled {
    cursor: not-allowed;
    background: #aab5ae;
}

@media (max-width: 575.98px) {
    .tp-chatbot {
        right: 14px;
        bottom: 14px;
    }

    .tp-chatbot-panel {
        position: fixed;
        right: 10px;
        bottom: 116px;
        left: 10px;
        width: auto;
        height: min(560px, calc(100vh - 136px));
    }
}
