/* Buttons */
button {
    font-family: inherit;
}

/* Message-only validation feedback.
 * Rule identity remains available to diagnostic surfaces but is intentionally
 * absent here so record editors can focus on the corrective message.
 */
.validation-feedback-stack {
    display: grid;
    gap: 8px;
}

.validation-feedback {
    --validation-feedback-accent: var(--color-primary-green);
    margin: 0;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--validation-feedback-accent) 24%, var(--color-border));
    border-left: 4px solid var(--validation-feedback-accent);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--validation-feedback-accent) 6%, var(--color-surface));
    box-shadow: 0 1px 2px color-mix(in srgb, var(--validation-feedback-accent) 8%, transparent);
    color: var(--color-text-primary);
    font-size: .9rem;
    line-height: 1.5;
    animation: validation-feedback-in .18s ease-out both;
}

.validation-feedback--warning {
    --validation-feedback-accent: #b56b00;
    background: color-mix(in srgb, var(--color-primary-yellow) 10%, var(--color-surface));
}

.validation-feedback--blocker {
    --validation-feedback-accent: var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 8%, var(--color-surface));
    font-weight: 650;
}

.validation-feedback--notification {
    --validation-feedback-accent: var(--color-primary-green);
}

.validation-save-notice {
    position: fixed;
    top: 76px;
    left: 50%;
    z-index: 1250;
    width: min(540px, calc(100vw - 32px));
    padding: 13px 16px;
    border: 1px solid color-mix(in srgb, var(--color-danger) 30%, var(--color-border));
    border-top: 4px solid var(--color-danger);
    border-radius: 12px;
    background: color-mix(in srgb, var(--color-danger) 6%, var(--color-surface));
    box-shadow: 0 18px 48px rgba(17, 42, 52, .2);
    color: var(--color-text-primary);
    font-size: .9rem;
    font-weight: 650;
    line-height: 1.45;
    transform: translateX(-50%);
    animation: validation-save-notice-life 5s ease both;
}

@keyframes validation-feedback-in {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes validation-save-notice-life {
    0% { opacity: 0; transform: translate(-50%, -8px); }
    5%, 88% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}

@media (prefers-reduced-motion: reduce) {
    .validation-feedback,
    .validation-save-notice {
        animation: none;
    }
}

/* Shared passive-file upload surface. */
.upload-dropzone {
    display: grid;
    place-items: center;
    gap: 5px;
    min-height: 132px;
    padding: 20px;
    border: 1px dashed color-mix(in srgb, var(--color-primary-green) 48%, var(--color-border));
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-primary-green) 4%, var(--color-surface));
    color: var(--color-text-primary);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.upload-dropzone:hover,
.upload-dropzone:focus-visible,
.upload-dropzone.is-dragging {
    border-color: var(--color-primary-green);
    background: color-mix(in srgb, var(--color-primary-green) 9%, var(--color-surface));
    box-shadow: var(--shadow-sm);
    outline: none;
}

.upload-dropzone > span {
    color: var(--color-text-secondary);
    font-size: .78rem;
}

/* Shared edit-heavy admin drag and drop primitives.
 * Payload owners decide which zones accept each typed element; these classes own
 * the common drag-start highlight, precise hover target, and direct remove affordance.
 */
.admin-drop-zone {
    position: relative;
    transition: min-height .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease, color .14s ease;
}

.admin-drag-surface.is-dragging .admin-drop-zone.is-available {
    border-color: color-mix(in srgb, var(--color-primary-green) 72%, var(--color-border));
    background: color-mix(in srgb, var(--color-primary-green) 7%, var(--color-surface));
    color: var(--color-text-primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-primary-green) 22%, transparent);
}

.admin-drag-surface.is-dragging .admin-drop-zone.is-available.is-over {
    border-color: var(--color-primary-green);
    background: color-mix(in srgb, var(--color-primary-green) 13%, var(--color-surface));
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--color-primary-green) 36%, transparent), var(--shadow-sm);
}

.admin-drop-zone__label {
    display: grid;
    min-height: 42px;
    place-items: center;
    padding: 8px 12px;
    color: var(--color-text-secondary);
    font-size: .76rem;
    font-weight: 600;
    text-align: center;
}

.admin-draggable-item {
    position: relative;
}

.admin-remove-control {
    position: absolute;
    top: 6px;
    right: 6px;
    bottom: auto;
    z-index: 3;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--color-danger) 26%, var(--color-border));
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-surface) 94%, var(--color-danger) 6%);
    box-shadow: var(--shadow-sm);
    color: var(--color-danger);
    cursor: pointer;
    line-height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-2px) scale(.86);
    transition: opacity .12s ease, transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease, color .12s ease;
}

.admin-remove-control svg {
    display: block;
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
    pointer-events: none;
    stroke-linecap: round;
    stroke-width: 2.25;
}

.admin-draggable-item:hover > .admin-remove-control,
.admin-draggable-item:focus-within > .admin-remove-control,
.admin-remove-control:focus-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.admin-remove-control:hover,
.admin-remove-control:focus-visible {
    border-color: var(--color-danger);
    background: var(--color-danger);
    box-shadow: 0 3px 10px color-mix(in srgb, var(--color-danger) 25%, transparent);
    color: #fff;
}

.admin-remove-control:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-danger) 42%, transparent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .admin-drop-zone,
    .admin-remove-control {
        transition: none;
    }
}

/* Native CRM record-page primitives.
 * Flow: docs/agent/flows/features/idea-234-crm-object-record-layout-builder.mmd
 */
.record-stage {
    padding: 24px 0 18px;
    border-bottom: 1px solid var(--color-border);
}

.record-stage__primary {
    display: flex;
    align-items: stretch;
    gap: 3px;
    overflow-x: auto;
    padding: 1px 1px 5px;
    scrollbar-width: thin;
}

.record-stage__primary button {
    --record-stage-fill: color-mix(in srgb, var(--color-primary-blue) 8%, var(--color-surface) 92%);
    position: relative;
    flex: 1 0 150px;
    min-height: 48px;
    padding: 10px 26px 10px 31px;
    border: 0;
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%, 16px 50%);
    background: var(--record-stage-fill);
    color: var(--color-text-secondary);
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: background .14s ease, color .14s ease, transform .14s ease;
}

.record-stage__primary button:first-child {
    padding-left: 18px;
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
}

.record-stage__primary button:hover:not(:disabled) {
    --record-stage-fill: color-mix(in srgb, var(--color-surface-active) 84%, var(--color-primary-red) 16%);
    color: var(--color-text-primary);
}

.record-stage__primary button:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--color-primary-blue);
}

.record-stage__primary button:active:not(:disabled) {
    transform: translateY(1px);
}

.record-stage__primary button:disabled {
    cursor: not-allowed;
    opacity: .62;
}

.record-stage__primary button span {
    margin-right: 7px;
    color: currentColor;
    font-size: .7rem;
    font-variant-numeric: tabular-nums;
    opacity: .78;
}

.record-stage__primary button.is-current {
    --record-stage-fill: var(--color-primary-red);
    color: #fff;
    font-weight: 700;
}

.record-stage__primary button.is-draft {
    --record-stage-fill: color-mix(in srgb, var(--color-primary-red) 13%, var(--color-surface) 87%);
    color: var(--color-primary-red);
}

.record-stage__primary button.is-current:hover:not(:disabled) {
    --record-stage-fill: color-mix(in srgb, var(--color-primary-red) 88%, #000 12%);
    color: #fff;
}

.record-stage__primary button.is-draft:hover:not(:disabled) {
    --record-stage-fill: color-mix(in srgb, var(--color-primary-red) 18%, var(--color-surface) 82%);
    color: var(--color-primary-red);
}

.record-stage__primary button.is-draft::after {
    content: "Draft";
    display: inline-block;
    margin-left: 7px;
    color: var(--color-primary-red);
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
}

.record-stage__secondary {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}

.record-stage__secondary button {
    padding: 5px 9px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-secondary);
    font: inherit;
    font-size: .72rem;
    cursor: pointer;
}

.record-stage__secondary button.is-current {
    border-color: var(--color-primary-red);
    color: var(--color-primary-red);
}

.record-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 38px;
    padding: 23px 0 18px;
    border-bottom: 1px solid var(--color-border);
}

.record-metric {
    min-width: 130px;
}

.record-metric > span,
.record-metric > strong,
.record-metric > small {
    display: block;
}

.record-metric > span {
    color: var(--color-text-secondary);
    font-size: .74rem;
    font-weight: 600;
}

.record-metric > strong {
    margin-top: 4px;
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -.025em;
}

.record-metric--small > strong { font-size: 1.1rem; font-weight: 400; }
.record-metric--standard > strong { font-size: 1.5rem; font-weight: 400; }
.record-metric--medium > strong { font-size: 1.7rem; font-weight: 600; }
.record-metric--large > strong { font-size: 2.1rem; font-weight: 600; }
.record-metric--xl > strong { font-size: 2.5rem; font-weight: 700; }
.record-metric--accent > strong { color: var(--color-primary-red); }
.record-metric--positive > strong { color: var(--color-primary-green); }
.record-metric--warning > strong { color: var(--color-primary-yellow); }
.record-metric--critical > strong { color: var(--color-danger); }

.record-metric > small {
    max-width: 260px;
    margin-top: 4px;
    color: var(--color-text-secondary);
    font-size: .68rem;
}

/* Brand names keep their canonical casing inside uppercase utility labels. */
.pushai-brand-name {
    text-transform: none;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    min-height: 32px;
    white-space: nowrap;
}

.btn-primary {
    border: none;
    background: var(--color-primary-red);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.1s;
    gap: 8px;
    text-decoration: none;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    border: 1px solid var(--color-primary-red);
    background: var(--color-surface);
    color: var(--color-primary-red);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.1s;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-cream);
}

tr:hover td {
    background: var(--color-surface-active);
    color: var(--color-text-primary);
}

.btn-secondary:disabled {
    border-color: var(--color-border);
    color: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
    filter: grayscale(1);
    box-shadow: inset 4px 0 0 rgba(245, 67, 47, 0.35);
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-primary);
}

.icon-btn.danger:hover {
    background: rgba(217, 48, 37, 0.1);
    color: var(--color-danger);
}

.icon-btn.transcript-jump-btn {
    color: var(--color-primary-red);
}

.icon-btn.transcript-jump-btn:disabled {
    color: var(--color-text-secondary);
}

/* Forms (Inputs, Selects, Textareas) */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-body);
}

.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--color-surface-input);
    color: var(--color-text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary-green);
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input[type="number"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary-green);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder,
input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="search"]::placeholder,
textarea::placeholder,
.select-search-input::placeholder,
.chip-input::placeholder,
.search-input::placeholder {
    color: var(--color-text-placeholder);
    opacity: 1;
}

