body {
    background: #f4f7fc;
}

.ai-admin {
    max-width: 1380px;
    margin: 0 auto;
    padding: 32px 24px 88px;
}

.ai-header,
.ai-toolbar,
.ai-tabs,
.ai-actions,
.ai-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ai-header {
    justify-content: space-between;
    margin-bottom: 26px;
}

.ai-header a {
    color: hsl(var(--primary));
    text-decoration: none;
    font-size: .875rem;
    font-weight: 700;
}

.ai-header a:hover {
    text-decoration: underline;
}

.ai-header h1 {
    margin: 8px 0 0;
    font-size: clamp(1.45rem, 2.5vw, 2rem);
}

.ai-header p,
.ai-section-heading p {
    margin: 4px 0 0;
    color: #64748b;
}

.ai-tabs {
    gap: 4px;
    border-bottom: 1px solid #dbe3ef;
    margin-bottom: 26px;
}

.ai-tabs button {
    min-height: 48px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    padding: 11px 18px;
    color: #64748b;
    font: inherit;
    font-weight: 700;
}

.ai-tabs button.is-active {
    color: hsl(var(--primary));
    border-bottom-color: hsl(var(--primary));
}

.ai-tabs button:hover {
    color: hsl(var(--primary));
}

.ai-toolbar {
    margin-bottom: 18px;
}

.ai-toolbar input {
    min-width: min(100%, 300px);
    flex: 1;
}

.ai-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
    gap: 18px;
    align-items: start;
}

.ai-list,
.ai-editor,
.ai-queue,
.ai-detail {
    background: #fff;
    border: 1px solid #dfe6f1;
    border-radius: 18px;
    box-shadow: 0 8px 28px rgb(32 62 110 / 4%);
}

.ai-list,
.ai-editor {
    padding: 20px;
}

.ai-list {
    min-height: 180px;
}

.ai-item {
    border-bottom: 1px solid #e8edf4;
    padding: 15px 0;
}

.ai-item:last-child {
    border-bottom: 0;
}

.ai-item h3 {
    font-size: 1rem;
    margin: 0 0 7px;
}

.ai-item p {
    margin: 4px 0;
    color: #475569;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ai-meta {
    font-size: .75rem;
    color: #64748b;
}

.ai-item button {
    margin-top: 8px;
    margin-left: 6px;
    cursor: pointer;
}

.ai-editor {
    display: grid;
    gap: 12px;
}

.ai-editor[hidden] {
    display: none;
}

.ai-editor label {
    display: grid;
    gap: 5px;
    min-width: 0;
    font-weight: 600;
}

.ai-editor textarea {
    resize: vertical;
    min-height: 64px;
}

.ai-actions .button {
    padding: 9px 15px;
}

.ai-pagination {
    justify-content: center;
    margin-top: 16px;
}

.ai-pagination button {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
}

.ai-pagination button:disabled {
    opacity: .4;
}

.ai-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 20px;
}

.ai-eyebrow {
    display: inline-block;
    color: hsl(var(--primary));
    font-size: .76rem;
    font-weight: 700;
}

.ai-section-heading h2 {
    margin: 4px 0 0;
    font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.ai-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: .86rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease;
}

.ai-button:disabled {
    opacity: .55;
    cursor: wait;
}

.ai-button-primary {
    color: #fff;
    background: hsl(var(--primary));
}

.ai-button-primary:hover:not(:disabled) {
    background: #1e40af;
}

.ai-button-secondary {
    color: #1e40af;
    border-color: #bfd0f5;
    background: #fff;
}

.ai-button-secondary:hover:not(:disabled) {
    background: #eff5ff;
}

.ai-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.ai-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 94px;
    border: 1px solid #dfe6f1;
    border-radius: 14px;
    background: #fff;
    padding: 14px 18px;
}

.ai-metric span {
    color: #64748b;
    font-size: .8rem;
}

.ai-metric strong {
    color: #172b4d;
    font-size: 1.5rem;
    line-height: 1.4;
}

.ai-metric-attention {
    border-color: #f5d5b5;
    background: #fffaf4;
}

.ai-metric-attention strong {
    color: #a34c08;
}

.ai-filterbar {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid #dfe6f1;
    border-radius: 16px;
    background: #fff;
}

.ai-filterbar label {
    display: grid;
    gap: 6px;
    min-width: 0;
    color: #475569;
    font-size: .78rem;
    font-weight: 700;
}

.ai-filterbar .input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border-radius: 9px;
}

.ai-clear-filters {
    min-height: 42px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    padding: 8px 12px;
    color: hsl(var(--primary));
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}

.ai-clear-filters:hover {
    background: #eff5ff;
}

.ai-workspace {
    display: grid;
    grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
    align-items: start;
    gap: 18px;
}

.ai-knowledge-filters {
    grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) auto;
}

.ai-knowledge-main {
    min-width: 0;
}

.ai-knowledge-main .ai-detail {
    position: static;
}

.ai-knowledge-main .ai-editor {
    padding: 24px;
}

.ai-knowledge-main .ai-editor h2 {
    margin: 0 0 8px;
}

.ai-queue-category {
    color: #64748b;
    font-size: .76rem;
}

.ai-knowledge-published {
    color: #08724e;
    background: #dcf8ea;
}

.ai-knowledge-draft {
    color: #99510e;
    background: #fff0d8;
}

.ai-knowledge-archived {
    color: #526174;
    background: #eef2f6;
}

.ai-knowledge-questions,
.ai-knowledge-steps {
    margin: 0 0 22px;
    padding-right: 22px;
    line-height: 1.9;
    overflow-wrap: anywhere;
}

.ai-knowledge-questions li,
.ai-knowledge-steps li {
    padding: 4px 0;
}

