/* =============================================================================
   APLOSCRM — APP SHELL LAYOUT
   Structural chrome: top nav, sidebar, main content area.
   Component / utility styles live in main.css.
   ============================================================================= */


/* =============================================================================
   VARIABLES (app-specific additions)
   ============================================================================= */

:root {
    --app-banner-height:  2.4rem;
    --app-nav-height:     56px;
    --app-sidebar-width: 220px;
    --app-nav-bg:        #061F38;    /* --color-navy-deep */
    --app-nav-border:    #2ECC71;    /* --color-green */
    --app-sidebar-bg:    #061F38;
    --app-sidebar-hover: rgba(214, 234, 248, 0.08);
    --app-sidebar-active-bg: rgba(46, 204, 113, 0.12);
    --app-sidebar-active-border: #2ECC71;
    --app-main-bg:       #F0F7FF;    /* --color-ice */
}


/* =============================================================================
   BODY RESET FOR APP LAYOUT
   ============================================================================= */

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--app-main-bg);
}


/* =============================================================================
   TOP NAVIGATION BAR
   ============================================================================= */

/* Test instance banner */
.app-test-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 201;
    height: var(--app-banner-height);
    background: #f97316;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

.app-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: var(--app-nav-height);
    background-color: var(--app-nav-bg);
    border-bottom: 3px solid var(--app-nav-border);
    box-shadow: 0 2px 8px rgba(6, 31, 56, 0.4);
}

body.has-test-banner .app-nav {
    top: var(--app-banner-height);
}

.app-nav__inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding-inline: 1.25rem;
    gap: 1.5rem;
}


/* --- Brand / Logo ---------------------------------------------------------- */

.app-nav__brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}

/* Three-bar logo mark */
.app-logo-mark {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 22px;
    flex-shrink: 0;
}

.app-logo-mark__bar {
    display: block;
    height: 4px;
    border-radius: 2px;
}

.app-logo-mark__bar--top,
.app-logo-mark__bar--bot {
    background-color: #D6EAF8; /* sky */
    width: 100%;
}

.app-logo-mark__bar--mid {
    background-color: #2ECC71; /* green */
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
}

.app-logo-mark__pip {
    position: absolute;
    right: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #FF8C00; /* orange */
}

/* Wordmark */
.app-nav__wordmark {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1;
    color: #FFFFFF;
    text-decoration: none;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.app-nav__wordmark:hover { color: #D6EAF8; }

.app-nav__wordmark-accent {
    color: #2ECC71;
}


/* --- Global nav links ------------------------------------------------------ */

.app-nav__links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.app-nav__link {
    font-family: 'Open Sans', 'Trebuchet MS', Arial, sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #D6EAF8; /* sky */
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    transition: color 150ms ease, background-color 150ms ease;
    white-space: nowrap;
}

.app-nav__link:hover {
    color: #FFFFFF;
    background-color: rgba(214, 234, 248, 0.10);
}

.app-nav__link.is-active {
    color: #2ECC71;
    background-color: rgba(46, 204, 113, 0.10);
}


/* --- User area ------------------------------------------------------------- */

.app-nav__user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
}

.app-nav__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #156BA5; /* mid-blue */
    color: #FFFFFF;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border: none;
    cursor: pointer;
    transition: background-color 150ms ease, box-shadow 150ms ease;
    flex-shrink: 0;
}

.app-nav__avatar:hover {
    background-color: #2ECC71;
    color: #0B3D6B;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.25);
}

.app-nav__logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    color: #D6EAF8;
    text-decoration: none;
    border-radius: 4px;
    transition: color 150ms ease, background-color 150ms ease;
}

.app-nav__logout:hover {
    color: #FF8C00;
    background-color: rgba(255, 140, 0, 0.12);
}


/* =============================================================================
   APP BODY — sidebar + main content
   ============================================================================= */

.app-body {
    display: flex;
    padding-top: var(--app-nav-height);
    min-height: 100vh;
}

body.has-test-banner .app-body {
    padding-top: calc(var(--app-nav-height) + var(--app-banner-height));
}


/* =============================================================================
   SIDEBAR
   ============================================================================= */