/* Checkboxes */
input[type="checkbox"] {
    accent-color: var(--color-primary-green);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-track {
    width: 40px;
    height: 22px;
    background: #ccc;
    border-radius: 999px;
    position: relative;
    transition: background 0.2s;
}

.toggle-track::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-track {
    background: var(--color-primary-green);
}

.toggle-switch input:checked+.toggle-track::after {
    transform: translateX(18px);
}

/* Custom Select Styling Override */
select,
.form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 40px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--color-text-body) 50%),
        linear-gradient(135deg, var(--color-text-body) 50%, transparent 50%),
        linear-gradient(to right, #d0d7de, #d0d7de);
    background-position: calc(100% - 22px) 50%, calc(100% - 14px) 50%, calc(100% - 2.8em) 50%;
    background-size: 7px 7px, 7px 7px, 1px 40%;
    background-repeat: no-repeat;
    cursor: pointer;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    overflow: auto;
    border-color: var(--color-border);
    padding-bottom: 14px;
    background-image: linear-gradient(-45deg,
            transparent 0 53%,
            var(--color-border-light) 53% 59%,
            transparent 59% 69%,
            var(--color-border) 69% 75%,
            transparent 75%);
    background-size: 14px 14px;
    background-repeat: no-repeat;
    background-position: right 6px bottom 6px;
}

/* === AI Improve Field === */
.ai-improve-field {
    position: relative;
}

.ai-improve-field__control--with-action {
    position: relative;
}

/* Scanning beam overlay — sits above the control, lets clicks through */
.ai-improve-field__overlay {
    position: absolute;
    inset: 1px;
    border-radius: 5px;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ai-improve-field.is-improving .ai-improve-field__overlay {
    opacity: 1;
}

/* Wide soft glow body */
.ai-improve-field__overlay::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 52px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(139, 92, 246, 0.10) 30%,
        rgba(167, 139, 250, 0.22) 50%,
        rgba(139, 92, 246, 0.10) 70%,
        transparent 100%
    );
    animation: ai-improve-scan 1.7s ease-in-out infinite;
}

/* Thin bright scan line */
.ai-improve-field__overlay::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1.5px;
    background: linear-gradient(90deg, transparent 0%, rgba(192, 132, 252, 0.8) 20%, rgba(216, 180, 254, 1) 50%, rgba(192, 132, 252, 0.8) 80%, transparent 100%);
    box-shadow: 0 0 8px rgba(192, 132, 252, 0.55);
    animation: ai-improve-scan 1.7s ease-in-out infinite;
}

@keyframes ai-improve-scan {
    0% { top: -60px; }
    100% { top: calc(100% + 60px); }
}

/* Border glow during improvement */
.ai-improve-field.is-improving .ai-improve-field__control {
    border-color: rgba(139, 92, 246, 0.35);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08);
    color: rgba(15, 23, 42, 0.55);
}

/* Button container — bottom-right of the field */
.ai-improve-field__actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    z-index: 2;
}

/* Pill button — hidden by default, revealed on hover/focus */
.ai-improve-field__action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px 0 7px;
    border-radius: 999px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.95);
    color: #6d28d9;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.015em;
    box-shadow: 0 1px 5px rgba(109, 40, 217, 0.1);
    cursor: pointer;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.ai-improve-field:hover .ai-improve-field__action:not(:disabled):not(.is-busy),
.ai-improve-field:focus-within .ai-improve-field__action:not(:disabled):not(.is-busy) {
    opacity: 1;
    transform: translateY(0);
}

.ai-improve-field__action:hover:not(:disabled):not(.is-busy) {
    background: rgba(237, 233, 254, 0.97);
    border-color: rgba(109, 40, 217, 0.4);
    box-shadow: 0 2px 10px rgba(109, 40, 217, 0.18);
}

/* Busy state: animated purple gradient */
.ai-improve-field__action.is-busy {
    opacity: 1 !important;
    transform: translateY(0) !important;
    border-color: transparent;
    background: linear-gradient(270deg, #6d28d9, #9333ea, #7c3aed, #a855f7, #6d28d9);
    background-size: 300% 100%;
    color: #fff;
    box-shadow: 0 2px 12px rgba(109, 40, 217, 0.3);
    cursor: default;
    animation: ai-improve-gradient-slide 2.4s linear infinite;
}

.ai-improve-field__action:disabled {
    cursor: default;
}

/* Sparkle pop on hover */
.ai-improve-field__action:hover:not(.is-busy) svg {
    animation: ai-improve-sparkle-pop 0.38s ease-out forwards;
}

/* Sparkle orbit while busy */
.ai-improve-field__action.is-busy svg {
    animation: ai-improve-sparkle-orbit 1.5s ease-in-out infinite;
}

@keyframes ai-improve-sparkle-orbit {
    0%,
    100% { transform: scale(1) rotate(0deg); }
    33% { transform: scale(1.25) rotate(14deg); }
    66% { transform: scale(1.25) rotate(-14deg); }
}

@keyframes ai-improve-sparkle-pop {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.35) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes ai-improve-gradient-slide {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

.ai-improve-field__error {
    margin-top: 6px;
    color: var(--color-danger);
    font-size: 0.85rem;
}

/* Custom Select & Multi-Pick */
.custom-select {
    position: relative;
    width: 100%;
}

.select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface-input);
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-trigger.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.select-trigger:focus,
.select-trigger.open {
    outline: none;
    border-color: var(--color-primary-green);
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1);
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    margin-top: 4px;
    background: var(--color-surface-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 50;
    /* Expand to fit the longest option when space allows (prevents cut-off labels). */
    min-width: 100%;
    width: max-content;
    max-width: calc(100vw - 24px);
    max-height: 200px;
    overflow-y: auto;
    overflow-x: auto;
    display: none;
}

.select-dropdown.open {
    display: block;
}

.select-search {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-surface-panel);
    border-bottom: 1px solid var(--color-border);
    padding: 8px 12px;
}

.select-search-input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.95rem;
    background: var(--color-surface-input);
    color: var(--color-text-primary);
}

.select-search-input:focus {
    outline: none;
    border-color: var(--color-primary-green);
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1);
}

.select-option {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--color-text-primary);
    transition: background 0.1s;
}

.select-option:hover {
    background: var(--color-surface-alt);
}

.select-option.selected {
    background: var(--color-surface-active);
    color: var(--color-text-primary);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--color-primary-green);
}

.select-empty,
.select-overflow-hint {
    padding: 8px 12px;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.select-overflow-hint {
    border-top: 1px dashed var(--color-border);
}

/* Input Wrapper (Search, Chip Inputs) */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-input);
    padding: 4px 12px;
    transition: box-shadow 0.2s;
    gap: 8px;
}

.input-wrapper:focus-within {
    border-color: var(--color-primary-green);
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1);
}

:root[data-ui-style="quiet"] .input-wrapper .chip-input:focus-visible {
    outline: none;
    outline-offset: 0;
}

.input-wrapper.multiline {
    align-items: flex-end;
}

.chip-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 120px;
    padding: 4px;
    font-family: inherit;
    font-size: 0.95rem;
    background: transparent;
    color: var(--color-text-primary);
    box-shadow: none !important;
    /* override default input focus */
}

textarea.chip-input.chip-textarea {
    resize: none;
    overflow-y: hidden;
    min-height: 34px;
    max-height: 180px;
    padding: 6px 4px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

textarea.chip-input.chip-textarea.form-input,
textarea.chip-input.chip-textarea.form-textarea {
    width: 100%;
    flex: initial;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-input);
    resize: vertical;
    overflow-y: auto;
    min-height: 120px;
    max-height: none;
    padding: 8px 12px 14px;
    background-image: linear-gradient(-45deg,
            transparent 0 53%,
            var(--color-border-light) 53% 59%,
            transparent 59% 69%,
            var(--color-border) 69% 75%,
            transparent 75%);
    background-size: 14px 14px;
    background-repeat: no-repeat;
    background-position: right 6px bottom 6px;
}

textarea.chip-input.chip-textarea.form-input:focus,
textarea.chip-input.chip-textarea.form-textarea:focus {
    border-color: var(--color-primary-green);
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1) !important;
}

.search-wrapper {
    position: relative;
    max-width: 300px;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

/* Chips */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 4px;
    margin-bottom: 2px;
}

.chip.tool,
.function-chip {
    background: var(--color-surface-active);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.function-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    gap: 4px;
}

.chip.kb {
    background: #fff4e0;
    color: #d68b00;
}

.chip.more {
    background: #eee;
    color: #666;
}

/* Authorization chips: compact, color-coded grants and visibility tags. */
.authorization-chip {
    --chip-color: var(--color-primary-blue);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid color-mix(in srgb, var(--chip-color) 25%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--chip-color) 9%, var(--color-surface));
    color: var(--color-text-primary);
    font-size: 0.78rem;
    font-weight: 600;
}

