/* Quick approvals: one table of the suggestions waiting for the signed-in person. */
.ci-saa {
    --saa-ink: #18302b;
    --saa-muted: #5e706b;
    --saa-line: #c9d8d3;
    --saa-accent: #0b6b57;
    --saa-danger: #8a2e27;
    display: block;
    box-sizing: border-box;
    margin: 0 0 14px;
    padding: 14px;
    border: 1px solid var(--saa-line);
    border-radius: 8px;
    background: #fff;
    color: var(--saa-ink);
    font: 13px/1.4 Arial, Helvetica, sans-serif;
}
.ci-saa[hidden] { display: none !important; }
.ci-saa *, .ci-saa *::before, .ci-saa *::after { box-sizing: border-box; }
.ci-saa-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ci-saa-heading-title { margin: 0; font-size: 19px; }
.ci-saa-summary { margin: 3px 0 0; color: var(--saa-muted); }
.ci-saa-header-controls, .ci-saa-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ci-saa-toolbar { margin-top: 12px; }
.ci-saa-filter { display: inline-flex; align-items: center; gap: 5px; color: var(--saa-muted); font-weight: 700; }
.ci-saa-filter[hidden] { display: none; }
.ci-saa-filter select { max-width: 340px; min-height: 30px; font: inherit; color: var(--saa-ink); }
.ci-saa-age-days { width: 5.5em; min-height: 30px; font: inherit; color: var(--saa-ink); }
.ci-saa-button {
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid var(--saa-line);
    border-radius: 5px;
    background: #fff;
    color: var(--saa-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.ci-saa-button:hover { background: #edf3f0; }
.ci-saa-button:focus-visible, .ci-saa a:focus-visible, .ci-saa summary:focus-visible { outline: 2px solid var(--saa-accent); outline-offset: 2px; }
.ci-saa-button.is-primary { border-color: var(--saa-accent); background: var(--saa-accent); color: #fff; }
.ci-saa-button.is-danger { border-color: #cfa8a4; color: var(--saa-danger); }
.ci-saa-button[disabled] { cursor: not-allowed; opacity: .55; }
.ci-saa-approve-selected { margin-left: auto; }
.ci-saa-status { min-height: 18px; margin: 8px 0 0; color: var(--saa-muted); font-weight: 700; }
.ci-saa-status.is-error, .ci-saa-error { color: var(--saa-danger); }
.ci-saa-table-wrap { margin-top: 6px; overflow-x: auto; }
.ci-saa-table { width: 100%; border-collapse: collapse; }
.ci-saa-table th {
    padding: 6px 8px;
    border-bottom: 2px solid var(--saa-line);
    color: var(--saa-muted);
    font-size: 12px;
    text-align: left;
    white-space: nowrap;
}
.ci-saa-table td { padding: 7px 8px; border-bottom: 1px solid #e3ebe8; vertical-align: top; }
.ci-saa-table tr[hidden] { display: none; }
.ci-saa-select { width: 28px; }
.ci-saa-select input { width: 16px; height: 16px; margin: 2px 0 0; }
.ci-saa-ticket { min-width: 120px; }
.ci-saa-ref { font-weight: 700; color: var(--saa-accent); }
.ci-saa-customer { display: block; color: var(--saa-muted); font-size: 12px; }
.ci-saa-suggestion { min-width: 240px; }
.ci-saa-details summary { cursor: pointer; font-weight: 700; }
.ci-saa-details-body { margin-top: 6px; }
.ci-saa-intent { margin: 0 0 6px; color: var(--saa-muted); }
.ci-saa-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; margin: 0 0 6px; }
.ci-saa-fields dt { color: var(--saa-muted); font-weight: 700; }
.ci-saa-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ci-saa-label { margin-top: 6px; color: var(--saa-muted); font-weight: 700; }
.ci-saa-draft { white-space: pre-wrap; overflow-wrap: anywhere; }
.ci-saa-screenshots { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; }
.ci-saa-screenshots > .ci-saa-label { flex-basis: 100%; }
.ci-saa-screenshot { margin: 0; width: 240px; max-width: 100%; }
.ci-saa-screenshot-link { display: block; }
/* A fixed box: the row keeps its height while the image loads (or fails), so nothing below it moves. */
.ci-saa-screenshot-image { display: block; box-sizing: border-box; width: 100%; height: 150px; object-fit: contain; border: 1px solid #d0d5dd; border-radius: 4px; background: #fff; }
.ci-saa-screenshot-caption { margin-top: 4px; font-size: 12px; color: #475467; overflow-wrap: anywhere; }
.ci-saa-type-cell, .ci-saa-age { white-space: nowrap; }
.ci-saa-risk { white-space: nowrap; font-weight: 700; }
.ci-saa-certainty { display: block; color: var(--saa-muted); font-size: 11px; font-weight: 400; }
.risk-high .ci-saa-risk, .risk-unknown .ci-saa-risk { color: var(--saa-danger); }
.ci-saa-decision { white-space: nowrap; }
.ci-saa-decision .ci-saa-button { margin: 0 4px 4px 0; }
.ci-saa-on-ticket { display: inline-block; margin: 0 6px 4px 0; }
.ci-saa-error { margin-top: 4px; max-width: 280px; white-space: normal; font-weight: 700; }
.ci-saa-outcome { font-weight: 700; }
.ci-saa-row.is-busy { opacity: .6; }
.ci-saa-row.is-done { background: #f6f8f7; }
.ci-saa-row.is-approved .ci-saa-outcome { color: var(--saa-accent); }
.ci-saa-editor td { background: #f8faf9; }
.ci-saa-editor label, .ci-saa-reject-editor .ci-saa-feedback-label, .ci-saa-bulk-note label { display: block; margin: 0 0 6px; font-weight: 600; }
.ci-saa-editor textarea, .ci-saa-reject-editor textarea, .ci-saa-bulk-note textarea { display: block; width: 100%; max-width: 640px; margin-top: 3px; font: inherit; }
.ci-saa-editor .ci-saa-button, .ci-saa-reject-editor .ci-saa-button { margin-right: 6px; }

/* Reject asks why, as on the ticket card; Approve selected can carry one note. */
.ci-saa-reject-editor td { background: #fbf6f5; }
/* A wide table scrolls inside its wrapper; the rejection stays within the visible width. */
.ci-saa-table-wrap { container-type: inline-size; }
.ci-saa-reject-editor td > * { max-width: calc(100cqw - 16px); }
.ci-saa-reasons { min-width: 0; margin: 0 0 8px; padding: 0; border: 0; }
.ci-saa-reasons legend { margin-bottom: 5px; padding: 0; font-weight: 700; }
.ci-saa-reason-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ci-saa-reason { position: relative; }
.ci-saa-reason input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.ci-saa-reason span { display: inline-block; padding: 3px 10px; border: 1px solid var(--saa-line); border-radius: 999px; background: #fff; font-weight: 600; cursor: pointer; }
.ci-saa-reason span:hover { background: #edf3f0; }
.ci-saa-reason input:checked + span { border-color: var(--saa-danger); background: var(--saa-danger); color: #fff; }
.ci-saa-reason input:focus-visible + span, .ci-saa-link:focus-visible { outline: 2px solid var(--saa-accent); outline-offset: 2px; }
.ci-saa-reason input:disabled + span { cursor: not-allowed; opacity: .55; }
.ci-saa-approve-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.ci-saa-approve-group .ci-saa-approve-selected { margin-left: 0; }
.ci-saa-quiet { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; cursor: pointer; }
.ci-saa-quiet input { margin: 0; }
.ci-saa-quiet input:disabled { cursor: not-allowed; }
.ci-saa-link { padding: 0; border: 0; background: none; color: var(--saa-accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.ci-saa-link[hidden], .ci-saa-bulk-note[hidden] { display: none; }
.ci-saa-link[disabled] { cursor: not-allowed; opacity: .55; }
.ci-saa-bulk-note { margin: 8px 0 0; }
.ci-saa-empty { margin: 12px 0 0; padding: 14px; border: 1px dashed var(--saa-line); border-radius: 6px; color: var(--saa-muted); text-align: center; }
.ci-saa-empty[hidden] { display: none; }
.ci-saa-foot { margin: 10px 0 0; color: var(--saa-muted); font-size: 12px; }

/* Inside the Agent Backlog Dashboard tab the list replaces the older view, which stays one click away. */
.ciAgentBacklog.ci-saa-ready:not(.ci-saa-show-old) > :not(.ci-saa) { display: none !important; }

/* Standalone page. */
body.ci-saa-standalone { margin: 0; padding: 16px; background: #f3f6f5; }
body.ci-saa-standalone .ci-saa { max-width: 1400px; margin: 0 auto; }

@media (max-width: 700px) {
    body.ci-saa-standalone { padding: 8px; }
    .ci-saa { padding: 10px; }
    .ci-saa-approve-selected, .ci-saa-approve-group { margin-left: 0; }
    .ci-saa-filter { display: flex; width: 100%; }
    .ci-saa-filter select { flex: 1 1 auto; min-width: 0; max-width: none; }
}

/* Current worker activity is separate from decisions and includes tickets with no proposal yet. */
.ci-saa-work { margin: 8px 0 14px; padding: 10px 12px; border: 1px solid var(--saa-line); border-radius: 6px; background: #f4f9f7; }
.ci-saa-work-heading { margin: 0; font-size: 14px; }
.ci-saa-work-summary { margin: 3px 0 0; color: var(--saa-muted); }
.ci-saa-work-list { display: flex; flex-wrap: wrap; gap: 7px 18px; margin: 8px 0 0; padding: 0; list-style: none; }
.ci-saa-work-list:empty { display: none; }
.ci-saa-work-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ci-saa-work-customer, .ci-saa-work-age { color: var(--saa-muted); font-size: 12px; }
.ci-saa-working-badge { display: inline-block; margin-top: 3px; padding: 2px 6px; border-radius: 10px; background: #dceee6; color: #145d43; font-size: 11px; font-weight: 700; white-space: nowrap; }
.ci-saa-ticket > .ci-saa-working-badge { display: block; width: fit-content; }

/* Auto-approval: the saved setting in words; its editors get the choices and Save. */
.ci-saa-auto { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--saa-line); border-radius: 6px; background: #f8faf9; }
.ci-saa-auto[hidden], .ci-saa-failed[hidden] { display: none; }
.ci-saa-auto-heading, .ci-saa-failed-heading { margin: 0; font-size: 14px; }
.ci-saa-auto-lines { margin: 6px 0 0; padding-left: 18px; }
.ci-saa-auto-meta { margin: 4px 0 0; color: var(--saa-muted); font-size: 12px; }
.ci-saa-auto-paused { margin: 6px 0 0; color: var(--saa-danger); font-weight: 700; }
.ci-saa-auto-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 8px; }
.ci-saa-auto-status { min-height: 16px; margin: 6px 0 0; color: var(--saa-muted); font-weight: 700; }
.ci-saa-auto-status.is-error { color: var(--saa-danger); }

/* Approved suggestions that then failed. */
.ci-saa-failed { margin: 14px 0 0; padding: 10px 12px; border: 1px solid #e2c3bf; border-radius: 6px; background: #fbf6f5; }
.ci-saa-failed-summary { margin: 3px 0 0; color: var(--saa-muted); }
.ci-saa-failed-list { margin: 8px 0 0; padding: 0; list-style: none; }
.ci-saa-failed-item { padding: 6px 0; border-top: 1px solid #ecdcd9; }
.ci-saa-failed-item:first-child { border-top: 0; }
.ci-saa-failed-item .ci-saa-details { margin-top: 3px; }
.ci-saa-review-manifest pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 26rem;
    overflow: auto;
}