.app-sidebar {
    position: fixed;
    top: var(--app-nav-height);
    left: 0;
    bottom: 0;
    width: var(--app-sidebar-width);
    background-color: var(--app-sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    padding: 0.75rem 0 1.5rem;

    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(214, 234, 248, 0.2) transparent;
}

body.has-test-banner .app-sidebar {
    top: calc(var(--app-nav-height) + var(--app-banner-height));
}

.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb { background-color: rgba(214, 234, 248, 0.2); border-radius: 2px; }


/* --- Sidebar nav list ------------------------------------------------------ */

.app-sidebar__nav {
    list-style: none;
    padding: 0 0 0 10px;
    margin: 0;
}

.app-sidebar__nav li {
    padding: 0;
    margin: 0;
}

/* Group label */
.app-sidebar__group-label {
    padding: 1.25rem 1.125rem 0.375rem;
    pointer-events: none;
}

.app-sidebar__group-label span {
    font-family: 'Open Sans', sans-serif;
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(214, 234, 248, 0.45);
}

/* Nav link */
.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5625rem 1.125rem;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.8125rem;
    font-weight: 400;
    color: rgba(214, 234, 248, 0.8);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 150ms ease,
                background-color 150ms ease,
                border-color 150ms ease;
    white-space: nowrap;
    min-height: 2.25rem;
}

.app-sidebar__link:hover {
    color: #FFFFFF;
    background-color: var(--app-sidebar-hover);
    border-left-color: rgba(214, 234, 248, 0.25);
}

.app-sidebar__link.is-active {
    color: #2ECC71;
    background-color: var(--app-sidebar-active-bg);
    border-left-color: var(--app-sidebar-active-border);
    font-weight: 600;
}

.app-sidebar__icon {
    width: 1rem;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 150ms ease;
}

.app-sidebar__link:hover .app-sidebar__icon,
.app-sidebar__link.is-active .app-sidebar__icon {
    opacity: 1;
}

/* Divider within sidebar */
.app-sidebar__divider {
    border: none;
    border-top: 1px solid rgba(214, 234, 248, 0.12);
    margin: 0.75rem 1.125rem;
}


/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */

.app-main {
    flex: 1;
    margin-left: var(--app-sidebar-width);
    min-height: 100vh;
    background-color: var(--app-main-bg);
    outline: none; /* tabindex="-1" focus target — suppress ring */
}

.app-main__inner {
    padding: 25px 2.5rem;
    max-width: 100%;
}


/* Unauthenticated / login layout — no sidebar, centered */
.app-main--centered {
    margin-left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}


/* =============================================================================
   MOBILE SIDEBAR TOGGLE BUTTON
   Hidden on desktop, visible on mobile — uses the logo mark as the icon.
   ============================================================================= */

/* Hide the desktop-only logo mark on mobile (toggle button replaces it) */
@media (max-width: 768px) {
    .app-logo-mark--desktop { display: none; }
}

.app-nav__sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 4px;
    margin-right: 0.5rem;
    flex-shrink: 0;
    transition: background-color 150ms ease;
}

.app-nav__sidebar-toggle:hover {
    background-color: rgba(214, 234, 248, 0.10);
}

.app-nav__sidebar-toggle:focus-visible {
    outline: 2px solid #2ECC71;
    outline-offset: 2px;
}


/* =============================================================================
   SIDEBAR OVERLAY — shown on mobile when sidebar is open
   ============================================================================= */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 31, 56, 0.65);
    z-index: 140;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.is-visible {
    display: block;
}


/* =============================================================================
   RESPONSIVE — MOBILE
   ============================================================================= */

@media (max-width: 768px) {

    /* Show the toggle button */
    .app-nav__sidebar-toggle {
        display: flex;
    }

    /* Hide top nav links to save space */
    .app-nav__links {
        display: none;
    }

    /* Sidebar slides off-screen by default */
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 150;
        /* Ensure it sits above the overlay */
        box-shadow: none;
    }

    /* Sidebar slides in when open */
    .app-sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(6, 31, 56, 0.5);
    }

    /* Main content fills full width */
    .app-main {
        margin-left: 0;
    }

    .app-main__inner {
        padding: 20px 1.25rem;
    }
}


/* =============================================================================
   RESPONSIVE — TABLET (≤ 900px): collapse sidebar to icon strip
   ============================================================================= */

