/* =========================================================
   DEALS / TEMATY
   ========================================================= */


.deal-filter-form {
    display: grid;
    grid-template-columns:
        minmax(220px, 1.5fr)
        minmax(130px, .8fr)
        minmax(140px, .9fr)
        minmax(170px, 1fr)
        minmax(190px, 1.1fr)
        auto;
    gap: 12px;
    align-items: end;
}

.deal-filter-autocomplete {
    position: relative;
}


.deal-filter-suggestions {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    left: 0;
    right: 0;

    max-height: 280px;
    overflow-y: auto;

    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 16px 36px rgb(0 0 0 / 32%);
}


.deal-filter-suggestion {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 10px 12px;

    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}


.deal-filter-suggestion:hover,
.deal-filter-suggestion:focus-visible {
    background: var(--surface-2);
    outline: none;
}


.deal-filter-suggestion span,
.deal-filter-suggestion-empty {
    color: var(--muted);
    font-size: 12px;
}


.deal-filter-suggestion-empty {
    display: block;
    padding: 10px 12px;
}


.deal-filter-form label {
    display: block;
    margin-bottom: 7px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 650;
}


.deal-list-card {
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
}


.deal-list-card .card-heading {
    padding-left: 24px;
    padding-right: 24px;
}


.deal-list {
    border-top: 1px solid var(--border);
}


.deal-row {
    display: grid;
    grid-template-columns:
        150px
        minmax(260px, 1fr)
        110px
        minmax(150px, 180px)
        130px
        24px;
    gap: 18px;
    align-items: center;

    padding: 15px 24px;

    border-bottom: 1px solid var(--border);

    transition: background 120ms ease;
}


.deal-row:hover {
    background: var(--surface-2);
}


.deal-number,
.deal-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


.deal-number strong {
    color: var(--blue);
}


.deal-number span,
.deal-main span {
    color: var(--muted);

    font-size: 11px;
}


.deal-type {
    color: var(--muted);

    font-size: 12px;
    font-weight: 650;
}

.deal-salesperson {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.deal-salesperson span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.deal-salesperson strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}


.deal-status-badge,
.deal-financing-badge {
    display: inline-flex;
    align-items: center;

    padding: 6px 9px;

    border: 1px solid var(--border);
    border-radius: 999px;

    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}


.deal-status-new {
    color: var(--blue);

    background: rgba(91, 184, 232, 0.08);

    border-color: rgba(91, 184, 232, 0.22);
}


.deal-status-in_progress {
    color: #c5a7ff;

    background: rgba(164, 122, 255, 0.08);

    border-color: rgba(164, 122, 255, 0.22);
}


.deal-status-waiting {
    color: #f4c96b;

    background: rgba(244, 201, 107, 0.08);

    border-color: rgba(244, 201, 107, 0.22);
}


.deal-status-waiting_client,
.deal-status-waiting_vehicle {
    color: #f4c96b;

    background: rgba(244, 201, 107, 0.08);

    border-color: rgba(244, 201, 107, 0.22);
}


.deal-status-client_withdrew,
.deal-status-financing_declined {
    color: #ff9f9f;

    background: rgba(239, 100, 100, 0.1);

    border-color: rgba(239, 100, 100, 0.28);
}


.deal-state-stack {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
}


.deal-workflow-stage {
    color: var(--muted);

    font-size: 10px;
    line-height: 1.3;
}


.deal-status-completed {
    color: #72d89d;

    background: rgba(114, 216, 157, 0.08);

    border-color: rgba(114, 216, 157, 0.22);
}


.deal-status-cancelled {
    color: #ff8c8c;

    background: rgba(255, 100, 100, 0.08);

    border-color: rgba(255, 100, 100, 0.22);
}


.deal-form-hint {
    margin: 15px 0 0;

    color: var(--muted);

    font-size: 11px;
}


.deal-create-form {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    grid-template-areas:
        "basics dealer"
        "client vehicle"
        "notes vehicle"
        "actions actions";
    align-items: start;
    gap: 20px;
}


.deal-create-form > .content-card {
    margin-bottom: 0;
}


.deal-create-errors {
    grid-column: 1 / -1;
}


.deal-create-basics {
    grid-area: basics;
}


.deal-create-dealer {
    grid-area: dealer;
}


.deal-create-client {
    grid-area: client;
}


.deal-create-vehicle {
    grid-area: vehicle;
}


.deal-create-notes {
    grid-area: notes;
}