.authorization-chip--blue { --chip-color: #2563eb; }
.authorization-chip--cyan { --chip-color: #0891b2; }
.authorization-chip--green { --chip-color: #16a34a; }
.authorization-chip--amber { --chip-color: #d97706; }
.authorization-chip--red { --chip-color: #dc2626; }
.authorization-chip--violet { --chip-color: #7c3aed; }
.authorization-chip--slate { --chip-color: #64748b; }

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.published {
    background: #e6f4ea;
    color: #137333;
}

.status-badge.draft {
    background: #f1f3f4;
    color: #5f6368;
}

.status-badge.deprecated {
    background: #fce8e6;
    color: #c5221f;
}

.status-badge.sync-completed {
    background: #e6f4ea;
    color: #0c5c20;
}

.status-badge.sync-in_progress {
    background: #fff4e0;
    color: #b15e0f;
}

.status-badge.sync-failed {
    background: #fbe4e2;
    color: #c5221f;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.active {
    background: var(--color-primary-green);
    box-shadow: 0 0 0 4px rgba(13, 102, 107, 0.15);
}

/* Chat UI */
.chat-wrapper {
    display: flex;
    flex: 0 1 auto;
    width: var(--chat-width, 800px);
    max-width: 100%;
    min-width: 480px;
    height: 100%;
    margin: 0 auto;
    position: relative;
    transition: width 0.1s;
    gap: 8px;
    min-height: 0;
}

.chat-shell {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    max-height: 100%;
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.chat-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface-alt);
    font-weight: 600;
}

.chat-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    min-height: 0;
    color: var(--color-text-primary);
}

.chat-footer {
    padding: 16px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.attachment-preview,
.message-attachment {
    display: flex;
    gap: 12px;
    align-items: center;
}

.attachment-preview {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-input);
    margin-bottom: 10px;
}

.message-attachment {
    align-items: flex-start;
    margin-bottom: 8px;
}

.attachment-thumb {
    width: 72px;
    height: 72px;
    border: 1px dashed var(--color-border-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    overflow: hidden;
    flex-shrink: 0;
}

.message-attachment .attachment-thumb {
    width: 140px;
    height: 96px;
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.attachment-name {
    font-weight: 700;
    color: var(--color-text-primary);
}

.attachment-meta {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.attachment-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-link {
    color: var(--color-primary-blue);
    font-weight: 600;
    text-decoration: none;
}

.attachment-link:hover {
    text-decoration: underline;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.message.user {
    align-self: flex-end;
    background-color: var(--color-user-bubble-bg);
    color: var(--color-text-inverse);
    border-bottom-right-radius: 4px;
}

.message.user * {
    color: var(--color-text-inverse) !important;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--color-bot-bubble-bg);
    color: var(--color-text-primary);
    border-bottom-left-radius: 4px;
}

.message.source-summary {
    max-width: min(760px, 92%);
    padding: 12px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.source-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.source-summary-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.source-summary-count {
    min-width: 24px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--color-primary-blue) 11%, var(--color-surface) 89%);
    color: var(--color-text-secondary);
}

.source-summary-list {
    display: grid;
    gap: 8px;
}

.source-summary-item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    background: color-mix(in srgb, var(--color-surface) 92%, var(--color-primary-green) 8%);
}

.source-summary-rank {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    font-weight: 700;
    color: #0d5558;
    background: color-mix(in srgb, var(--color-primary-green) 16%, var(--color-surface) 84%);
}

.source-summary-body {
    min-width: 0;
}

.source-summary-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.source-summary-link {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    flex: 0 1 auto;
    color: var(--color-text-link);
    font-weight: 400;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.source-summary-link:hover {
    text-decoration: underline;
}

.source-summary-link-muted {
    color: var(--color-text-primary);
}

.source-summary-quality {
    flex: 0 0 auto;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
}

.source-summary-extract-btn {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    min-width: 26px;
    color: var(--color-text-secondary);
}

.source-summary-extract-btn[aria-expanded="true"] {
    color: var(--color-text-link);
    background: color-mix(in srgb, var(--color-text-link) 10%, var(--color-surface) 90%);
}

.source-summary-meta {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
}

.source-summary-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-light);
    line-height: 1.4;
}

.source-summary-excerpt {
    margin: 6px 0 0;
    padding: 6px 8px;
    border-left: 3px solid color-mix(in srgb, var(--color-primary-green) 38%, var(--color-border) 62%);
    border-radius: 0 6px 6px 0;
    background: color-mix(in srgb, var(--color-surface) 86%, var(--color-primary-blue) 14%);
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    line-height: 1.4;
}

.source-summary-actions {
    opacity: 0;
}

.message.support {
    align-self: flex-start;
    background: color-mix(in srgb, #6d28d9 9%, var(--color-surface) 91%);
    color: var(--color-text-primary);
    border: 1px solid rgba(109, 40, 217, 0.24);
    border-bottom-left-radius: 4px;
    box-shadow: 0 6px 18px rgba(109, 40, 217, 0.10);
}

.message.support .message-author {
    color: #6d28d9;
}

.message.support.support-admin {
    background: color-mix(in srgb, #4c1d95 17%, var(--color-surface) 83%);
    border-color: rgba(76, 29, 149, 0.36);
    box-shadow: 0 7px 20px rgba(76, 29, 149, 0.15);
}

.message.support.support-admin .message-author {
    color: #4c1d95;
}

.message-author {
    margin-bottom: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.message.tool {
    align-self: center;
    background-color: #e7f2f5;
    color: #0d666b;
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #b5dfe2;
    width: auto;
    max-width: 90%;
}

.message.tool-progress {
    align-self: center;
    max-width: min(720px, 92%);
    padding: 7px 11px;
    border-radius: 8px;
    box-shadow: none;
    font-size: 0.82rem;
    line-height: 1.35;
    overflow: visible;
    transform-origin: center center;
    transition:
        transform 0.14s cubic-bezier(0.2, 0, 0.2, 1),
        opacity 0.1s ease;
    will-change: transform, opacity;
}

.message.tool-progress-collapsing,
.message.tool-progress-expanding {
    overflow: hidden;
}

.message.tool-progress-collapsing {
    opacity: 0.72;
    transform: scaleX(0.06);
}

.message.tool-progress-expanding {
    opacity: 1;
    transform: scaleX(1);
}

.message.tool-progress .tool-progress-content {
    transition: opacity 0.08s ease;
}

.message.tool-progress .tool-progress-content p {
    margin: 0;
}

.message.tool-progress-collapsing .tool-progress-content {
    opacity: 0;
}

.message.tool-progress-expanding .tool-progress-content {
    animation: tool-progress-content-in 0.14s ease-out both;
}

@keyframes tool-progress-content-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.message.tool-progress-transient {
    background: color-mix(in srgb, var(--color-surface) 90%, var(--color-primary-blue) 10%);
    border-color: color-mix(in srgb, var(--color-border) 72%, var(--color-primary-blue) 28%);
    color: var(--color-text-secondary);
}

.message.tool-progress-milestone {
    background: color-mix(in srgb, var(--color-surface) 88%, var(--color-primary-green) 12%);
    border-color: color-mix(in srgb, var(--color-border) 68%, var(--color-primary-green) 32%);
    color: #0d5558;
}

.message.tool-progress-decision {
    background: color-mix(in srgb, var(--color-surface) 88%, #c97a00 12%);
    border-color: color-mix(in srgb, var(--color-border) 62%, #c97a00 38%);
    color: #704a00;
}

.message.tool-progress-diagnostic {
    background: #f4f7fa;
    border-color: #d6dde6;
    color: #274055;
    font-family: Consolas, "Courier New", monospace;
}

@media (prefers-reduced-motion: reduce) {
    .message.tool-progress,
    .message.tool-progress .tool-progress-content {
        animation: none;
        opacity: 1;
        transform: none;
        transition: none;
    }
}

.message-feedback-badge {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-surface-pilled);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.message-feedback-badge svg {
    width: 16px;
    height: 16px;
}

.message-feedback-badge.thumbs_up {
    color: var(--color-primary-green);
}

.message-feedback-badge.thumbs_down {
    color: var(--color-primary-red);
}

.message-actions {
    position: absolute;
    bottom: -16px;
    right: 0;
    background: var(--color-surface-pilled);
    border-radius: 20px;
    padding: 2px;
    box-shadow: var(--shadow-sm);
    display: flex;
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid var(--color-border);
}

.message-actions .icon-btn.active.thumbs-up {
    color: var(--color-primary-green);
}

.message-actions .icon-btn.active.thumbs-down {
    color: var(--color-primary-red);
}

.message:hover .message-actions {
    opacity: 1;
}

.typing-indicator span {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #aaa;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* Chat Overlays */
.chat-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: var(--color-text-primary);
}

:root[data-theme="dark"] .chat-overlay {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
}

.chat-overlay.unauth {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(255, 243, 236, 0.9));
    backdrop-filter: blur(8px) saturate(115%);
    border: 1px solid rgba(217, 48, 37, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] .chat-overlay.unauth {
    background: linear-gradient(135deg, rgba(40, 40, 40, 0.9), rgba(28, 28, 28, 0.92));
    border: 1px solid rgba(110, 204, 223, 0.22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.chat-overlay .chat-overlay-card {
    background: var(--color-surface);
    border-radius: 18px;
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 260px;
    max-width: 340px;
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

:root[data-theme="dark"] .chat-overlay .chat-overlay-card {
    background: var(--color-surface-panel);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.chat-overlay .chat-overlay-headline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-overlay .chat-overlay-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(217, 48, 37, 0.1);
    color: var(--color-primary-red);
}

:root[data-theme="dark"] .chat-overlay .chat-overlay-icon {
    background: rgba(245, 67, 47, 0.16);
}

.chat-overlay .chat-overlay-title {
    font-weight: 700;
    color: var(--color-text-primary);
}

.chat-overlay .chat-overlay-subtitle {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.chat-overlay .chat-overlay-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.chat-overlay .chat-overlay-actions .btn-secondary {
    padding: 6px 12px;
}

.chat-blur-target {
    filter: blur(3px);
    pointer-events: none;
    user-select: none;
}

.drag-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 102, 107, 0.1);
    border: 2px dashed var(--color-primary-green);
    border-radius: var(--radius-lg);
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-green);
}

.drag-overlay.active {
    opacity: 1;
    background: radial-gradient(circle at 50% 30%, rgba(13, 102, 107, 0.15), rgba(13, 102, 107, 0.05));
    box-shadow: 0 12px 32px rgba(13, 102, 107, 0.12);
}

.drag-overlay .drag-overlay-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 18px;
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(13, 102, 107, 0.15);
}

.drag-overlay .drag-overlay-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 102, 107, 0.1);
    color: var(--color-primary-green);
}

.drag-overlay .drag-overlay-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}

.drag-overlay .drag-overlay-text .title {
    font-weight: 700;
    color: var(--color-text-primary);
}

.drag-overlay .drag-overlay-text .subtitle {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* Slash Menu */
.slash-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 8px;
    z-index: 20;
}

.slash-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border-light);
}

.slash-item:last-child {
    border-bottom: none;
}

.slash-item .small {
    color: var(--color-text-secondary);
}

.slash-item.active {
    background: var(--color-surface-active);
}

.slash-item:hover {
    background: color-mix(in srgb, var(--color-surface-active) 70%, var(--color-surface) 30%);
}

/* Side Panel (Chat Context) */
.side-panel {
    background: var(--color-surface);
    /* Width is handled inline by JS for resizing */
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    z-index: 20;
    height: calc(100% - 32px);
    /* Vertical float */
    color: var(--color-text-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    margin: 16px;
    /* Fully floating */
    transition: opacity 0.2s;
    position: relative;
    min-width: 300px;
    max-width: 800px;
}

.side-panel.inactive {
    border-color: var(--color-border-light);
    box-shadow: inset 0 0 0 1px var(--color-border-light);
    background: var(--color-surface-alt);
}

/* Disabled state applies to the body content wrapper, not the whole panel */
.sp-content-wrapper.disabled {
    pointer-events: none;
    opacity: 0.6;
    filter: grayscale(1);
}

.sp-content-wrapper.inactive {
    pointer-events: none;
    opacity: 0.8;
    filter: grayscale(0.2);
}

.side-panel.inactive .sp-header h3 {
    color: var(--color-text-secondary);
}

.side-panel.inactive .sp-field input,
.side-panel.inactive .sp-field select,
.side-panel.inactive .sp-field textarea {
    pointer-events: none;
    background: var(--color-surface);
    border-color: var(--color-border-light);
    color: var(--color-text-secondary);
}

.side-panel.inactive .sp-actions,
.side-panel.inactive .sp-body .btn-primary,
.side-panel.inactive .sp-body .btn-secondary {
    display: none !important;
}

.sp-record-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 12px;
}

.sp-record-link,
.sp-record-link:link,
.sp-record-link:visited,
.markdown-content .sp-record-link,
.markdown-content .sp-record-link:visited {
    color: var(--color-primary-red) !important;
    text-decoration: none;
}

.sp-record-link:hover {
    text-decoration: underline;
}

.deep-dive-table td {
    vertical-align: top;
}

.sp-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    word-break: break-word;
}

.sp-truncate.sp-value {
    color: var(--color-text-body);
}

.panel-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 8px;
    border-left: 1px solid transparent;
    /* Placeholder for alignment */
    height: 100%;
}

.panel-rail.disabled {
    pointer-events: none;
    opacity: 0.6;
    filter: grayscale(1);
}

.panel-chip {
    min-width: 44px;
    max-width: 132px;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid var(--color-primary-red);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-primary-red);
    text-align: center;
    line-height: 1.15;
    padding: 8px 10px;
    white-space: normal;
    word-break: break-word;
    transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
}

.panel-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--color-bg-cream);
}