@media (max-width: 900px) {
    :root {
        --app-sidebar-width: 60px;
    }

    .app-sidebar__group-label,
    .app-sidebar__link span:not(.app-sidebar__icon) {
        display: none;
    }

    .app-sidebar__link {
        justify-content: center;
        padding: 0.625rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .app-sidebar__link.is-active {
        border-left: none;
        border-bottom-color: var(--app-sidebar-active-border);
    }

    .app-sidebar__icon {
        font-size: 1.125rem;
        width: auto;
    }

    .app-sidebar__divider {
        margin: 0.5rem 0.5rem;
    }

    .app-main__inner {
        padding: 1.5rem;
    }
}


/* =============================================================================
   RESPONSIVE — MOBILE (≤ 480px): hide sidebar entirely
   ============================================================================= */

@media (max-width: 480px) {
    .app-sidebar {
        display: none;
    }

    .app-sidebar.is-open {
        display: block;
        width: 260px;
    }

    /* Undo tablet icon-strip overrides — show full labels in mobile flyout */
    .app-sidebar.is-open .app-sidebar__group-label,
    .app-sidebar.is-open .app-sidebar__link span:not(.app-sidebar__icon) {
        display: revert;
    }

    .app-sidebar.is-open .app-sidebar__link {
        justify-content: flex-start;
        padding: 0.55rem 1rem 0.55rem 0.75rem;
        border-left: 3px solid transparent;
        border-bottom: none;
    }

    .app-sidebar.is-open .app-sidebar__link.is-active {
        border-left-color: var(--app-sidebar-active-border);
        border-bottom: none;
    }

    .app-sidebar.is-open .app-sidebar__icon {
        font-size: 0.875rem;
        width: 1rem;
        color: #fff;
        opacity: 0.75;
    }

    .app-sidebar.is-open .app-sidebar__link:hover .app-sidebar__icon,
    .app-sidebar.is-open .app-sidebar__link.is-active .app-sidebar__icon {
        opacity: 1;
    }

    .app-main {
        margin-left: 0;
    }

    .app-nav__links {
        display: none;
    }

    .app-main__inner {
        padding: 1rem;
    }
}


/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 420px;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(11, 61, 107, 0.18);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    animation: toast-in 250ms ease forwards;
}

.toast--hiding {
    animation: toast-out 400ms ease forwards;
}

.toast--error {
    background-color: #fff3e0;
    border-left: 4px solid #FF8C00;
    color: #7a4200;
}

.toast--success {
    background-color: #e8fbf0;
    border-left: 4px solid #2ECC71;
    color: #1a5c35;
}

.toast--info {
    background-color: #d6eaf8;
    border-left: 4px solid #156BA5;
    color: #0b3d6b;
}

.toast__icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.toast__message {
    flex: 1;
}

.toast__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    font-size: 0.875rem;
    opacity: 0.5;
    color: inherit;
    flex-shrink: 0;
    transition: opacity 150ms ease;
}

.toast__close:hover {
    opacity: 1;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(0.75rem); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(0.75rem); }
}

/* =============================================================================
   PAGINATION
   ============================================================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pagination__info {
    font-size: 0.8125rem;
    color: #647D92;
}


.pagination__controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination__ellipsis {
    padding: 0 0.25rem;
    color: #647D92;
    font-size: 0.875rem;
}

.btn--sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8125rem;
    min-width: 2rem;
}

.btn--ghost {
    background: transparent;
    color: var(--color-text, #374151);
    border: 1px solid var(--color-border, #e5e7eb);
}

.btn--ghost:hover {
    background: var(--color-bg-subtle, #f9fafb);
}

/* =============================================================================
   LIST SEARCH BAR
   ============================================================================= */

.list-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.list-search__field {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.list-search__icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #647D92;
    font-size: 0.875rem;
    pointer-events: none;
}

/* input[type="search"] in main.css has specificity (0,1,1); match it here */
input.list-search__input {
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

/* Remove WebKit's built-in search-field cancel button, which can shift text */
input.list-search__input::-webkit-search-decoration,
input.list-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* =============================================================================
   SORTABLE COLUMN HEADERS
   ============================================================================= */

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
}

