body {
    background: var(--app-body-bg);
    color: var(--app-body-color, inherit);
}

body .queue-detail-hero-card,
body .queue-sidebar-card,
body .case-page-timeline-card,
body .queue-detail-conversation-card,
body .case-live-actions-panel {
    border: 1px solid var(--app-card-border);
    border-radius: 18px;
    box-shadow: var(--app-card-shadow);
    background: var(--app-card-bg);
}

body .case-workspace-layout,
body .queue-detail-grid {
    align-items: start;
}

body .case-workspace-hero-card {
    position: relative;
    z-index: 4 !important;
    overflow: visible !important;
    border-top: 3px solid #2f6fed;
}

body .case-page-timeline-card,
body .queue-detail-conversation-card {
    position: relative;
    z-index: 1 !important;
}

body .case-workspace-hero-main {
    display: grid;
    gap: 1rem;
}

body .case-workspace-hero-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem 1rem;
    flex-wrap: wrap;
}

body .queue-detail-hero-title-link {
    color: var(--app-strong-text);
    text-decoration: none;
}

body .queue-detail-hero-title-link:hover,
body .queue-detail-hero-title-link:focus-visible {
    color: #1d4ed8;
}

body .case-workspace-hero-title-row {
    row-gap: 0.55rem;
}

body .case-workspace-hero-actions {
    align-items: center;
}

body .case-header-contact-pill,
body .case-contact-phone-link.case-contact-phone-link-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.25rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid #d7e3fb;
    background: #f7faff;
    color: #18408b;
    font-size: 0.88rem;
    font-weight: 600;
}

body .case-contact-phone-link.case-contact-phone-link-sm {
    box-shadow: none;
}

body .badge-soft,
body .case-header-order-badge {
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #dbe4ff;
    border-radius: 999px;
}

body .case-workspace-hero-subline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-left: auto;
    color: #64748b;
    font-size: 0.86rem;
}

body .case-workspace-company {
    font-weight: 600;
    color: #334155;
}

body .case-workspace-address {
    min-width: 0;
}

body .case-workspace-hero-controls {
    flex: 1 1 28rem;
    padding-bottom: 0.1rem;
}

body .case-workspace-hero-controls .case-workflow-inline,
body .queue-detail-tagged-user-editor .case-workflow-inline,
body .queue-detail-issue-label-editor .case-workflow-inline {
    z-index: 1;
}

body .case-workspace-hero-controls .case-workflow-inline:has([aria-expanded="true"]),
body .queue-detail-tagged-user-editor .case-workflow-inline:has([aria-expanded="true"]),
body .queue-detail-issue-label-editor .case-workflow-inline:has([aria-expanded="true"]) {
    z-index: 25 !important;
}

body .case-workspace-summary-strip {
    display: grid;
    gap: 1px;
    border: 1px solid #e7d9b3;
    border-radius: 16px;
    overflow: hidden;
    background: #e7d9b3;
}

body .case-workspace-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.04rem;
    padding: 0.3rem 0.8rem;
    min-height: 0;
    background: #faf6ea;
}

body .case-workspace-summary-item.response-target {
    background: #f6e9bf;
}

body .case-workspace-summary-item.response-target.tone-good {
    background: #e9f6de;
}

body .case-workspace-summary-item.response-target.tone-danger {
    background: #fde7e5;
}

body .case-workspace-summary-label {
    font-size: 0.61rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

body .case-workspace-summary-value {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.15;
    color: #0f172a;
}

body .case-workspace-summary-response-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
}

body .case-workspace-summary-help {
    font-size: 0.72rem;
    line-height: 1.05;
    color: #6b7280;
}

body .case-timeline-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

body .case-timeline-toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem 1rem;
    flex-wrap: wrap;
}

body .case-timeline-filter-bar,
body .case-order-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

body .case-timeline-toolbar-header .case-timeline-filter-bar {
    justify-content: flex-end;
    margin-left: auto;
}

body .case-order-filter-bar {
    justify-content: flex-start;
}

body .case-timeline-filter-btn,
body .case-order-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    padding: 0.42rem 0.82rem;
    border: 1px solid #d6dfec;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

body .case-timeline-filter-btn:hover,
body .case-order-filter-btn:hover,
body .case-timeline-filter-btn:focus-visible,
body .case-order-filter-btn:focus-visible {
    border-color: #b9c9e3;
    background: #f1f5f9;
    color: #1f2937;
    box-shadow: none;
}