:root[data-theme="dark"] .panel-chip {
    background: var(--color-surface-panel);
    border-color: var(--color-primary-red);
    color: var(--color-primary-red);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.panel-chip.disabled {
    border-color: var(--color-border);
    color: var(--color-text-secondary);
    background: var(--color-surface-alt);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

:root[data-theme="dark"] .panel-chip.disabled {
    background: var(--color-surface);
}


.sp-header {
    min-height: 64px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    gap: 16px;
}

.sp-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sp-grid {
    display: grid;
    gap: 12px;
}

.sp-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
    .sp-grid.two-col {
        grid-template-columns: 1fr;
    }
}

.sp-field label {
    font-size: 0.8rem;
    color: var(--color-text-body);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.sp-field input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
}

/* Tables */
.table-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    /* Enable vertical scrolling for CRUD/admin tables inside fixed-height shells */
    overflow: auto;
    background: var(--color-surface);
    flex: 1 1 auto;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    color: var(--color-text-primary);
}

th {
    text-align: left;
    padding: 12px 16px;
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

th.sortable-th {
    cursor: pointer;
    user-select: none;
}

th.sortable-th:hover {
    background: var(--color-surface-active);
}

th.sortable-th:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(13, 102, 107, 0.25);
}

.th-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.th-indicator {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    transform: translateY(-1px);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--color-surface-active);
    cursor: pointer;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--color-surface);
    padding: 24px;
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
    box-shadow: var(--shadow-lg);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

:root[data-theme="dark"] .modal {
    background: var(--color-surface-panel);
}

.floating-table-overlay {
    position: fixed;
    inset: 0;
    z-index: 260;
    background: rgba(0, 0, 0, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.floating-table-dialog {
    position: relative;
    width: min(1100px, calc(100vw - 48px));
    max-height: calc(100vh - 56px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.floating-table-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 14px;
    cursor: ew-resize;
    z-index: 2;
    touch-action: none;
}

.floating-table-resize-handle--left {
    left: -7px;
}

.floating-table-resize-handle--right {
    right: -7px;
}

.floating-table-dialog__header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.floating-table-dialog__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.floating-table-dialog__body {
    padding: 16px;
    overflow: auto;
    min-height: 180px;
}

.pushai-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.pushai-tooltip__trigger {
    display: inline-flex;
    align-items: center;
    outline: none;
}

.pushai-tooltip__bubble {
    position: absolute;
    z-index: 420;
    width: max-content;
    max-width: min(320px, calc(100vw - 32px));
    padding: 8px 10px;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    background: var(--color-surface-elevated);
    box-shadow: var(--shadow-lg);
    color: var(--color-text-primary);
    font-size: 0.78rem;
    line-height: 1.35;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.pushai-tooltip:hover .pushai-tooltip__bubble,
.pushai-tooltip:focus-within .pushai-tooltip__bubble {
    opacity: 1;
    transform: translateY(0);
}

.pushai-tooltip--top .pushai-tooltip__bubble {
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, 4px);
}

.pushai-tooltip--top:hover .pushai-tooltip__bubble,
.pushai-tooltip--top:focus-within .pushai-tooltip__bubble {
    transform: translate(-50%, 0);
}

.pushai-tooltip--right .pushai-tooltip__bubble {
    left: calc(100% + 8px);
    top: 50%;
    transform: translate(0, -50%);
}

.pushai-tooltip--bottom .pushai-tooltip__bubble {
    top: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, -4px);
}

.pushai-tooltip--bottom:hover .pushai-tooltip__bubble,
.pushai-tooltip--bottom:focus-within .pushai-tooltip__bubble {
    transform: translate(-50%, 0);
}

.pushai-tooltip--left .pushai-tooltip__bubble {
    right: calc(100% + 8px);
    top: 50%;
    transform: translate(0, -50%);
}

@media (max-width: 720px) {
    .floating-table-overlay {
        padding: 12px;
    }

    .floating-table-dialog {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
    }

    .floating-table-dialog__body {
        padding: 12px;
    }
}

/* Typography Utilities */
.text-h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-link);
    margin-bottom: 1rem;
}

.text-h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-link);
    margin-bottom: 0.75rem;
}

.text-body {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-primary);
}

.text-meta {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.text-link,
a {
    color: var(--color-text-link);
    text-decoration: none;
    font-weight: inherit;
    cursor: pointer;
}

.text-link:hover,
a:hover {
    text-decoration: underline;
}

.text-link:visited,
a:visited {
    color: var(--color-text-link);
}

.link-button {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    color: var(--color-text-link);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.link-button:hover {
    color: var(--color-primary-red);
}

/* Tabs */
.tabs {
    --tabs-accent: color-mix(in srgb, var(--color-primary-blue) 55%, var(--color-primary-green) 45%);

    display: flex;
    align-items: stretch;
    gap: 2px;
    width: 100%;
    max-width: 100%;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--color-surface) 78%, transparent 22%), transparent),
        color-mix(in srgb, var(--color-surface-alt) 78%, var(--color-surface) 22%);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--color-surface) 80%, transparent 20%);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    appearance: none;
    background: transparent;
    cursor: pointer;
    color: color-mix(in srgb, var(--color-text-secondary) 86%, var(--color-text-primary) 14%);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    user-select: none;
    transition:
        background 0.16s ease,
        border-color 0.16s ease,
        box-shadow 0.16s ease,
        color 0.16s ease,
        transform 0.16s ease;
}

.tab .atlas-inline-icon,
.tab .tab__icon,
.tab svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.tab .atlas-inline-icon svg,
.tab .tab__icon svg {
    width: 16px;
    height: 16px;
}

.tab:hover:not(:disabled):not([aria-disabled="true"]) {
    background: color-mix(in srgb, var(--color-surface) 72%, var(--color-surface-active) 28%);
    color: var(--color-text-primary);
}

.tab:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--tabs-accent) 42%, var(--color-border) 58%);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tabs-accent) 16%, transparent 84%);
}

.tab.active,
.tab.is-active,
.tab[aria-selected="true"] {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--color-surface-active) 76%, var(--color-surface) 24%), var(--color-surface-active));
    border-color: color-mix(in srgb, var(--tabs-accent) 24%, var(--color-border) 76%);
    color: var(--color-text-primary);
    box-shadow:
        0 1px 2px rgba(17, 42, 52, 0.08),
        inset 0 1px 0 color-mix(in srgb, var(--color-surface) 78%, transparent 22%);
}

.tab.active::after,
.tab.is-active::after,
.tab[aria-selected="true"]::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: -1px;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: var(--tabs-accent);
}

.tab:disabled,
.tab[aria-disabled="true"] {
    cursor: not-allowed;
    color: var(--color-text-secondary);
    opacity: 0.48;
}

@media (max-width: 640px) {
    .tabs {
        border-radius: 12px;
    }

    .tab {
        min-height: 38px;
        padding: 9px 14px;
        font-size: 0.84rem;
    }
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-body);
    text-align: center;
    padding: 40px;
}

/* Markdown Styles */
.markdown-content p {
    margin-bottom: 0.5em;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.markdown-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.markdown-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 0.9em;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}

.markdown-content th {
    background: rgba(0, 0, 0, 0.05);
}

/* Conversation List Item (Left Panel) */
.conv-item {
    padding: 12px;
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    color: var(--color-text-primary);
}

.conv-item:hover {
    background: var(--color-surface-alt);
}

.conv-item.active {
    background: var(--color-surface-active);
    border-left: 3px solid var(--color-primary-green);
    color: var(--color-text-primary);
}

.conv-date {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid var(--color-border-light);
    border-top-color: var(--color-primary-blue);
    animation: spin 0.9s linear infinite;
}

.loading-spinner.sm {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.loading-spinner.lg {
    width: 44px;
    height: 44px;
    border-width: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.loading-spinner-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text-secondary);
}