.sort-link:hover {
    color: var(--color-primary, #2ecc71);
}

.sort-icon {
    font-size: 0.75rem;
}

.sort-icon--idle {
    opacity: 0.35;
}

.sort-icon--active {
    color: var(--color-primary, #2ecc71);
    opacity: 1;
}

/* =============================================================================
   ACCOUNT DETAIL LAYOUT — left: related panels, right: account info
   ============================================================================= */

.account-detail-layout {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 1.5rem;
    align-items: start;
}

.account-detail-layout__related {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.account-detail-layout__info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Related cards */
.related-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.related-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
}

.related-card__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1.25rem;
    color: #647D92;
    font-size: 0.875rem;
    text-align: center;
}

.related-card__empty i {
    font-size: 1.5rem;
    opacity: 0.4;
}

/* Drag handle */
.related-card__drag-handle {
    cursor: grab;
    color: #647D92;
    font-size: 0.8rem;
    margin-right: 0.25rem;
    transition: color 150ms ease;
}

.related-card__drag-handle:hover {
    color: var(--color-text, #374151);
}

/* Dragging state */
[data-tile].is-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

/* Drop target indicator */
[data-tile].drag-over {
    outline: 2px solid var(--color-primary, #2ecc71);
    outline-offset: 2px;
}

@media (max-width: 1024px) {
    .account-detail-layout {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   DETAIL LIST — field label / value pairs
   ============================================================================= */

.detail-list {
    margin: 0 0 0.25rem;
    padding: 0;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    overflow: hidden;
}

.detail-list__row {
    display: grid;
    grid-template-columns: 10rem 1fr;
    align-items: baseline;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.detail-list__row:last-child {
    border-bottom: none;
}

.detail-list__row dt {
    padding: 0.55rem 0.875rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text, #111827);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--color-bg-subtle, #f9fafb);
    border-right: 1px solid var(--color-border, #e5e7eb);
}

.detail-list__row dd {
    padding: 0.55rem 0.875rem;
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text, #111827);
    word-break: break-word;
}

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

.detail-list__row--block dt {
    border-right: none;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

/* Section labels that divide groups of fields */
.detail-section-label {
    margin: 1.25rem 0 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #647D92;
}

.profile-card > .detail-section-label:first-child {
    margin-top: 0;
}

.detail-description {
    font-size: 0.9rem;
    color: var(--color-text, #111827);
    line-height: 1.6;
    margin: 0 0 0.25rem;
}

/* Edit mode field groups */
.edit-group {
    background: var(--color-bg-subtle, #f9fafb);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.25rem;
}

/* =============================================================================
   ACCOUNT LOOKUP — inline typeahead for linking contacts to accounts
   ============================================================================= */

.account-lookup {
    position: relative;
}

.account-lookup__input {
    width: 100%;
}

.account-lookup__results {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(6, 31, 56, 0.12);
    max-height: 220px;
    overflow-y: auto;
}

.account-lookup__option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text, #111827);
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.account-lookup__option:last-child {
    border-bottom: none;
}

.account-lookup__option:hover,
.account-lookup__option.is-active {
    background: var(--app-sidebar-active-bg, rgba(46, 204, 113, 0.10));
    color: var(--color-navy-deep, #061F38);
}

.account-lookup__empty {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #647D92;
    font-style: italic;
}

/* Contact Lookup typeahead — mirrors account-lookup */
.contact-lookup {
    position: relative;
}

.contact-lookup__input {
    width: 100%;
}

.contact-lookup__results {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
}

.contact-lookup__option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.contact-lookup__option:last-child {
    border-bottom: none;
}

.contact-lookup__option:hover,
.contact-lookup__option.is-active {
    background: var(--app-sidebar-active-bg, rgba(46, 204, 113, 0.10));
    color: var(--color-navy-deep, #061F38);
}

.contact-lookup__empty {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #647D92;
    font-style: italic;
}

/* =============================================================================
   OPPORTUNITY STAGE PROGRESS BAR
   ============================================================================= */

.stage-progress {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.875rem 1.25rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.stage-progress::-webkit-scrollbar { display: none; }

/* Individual step */
.stage-progress__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    min-width: 72px;
}

/* Circle node */
.stage-progress__node {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid var(--color-border, #e5e7eb);
    background: var(--color-bg-subtle, #f9fafb);
    color: #647D92;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

/* Label under node */
.stage-progress__label {
    font-size: 0.7rem;
    font-weight: 500;
    color: #647D92;
    text-align: center;
    white-space: nowrap;
    transition: color 0.2s;
}

/* Connector line between steps */
.stage-progress__connector {
    flex: 1;
    height: 2px;
    background: var(--color-border, #e5e7eb);
    margin-bottom: 1.4rem; /* align with node centers */
    min-width: 1rem;
    transition: background 0.2s;
}

/* Completed step */
.stage-progress__step.is-done .stage-progress__node {
    background: var(--color-primary, #2ecc71);
    border-color: var(--color-primary, #2ecc71);
    color: #fff;
}
.stage-progress__step.is-done .stage-progress__label {
    color: var(--color-primary, #2ecc71);
    font-weight: 600;
}
.stage-progress__connector.is-done {
    background: var(--color-primary, #2ecc71);
}

/* Active (current) step */
.stage-progress__step.is-active .stage-progress__node {
    background: var(--color-navy-deep, #061F38);
    border-color: var(--color-primary, #2ecc71);
    color: var(--color-primary, #2ecc71);
    box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.15);
}
.stage-progress__step.is-active .stage-progress__label {
    color: var(--color-navy-deep, #061F38);
    font-weight: 700;
}

/* Closed Lost state */
.stage-progress--lost .stage-progress__lost {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: auto;
    color: #ef4444;
    font-weight: 700;
    font-size: 1rem;
}
.stage-progress--lost .stage-progress__lost i {
    font-size: 1.25rem;
}

/* =============================================================================
   OPPORTUNITY DETAIL LAYOUT — 2/3 line items | 1/3 detail
   ============================================================================= */

.opp-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.opp-layout__detail {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.opp-layout__line-items {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Mobile: tabs */
/* Tab bar — hidden on desktop */
.opp-tab-bar {
    display: none;
}

@media (max-width: 1024px) {
    .opp-layout {
        display: block;
    }

    .opp-tab-bar {
        display: flex;
        border-bottom: 2px solid var(--color-border, #e5e7eb);
        margin-bottom: 1.25rem;
    }

    .opp-tab-bar__btn {
        flex: 1;
        padding: 0.6rem 0.5rem;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        margin-bottom: -2px;
        font-size: 0.9rem;
        font-weight: 500;
        color: #647D92;
        cursor: pointer;
        transition: color 0.15s, border-color 0.15s;
    }

    .opp-tab-bar__btn.is-active {
        color: var(--color-primary, #2ecc71);
        border-bottom-color: var(--color-primary, #2ecc71);
    }

    /* Hide both panels by default; show only the active one */
    .opp-layout__line-items,
    .opp-layout__detail {
        display: none;
    }

    .opp-layout__line-items.is-active,
    .opp-layout__detail.is-active {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }
}

/* Line items table */
.text-right {
    text-align: right;
}

.li-edit-row > td {
    background: var(--color-ice, #F0F7FF);
    border-top: 2px solid var(--color-primary, #2ECC71);
    border-bottom: 2px solid var(--color-primary, #2ECC71);
    padding: 0;
}

.li-edit-cell {
    padding: 1rem 1.25rem;
}

.li-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

.line-items-total td {
    border-top: 2px solid var(--color-border, #e5e7eb);
    padding-top: 0.6rem;
}

.line-item__name {
    font-weight: 500;
}

.line-item__sub {
    display: block;
    font-size: var(--fs-ui-label, 0.75rem);
    color: #647D92;
    margin-top: 0.1rem;
}

/* =============================================================================
   PRODUCT Lookup typeahead
   ============================================================================= */

.product-lookup {
    position: relative;
}

.product-lookup__input {
    width: 100%;
}

.product-lookup__results {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
}

.product-lookup__option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-lookup__option:last-child {
    border-bottom: none;
}

.product-lookup__option:hover,
.product-lookup__option.is-active {
    background: var(--app-sidebar-active-bg, rgba(46, 204, 113, 0.10));
    color: var(--color-navy-deep, #061F38);
}

.product-lookup__name {
    flex: 1;
}

.product-lookup__sku {
    font-size: 0.75rem;
    color: #647D92;
    font-family: monospace;
}

.product-lookup__price {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary, #2ecc71);
    margin-left: auto;
}

.product-lookup__empty {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #647D92;
    font-style: italic;
}

/* =============================================================================
   DASHBOARD — stat link + sub-value + three-column panels
   ============================================================================= */

/* Stat tile as a link */
a.dash-stat--link {
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
    cursor: pointer;
}
a.dash-stat--link:hover {
    box-shadow: 0 4px 18px rgba(46, 204, 113, 0.18);
    transform: translateY(-1px);
}

.dash-stat__sub {
    font-size: 0.75rem;
    color: #647D92;
    font-weight: 500;
    margin-top: 0.1rem;
}

/* Three-column panel row */
.dash-panels--three {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
    .dash-panels--three {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   DASHBOARD WIDGET LIST — shared row list for Contacts / Deals / Leads tiles
   ============================================================================= */

.dash-widget-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-widget-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.dash-widget-list__item:last-child {
    border-bottom: none;
}

.dash-widget-list__main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.dash-widget-list__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-navy-deep, #061F38);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-widget-list__name:hover {
    color: var(--color-primary, #2ecc71);
}

.dash-widget-list__sub {
    font-size: 0.75rem;
    color: #647D92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-widget-list__right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    flex-shrink: 0;
}

.dash-widget-list__amount {
    font-size: 0.75rem;
    font-weight: 600;
    color: #647D92;
}

.dash-widget-footer {
    padding-top: 0.75rem;
    font-size: 0.8rem;
    text-align: right;
}
.dash-widget-footer a {
    color: var(--color-primary, #2ecc71);
    text-decoration: none;
    font-weight: 600;
}
.dash-widget-footer a:hover {
    text-decoration: underline;
}

/* =============================================================================
   WIDGET — Account Performance (CLV + Pipeline)
   ============================================================================= */

/* Two stat blocks side by side */
.perf-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.perf-stat {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem;
    border-radius: 8px;
    background: var(--color-bg-subtle, #f9fafb);
    border: 1px solid var(--color-border, #e5e7eb);
}

.perf-stat__icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.perf-stat--clv .perf-stat__icon {
    background: rgba(46, 204, 113, 0.15);
    color: var(--color-primary, #2ecc71);
}

.perf-stat--pipeline .perf-stat__icon {
    background: rgba(52, 152, 219, 0.15);
    color: #3498db;
}

.perf-stat__body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.perf-stat__label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #647D92;
}

.perf-stat__value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-navy-deep, #061F38);
    line-height: 1.2;
    white-space: nowrap;
}

.perf-stat--clv .perf-stat__value    { color: var(--color-primary, #2ecc71); }
.perf-stat--pipeline .perf-stat__value { color: #3498db; }

.perf-stat__sub {
    font-size: 0.7rem;
    color: #647D92;
}

/* Proportion bar */
.perf-bar {
    display: flex;
    height: 8px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--color-border, #e5e7eb);
    margin-bottom: 0.4rem;
}

.perf-bar__segment {
    height: 100%;
    transition: width 0.4s ease;
}

.perf-bar__segment--won {
    background: var(--color-primary, #2ecc71);
}

.perf-bar__segment--pipeline {
    background: #3498db;
}

.perf-bar__legend {
    display: flex;
    gap: 1rem;
    font-size: 0.7rem;
    color: #647D92;
    margin-bottom: 0.25rem;
}

.perf-bar__legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.perf-bar__legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.perf-bar__legend-item--won      .perf-bar__legend-dot { background: var(--color-primary, #2ecc71); }
.perf-bar__legend-item--pipeline .perf-bar__legend-dot { background: #3498db; }

/* Open deals by stage breakdown */
.perf-stage-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.perf-stage-list__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    font-size: 0.8rem;
}

.perf-stage-list__item:last-child {
    border-bottom: none;
}

.perf-stage-list__count {
    color: #647D92;
    flex: 1;
}

.perf-stage-list__value {
    font-weight: 600;
    color: var(--color-navy-deep, #061F38);
}

/* Collapse to single column on narrow tiles */
@media (max-width: 480px) {
    .perf-stats {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   WIDGET — Account Opportunities list
   ============================================================================= */

.opp-widget-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.opp-widget-list__item {
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.opp-widget-list__item:last-child {
    border-bottom: none;
}

.opp-widget-list__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.opp-widget-list__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-navy-deep, #061F38);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.opp-widget-list__name:hover {
    color: var(--color-primary, #2ecc71);
}

.opp-widget-list__meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.775rem;
    color: #647D92;
}

.opp-widget-list__amount {
    font-weight: 700;
    color: var(--color-navy-deep, #061F38);
}

.opp-widget-list__prob {
    color: #647D92;
}

.opp-widget-list__date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.opp-widget-list__date--overdue {
    color: #ef4444;
}

.opp-widget-list__overdue-label {
    font-size: 0.68rem;
    font-weight: 700;
    background: #fef2f2;
    color: #ef4444;
    border-radius: 4px;
    padding: 0 0.3rem;
    line-height: 1.5;
}

/* =============================================================================
   WIDGET — Account Contacts list
   ============================================================================= */

.widget-contact-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.widget-contact-list__item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.widget-contact-list__item:last-child {
    border-bottom: none;
}

.widget-contact-list__main {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.widget-contact-list__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-navy-deep, #061F38);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-contact-list__name:hover {
    text-decoration: underline;
    color: var(--color-green, #2ECC71);
}

.widget-contact-list__job {
    font-size: 0.8rem;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-contact-list__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.widget-contact-list__email {
    font-size: 0.8rem;
    color: #374151;
    text-decoration: none;
    white-space: nowrap;
}

.widget-contact-list__email:hover {
    text-decoration: underline;
}

.widget-contact-list__stage {
    font-size: 0.7rem;
}

.widget-contact-list__footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
    background: var(--color-bg-subtle, #f9fafb);
    border-radius: 0 0 8px 8px;
}

.widget-contact-list__all {
    font-size: 0.8rem;
    color: #374151;
    text-decoration: none;
}

.widget-contact-list__all:hover {
    color: var(--color-navy-deep, #061F38);
    text-decoration: underline;
}

/* Lifecycle stage badge variants */
.badge--neutral  { background: #e5e7eb; color: #374151; }
.badge--warning  { background: #fef3c7; color: #92400e; }
.badge--success  { background: #d1fae5; color: #065f46; }
.badge--purple   { background: #ede9fe; color: #5b21b6; }

/* =============================================================================
   LOCATIONS WIDGET
   ============================================================================= */

/* ── List ─────────────────────────────────────────────────────────────────── */
.loc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.loc-list__item {
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.loc-list__item:last-child {
    border-bottom: none;
}

.loc-list__display {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    transition: background 120ms ease;
}

.loc-list__display:hover {
    background: var(--color-ice, #f0f4f8);
}

.loc-list__main {
    flex: 1;
    min-width: 0;
}

.loc-list__name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-navy, #0B3D6B);
    margin-bottom: 0.2rem;
}

.loc-list__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.loc-list__addr {
    margin: 0;
    font-size: 0.8125rem;
    color: #647D92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loc-list__actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* ── Edit panel ───────────────────────────────────────────────────────────── */
.loc-list__edit-panel {
    background: var(--color-ice, #f0f4f8);
    border-top: 2px solid var(--color-primary, #0B3D6B);
    border-bottom: 2px solid var(--color-primary, #0B3D6B);
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.loc-form {
    padding: 0;
}

.loc-form__body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.loc-form__section-head {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #647D92;
    padding: 0.75rem 0 0.4rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    margin-bottom: 0.5rem;
}

.loc-form__section-head--toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    user-select: none;
}

.loc-form__section-head--toggle::-webkit-details-marker { display: none; }

.loc-form__chevron {
    font-size: 0.65rem;
    transition: transform 200ms ease;
}

details[open] .loc-form__chevron {
    transform: rotate(180deg);
}

.loc-form__details {
    margin-bottom: 0;
}

.loc-form__details > summary {
    margin-bottom: 0;
}

.loc-form__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

.loc-form__span2 {
    grid-column: 1 / -1;
}

.loc-form__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
    background: var(--color-white, #fff);
}

/* Add-panel divider */
#loc-add-wrap .divider--green {
    margin: 0;
}

/* form-check — reuse pattern */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--color-primary, #0B3D6B);
}