.deal-create-actions {
    grid-area: actions;
    margin-top: 4px;
}


.deal-create-vehicle .form-grid-2 {
    grid-template-columns: 1fr;
}


.deal-create-vehicle .deal-vehicle-actions {
    align-items: stretch;
    flex-direction: column;
}


.deal-create-vehicle .deal-vehicle-actions .secondary-button {
    width: 100%;
}


@media (max-width: 1050px) {

    .deal-create-form {
        grid-template-columns: 1fr;
        grid-template-areas:
            "basics"
            "client"
            "dealer"
            "vehicle"
            "notes"
            "actions";
    }

}


.deal-vehicle-actions {
    display: flex;
    align-items: center;
    gap: 12px;

    margin-top: 20px;

    color: var(--muted);

    font-size: 11px;
}


.deal-detail-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 24px;
}


.deal-detail-header-side {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 12px;
}


.deal-detail-header h1 {
    margin: 5px 0 3px;

    font-size: clamp(28px, 4vw, 44px);
    letter-spacing: -1.5px;
}


.deal-detail-header p {
    margin: 0;

    color: var(--muted);
}

.deal-header-contact {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    color: var(--muted);
    font-size: 14px;
}

.deal-header-contact strong {
    color: var(--muted);
}

.deal-header-contact .deal-header-client-link {
    color: var(--muted);
    font-weight: 800;
}

.deal-header-contact .deal-header-client-link::before {
    content: none;
}

.deal-header-contact .deal-header-client-link:hover {
    color: var(--accent);
}

.deal-header-contact > span::before,
.deal-header-contact > a::before {
    content: "·";
    margin-right: 10px;
    color: var(--border-strong, var(--muted));
}

.deal-header-contact a {
    color: var(--muted);
    text-decoration: none;
}

.deal-header-contact a:hover {
    color: var(--accent);
}

.deal-header-contact .deal-header-contact-edit {
    color: #ff6b6b;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.deal-header-contact .deal-header-contact-edit::before {
    content: "·";
    margin-right: 10px;
    color: var(--muted);
}


.deal-header-badges {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
}


.deal-stage-badge {
    display: inline-flex;
    align-items: center;

    padding: 6px 9px;

    color: var(--blue);
    background: rgba(91, 184, 232, 0.08);

    border: 1px solid rgba(91, 184, 232, 0.22);
    border-radius: 999px;

    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}


.deal-header-quick-action {
    margin: 0;
}


.deal-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}


.deal-financing-badge {
    color: var(--text);

    background: var(--surface-2);
}


.deal-detail-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 2fr)
        minmax(330px, 1fr);
    gap: 20px;
}


.deal-detail-main,
.deal-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}


.deal-client-card {
    order: 1;
}

.deal-offers-card {
    order: 1;
}


.deal-notes-card {
    order: 2;
    padding: 20px;
}

.deal-reminders-card {
    order: 2;
    padding: 20px;
}

.deal-reminders-card .card-heading {
    margin-bottom: 14px;
}

.deal-reminder-list {
    display: grid;
    gap: 8px;
}

.deal-reminder-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
}

.deal-reminder-row > div strong,
.deal-reminder-row > div span {
    display: block;
}

.deal-reminder-row > div span {
    margin-top: 3px;
    color: var(--muted);
    font-size: .8rem;
}

.deal-reminder-row.is-overdue {
    border-color: rgba(255, 100, 100, .55);
}

@media (max-width: 720px) {
    .deal-reminder-row {
        align-items: stretch;
        flex-direction: column;
    }
}

.deal-note-add {
    position: relative;
}

.deal-note-add > summary,
.deal-note-edit > summary {
    cursor: pointer;
    list-style: none;
}

.deal-note-add > summary::-webkit-details-marker,
.deal-note-edit > summary::-webkit-details-marker {
    display: none;
}

.deal-note-add > form {
    position: absolute;
    z-index: 20;
    right: 0;
    top: calc(100% + 10px);
    width: min(520px, 80vw);
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, .35);
}

.deal-note-timeline {
    display: grid;
    gap: 8px;
}

.deal-note-entry {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 11px;
}

.deal-note-entry.is-legacy {
    border-style: dashed;
}

.deal-note-entry-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.deal-note-entry-meta strong,
.deal-note-entry-meta span {
    display: block;
}

.deal-note-entry-meta span,
.deal-note-revision > span {
    margin-top: 3px;
    color: var(--muted);
    font-size: .82rem;
}