body .case-timeline-filter-btn.is-active,
body .case-order-filter-btn.is-active {
    background: linear-gradient(135deg, #2f6fed, #255dd0);
    border-color: #255dd0;
    color: #fff;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

body .case-timeline-filter-count {
    min-width: 1.4rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    text-align: center;
    font-size: 0.72rem;
}

body .case-timeline-filter-btn.is-active .case-timeline-filter-count {
    background: rgba(255, 255, 255, 0.2);
}

body .case-page-timeline-scroll,
body .queue-detail-timeline {
    gap: 0.9rem !important;
}

body .timeline-item-row {
    display: block;
    width: 100%;
    margin-bottom: 0.9rem;
}

body .timeline-item {
    width: 100% !important;
    margin: 0 !important;
    border: 1px solid #e2e8f0;
    border-left-width: 1px;
    border-radius: 16px !important;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.03);
}

body .timeline-item-row.timeline-item-align-start,
body .timeline-item-row.timeline-item-align-end {
    justify-content: stretch;
}

body .timeline-item.direction-outbound,
body .timeline-item.direction-internal {
    background: #fcfdff;
}

body .timeline-entry-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
}

body .timeline-email-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}

body .timeline-item .badge.text-bg-light.border {
    background: #f8fafc !important;
    border-color: #dbe4ef !important;
    color: #475569 !important;
}

body .timeline-image-preview-modal .timeline-image-preview-dialog {
    width: fit-content;
    max-width: calc(100vw - 1rem);
    margin: 0.5rem auto;
}

body .timeline-image-preview-modal .modal-content {
    width: fit-content;
    max-width: 100%;
    border-radius: 20px;
    overflow: hidden;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

body .timeline-image-preview-modal .modal-header,
body .timeline-image-preview-modal .modal-footer {
    padding-left: 1rem;
    padding-right: 1rem;
}

body .timeline-image-preview-modal .modal-body {
    padding: 0.5rem;
}

body .timeline-image-preview-wrap {
    width: fit-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 0;
    background: var(--bs-tertiary-bg);
}

body .timeline-image-preview-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 10rem);
    width: auto;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

html[data-bs-theme="dark"] body .timeline-image-preview-modal .modal-content {
    background: #08111f;
    color: #d3deea;
    border-color: rgba(148, 163, 184, 0.28);
}

html[data-bs-theme="dark"] body .timeline-image-preview-wrap {
    background: #0d1728;
}

body .queue-sidebar-card {
    font-size: 0.88rem;
}

body .case-workspace-sidebar-card .queue-sidebar-heading,
body .queue-sidebar-card .queue-sidebar-heading {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
}

body .queue-sidebar-contact-name {
    margin-top: 0.2rem;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

body .case-workspace-contact-meta {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0.85rem 0 1rem;
}

body .queue-sidebar-phone {
    width: 100%;
    justify-content: flex-start;
}

body .case-workspace-email {
    padding: 0 0.1rem;
    font-size: 0.9rem;
    color: #334155;
    word-break: break-word;
}

body .case-workspace-address-block,
body .case-workspace-payment-panel {
    margin-top: 0.9rem;
    padding: 0.95rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
}

body .queue-sidebar-facts {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.85rem;
}

body .queue-sidebar-fact {
    display: grid;
    gap: 0.15rem;
    align-items: flex-start;
}

body .queue-sidebar-fact-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

body .queue-sidebar-fact-value {
    color: #0f172a;
    word-break: break-word;
}

body .case-workspace-payment-list {
    display: grid;
    gap: 0.55rem;
}

body .case-workspace-payment-row {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    padding: 0.75rem 0.85rem;
}

body .case-workspace-payment-main {
    display: grid;
    gap: 0.35rem;
}

body .case-workspace-payment-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.84rem;
    flex-wrap: wrap;
}

body .case-workspace-payment-order {
    color: #2563eb;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
}

body .case-workspace-payment-order:hover,
body .case-workspace-payment-order:focus-visible {
    color: #1d4ed8;
}

body .case-workspace-payment-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 600;
}

body .case-workspace-payment-method {
    color: #64748b;
    font-size: 0.78rem;
}

body .case-workspace-opt-out-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

body .queue-sidebar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

body .case-workspace-focus-card {
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    border: 1px solid #f5c97a;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff8eb 0%, #fffdf8 100%);
}

body .case-workspace-focus-title {
    font-size: 0.96rem;
    font-weight: 700;
    color: #0f172a;
}

body .case-workspace-focus-copy {
    color: #64748b;
    font-size: 0.84rem;
    line-height: 1.5;
}

body .case-workspace-focus-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 600;
}

body .case-workspace-controls-card {
    display: grid;
    gap: 0.85rem;
}

body .case-workspace-controls-sla {
    padding: 0.95rem 1rem;
    border: 1px solid #f5d694;
    border-radius: 14px;
    background: linear-gradient(180deg, #fff8eb 0%, #fffdf7 100%);
}

body .case-workspace-controls-sla-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #8a5a00;
}