.loading-spinner-wrap .loading-label {
    font-weight: 600;
    color: var(--color-text-primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utilities */
.small {
    font-size: 0.85rem;
    color: #666;
}

.flex-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Top Nav - Dropdown (Reusable) */
.nav-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.nav-dropdown > summary:hover {
    background: var(--color-surface-alt);
}

.nav-summary-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-dropdown > summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown[open] > summary {
    box-shadow: 0 0 0 3px rgba(13, 102, 107, 0.1);
    border-color: rgba(13, 102, 107, 0.35);
}

.nav-dropdown .nav-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: auto;
    min-width: 220px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: visible;
    padding: 6px;
    z-index: 60;
}

.nav-menu-cascade {
    position: relative;
}

.nav-menu .nav-menu-item {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: 10px;
    padding: 10px 10px;
    font-weight: 600;
}

.nav-menu-item__content,
.nav-menu-item__with-chevron {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-menu-item__with-chevron {
    width: 100%;
    justify-content: space-between;
}

.nav-menu-item__chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-menu .nav-menu-item.nav-menu-item--danger {
    color: var(--color-primary-red);
}

.nav-menu .nav-menu-item.nav-menu-item--active {
    background: var(--color-surface-alt);
}

.nav-menu .nav-menu-item.nav-menu-item--highlight {
    background: var(--color-primary-red);
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.nav-menu .nav-menu-item.nav-menu-item--muted {
    color: var(--color-text-secondary);
}

.nav-menu .nav-menu-item.nav-menu-item--highlight:hover {
    background: var(--color-primary-light, #e04130);
    color: #fff;
}

.nav-menu .nav-menu-item.nav-menu-item--disabled,
.nav-menu .nav-menu-item:disabled {
    color: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.55;
    filter: grayscale(0.6);
}

.nav-menu .nav-menu-item.nav-menu-item--disabled:hover,
.nav-menu .nav-menu-item:disabled:hover {
    background: transparent;
}

.nav-menu .nav-menu-item:hover {
    background: var(--color-surface-alt);
}

.nav-menu .nav-menu-cascade:hover > .nav-menu-item,
.nav-menu .nav-menu-cascade:focus-within > .nav-menu-item,
.nav-menu .nav-menu-cascade--open > .nav-menu-item {
    background: var(--color-surface-alt);
}

.nav-submenu {
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    min-width: 242px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    padding: 6px;
    z-index: 70;
}

.nav-menu-cascade:hover > .nav-submenu,
.nav-menu-cascade:focus-within > .nav-submenu,
.nav-menu-cascade--open > .nav-submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav-menu .nav-menu-divider {
    height: 1px;
    background: var(--color-border);
    margin: 6px 2px;
}

.nav-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 10px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    line-height: 1.2;
}

.nav-menu-row__label {
    font-weight: 600;
}

.nav-menu-row--theme .toggle-switch {
    flex-shrink: 0;
}

.nav-menu-row--release {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: var(--color-text-secondary);
}

.nav-menu-row--release:hover,
.nav-menu-row--release:focus-visible {
    background: var(--color-surface-alt);
    color: var(--color-text-primary);
    outline: none;
}

.nav-menu-row__value {
    color: var(--color-text-placeholder);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.release-history-overlay {
    z-index: 320;
    padding: 20px;
}

.release-history-modal {
    width: min(760px, calc(100vw - 40px));
    max-width: min(760px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
}

.release-history-modal__header,
.release-history-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--color-border);
}

.release-history-modal__header h2 {
    margin: 0 0 4px;
    color: var(--color-text-primary);
    font-size: 1.05rem;
}

.release-history-current {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.82rem;
}

.release-history-modal__body {
    overflow: auto;
    padding: 16px 18px;
}

.release-history-modal__footer {
    justify-content: flex-end;
    border-top: 1px solid var(--color-border);
    border-bottom: 0;
}

.release-history-table-wrap {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: auto;
    background: var(--color-surface);
}

.release-history-table {
    width: 100%;
    border-collapse: collapse;
}

.release-history-table th,
.release-history-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
    font-size: 0.86rem;
}

.release-history-table th {
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.release-history-table tr:hover td {
    background: transparent;
    cursor: default;
}

.release-history-highlights {
    margin: 0;
    padding-left: 18px;
    color: var(--color-text-primary);
}

.release-history-highlights li + li {
    margin-top: 4px;
}

.release-history-empty,
.release-history-unavailable {
    color: var(--color-text-secondary);
}

@media (max-width: 640px) {
    .nav-submenu {
        top: calc(100% + 6px);
        right: 0;
    }

    .release-history-modal__header,
    .release-history-modal__body,
    .release-history-modal__footer {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/*
========================================
   Forecast Target Coverage
========================================
*/

.forecast-widget {
    --forecast-won: #0d666b;
    --forecast-commit: #147a92;
    --forecast-stretch: #fbae0f;
    --forecast-best-case: #6d5bd0;
    --forecast-over: color-mix(in srgb, var(--color-primary-green) 12%, var(--color-surface) 88%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    color: var(--color-text-primary);
    overflow: hidden;
}

.forecast-widget__header,
.forecast-widget__controls,
.forecast-widget__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.forecast-widget__header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--color-border);
}

.forecast-widget__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.forecast-widget__title h3 {
    margin: 0;
    color: var(--color-text-primary);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
}

.forecast-widget__subtitle,
.forecast-widget__meta,
.forecast-control__label,
.forecast-chart__label,
.forecast-summary-item__label {
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
}

.forecast-widget__meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.forecast-widget__body {
    padding: 18px 20px 20px;
    display: grid;
    gap: 18px;
}

.forecast-widget__controls {
    align-items: flex-end;
    flex-wrap: wrap;
}

.forecast-refresh-button--spinning svg {
    animation: spin 0.8s linear infinite;
}

.forecast-control {
    display: grid;
    gap: 6px;
}

.forecast-control--filters {
    flex: 1 1 360px;
    min-width: 260px;
}

.forecast-control--target {
    flex: 0 1 220px;
    min-width: 180px;
}

.forecast-control__label,
.forecast-chart__label,
.forecast-summary-item__label {
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.forecast-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.forecast-filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.forecast-filter-selects {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.forecast-filter-select {
    display: grid;
    gap: 5px;
    min-width: 180px;
}

.forecast-filter-select span {
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

.forecast-modal-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.forecast-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid color-mix(in srgb, var(--color-primary-green) 20%, var(--color-border) 80%);
    border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--color-primary-green) 9%, var(--color-surface) 91%);
    color: var(--color-primary-green);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.forecast-filter-chip:not(.forecast-filter-chip--active) {
    border-color: var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-body);
}

.forecast-filter-chip--active {
    border-color: color-mix(in srgb, var(--color-primary-green) 35%, var(--color-border) 65%);
    background: color-mix(in srgb, var(--color-primary-green) 12%, var(--color-surface) 88%);
    color: var(--color-primary-green);
}

.forecast-control__empty {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.forecast-control--target input {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font: inherit;
    font-weight: 700;
}

.forecast-filter-chip svg {
    width: 14px;
    height: 14px;
}

.forecast-filter-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.forecast-filter-add:hover,
.forecast-filter-add:focus-visible {
    border-color: var(--color-primary-green);
    color: var(--color-primary-green);
    outline: none;
}

.forecast-target-input {
    position: relative;
    display: block;
    width: 100%;
}

.forecast-target-input input {
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    padding-left: 10px;
    padding-right: 58px;
    font-weight: 700;
}

.forecast-target-input__prefix,
.forecast-target-input__action,
.forecast-target-input__currency {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
}

.forecast-target-input__prefix {
    left: 11px;
    font-weight: 700;
}

.forecast-target-input__action {
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    cursor: pointer;
}

.forecast-target-input__action:hover {
    background: color-mix(in srgb, var(--color-surface-active) 82%, transparent 18%);
    color: var(--color-text-primary);
}

.forecast-target-input__currency {
    right: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    pointer-events: none;
}

.forecast-control__error,
.forecast-refresh-error {
    color: var(--color-danger, #b42318);
    font-size: 0.78rem;
    line-height: 1.35;
}

.forecast-refresh-error {
    padding: 9px 11px;
    border: 1px solid color-mix(in srgb, var(--color-danger, #b42318) 24%, var(--color-border) 76%);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-danger, #b42318) 7%, var(--color-surface) 93%);
}

.forecast-initial-state {
    display: grid;
    place-items: center;
    gap: 5px;
    min-height: 76px;
    padding: 16px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    text-align: center;
}

.forecast-initial-state strong {
    color: var(--color-text-primary);
}

.forecast-chart {
    display: grid;
    gap: 10px;
}

.forecast-chart__topline {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.forecast-chart__metric {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.forecast-chart__total {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.forecast-chart__amount {
    color: var(--color-text-primary);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}

.forecast-chart__target {
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    font-weight: 700;
}

.forecast-chart__coverage {
    color: var(--color-primary-green);
    font-size: 0.88rem;
    font-weight: 700;
}

.forecast-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
}

.forecast-pill--success {
    border-color: color-mix(in srgb, var(--color-primary-green) 24%, transparent 76%);
    background: color-mix(in srgb, var(--color-primary-green) 10%, var(--color-surface) 90%);
    color: var(--color-primary-green);
}

.forecast-pill--missing {
    border-color: color-mix(in srgb, #F5432F 35%, var(--color-border) 65%);
    background: color-mix(in srgb, #F5432F 7%, var(--color-surface) 93%);
    color: var(--color-text-secondary);
}

.forecast-target-rail {
    position: relative;
    min-height: 30px;
}

.forecast-target-rail__anchor {
    position: absolute;
    left: var(--target-position, 68%);
    bottom: 0;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2;
}

.forecast-target-rail__anchor::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 2px;
    height: 11px;
    background: #F5432F;
    transform: translateX(-50%);
}

.forecast-target-rail__anchor--start {
    transform: none;
}

.forecast-target-rail__anchor--start::after {
    left: 0;
}

.forecast-target-rail__anchor--end {
    transform: translateX(-100%);
}

.forecast-target-rail__anchor--end::after {
    left: 100%;
}

.forecast-target-rail__label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid #F5432F;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: #F5432F;
    box-shadow: var(--shadow-sm);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.forecast-bar {
    position: relative;
    display: flex;
    min-height: 92px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-surface-alt);
}

.forecast-segment {
    --segment-color: var(--color-primary-green);
    position: relative;
    display: flex;
    min-width: 32px;
    min-height: 92px;
    flex: var(--segment-weight, 1) 1 0;
    align-items: flex-end;
    border: none;
    border-right: 1px solid color-mix(in srgb, white 28%, transparent 72%);
    background: var(--segment-color);
    color: #fff;
    cursor: pointer;
    container-type: inline-size;
    overflow: hidden;
    text-align: left;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.forecast-segment:last-child {
    border-right: none;
}

.forecast-segment:hover,
.forecast-segment:focus-visible {
    filter: brightness(1.06);
    outline: none;
}

.forecast-segment__body {
    position: relative;
    z-index: 2;
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 13px 12px 12px;
    min-width: 0;
}

.forecast-segment__value {
    overflow: hidden;
    font-size: 0.98rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forecast-segment__label,
.forecast-segment__percent {
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forecast-segment__percent {
    opacity: 0.82;
}

.forecast-segment--over {
    border-left: 1px dashed color-mix(in srgb, var(--color-primary-green) 42%, var(--color-border) 58%);
    background: var(--forecast-over);
    color: var(--color-primary-green);
}

.forecast-segment--target-gap {
    min-width: 18px;
    cursor: default;
    background:
        repeating-linear-gradient(
            135deg,
            var(--color-surface) 0,
            var(--color-surface) 8px,
            color-mix(in srgb, var(--color-text-secondary) 34%, var(--color-surface) 66%) 8px,
            color-mix(in srgb, var(--color-text-secondary) 34%, var(--color-surface) 66%) 10px
        );
}

.forecast-segment--target-gap:hover,
.forecast-segment--target-gap:focus-visible {
    filter: none;
}

.forecast-segment--missing-target {
    min-width: 100%;
    flex: 1 1 100%;
    align-items: stretch;
    border-right: 0;
    background:
        repeating-linear-gradient(
            135deg,
            color-mix(in srgb, var(--color-surface-alt) 92%, var(--color-surface) 8%) 0,
            color-mix(in srgb, var(--color-surface-alt) 92%, var(--color-surface) 8%) 12px,
            color-mix(in srgb, var(--color-text-secondary) 18%, var(--color-surface) 82%) 12px,
            color-mix(in srgb, var(--color-text-secondary) 18%, var(--color-surface) 82%) 16px
        );
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #F5432F 22%, transparent 78%);
    color: var(--color-text-primary);
    cursor: default;
}

.forecast-segment--missing-target:hover,
.forecast-segment--missing-target:focus-visible {
    filter: none;
}

.forecast-segment--missing-target .forecast-segment__body {
    align-content: center;
    justify-items: center;
    text-align: center;
}

.forecast-segment__missing-copy {
    display: grid;
    gap: 4px;
    justify-items: center;
    max-width: calc(100% - 24px);
    padding: 8px 14px;
    border: 1px solid color-mix(in srgb, var(--color-border) 72%, transparent 28%);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-surface) 92%, transparent 8%);
    box-shadow: var(--shadow-sm);
}

.forecast-segment--missing-target .forecast-segment__value,
.forecast-segment--missing-target .forecast-segment__label {
    max-width: 100%;
}

.forecast-segment--missing-target .forecast-segment__label {
    color: var(--color-text-secondary);
}

.forecast-segment--empty {
    min-width: 100%;
}

.forecast-segment--non-counting {
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.45);
}

.forecast-target-marker {
    position: absolute;
    left: var(--target-position, 68%);
    top: 0;
    bottom: 56px;
    width: 3px;
    background: #F5432F;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-surface) 88%, transparent 12%);
    pointer-events: none;
    transform: translateX(-50%);
    z-index: 3;
}

.forecast-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
    gap: 2px 18px;
}

.forecast-legend__item {
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 6px 4px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.forecast-legend__item:hover,
.forecast-legend__item:focus-visible {
    background: color-mix(in srgb, var(--color-surface-alt) 82%, transparent 18%);
    color: var(--color-text-primary);
    outline: none;
}

.forecast-legend__dot {
    width: 9px;
    height: 9px;
    border-radius: var(--radius-full);
    background: var(--legend-color, var(--color-primary-green));
}

.forecast-legend__label {
    overflow: hidden;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forecast-legend__value {
    color: var(--color-text-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

@container (max-width: 118px) {
    .forecast-segment__body {
        padding-inline: 8px;
    }

    .forecast-segment__label {
        display: none;
    }
}

@container (max-width: 64px) {
    .forecast-segment__body {
        display: none;
    }
}

.forecast-widget__summary {
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-surface-alt) 72%, var(--color-surface) 28%);
    flex-wrap: wrap;
}

.forecast-summary-item {
    display: grid;
    gap: 2px;
    min-width: 118px;
}

.forecast-summary-item__value {
    color: var(--color-text-primary);
    font-size: 1rem;
    font-weight: 700;
}

@media (max-width: 860px) {
    .forecast-widget__header,
    .forecast-widget__controls,
    .forecast-widget__summary,
    .forecast-chart__topline {
        align-items: flex-start;
        flex-direction: column;
    }

    .forecast-widget__meta {
        white-space: normal;
    }

    .forecast-control--filters,
    .forecast-control--target {
        width: 100%;
        min-width: 0;
    }

    .forecast-bar {
        min-height: 80px;
    }

    .forecast-segment {
        min-width: 28px;
        min-height: 80px;
    }

    .forecast-target-marker {
        bottom: 50px;
    }

    .forecast-chart__amount {
        font-size: 1.55rem;
    }

    .forecast-legend {
        grid-template-columns: 1fr;
    }
}

.forecast-admin-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.forecast-admin-settings {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(180px, 1fr) auto auto;
    gap: 12px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
}

.forecast-admin-toggle,
.forecast-admin-checks label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-body);
    font-weight: 600;
}

.forecast-admin-help {
    display: block;
    margin-top: 6px;
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
}

.forecast-admin-modal {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: var(--radius-sm);
}

.forecast-admin-modal__header,
.forecast-admin-modal__actions,
.forecast-admin-checks {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.forecast-admin-modal__header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.forecast-admin-modal__actions {
    justify-content: flex-end;
    margin-top: 16px;
}

.forecast-admin-color-field {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.forecast-admin-color-field input[type="color"] {
    width: 44px;
    height: 38px;
    padding: 2px;
}

.forecast-admin-swatch {
    width: 22px;
    height: 22px;
    display: inline-block;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
}

.forecast-admin-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

@media (max-width: 860px) {
    .forecast-admin-settings {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
}

.admin-page-shell {
    min-height: 100vh;
    background: var(--color-page-bg);
}

.admin-layout-shell {
    display: flex;
    align-items: stretch;
    height: calc(100vh - var(--pushai-nav-height, 48px));
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.admin-content-card {
    flex: 1 1 auto;
    min-width: 0;
    margin: 24px;
    overflow: auto;
}

@media (max-width: 720px) {
    .admin-layout-shell {
        gap: 0;
    }

    .admin-console.admin-console--docked {
        width: 196px;
        flex-basis: 196px;
    }

    .admin-content-card {
        margin: 12px;
    }
}

/* Admin Console */
.admin-console-scrim {
    position: fixed;
    top: var(--pushai-nav-height, 48px);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 12, 20, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 120;
}

.admin-console-scrim.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.admin-console {
    position: fixed;
    top: var(--pushai-nav-height, 48px);
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.2s ease;
    z-index: 130;
    display: flex;
    flex-direction: column;
}

.admin-console.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.admin-console__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
}

.admin-console__title {
    font-size: 1rem;
    color: var(--color-text-primary);
}

.admin-console__toggle {
    margin-left: auto;
    flex-shrink: 0;
}

.admin-console__body {
    padding: 10px 0 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-console__section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-console__section + .admin-console__section {
    border-top: 1px solid var(--color-border);
    padding-top: 10px;
}

.admin-console__section-title {
    display: inline-flex;
    align-self: flex-start;
    margin: 0 14px 4px;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-transform: uppercase;
    cursor: default;
    user-select: none;
    pointer-events: none;
}

.admin-console__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    cursor: pointer;
    padding: 9px 20px;
    font-weight: 600;
    transition: background 0.1s;
}

.admin-console__item:hover {
    background: var(--color-surface-alt);
}

.admin-console__item-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    opacity: 0.55;
    transition: opacity 0.1s, color 0.1s;
}

.admin-console__item-icon svg {
    width: 15px;
    height: 15px;
}

.admin-console__item:hover .admin-console__item-icon,
.admin-console__item--active .admin-console__item-icon {
    opacity: 1;
    color: var(--color-primary-red);
}

.admin-console.admin-console--docked {
    position: relative;
    top: 0;
    left: 0;
    bottom: auto;
    height: 100%;
    width: 240px;
    max-width: none;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    box-shadow: none;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    flex: 0 0 240px;
    overflow: hidden;
}

.admin-console--docked .admin-console__body {
    flex: 1;
    min-height: 0;
}

.admin-console.admin-console--docked.admin-console--collapsed {
    width: 50px;
    min-width: 50px;
    flex-basis: 50px;
}

.admin-console--docked.admin-console--collapsed .admin-console__header {
    justify-content: center;
    padding: 12px 7px;
}

.admin-console__item--active {
    background: var(--color-surface-alt);
    box-shadow: inset 3px 0 0 var(--color-primary-red);
}

/*
========================================
   Mobile Components (Drawer & Sheet)
========================================
*/

/* Drawer (Side Menu) */
.drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(2px);
}

.drawer-scrim.open {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 80%;
    background: var(--color-surface);
    z-index: 950;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Bottom Sheet */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sheet-overlay.open {
    opacity: 1;
    visibility: visible;
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-surface);
    z-index: 950;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.sheet.open {
    transform: translateY(0);
}

:root[data-theme='dark'] .sheet {
    border-top: 1px solid var(--color-border);
}

.sheet-handle-bar {
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 4px;
}

.sheet-header {
    padding: 0 20px 12px 20px;
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--color-border-light);
}

.sheet-body {
    padding: 16px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sheet-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--color-border-light);
}

.sheet-item:last-child {
    border-bottom: none;
}

.sheet-item:active {
    background: var(--color-surface-active);
}

.sheet-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--color-surface-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.sheet-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sheet-item-title {
    font-weight: 600;
    color: var(--color-text-primary);
}

.sheet-item-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* Manager Workspace: full-width team table with the canonical forecast bar. */
.manager-workspace {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 20px clamp(16px, 2vw, 32px) 40px;
    overflow: auto;
    background: var(--color-page-bg);
}

.manager-workspace__toolbar,
.manager-pagination,
.forecast-modal-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.manager-workspace__heading {
    margin-bottom: 16px;
}

.manager-workspace__toolbar {
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 12px 0;
    border-block: 1px solid var(--color-border);
}

.manager-workspace__controls {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.manager-workspace__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    align-self: end;
    gap: 4px;
    min-height: 38px;
}

.manager-workspace__actions .icon-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
}

.manager-workspace__actions .icon-btn:hover,
.manager-workspace__actions .icon-btn:focus-visible {
    border-color: var(--color-primary-green);
    background: var(--color-surface-active);
    color: var(--color-primary-green);
    outline: none;
}

.manager-control {
    display: grid;
    gap: 5px;
    min-width: 150px;
}

.manager-control--sort {
    min-width: 170px;
}

.manager-control .form-select {
    min-height: 38px;
}

.manager-refresh--busy svg {
    animation: spin 0.8s linear infinite;
}

.manager-refresh-status {
    margin: 0 0 12px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.manager-refresh-status--failed,
.manager-refresh-status--partial {
    color: var(--color-danger);
}

.manager-forecast-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.manager-forecast-table {
    width: 100%;
    min-width: 1080px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.manager-col-name {
    width: 150px;
}

.manager-col-target {
    width: 240px;
}

.manager-col-coverage {
    width: 125px;
}

.manager-col-percent {
    width: 100px;
}

.manager-col-forecast {
    width: auto;
}

.manager-forecast-table th,
.manager-forecast-table td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
    text-align: left;
    vertical-align: middle;
}

.manager-forecast-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.manager-forecast-table tbody tr:last-child > * {
    border-bottom: 0;
}

.manager-forecast-table tbody tr:hover > * {
    background: color-mix(in srgb, var(--color-surface-active) 46%, var(--color-surface) 54%);
}

.manager-forecast-table__row--error > :first-child {
    box-shadow: inset 3px 0 0 var(--color-danger);
}

.manager-seller-link {
    display: inline-block;
    max-width: 100%;
    color: var(--color-primary-blue);
    font-weight: 700;
    overflow: hidden;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manager-seller-link:hover,
.manager-seller-link:focus-visible {
    text-decoration: underline;
}

.manager-forecast-table__number {
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    white-space: nowrap;
}

.manager-forecast-table__bar {
    min-width: 0;
}

.forecast-chart--manager-row {
    min-width: 0;
}

.forecast-chart--manager-row .forecast-bar,
.forecast-chart--manager-row .forecast-segment {
    min-height: 56px;
}

.forecast-chart--manager-row .forecast-target-marker {
    bottom: 0;
}

.forecast-chart--manager-row .forecast-segment__body {
    gap: 2px;
    padding: 9px 10px;
}

.forecast-chart--manager-row .forecast-segment__value {
    font-size: 0.88rem;
}

.forecast-chart--manager-row .forecast-segment__label {
    font-size: 0.72rem;
}

.manager-target-editor {
    display: grid;
    gap: 4px;
}

.manager-target-editor__control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.manager-target-save {
    min-height: 38px;
    padding-inline: 10px;
}

.manager-target-editor__error {
    color: var(--color-danger);
    font-size: 0.72rem;
    line-height: 1.25;
}

.manager-target-readonly {
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.manager-row-empty {
    display: flex;
    min-height: 56px;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 0.82rem;
}

.manager-pagination {
    margin: 18px 0 0;
    justify-content: flex-end;
}

.forecast-modal-actions {
    margin-bottom: 10px;
}

.forecast-modal-warning {
    margin-top: 10px;
}

@media (max-width: 880px) {
    .manager-workspace {
        padding-inline: 16px;
    }

    .manager-workspace__toolbar {
        align-items: end;
    }

    .manager-workspace__controls {
        flex-basis: calc(100% - 92px);
    }

    .manager-control {
        min-width: min(170px, 100%);
    }
}

/*
 * Quiet shared component skin.
 * Flow: docs/agent/flows/features/idea-197-admin-ui-style-switch.mmd
 */
:root[data-ui-style="quiet"] .btn-primary,
:root[data-ui-style="quiet"] .btn-secondary {
    min-height: 30px;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

:root[data-ui-style="quiet"] .btn-primary:hover:not(:disabled) {
    filter: brightness(0.96);
    transform: none;
}

:root[data-ui-style="quiet"] .btn-secondary {
    border-color: var(--color-primary-blue);
    background: transparent;
    color: var(--color-primary-blue);
}

:root[data-ui-style="quiet"] .btn-secondary:hover:not(:disabled) {
    border-color: var(--quiet-navy-hover);
    background: var(--quiet-surface-active);
    color: var(--quiet-navy-hover);
}

:root[data-ui-style="quiet"] .btn-prominent-secondary {
    border-color: var(--quiet-coral);
    background: color-mix(in srgb, var(--quiet-coral) 10%, var(--quiet-surface) 90%);
    color: var(--quiet-ink);
}

:root[data-ui-style="quiet"] .btn-prominent-secondary:hover:not(:disabled) {
    border-color: var(--quiet-coral);
    background: color-mix(in srgb, var(--quiet-coral) 18%, var(--quiet-surface) 82%);
    color: var(--quiet-ink);
}

:root[data-ui-style="quiet"] .icon-btn {
    border-radius: 6px;
    color: var(--color-primary-blue);
}

:root[data-ui-style="quiet"] .icon-btn:hover {
    background: var(--quiet-surface-active);
    color: var(--quiet-navy-hover);
}

:root[data-ui-style="quiet"] .form-group {
    margin-bottom: 12px;
}

:root[data-ui-style="quiet"] .form-label,
:root[data-ui-style="quiet"] .sp-field label {
    margin-bottom: 5px;
    font-size: 0.76rem;
    font-weight: 600;
}

:root[data-ui-style="quiet"] .form-input,
:root[data-ui-style="quiet"] .form-select,
:root[data-ui-style="quiet"] .form-textarea,
:root[data-ui-style="quiet"] .search-input,
:root[data-ui-style="quiet"] .input-wrapper,
:root[data-ui-style="quiet"] .select-trigger {
    border-color: var(--quiet-line-strong);
    border-radius: 6px;
}

:root[data-ui-style="quiet"] .form-input,
:root[data-ui-style="quiet"] .form-select,
:root[data-ui-style="quiet"] .search-input,
:root[data-ui-style="quiet"] .select-trigger {
    min-height: 36px;
    padding-top: 7px;
    padding-bottom: 7px;
}

:root[data-ui-style="quiet"] .form-input:focus,
:root[data-ui-style="quiet"] .form-select:focus,
:root[data-ui-style="quiet"] .form-textarea:focus,
:root[data-ui-style="quiet"] .search-input:focus,
:root[data-ui-style="quiet"] .input-wrapper:focus-within,
:root[data-ui-style="quiet"] .select-trigger:focus,
:root[data-ui-style="quiet"] .select-trigger.open {
    border-color: var(--color-primary-blue);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary-blue) 12%, transparent 88%);
}

:root[data-ui-style="quiet"] .select-menu,
:root[data-ui-style="quiet"] .dropdown-menu {
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

:root[data-ui-style="quiet"] .chip,
:root[data-ui-style="quiet"] .status-badge,
:root[data-ui-style="quiet"] .toggle-track,
:root[data-ui-style="quiet"] .forecast-filter-chip,
:root[data-ui-style="quiet"] .source-summary-count {
    border-radius: var(--radius-full);
}

:root[data-ui-style="quiet"] .tabs {
    gap: 1px;
    padding: 3px;
    border-radius: 8px;
    background: var(--quiet-surface-subtle);
    box-shadow: none;
}

:root[data-ui-style="quiet"] .tab {
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

:root[data-ui-style="quiet"] .tab.active,
:root[data-ui-style="quiet"] .tab.is-active,
:root[data-ui-style="quiet"] .tab[aria-selected="true"] {
    border-color: var(--quiet-line-strong);
    background: var(--quiet-surface);
    box-shadow: none;
}

:root[data-ui-style="quiet"] .chat-shell {
    border-radius: 8px;
    box-shadow: none;
}

:root[data-ui-style="quiet"] .chat-header {
    padding: 12px 16px;
    background: var(--quiet-surface);
}

:root[data-ui-style="quiet"] .chat-body {
    gap: 12px;
    padding: 18px 20px 12px;
    background: color-mix(in srgb, var(--quiet-surface) 78%, var(--quiet-canvas) 22%);
}

:root[data-ui-style="quiet"] .message {
    border-radius: 0;
    box-shadow: none;
    font-size: 0.86rem;
    line-height: 1.55;
}

:root[data-ui-style="quiet"] .message.bot {
    align-self: stretch;
    width: auto;
    max-width: none;
    padding: 10px 14px;
    border-left: 2px solid var(--quiet-line-strong);
    background: transparent;
}

:root[data-ui-style="quiet"] .message.bot:hover {
    border-left-color: var(--color-primary-blue);
}

:root[data-ui-style="quiet"] .message.user {
    max-width: 74%;
    padding: 9px 12px;
    border-radius: 8px;
    background: #112a34;
}

:root[data-ui-style="quiet"] .message.support,
:root[data-ui-style="quiet"] .message.admin-note {
    align-self: stretch;
    width: auto;
    max-width: none;
    padding: 10px 14px;
    border: 0;
    border-left: 2px solid var(--quiet-coral);
    border-radius: 0;
    background: color-mix(in srgb, var(--quiet-coral) 4%, var(--quiet-surface) 96%);
    box-shadow: none;
}

:root[data-ui-style="quiet"] .message.support.support-admin {
    border-left-color: #4c1d95;
    background: color-mix(in srgb, #4c1d95 9%, var(--quiet-surface) 91%);
}

:root[data-ui-style="quiet"] .message.tool {
    width: auto;
    max-width: none;
    border-color: var(--quiet-line);
    border-radius: 4px;
    background: var(--quiet-surface-subtle);
    box-shadow: none;
}

:root[data-ui-style="quiet"] .message-actions {
    position: static;
    width: fit-content;
    margin-top: 8px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 0.55;
}

:root[data-ui-style="quiet"] .message:hover .message-actions,
:root[data-ui-style="quiet"] .message:focus-within .message-actions {
    opacity: 1;
}

:root[data-ui-style="quiet"] .chat-footer {
    padding: 12px 14px;
    background: var(--quiet-surface);
}

:root[data-ui-style="quiet"] .chat-footer .input-wrapper {
    border-color: var(--quiet-line-strong);
    border-radius: 8px;
    background: color-mix(in srgb, var(--quiet-surface) 94%, var(--quiet-canvas) 6%);
}

:root[data-ui-style="quiet"] .modal-content,
:root[data-ui-style="quiet"] .floating-table-dialog,
:root[data-ui-style="quiet"] .menu-dropdown {
    border-radius: 10px;
}

:root[data-ui-style="quiet"] .side-panel,
:root[data-ui-style="quiet"] .modal,
:root[data-ui-style="quiet"] .modal-content,
:root[data-ui-style="quiet"] .floating-table-dialog {
    border-radius: var(--radius-md) !important;
    border-color: var(--color-border);
    box-shadow: none !important;
}

/* Adaptive compact primitives. Flow: docs/agent/flows/features/idea-219-adaptive-mobile-sales-workspaces.mmd */
.nav-active-destination {
    display: none;
    min-width: 0;
    color: var(--color-text-primary);
    font-size: 0.86rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-workspace-toolbar {
    display: none;
}

.compact-overlay {
    position: fixed;
    inset: 0;
    z-index: 980;
    display: grid;
    background: rgba(9, 18, 33, 0.42);
    backdrop-filter: blur(2px);
}

.compact-drawer,
.compact-sheet,
.compact-drill-in {
    min-width: 0;
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-lg);
}

.compact-drawer {
    width: min(22rem, calc(100vw - 28px));
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
    animation: compact-drawer-enter 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.compact-sheet {
    align-self: end;
    width: 100%;
    max-height: min(88dvh, 46rem);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-radius: 18px 18px 0 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    animation: compact-sheet-enter 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.compact-drill-in {
    width: 100%;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: env(safe-area-inset-top);
    animation: compact-drill-enter 160ms ease-out;
}

.compact-drill-in__header {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid var(--color-border-light);
}

.compact-drill-in__header h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-drill-in__close {
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
}

.compact-drill-in__body {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.compact-overlay__header,
.compact-overlay__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--color-surface);
}

.compact-overlay__header {
    min-height: 56px;
    border-bottom: 1px solid var(--color-border);
}

.compact-overlay__header > :first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.compact-overlay__header h2,
.compact-overlay__header h3 {
    margin: 0;
    font-size: 1rem;
}

.compact-overlay__footer {
    justify-content: flex-end;
    border-top: 1px solid var(--color-border);
}

.compact-overlay__body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px;
}

.compact-data-list {
    display: grid;
    gap: 0;
    border-block: 1px solid var(--color-border);
    background: var(--color-surface);
}

.compact-data-row {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 8px;
    padding: 14px 0;
    border: 0;
    border-bottom: 1px solid var(--color-border-light);
    background: transparent;
    color: inherit;
    text-align: left;
}

.compact-data-row:last-child {
    border-bottom: 0;
}

button.compact-data-row {
    min-height: 44px;
    cursor: pointer;
}

button.compact-data-row:active {
    background: var(--color-surface-active);
}

.compact-data-row__title,
.compact-data-row__meta,
.compact-data-row__value {
    min-width: 0;
    overflow-wrap: anywhere;
}

.compact-data-row__title {
    font-weight: 700;
}

.compact-data-row__meta {
    color: var(--color-text-secondary);
    font-size: 0.78rem;
}

.compact-data-row__value {
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.compact-filter-summary {
    min-width: 0;
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-panel-switcher {
    display: flex;
    min-width: 0;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.compact-panel-switcher::-webkit-scrollbar {
    display: none;
}

.compact-panel-switcher button {
    min-height: 44px;
    flex: 0 0 auto;
}

.compact-status-banner {
    padding: 10px 12px;
    border-left: 3px solid var(--color-primary-blue);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-size: 0.82rem;
}

@keyframes compact-drawer-enter {
    from { transform: translateX(-100%); opacity: 0.92; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes compact-sheet-enter {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes compact-drill-enter {
    from { transform: translateX(20px); opacity: 0.7; }
    to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 47.999rem) {
    .nav-active-destination,
    .compact-workspace-toolbar {
        display: flex;
        align-items: center;
    }

    .nav-active-destination {
        flex: 1 1 auto;
        justify-content: center;
    }

    .top-nav .nav-group,
    .top-nav .nav-dropdown {
        position: static;
    }

    .top-nav .nav-dropdown > summary {
        min-width: 74px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .top-nav .nav-menu {
        position: fixed;
        inset: var(--pushai-nav-height, 56px) 0 0;
        width: 100%;
        max-width: none;
        max-height: none;
        overflow-y: auto;
        border: 0;
        border-top: 1px solid var(--color-border);
        border-radius: 0;
        padding: 10px max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        box-shadow: none;
    }

    .top-nav .nav-menu-item,
    .top-nav .nav-menu-row {
        min-height: 48px;
    }

    .compact-workspace-toolbar {
        min-height: 52px;
        width: 100%;
        justify-content: space-between;
        gap: 8px;
        padding: 6px 10px;
        border-bottom: 1px solid var(--color-border);
        background: var(--color-surface);
    }

    .compact-workspace-toolbar .btn-secondary,
    .compact-workspace-toolbar .icon-btn,
    :root[data-ui-style="quiet"] .compact-workspace-toolbar .btn-secondary,
    :root[data-ui-style="quiet"] .compact-workspace-toolbar .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .compact-drawer,
    .compact-sheet,
    .compact-drill-in {
        animation: none;
    }
}

/* Manager Workspace compact review presenter. Target mutation stays on wide screens. */
.manager-filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 988;
    border: 0;
    background: rgba(9, 18, 33, 0.42);
    backdrop-filter: blur(2px);
}

@media (max-width: 47.999rem) {
    .manager-workspace-app .main-layout {
        overflow: hidden;
    }

    .manager-workspace {
        height: 100%;
        padding: 12px 12px max(24px, env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    .manager-workspace__heading {
        margin-bottom: 10px;
    }

    .manager-workspace__heading h1 {
        font-size: 1.35rem;
    }

    .manager-workspace button,
    .manager-workspace select,
    .manager-workspace input,
    :root[data-ui-style="quiet"] .manager-workspace button,
    :root[data-ui-style="quiet"] .manager-workspace select,
    :root[data-ui-style="quiet"] .manager-workspace input {
        min-height: 44px;
    }

    .manager-workspace .icon-btn,
    :root[data-ui-style="quiet"] .manager-workspace .icon-btn {
        min-width: 44px;
    }

    .manager-seller-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .manager-compact-toolbar {
        position: sticky;
        top: -12px;
        z-index: 8;
        margin: 0 -12px 12px;
    }

    .manager-compact-toolbar .compact-filter-summary {
        flex: 1 1 auto;
    }

    .manager-filter-sheet {
        position: fixed;
        inset: auto 0 0;
        z-index: 989;
        width: 100%;
        max-height: min(88dvh, 46rem);
        margin: 0;
        padding: 0 0 max(10px, env(safe-area-inset-bottom));
        border: 0;
        border-radius: 18px 18px 0 0;
        background: var(--color-surface);
    }

    .manager-filter-sheet .manager-workspace__controls {
        min-height: 0;
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 14px;
        overflow-y: auto;
        padding: 14px 16px;
        overscroll-behavior: contain;
    }

    .manager-filter-sheet .manager-control {
        width: 100%;
        min-width: 0;
    }

    .manager-filter-sheet .manager-workspace__actions {
        min-height: 64px;
        justify-content: flex-end;
        align-self: auto;
        padding: 10px 16px;
        border-top: 1px solid var(--color-border);
    }

    .manager-filter-sheet .manager-refresh {
        display: none;
    }

    .manager-seller-list {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding-inline: 14px;
    }

    .manager-seller-row {
        gap: 12px;
    }

    .manager-seller-row--error {
        box-shadow: inset 3px 0 0 var(--color-danger);
        padding-left: 10px;
    }

    .manager-seller-row__heading {
        display: flex;
        min-width: 0;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
    }

    .manager-seller-row__warning {
        flex: 0 0 auto;
        color: var(--color-danger);
        font-size: 0.72rem;
        font-weight: 700;
    }

    .manager-seller-row__metrics {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin: 0;
    }

    .manager-seller-row__metrics div {
        min-width: 0;
    }

    .manager-seller-row__metrics dt {
        color: var(--color-text-secondary);
        font-size: 0.7rem;
    }

    .manager-seller-row__metrics dd {
        min-width: 0;
        margin: 2px 0 0;
        overflow: hidden;
        font-size: 0.82rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .manager-seller-row__forecast {
        min-width: 0;
        overflow-x: auto;
    }

    .manager-pagination {
        justify-content: space-between;
    }

    .floating-table-overlay {
        z-index: 996;
        align-items: stretch;
        padding: 0;
    }

    .floating-table-dialog,
    :root[data-ui-style="quiet"] .floating-table-dialog {
        width: 100vw !important;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border: 0;
        border-radius: 0 !important;
    }

    .floating-table-dialog__header {
        min-height: 56px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .floating-table-dialog__body {
        padding: 12px 12px max(18px, env(safe-area-inset-bottom));
    }

    .floating-table-resize-handle {
        display: none;
    }
}
/* Unified CRM Formula authoring — idea-237-unified-crm-formula-authoring.mmd */
.crm-formula-expression {
  min-width: 0;
}

.crm-formula-expression__input {
  position: relative;
}

.crm-formula-expression .form-textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
}

.crm-formula-expression.is-compact .form-textarea {
  min-height: 72px;
}

.crm-formula-expression.is-invalid .form-textarea,
.crm-formula-expression .form-textarea[aria-invalid="true"] {
  border-color: var(--color-primary-red);
}

.crm-completion-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: min(320px, 42vh);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  animation: crm-completion-in 100ms ease-out both;
}

.crm-completion-menu.is-portal {
  position: fixed;
  z-index: 10000;
  right: auto;
  bottom: auto;
}

.crm-completion-group {
  padding: 8px 10px 4px;
  color: var(--color-text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.crm-completion-option {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.crm-completion-option:hover,
.crm-completion-option.is-highlighted {
  background: var(--color-surface-active);
}

.crm-completion-option:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.crm-completion-option__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.crm-completion-option strong {
  color: var(--color-text-primary);
  font-size: 0.82rem;
}

.crm-completion-option > span,
.crm-completion-empty {
  color: var(--color-text-secondary);
  font-size: 0.74rem;
}

.crm-completion-option__reason {
  color: var(--color-primary-red) !important;
}

.crm-completion-empty {
  padding: 12px;
}

.crm-formula-badge {
  padding: 1px 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
}

.crm-formula-expected,
.crm-formula-status,
.crm-formula-analysis,
.crm-formula-diagnostic {
  margin-top: 6px;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
}

.crm-formula-status.is-checking,
.crm-formula-status.is-valid {
  color: var(--color-primary-green);
}

.crm-formula-status.is-dirty {
  color: var(--color-text-secondary);
}

.crm-formula-status.is-invalid,
.crm-formula-diagnostic.is-error {
  color: var(--color-primary-red);
}

.crm-formula-diagnostics {
  margin-top: 6px;
  padding: 8px 10px;
  border-left: 2px solid var(--color-primary-red);
  background: var(--color-surface-alt);
}

.crm-formula-diagnostic {
  margin: 0;
}

.crm-formula-analysis summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 600;
}

.crm-formula-analysis > div {
  padding-top: 5px;
}

@media (prefers-reduced-motion: reduce) {
  .crm-completion-menu {
    animation: none;
  }
}
/* Interactive CRM lookup preview. This is a persistent, focusable surface, not a tooltip. */
.crm-record-hovercard {
  position: absolute;
  z-index: 1200;
  width: min(340px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  color: var(--color-text-primary);
  font-family: inherit;
}

.crm-record-hovercard[hidden] { display: none; }
.crm-record-hovercard__header { display: grid; gap: 2px; }
.crm-record-hovercard__object,
.crm-record-hovercard__label {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  line-height: 1.3;
}

.crm-record-hovercard__title {
  color: var(--color-text-link);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.crm-record-hovercard__details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.crm-record-hovercard__detail,
.crm-record-hovercard__metric { display: grid; min-width: 0; gap: 2px; }
.crm-record-hovercard__value {
  color: var(--color-text-primary);
  font-size: 0.875rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-record-hovercard__lookup { color: var(--color-text-link); }
.crm-record-hovercard__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.crm-record-hovercard__metric .crm-record-hovercard__value {
  font-size: 1rem;
  font-weight: 650;
}

.crm-record-hovercard__status {
  display: block;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.crm-record-hovercard :focus-visible {
  outline: 2px solid var(--color-text-link);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .crm-record-hovercard__details { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .crm-record-hovercard:not([hidden]) { animation: crm-hovercard-in 120ms ease-out; }
}

@keyframes crm-hovercard-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Workflow builder primitives.
   Layout remains page-owned; these cards are the reusable visual contract. */
.workflow-node-glyph {
  display: grid;
  width: 24px;
  height: 24px;
  flex: none;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--color-primary-blue) 10%, var(--color-surface));
  color: var(--color-primary-blue);
  font-size: 0.7rem;
  font-weight: 750;
}

.workflow-palette-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  cursor: grab;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.workflow-palette-item:hover {
  border-color: color-mix(in srgb, var(--color-primary-blue) 32%, var(--color-border));
  background: color-mix(in srgb, var(--color-primary-blue) 4%, var(--color-surface));
  transform: translateY(-1px);
}

.workflow-palette-item:active { cursor: grabbing; }
.workflow-palette-item__copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 1px;
}
.workflow-palette-item__copy strong {
  color: var(--color-text-primary);
  font-size: 0.72rem;
}
.workflow-palette-item__copy small {
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-palette-item__add {
  display: grid;
  width: 24px;
  height: 24px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-primary-blue);
  font: inherit;
  cursor: pointer;
}

.workflow-graph-node {
  min-height: 92px;
  padding: 11px 13px;
  border: 1px solid var(--color-border);
  border-left: 3px solid color-mix(in srgb, var(--color-primary-blue) 60%, var(--color-border));
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--color-primary-blue) 6%, transparent);
  cursor: pointer;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.workflow-graph-node:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px color-mix(in srgb, var(--color-primary-blue) 9%, transparent);
}

.workflow-graph-node.is-selected {
  border-color: var(--color-primary-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary-blue) 13%, transparent),
              0 10px 25px color-mix(in srgb, var(--color-primary-blue) 9%, transparent);
}

.workflow-graph-node--logic { border-left-color: var(--color-primary-blue); }
.workflow-graph-node--data { border-left-color: color-mix(in srgb, var(--color-primary-blue) 60%, var(--color-success)); }
.workflow-graph-node--crm_action { border-left-color: var(--color-success); }
.workflow-graph-node--composition { border-left-color: color-mix(in srgb, var(--color-primary-blue) 68%, var(--color-warning)); }
.workflow-graph-node--timing { border-left-color: var(--color-warning); }
.workflow-graph-node--outcome { border-left-color: var(--color-text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .workflow-palette-item,
  .workflow-graph-node { transition: none; }
  .workflow-palette-item:hover,
  .workflow-graph-node:hover { transform: none; }
}