.deal-note-entry > p,
.deal-note-revision p {
    margin: 8px 0 0;
    line-height: 1.45;
}

.deal-note-edit {
    min-width: 72px;
}

.deal-note-edit > summary,
.deal-note-revisions > summary {
    color: var(--blue);
    cursor: pointer;
    font-size: .84rem;
    font-weight: 800;
}

.deal-note-edit form {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.deal-note-edit form label {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 700;
}

.deal-note-revisions {
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.deal-note-revision {
    margin-top: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, .12);
    border-radius: 10px;
}

@media (max-width: 720px) {
    .deal-note-add > form {
        position: fixed;
        inset: 82px 14px auto;
        width: auto;
    }
    .deal-note-entry-heading {
        flex-direction: column;
    }
}

.deal-notes-card .card-heading {
    align-items: center;
    margin-bottom: 14px;
}

.deal-notes-card .card-heading h2 {
    font-size: 21px;
}


.inline-edit-hint {
    color: var(--blue);
    font-size: 11px;
    font-weight: 700;
}


.deal-note-display {
    margin-top: 14px;
}


.deal-issues-alert-card {
    order: 3;
}


.workflow-card {
    order: 4;
}


.deal-history-card {
    order: 5;
}

.deal-detail-main.has-accepted-offer .workflow-card {
    order: 1;
}

.deal-detail-main.has-accepted-offer .deal-notes-card {
    order: 2;
}

.deal-detail-main.has-accepted-offer .deal-offers-card {
    order: 3;
}

.deal-detail-main.has-accepted-offer .deal-issues-alert-card {
    order: 4;
}

.deal-detail-main.has-open-issues .deal-issues-alert-card,
.deal-detail-main.has-pending-offer .deal-offers-card,
.deal-detail-main.is-editing-offer .deal-offers-card {
    order: 0;
}


.deal-contact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}


.deal-contact-grid .info-line {
    min-width: 0;
    margin: 0;
    padding: 14px;

    background: var(--surface-2);

    border: 1px solid var(--border);
    border-radius: 11px;
}


.deal-contact-grid .info-line strong,
.deal-sidebar-vehicle-card .info-line strong {
    overflow-wrap: anywhere;
}


.deal-sidebar-vehicle-card h2 {
    margin-top: 7px;
}


.deal-financing-setup-card {
    order: 1;
}


.deal-current-state-card {
    order: 2;
}

.deal-state-stack {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}


.deal-inline-status-form {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0;
    padding: 14px;

    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
}


.deal-inline-status-form label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}


.deal-inline-status-form .fincrm-select {
    width: 100%;
    min-height: 44px;
    padding-top: 9px;
    padding-bottom: 9px;
    border-color: transparent;
    background-color: var(--surface-3);
    font-weight: 700;
}


.deal-inline-status-feedback {
    position: absolute;
    top: 14px;
    right: 14px;

    color: var(--green);
    font-size: 10px;
    font-weight: 700;
}


.deal-inline-status-feedback.is-error {
    color: var(--red);
}

.deal-state-stage {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 14px 16px;

    border: 1px solid rgba(91, 184, 232, .28);
    border-left: 3px solid var(--blue);
    border-radius: 13px;
    background: rgba(91, 184, 232, .07);
}


.deal-state-stage span,
.deal-state-metric > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
}


.deal-state-stage strong {
    font-size: 17px;
}


.deal-state-metrics {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(100px, .75fr);
    gap: 10px;
}


.deal-state-metric {
    min-width: 0;
    padding: 14px;

    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
}


.deal-state-metric strong {
    display: flex;
    align-items: baseline;
    gap: 7px;
    margin-top: 5px;
    font-size: 19px;
}


.deal-state-metric strong small {
    color: var(--muted);
    font-size: 12px;
}


.deal-state-progress-track {
    height: 5px;
    margin-top: 10px;
    overflow: hidden;

    border-radius: 999px;
    background: var(--surface-3);
}


.deal-state-progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--blue);
}


.deal-state-metric.has-warning {
    border-color: rgba(240, 201, 75, .42);
    background: rgba(240, 201, 75, .07);
}


.deal-state-metric.has-warning strong {
    color: var(--accent);
}


.deal-status-change-card {
    order: 3;
}


.deal-sidebar-vehicle-card {
    order: 4;
}


.deal-dealer-card {
    order: 5;
}