body .case-workspace-label-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

body .case-workspace-label-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.75rem;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    background: #f4f7fb;
    border: 1px solid #dbe4ef;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 700;
}

body .case-workspace-note-form textarea,
body .case-workspace-note-item {
    border-radius: 14px;
}

body .case-workspace-customer-notes [data-customer-note-toggle] {
    white-space: nowrap;
}

body .case-workspace-note-editor {
    margin-bottom: 0.75rem;
}

body .case-workspace-note-form textarea {
    border-color: #d9e1ec;
    min-height: 88px;
}

body .case-workspace-note-form {
    margin-bottom: 0;
}

body .case-workspace-note-item {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0.9rem 1rem;
}

body .case-workspace-note-item:nth-child(odd) {
    background: linear-gradient(180deg, #eefbf0 0%, #f8fafc 100%);
}

body .case-workspace-note-item:nth-child(even) {
    background: linear-gradient(180deg, #fff8e8 0%, #f8fafc 100%);
}

body .case-live-actions-panel,
body .queue-sidebar-card:not(.case-workspace-sidebar-card) {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
    border-color: #e5ebf3;
}

body .queue-sidebar-card:not(.case-workspace-sidebar-card) .queue-sidebar-heading,
body .case-live-actions-panel .text-muted.small:first-child {
    color: #94a3b8 !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

body .case-workspace-note-list {
    display: grid;
    gap: 0.7rem;
}

body .case-route-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 0.26rem 0.6rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

body .case-route-pill.tone-default {
    background: #e2e8f0;
    color: #0f172a;
}

body .case-route-pill.tone-good {
    background: #dcfce7;
    color: #166534;
}

body .case-route-pill.tone-warning {
    background: #fef3c7;
    color: #92400e;
}

body .case-route-pill.tone-danger {
    background: #fee2e2;
    color: #b91c1c;
}

body .case-route-pill.tone-info {
    background: #ede9fe;
    color: #6d28d9;
}

body .case-route-pill.tone-muted {
    background: #e2e8f0;
    color: #475569;
}

body .agent-config-card {
    border-color: var(--app-card-border) !important;
    border-radius: 18px;
    background: var(--app-card-bg);
    box-shadow: var(--app-card-shadow);
}

body .agent-config-label {
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    font-weight: 700;
}

body .agent-config-clamp {
    display: -webkit-box;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    white-space: pre-line;
    line-height: 1.45;
    color: var(--app-body-color, inherit);
}

body .agent-config-empty {
    color: var(--bs-secondary-color) !important;
}

body .agent-config-field-help {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
}

body .agent-config-modal .modal-content {
    background: var(--app-card-bg);
    color: var(--app-body-color, inherit);
    border-color: var(--app-card-border);
    max-height: calc(100vh - 1.5rem);
}

body .agent-config-modal {
    z-index: 2010;
}

body .agent-config-modal .modal-header,
body .agent-config-modal .modal-footer {
    border-color: var(--app-card-border);
}

body .agent-config-modal .modal-dialog {
    max-width: min(1140px, calc(100vw - 1rem));
    margin: 0.75rem auto;
}

body .agent-config-modal .modal-body {
    overflow-y: auto;
}

body .agent-config-modal .agent-config-instructions-input {
    min-height: min(22rem, 42vh);
    white-space: pre-wrap;
}

body .new-case-flow-card .new-case-step + .new-case-step {
    border-top: 1px solid var(--app-card-border);
    padding-top: 1.5rem;
}

body .new-case-match {
    background: var(--app-card-bg);
    color: var(--app-body-color, inherit);
    border: 1px solid var(--app-card-border);
}

body .new-case-match .card-body {
    background: transparent;
}

@media (min-width: 992px) {
    body .case-workspace-summary-strip {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.95fr) minmax(0, 0.95fr) minmax(0, 0.95fr) minmax(0, 1.8fr);
    }
}

@media (max-width: 1199.98px) {
    body .case-page-sidebar-column,
    body .queue-detail-sidebar {
        max-width: none;
    }
}

@media (max-width: 767.98px) {
    body .case-workspace-hero-meta-row {
        flex-direction: column;
        align-items: stretch;
    }

    body .case-workspace-hero-subline {
        justify-content: flex-start;
        margin-left: 0;
    }

    body .case-timeline-toolbar-header .case-timeline-filter-bar {
        justify-content: flex-start;
        margin-left: 0;
    }

    body .case-workspace-summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body .case-workspace-focus-meta,
    body .case-workspace-payment-row,
    body .case-workspace-opt-out-row {
        grid-auto-flow: row;
        flex-direction: column;
        align-items: flex-start;
    }
}