.ai-detail-text {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.9;
    overflow-wrap: anywhere;
}

.ai-knowledge-main .ai-detail-actions {
    justify-content: space-between;
}

.ai-queue {
    overflow: hidden;
}

.ai-queue-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 16px 18px;
    border-bottom: 1px solid #e8edf4;
}

.ai-queue-heading h3 {
    margin: 0;
    font-size: .95rem;
}

.ai-queue-heading span {
    color: #64748b;
    font-size: .77rem;
}

.ai-queue-list {
    max-height: 700px;
    overflow-y: auto;
}

.ai-queue-item {
    display: grid;
    gap: 10px;
    width: 100%;
    border: 0;
    border-right: 3px solid transparent;
    border-bottom: 1px solid #edf1f6;
    background: #fff;
    padding: 16px;
    text-align: right;
}

.ai-queue-item:hover,
.ai-queue-item.is-selected {
    background: #f1f6ff;
}

.ai-queue-item.is-selected {
    border-right-color: hsl(var(--primary));
}

.ai-queue-item strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: .9rem;
    line-height: 1.8;
}

.ai-queue-item-top,
.ai-queue-item-bottom,
.ai-detail-top,
.ai-detail-badges,
.ai-sources,
.ai-detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-queue-item-top,
.ai-detail-top {
    justify-content: space-between;
}

.ai-queue-item time,
.ai-detail-top time {
    color: #64748b;
    font-size: .73rem;
}

.ai-queue-item-bottom {
    color: #64748b;
    font-size: .75rem;
}

.ai-review-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
}

.ai-review-new {
    background: #e27a22;
}

.ai-review-converted {
    background: #22a06b;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    border-radius: 999px;
    padding: 3px 10px;
    color: #475569;
    background: #eef2f6;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.4;
}

.ai-kind-knowledge,
.ai-status-converted {
    color: #08724e;
    background: #dcf8ea;
}

.ai-kind-general,
.ai-kind-conversation {
    color: #2659a8;
    background: #e8f1ff;
}

.ai-kind-clarification,
.ai-status-new {
    color: #99510e;
    background: #fff0d8;
}

.ai-kind-no_answer,
.ai-kind-error {
    color: #ac3540;
    background: #fff0f1;
}

.ai-detail {
    position: sticky;
    min-width: 0;
    top: 20px;
    min-height: 440px;
    padding: 24px;
}

.ai-detail-badges {
    margin-top: 14px;
}

.ai-detail-question {
    margin: 16px 0 22px;
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.ai-answer-block {
    border-right: 3px solid hsl(var(--primary));
    border-radius: 10px;
    background: #f2f6fd;
    padding: 14px 18px;
}

.ai-answer-block h4,
.ai-detail-section h4 {
    margin: 0 0 8px;
    font-size: .86rem;
}

.ai-answer-block p,
.ai-turn p {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.9;
}

.ai-detail-section {
    margin-top: 22px;
}

.ai-detail-section h4 small {
    margin-right: 7px;
    color: #64748b;
    font-size: .74rem;
    font-weight: 400;
}

.ai-turns {
    display: grid;
    gap: 10px;
}

.ai-turn {
    border: 1px solid #e4eaf3;
    border-radius: 12px;
    background: #fafcff;
    padding: 10px 13px;
}

.ai-turn-assistant {
    border-color: #dce8fc;
    background: #f3f7ff;
}

.ai-turn span {
    display: block;
    margin-bottom: 3px;
    color: #537099;
    font-size: .72rem;
    font-weight: 700;
}

.ai-source {
    border: 1px solid #dbe7f7;
    border-radius: 7px;
    background: #f5f9ff;
    padding: 3px 9px;
    color: #315b94;
    font-size: .73rem;
    direction: ltr;
}

.ai-muted {
    margin: 0;
    color: #64748b;
    font-size: .82rem;
}

.ai-detail-actions {
    justify-content: flex-end;
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid #e8edf4;
}

.ai-detail-empty,
.ai-queue-empty {
    display: grid;
    align-content: center;
    justify-items: center;
    min-height: 190px;
    padding: 24px;
    color: #64748b;
    text-align: center;
}

.ai-detail-empty {
    min-height: 390px;
}

.ai-detail-empty > span {
    color: hsl(var(--primary));
    font-size: 2rem;
}

.ai-detail-empty h3 {
    margin: 8px 0 0;
    color: #334155;
}

.ai-detail-empty p {
    margin: 4px 0 0;
    font-size: .84rem;
}

.ai-queue .ai-pagination {
    margin: 0;
    padding: 12px;
    border-top: 1px solid #e8edf4;
}

.ai-admin button:focus-visible,
.ai-admin a:focus-visible,
.ai-admin input:focus-visible,
.ai-admin select:focus-visible {
    outline: 3px solid #8bb4ff;
    outline-offset: 2px;
}

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

@media (max-width: 900px) {
    .ai-workspace,
    .ai-grid {
        grid-template-columns: 1fr;
    }

    .ai-detail {
        position: static;
    }

    .ai-queue-list {
        max-height: 360px;
    }
}

@media (max-width: 600px) {
    .ai-admin {
        padding: 22px 14px 72px;
    }

    .ai-header,
    .ai-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .ai-overview,
    .ai-filterbar,
    .ai-knowledge-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-filterbar {
        padding: 14px;
    }

    .ai-search-field,
    .ai-clear-filters {
        grid-column: 1 / -1;
    }

    .ai-clear-filters {
        justify-self: start;
    }

    .ai-metric {
        min-height: 82px;
        padding: 12px;
    }

    .ai-metric strong {
        font-size: 1.25rem;
    }

    .ai-detail {
        padding: 18px;
    }

    .ai-detail-actions .ai-button {
        width: 100%;
        white-space: normal;
    }
}