.deal-system-card {
    order: 6;
}


@media (max-width: 900px) {

    .deal-filter-form {
        grid-template-columns: 1fr;
    }


    .deal-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .deal-salesperson strong {
        white-space: normal;
    }


    .deal-detail-grid {
        grid-template-columns: 1fr;
    }


    .deal-detail-header {
        align-items: flex-start;
        flex-direction: column;
    }


    .deal-detail-header-side {
        align-items: flex-start;
    }


    .deal-header-badges {
        justify-content: flex-start;
    }

}


@media (max-width: 600px) {

    .deal-contact-grid {
        grid-template-columns: 1fr;
    }

    .deal-header-quick-action,
    .deal-header-quick-action .secondary-button {
        width: 100%;
    }

    .deal-header-actions,
    .deal-header-actions > .secondary-button {
        width: 100%;
    }

}


/* =========================================================
   DEAL WORKFLOW
   ========================================================= */


.deal-quick-actions {
    display: flex;
    align-items: center;
    gap: 12px;

    margin-bottom: 20px;
}


.deal-quick-actions form {
    margin: 0;
}


.workflow-progress-label {
    display: flex;
    align-items: center;
    gap: 8px;

    color: var(--muted);

    font-size: 11px;
}


.workflow-progress-label strong {
    color: var(--text);

    font-size: 15px;
}


.workflow-progress-track {
    width: 100%;
    height: 7px;

    margin-bottom: 24px;

    background: var(--surface-2);

    border-radius: 999px;

    overflow: hidden;
}


.workflow-progress-fill {
    height: 100%;

    background: var(--blue);

    border-radius: inherit;

    transition: width 250ms ease;
}


.workflow-stage-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}


.workflow-stage {
    overflow: hidden;

    background: var(--surface-2);

    border: 1px solid var(--border);
    border-radius: 13px;
}


.workflow-stage.is-current {
    border-color: rgba(91, 184, 232, 0.42);

    box-shadow:
        inset 3px 0 0 var(--blue);
}


.workflow-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;

    padding: 14px 16px;

    border-bottom: 1px solid var(--border);

    cursor: pointer;
    list-style: none;
}


.workflow-stage-header::-webkit-details-marker {
    display: none;
}


.workflow-stage-header::after {
    content: "▾";

    color: var(--muted);

    font-size: 12px;
    transition: transform 160ms ease;
}


.workflow-stage:not([open]) .workflow-stage-header {
    border-bottom: 0;
}


.workflow-stage:not([open]) .workflow-stage-header::after {
    transform: rotate(-90deg);
}


.workflow-stage-header h3 {
    margin: 0;

    font-size: 14px;
}


.workflow-current-label {
    display: block;

    margin-bottom: 4px;

    color: var(--blue);

    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
}


.workflow-stage-count {
    color: var(--muted);

    font-size: 11px;
    font-weight: 700;
}

.workflow-task-group + .workflow-task-group {
    border-top: 1px solid var(--border);
}

.workflow-task-group-header {
    align-items: center;
    background: rgba(255, 255, 255, 0.018);
    cursor: pointer;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    list-style: none;
    padding: 12px 16px 12px 28px;
}

.workflow-task-group-header::-webkit-details-marker {
    display: none;
}

.workflow-task-group-header strong {
    font-size: 12px;
}

.workflow-task-group-header span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.workflow-task-group-header::after {
    color: var(--muted);
    content: "▾";
    font-size: 10px;
    transition: transform 160ms ease;
}

.workflow-task-group:not([open]) .workflow-task-group-header::after {
    transform: rotate(-90deg);
}

.workflow-task-group.is-current .workflow-task-group-header {
    background: rgba(91, 184, 232, 0.07);
    color: var(--blue);
}

.workflow-task-group .workflow-task-row {
    padding-left: 34px;
}


.workflow-task-list {
    display: flex;
    flex-direction: column;
}


.workflow-task-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;

    padding: 11px 16px;

    border-bottom: 1px solid var(--border);
}


.workflow-task-row:last-child {
    border-bottom: 0;
}


.workflow-task-row.is-done {
    opacity: 0.58;
}

.workflow-task-row.is-saving {
    opacity: 0.58;
    pointer-events: none;
}


.workflow-task-row.is-done
.workflow-task-content strong {
    text-decoration: line-through;
}


.workflow-task-row form {
    margin: 0;
}


.workflow-task-toggle {
    width: 25px;
    height: 25px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    color: var(--muted);
    background: var(--surface-3);

    border: 1px solid var(--border);
    border-radius: 50%;

    cursor: pointer;

    font-size: 13px;
    font-weight: 800;
}


.workflow-task-row.is-done
.workflow-task-toggle {
    color: #72d89d;

    border-color: rgba(114, 216, 157, 0.35);

    background: rgba(114, 216, 157, 0.08);
}


.workflow-task-toggle:hover {
    border-color: var(--blue);
}


.workflow-task-content {
    min-width: 0;

    display: flex;
    flex-direction: column;
    gap: 3px;
}


.workflow-task-content strong {
    font-size: 12px;
    line-height: 1.45;
}


.workflow-task-content span {
    color: var(--muted);

    font-size: 10px;
}


/* =========================================================
   DEAL ISSUES
   ========================================================= */


.deal-issue-list {
    display: flex;
    flex-direction: column;
    gap: 9px;

    margin-bottom: 18px;
}


.deal-issues-alert-card {
    border-color: rgba(244, 201, 107, 0.3);

    box-shadow:
        inset 3px 0 0 rgba(244, 201, 107, 0.72);
}


.deal-issue-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;

    padding: 14px;

    background: rgba(255, 100, 100, 0.035);

    border: 1px solid rgba(255, 100, 100, 0.16);
    border-radius: 11px;
}


.deal-issue-item.is-resolved {
    opacity: 0.5;

    background: var(--surface-2);

    border-color: var(--border);
}


.deal-issue-main {
    min-width: 0;
}


.deal-issue-main > strong {
    display: block;

    margin-top: 7px;

    font-size: 13px;
}


.deal-issue-main p {
    margin: 7px 0 0;

    color: var(--text);

    font-size: 12px;
    line-height: 1.55;
}


.deal-issue-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}


.deal-issue-meta span {
    padding: 3px 6px;

    color: var(--muted);
    background: var(--surface-3);

    border-radius: 6px;

    font-size: 9px;
    font-weight: 700;
}


.deal-add-issue {
    margin-top: 18px;

    border-top: 1px solid var(--border);
}


.deal-add-issue summary {
    padding: 16px 0 0;

    color: var(--blue);

    cursor: pointer;

    font-size: 11px;
    font-weight: 700;
}


.deal-add-issue form {
    margin-top: 18px;
}


/* =========================================================
   DEAL TIMELINE
   ========================================================= */


.deal-history-card {
    padding: 0;
}


.deal-history-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    padding: 24px 26px;

    cursor: pointer;
    list-style: none;
}


.deal-history-summary::-webkit-details-marker {
    display: none;
}


.deal-history-summary > span:first-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


.deal-history-summary strong {
    font-size: 23px;
}


.deal-history-summary-meta {
    display: flex;
    align-items: center;
    gap: 10px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 650;
}


.deal-history-summary-meta::after {
    content: "▾";

    font-size: 13px;
    transition: transform 160ms ease;
}


.deal-history-card:not([open]) .deal-history-summary-meta::after {
    transform: rotate(-90deg);
}


.deal-history-content {
    display: grid;
    gap: 28px;

    padding: 0 26px 26px;

    border-top: 1px solid var(--border);
}

.deal-history-actions {
    display: flex;
    justify-content: flex-end;

    padding-top: 24px;
}


.deal-history-content > section {
    padding-top: 24px;
}


.deal-history-content h3 {
    margin: 0 0 12px;

    font-size: 15px;
}


.deal-history-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;

    margin-top: 14px;
    padding-top: 12px;

    border-top: 1px solid var(--border);

    color: var(--muted);

    font-size: 10px;
    font-weight: 650;
    text-align: center;
}


.deal-history-pagination a:first-child {
    justify-self: start;
}


.deal-history-pagination a:last-child {
    justify-self: end;
}


.deal-timeline {
    display: flex;
    flex-direction: column;
}


@media (max-width: 600px) {

    .deal-history-summary {
        align-items: flex-start;
        flex-direction: column;
    }

}


.deal-timeline-item {
    display: grid;
    grid-template-columns:
        12px
        120px
        minmax(0, 1fr);
    gap: 12px;

    padding: 11px 0;

    border-bottom: 1px solid var(--border);
}


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


.deal-timeline-dot {
    width: 8px;
    height: 8px;

    margin-top: 5px;

    background: var(--blue);

    border-radius: 50%;
}


.deal-timeline-time {
    color: var(--muted);

    font-size: 10px;
}


.deal-timeline-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


.deal-timeline-content strong {
    font-size: 12px;
}


.deal-timeline-content p {
    margin: 0;

    color: var(--muted);

    font-size: 11px;
}


.deal-timeline-content span {
    color: var(--muted);

    font-size: 9px;
}

.deal-client-contact-form {
    display: grid;
    gap: 18px;

    margin-top: 24px;
    padding-top: 24px;

    border-top: 1px solid var(--border);
}

.deal-client-search-field {
    position: relative;
}

.deal-client-search-field > label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.deal-client-search-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    left: 0;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    box-shadow: 0 18px 40px rgb(0 0 0 / 28%);
}

.deal-client-search-results button,
.deal-client-search-results span {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
}

.deal-client-search-results button {
    cursor: pointer;
}

.deal-client-search-results button:hover {
    background: var(--surface-3);
}

.deal-selected-client {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.deal-selected-client span {
    color: var(--muted);
    font-size: 10px;
}

.deal-client-native-field {
    display: none;
}

.deal-client-contact-actions {
    justify-content: flex-end;
}

.company-owner-contact-sync {
    margin-top: 18px;
}

[data-owner-contact-fields] {
    margin-top: 22px;
}

[data-owner-contact-fields][hidden] {
    display: none;
}

.representative-contact-grid {
    margin-top: 22px;
}

.deal-client-modal {
    width: min(1120px, calc(100vw - 36px));
    height: min(820px, calc(100vh - 36px));
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 28px 90px rgb(0 0 0 / 65%);
}

.deal-client-modal::backdrop {
    background: rgb(2 6 12 / 78%);
    backdrop-filter: blur(5px);
}

.deal-contact-choice-modal {
    width: min(560px, calc(100vw - 32px));
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 28px 90px rgb(0 0 0 / 55%);
}

.deal-contact-choice-modal::backdrop {
    background: rgb(2 6 12 / 68%);
    backdrop-filter: blur(4px);
}

.deal-contact-choice-modal h3 {
    margin: 8px 0 12px;
    font-size: 24px;
}

.deal-contact-choice-modal p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.deal-contact-choice-summary {
    display: block;
    margin: 16px 0;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.deal-contact-choice-hint {
    font-size: 12px;
}

.deal-contact-choice-actions {
    margin-top: 24px;
    justify-content: flex-end;
}

.deal-sidebar-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.deal-sidebar-heading h2 {
    margin: 0;
}

.workflow-card-heading,
.workflow-heading-content {
    width: 100%;
}

.workflow-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.section-edit-link {
    color: #ff6b6b;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
}

.section-edit-link:hover,
.section-edit-link:focus-visible {
    color: #ff9494;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.deal-section-kicker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.deal-section-kicker-row .eyebrow {
    margin: 0;
}

.workflow-scenario-edit {
    max-width: 680px;
    margin: 20px 0 24px;
}

.workflow-scenario-edit .deal-inline-edit-warning {
    margin-top: 0;
}

@media (max-width: 700px) {
    .workflow-title-row {
        align-items: flex-start;
    }
}

.deal-sidebar-edit-form {
    display: grid;
    gap: 15px;
    margin-top: 20px;
}

.deal-sidebar-edit-form .form-actions {
    margin-top: 3px;
}

.deal-inline-edit-warning {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid rgb(245 196 66 / 28%);
    border-radius: 11px;
    background: rgb(245 196 66 / 8%);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .deal-contact-choice-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .deal-contact-choice-actions .primary-button,
    .deal-contact-choice-actions .secondary-button {
        width: 100%;
    }
}

.deal-client-modal-header {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.deal-client-modal-header > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.deal-client-modal iframe {
    width: 100%;
    height: calc(100% - 76px);
    border: 0;
    background: var(--bg);
}

.popup-mode .topbar {
    display: none;
}

.popup-mode .app-container {
    width: 100%;
    max-width: none;
    padding: 20px;
}

@media (max-width: 700px) {
    .deal-client-modal {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
}


@media (max-width: 700px) {

    .deal-timeline-item {
        grid-template-columns:
            12px
            1fr;
    }


    .deal-timeline-time {
        grid-column: 2;
    }


    .deal-timeline-content {
        grid-column: 2;
    }


    .deal-issue-item {
        flex-direction: column;
    }

}
