/* ==========================================================================
   bware.theme.css
   Single source of truth theme + layout + component tweaks
   Load LAST (after site.bundle.css and app.css)
   ========================================================================= */

/* -----------------------------
   0) Design tokens
------------------------------ */
:root {
    /* Brand */
    --bware-blue: var(--bware-primary);
    --bware-ink: var(--bware-text);
    /* Surfaces */
    --bware-surface: #ffffff;
    --bware-surface-alt: var(--bware-alt-bg);
    --bware-surface-soft: rgba(0,0,0,.02);
    /* Text */
    --bware-text: var(--bware-ink);
    --bware-muted: rgba(0,0,0,.55);
    /* Borders / radii / shadows */
    --bware-border-color: var(--bware-border);
    --bware-border: 1px solid var(--bware-border-color);
    --bware-radius: 10px;
    --bware-radius-sm: 8px;
    --bware-shadow: 0 10px 26px rgba(0,0,0,.08);
    --bware-shadow-sm: 0 6px 16px rgba(0,0,0,.07);
    /* Spacing scale */
    --bware-gap-1: 6px;
    --bware-gap-2: 10px;
    --bware-gap-3: 14px;
    --bware-gap-4: 18px;
    /* Typography */
    --bware-font: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    --bware-font-size: 0.95rem;
    --bware-line: 1.35;
    /* Controls */
    --bware-control-radius: 8px;
    --bware-focus: 0 0 0 .2rem rgba(34, 101, 154, .18);
    /* Navbar + tabs metrics */
    --bware-nav-h: 56px;
    --bware-tab-minh: 34px;
}

/* -----------------------------
   1) Global base + typography
------------------------------ */
html, body {
    font-family: var(--bware-font) !important;
    font-size: var(--bware-font-size);
    line-height: var(--bware-line);
    color: var(--bware-text);
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

a, .btn-link {
    color: var(--bware-blue);
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.35rem;
}

h3 {
    font-size: 1.15rem;
}

.form-control, .form-select, .btn {
    border-radius: var(--bware-control-radius);
}

    .form-control:focus, .form-select:focus, .btn:focus {
        box-shadow: var(--bware-focus);
    }

.bware-action-notice {
    padding: .65rem .75rem;
    border: 1px solid var(--bware-border-color, var(--bs-border-color));
    border-left: .25rem solid var(--bware-primary, var(--bs-primary));
    border-radius: var(--bware-control-radius);
    background: var(--bware-surface-2, var(--bs-tertiary-bg));
    color: var(--bware-text, var(--bs-body-color));
}

    /* Normalize Bootstrap focus ring */
    .btn:focus, .btn:active:focus,
    .btn-link.nav-link:focus,
    .form-control:focus, .form-check-input:focus {
        box-shadow: var(--bware-focus) !important;
    }

/* Prevent Bootstrap from highlighting clicked action buttons */
.addline-btn:focus,
.addline-btn:active,
.addline-btn:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
    color: inherit !important;
}

.addline-btn.btn-outline-primary:active,
.addline-btn.btn-outline-primary.active,
.addline-btn.btn-outline-secondary:active,
.addline-btn.btn-outline-secondary.active {
    background-color: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
}

/* -----------------------------
   2) App shell helpers
------------------------------ */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    flex: 0 0 auto;
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* -----------------------------
   3) Navbar (BWARE) – hard normalize
   Fixes: icon top:-1px, baseline wobble, per-item padding anomalies
------------------------------ */
.bware-navbar.navbar {
    min-height: var(--bware-nav-h);
    padding-top: 0;
    padding-bottom: 0;
}

.bware-navbar > .container-fluid {
    min-height: var(--bware-nav-h);
    align-items: center;
}

/* Kill any weird per-item padding on li from site.bundle.css */
.bware-navbar .navbar-nav .nav-item {
    padding: 0 !important;
    margin: 0 !important;
}

/* Brand + links: consistent height + padding */
.bware-navbar .navbar-brand,
.bware-navbar .navbar-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    height: var(--bware-nav-h);
    padding: 0 1rem !important;
    line-height: 1 !important;
    white-space: nowrap;
    box-sizing: border-box;
}

/* Neutralize bootstrap-icons defaults (width/height/top/margin-right) only in navbar */
.bware-navbar .bi {
    position: static !important;
    top: auto !important;
    width: 1em !important;
    height: 1em !important;
    margin-right: 0 !important; /* use flex gap instead */
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    vertical-align: middle !important;
    opacity: .9;
}

.bware-navbar .navbar-nav .nav-link.active {
    font-weight: 650;
    color: var(--bware-surface);
}

@media (min-width: 1200px) {
    .bware-navbar .navbar-collapse,
    .bware-navbar .navbar-nav {
        align-items: center;
    }

    .bware-navbar .navbar-nav.ms-auto {
        gap: .25rem;
    }

    .bware-navbar .navbar-nav.ms-auto > .nav-item {
        display: flex;
        align-items: center;
        min-height: var(--bware-nav-h);
    }
}

@media (max-width: 1199.98px) {
    .bware-navbar .navbar-toggler {
        display: block;
        flex: 0 0 auto;
        margin-left: auto;
    }

    .bware-navbar .navbar-collapse {
        width: 100%;
        max-height: calc(100dvh - var(--bware-nav-h));
        overflow-y: auto;
        scrollbar-gutter: stable;
    }

    .bware-navbar .navbar-collapse.show {
        display: block;
    }

    .bware-navbar .navbar-nav {
        width: 100%;
    }
}

/* -----------------------------
   4) Tabs (DROP-IN)
   Fixes: last tab kicked, baseline wobble, mixed <a>/<button>
------------------------------ */
.bware-tabs-host {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.bware-tabs.nav-tabs {
    border-bottom: 1px solid #dee2e6;
    gap: 6px;
    padding: 0;
    margin: 0;
}

/* Stop any Bootstrap .nav-item padding rules leaking in */
.bware-tabs .nav-item,
.bware-tabs > li {
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
}

/* Applies to <button class="nav-link"> and <a class="nav-link"> */
.bware-tabs .nav-link {
    appearance: none;
    border: 1px solid #dee2e6;
    border-bottom: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--bware-tab-minh);
    padding: 0 14px;
    margin: 0 !important;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-weight: 600;
    font-size: 0.90rem;
    line-height: 1 !important;
    white-space: nowrap;
    background: var(--bware-surface-alt);
    color: var(--bware-blue);
}

    .bware-tabs .nav-link:hover {
        background: #eaeaea;
        color: var(--bware-blue);
    }

    /* Seam fix without height jump */
    .bware-tabs .nav-link.active {
        background: var(--bware-blue) !important;
        color: var(--bware-surface) !important;
        border-color: var(--bware-blue) !important;
        margin-bottom: -1px;
    }

.tab-panel {
    border: 1px solid #dee2e6;
    border-top: none;
    padding: 0.75rem;
    background: var(--bware-surface);
    font-size: 0.95rem;
}

.bware-tab-panel {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* -----------------------------
   5) CRM layout
------------------------------ */
.crm-shell {
    height: calc(100vh - var(--bware-nav-h));
    padding-top: .5rem;
    overflow: hidden;
}

    .crm-shell .crm-row {
        height: 100%;
        min-height: 0;
    }

.crm-left {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    min-width: 300px;
    max-width: 300px;
}

.crm-right {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.crm-mobile-toolbar,
.crm-drawer-header,
.crm-drawer-backdrop {
    display: none;
}

.tab-panel-wrap {
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.listbox-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.list-group-item {
    font-size: 0.90rem;
    padding: 0.50rem 0.75rem;
}

    .list-group-item:nth-child(odd):not(.selected) {
        background-color: var(--bware-surface-alt);
    }

    .list-group-item.selected {
        background-color: var(--bware-blue) !important;
        color: var(--bware-surface) !important;
        font-weight: 600;
    }

        .list-group-item.selected .item-org-name,
        .list-group-item.selected .item-version,
        .list-group-item.selected .item-info,
        .list-group-item.selected .renew-past,
        .list-group-item.selected .renew-soon,
        .list-group-item.selected .renew-normal {
            color: var(--bware-surface) !important;
        }

.org-item {
    cursor: pointer;
}

.item-header {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.item-version {
    white-space: nowrap;
    opacity: .85;
}

.crm-organisation-status {
    flex: 0 0 auto;
    margin-top: .05rem;
    font-size: .67rem;
    line-height: 1.15;
}

.item-org-name {
    font-weight: 700;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-info {
    margin-top: 4px;
}

.renew-past {
    color: #d11;
}

.renew-soon {
    color: #c77700;
}

.renew-normal {
    color: #198754;
}

/* -----------------------------
   6) Details page layout + action bar
------------------------------ */
.details-shell {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.details-actionbar {
    padding: 8px 10px;
    border-bottom: 1px solid #dee2e6;
    background: var(--bware-surface);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex: 0 0 auto;
}

    /* Prevent sticky focus look in the action bar */
    .details-actionbar .btn:focus,
    .details-actionbar .btn:focus-visible {
        outline: none !important;
        box-shadow: none !important;
    }

.details-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    gap: 14px;
    padding: 14px;
}

.left-column,
.right-column {
    flex: 1;
    display: grid;
    gap: 10px;
    min-height: 0;
}

.left-column {
    grid-template-rows: 1.95fr 0.85fr;
}

.right-column {
    grid-template-rows: 1fr 1fr;
}

/* -----------------------------
   7) Cards
------------------------------ */
.card-item {
    border: var(--bware-border);
    border-radius: var(--bware-radius);
    background: var(--bware-surface);
    box-shadow: var(--bware-shadow-sm);
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--bware-border);
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,0));
    min-height: 36px;
}

.card-body {
    flex: 1;
    min-height: 0;
    padding: 10px 12px;     /* slightly tighter to reduce scrolling */
    overflow: auto;
}

.card-subtitle {
    font-size: .9rem;
    color: var(--bware-surface-2);
    font-weight: 500;
}

/* -----------------------------
   8) Forms density helpers
------------------------------ */
.bware-form-compact .form-label {
    font-size: .85rem;
    line-height: 1.1;
    margin-bottom: 0;
    color: var(--bware-muted);
}

.bware-form-compact .form-control,
.bware-form-compact .form-select,
.bware-form-compact .input-group-text {
    padding-top: .32rem;
    padding-bottom: .32rem;
}

    /* readonly should still read as readonly in both themes */
    .bware-form-compact .form-control[readonly] {
        background-color: var(--bware-surface-2);
        color: var(--bware-text);
    }

.bware-form-compact .row {
    row-gap: .35rem;
}

/* -----------------------------
   9) Buttons
------------------------------ */
.btn-bware-outline {
    border: 1px solid var(--bware-primary);
    color: var(--bware-primary);
    background: transparent; /* <-- was #fff */
}

    .btn-bware-outline:hover,
    .btn-bware-outline:active {
        background: rgba(34, 101, 154, 0.12) !important;
        color: var(--bware-primary) !important;
    }


html[data-theme="dark"] .btn-bware-outline {
    border-color: rgba(255,255,255,.16);
    color: var(--bware-text);
    background: rgba(255,255,255,.02);
}

    html[data-theme="dark"] .btn-bware-outline:hover {
        background: rgba(255,255,255,.06);
        border-color: rgba(255,255,255,.22);
    }

    /* Make the icons match text colour (bootstrap icons inherit, but some rules can override) */
    html[data-theme="dark"] .btn-bware-outline .bi {
        color: inherit;
    }

/* -----------------------------
   10) Tables: compact + softer headers
------------------------------ */
.bware-table-scroll {
    max-height: 350px;
    overflow: auto;
}

/* Tighter than table-sm */
.table.bware-table-compact > :not(caption) > * > * {
    padding: .35rem .55rem;
    font-size: .90rem;
    vertical-align: middle;
}

/* Softer header */
.bware-table-compact thead th,
.table.bware-table-compact thead th,
.table thead.table-light th {
    background: var(--bware-surface-2) !important;
    color: var(--bware-text) !important;
    border-bottom: 1px solid var(--bware-border) !important;
}


/* Lighter gridlines */
.table td, .table th {
    border-color: rgba(0,0,0,.08);
}

/* Hover */
.table-hover tbody tr:hover {
    background: rgba(34, 101, 154, .06);
}

/* -----------------------------
   11) Modal body sizing
------------------------------ */
.bware-modal-body {
    max-height: 75vh;
    overflow: auto;
}

/* -----------------------------
   12) Blazor error UI
------------------------------ */
#blazor-error-ui {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    padding: 0.75rem 1rem;
    background: #b32121;
    color: var(--bware-surface);
    font-size: 0.9rem;
    display: none;
}

    #blazor-error-ui .reload,
    #blazor-error-ui .dismiss {
        color: var(--bware-surface);
        font-weight: 700;
        margin-left: 0.75rem;
        text-decoration: underline;
        cursor: pointer;
    }

/* -----------------------------
   13) Optional: tighten container-fluid padding
------------------------------ */
@media (min-width: 1200px) {
    .container-fluid {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* -----------------------------
   14) Mobile: stack details columns
------------------------------ */
@media (max-width: 992px) {
    .crm-shell {
        position: relative;
    }

    .crm-mobile-toolbar {
        display: flex;
        align-items: center;
        padding: 6px 0 8px;
    }

    .crm-row {
        height: calc(100% - 42px) !important;
    }

    .crm-left {
        position: fixed;
        top: var(--bware-nav-h);
        bottom: 0;
        left: 0;
        z-index: 2050;
        width: min(360px, 90vw);
        min-width: 0;
        max-width: none;
        padding: 12px;
        background: var(--bware-surface);
        box-shadow: var(--bware-shadow);
        transform: translateX(-105%);
        transition: transform 160ms ease;
    }

    .crm-left.is-open {
        transform: translateX(0);
    }

    .crm-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 10px;
    }

    .crm-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .crm-drawer-backdrop {
        display: block;
        position: fixed;
        inset: var(--bware-nav-h) 0 0;
        z-index: 2040;
        width: 100%;
        border: 0;
        background: rgba(0,0,0,.4);
    }

    .crm-right {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-left: 0 !important;
    }

    .crm-right .bware-tabs-host,
    .crm-right .bware-tab-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .crm-right .bware-tabs {
        flex-wrap: nowrap;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
    }

    .crm-right .bware-tab-item {
        flex: 0 0 auto;
    }

    .details-content {
        flex-direction: column;
    }

    .left-column, .right-column {
        grid-template-rows: auto;
    }

    .details-content .card-body {
        padding: 10px 12px;
    }
}

/* ----------------------------------------------------------
   DETAILS PAGE — COMPACT VERTICAL MODE
   Reduces wasted space without looking cramped
---------------------------------------------------------- */

/* 1) Reduce vertical padding around entire details content area */
.details-content {
    padding: 10px 12px !important; /* was 14px */
}

/* 2) Tighten card body interior spacing */
.card-body {
    padding: 10px 12px !important; /* was 14px */
}

/* 3) Make the action bar slightly shorter */
.details-actionbar {
    padding: 6px 10px !important; /* was 8px 10px */
    border-bottom: none !important; /* remove the line above the cards */
    margin-bottom: 4px; /* tiny breathing room */
}

/* 4) Remove extra separator line above first card cluster */
.details-shell {
    border-top: none !important;
}

/* 5) Optional: reduce card header height slightly */
.card-header {
    padding: 8px 12px !important; /* was ~10px */
    min-height: 32px !important; /* was 36px */
}

/* ==========================================================================
   BWARE polish pack (1–7)
   Paste at VERY BOTTOM of bware.theme.css
   ========================================================================== */

/* (1) Softer, more “cloud” shadows + slightly calmer radius feel */
:root {
    --bware-shadow-sm: 0 4px 14px rgba(0,0,0,.06);
    --bware-shadow: 0 10px 26px rgba(0,0,0,.07);
}

/* (2) Table header text slightly smaller + lighter (less heavy) */
.table thead th,
.table thead.table-light th,
.table.bware-table-compact thead th,
.bware-table-compact thead th {
    font-size: .88rem;
    letter-spacing: .1px;
    color: var(--bware-text) !important;
    background: var(--bware-surface-2) !important;
    border-bottom: 1px solid var(--bware-border) !important;
}

/* Also calm row borders slightly */
.table td, .table th {
    border-color: var(--bware-border);
}

/* (3) Card titles a touch bolder + clearer hierarchy */
.card-header {
    font-weight: 600;
    font-size: .96rem;
}

    .card-header .card-subtitle {
        font-weight: 500;
        color: var(--bware-text);
    }

/* (4) Rounded scrollbars (Chrome/Edge/Safari) */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.18);
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,.75);
}

    *::-webkit-scrollbar-thumb:hover {
        background: rgba(0,0,0,.26);
    }

/* (5) Action bar button spacing + consistent height */
.details-actionbar {
    gap: 10px;
    padding: 10px 12px; /* slightly roomier but still compact */
}

    .details-actionbar .btn {
        min-height: 32px;
        padding: .32rem .62rem;
        border-radius: 10px; /* matches your modern feel */
    }

    .details-actionbar .bi {
        margin-right: .35rem !important;
    }

/* (6) Subtle hover “lift” on cards (very light, not annoying) */
.card-item {
    transition: box-shadow 120ms ease, border-color 120ms ease;
}

    .card-item:hover {
        box-shadow: 0 10px 24px rgba(0,0,0,.08);
        border-color: rgba(34, 101, 154, .18);
    }

/* (7) Flatten left navigation background so list items pop */
.crm-left {
    background: var(--bware-bg); /* keep clean */
    border-right: 1px solid rgba(0,0,0,.06);
}

    .crm-left .list-group {
        border: 0;
        border-radius: 0;
    }

    .crm-left .list-group-item {
        border-left: 0;
        border-right: 0;
    }

        .crm-left .list-group-item.selected {
            box-shadow: inset 3px 0 0 rgba(255,255,255,.55);
        }

/* Bonus micro-polish (safe): make form labels a touch calmer */
.bware-form-compact .form-label {
    font-size: .85rem;
    color: rgba(0,0,0,.62);
}
/* =======================================================================  
   SaaS Touch A  
   Selected org “accent rail” + modern SaaS highlighting  
   ======================================================================= */

.crm-left .list-group-item.selected {
    position: relative;
    background: rgba(34,101,154,.10) !important;
    color: var(--bware-blue) !important;
    font-weight: 700;
}

    /* Accent rail on the left */
    .crm-left .list-group-item.selected::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 5px;
        background: var(--bware-blue);
        border-top-left-radius: 6px;
        border-bottom-left-radius: 6px;
    }

    /* Ensure inner text also turns blue (but not white) */
    .crm-left .list-group-item.selected .item-org-name,
    .crm-left .list-group-item.selected .item-version,
    .crm-left .list-group-item.selected .item-info,
    .crm-left .list-group-item.selected .renew-past,
    .crm-left .list-group-item.selected .renew-soon,
    .crm-left .list-group-item.selected .renew-normal {
        color: var(--bware-blue) !important;
    }

/* Slightly softer hover for non-selected list items */
.crm-left .list-group-item:not(.selected):hover {
    background: rgba(0,0,0,.04);
}
/* =======================================================================
   A + Modern Tables (drop-in)
   - Softer headers, cleaner lines, better hover
   - Optional sticky header via .bware-sticky-head
   - Keeps Renew conditional colouring (renew-past/soon/normal)
   ======================================================================= */

/* --- Table container polish --- */
.table-responsive,
.bware-table-scroll {
    border-radius: var(--bware-radius);
}

/* If you use your own scroll wrapper, keep it looking like a card */
.bware-table-scroll {
    border: var(--bware-border);
    background: var(--bware-surface);
    box-shadow: var(--bware-shadow-sm);
    overflow: auto;
}

/* --- Base table look --- */
table.table {
    margin-bottom: 0; /* removes extra space that can cause “mystery” gaps */
}

.table.bware-table-compact,
.table.bware-table-modern {
    border-collapse: separate;
    border-spacing: 0;
}

/* --- Header: lighter, SaaS-style --- */
.table thead th,
.table .table-light th {
    background: var(--bware-surface-2) !important;
    color: rgba(0,0,0,.78);
    font-weight: 650;
    border-bottom: 1px solid rgba(0,0,0,.12) !important;
    padding-top: .45rem;
    padding-bottom: .45rem;
    white-space: nowrap;
}

/* Reduce heavy vertical gridlines (Bootstrap can look “Excel-like”) */
.table > :not(caption) > * > * {
    border-color: var(--bware-border);
}

/* --- Body cells: slightly tighter + cleaner --- */
.table.table-sm > :not(caption) > * > * {
    padding: .40rem .60rem; /* tighter than default table-sm */
    font-size: .90rem;
    vertical-align: middle;
}

/* If you’re using truncation, keep it crisp */
.table td.text-truncate {
    max-width: 1px; /* allows truncation to work with flex layouts */
}

/* --- Hover: subtle blue SaaS hover (not loud grey) --- */
.table-hover tbody tr:hover {
    background: rgba(34,101,154,.06) !important;
}

/* --- Optional zebra: very subtle (feel free to remove if you dislike) --- */
.table tbody tr:nth-child(even) {
    background: rgba(0,0,0,.012);
}

/* --- Sticky header (opt-in)
   Add class "bware-sticky-head" to table OR wrapper.
   Example: <div class="bware-table-scroll bware-sticky-head">...
*/
.bware-sticky-head thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

    /* If table is inside a card-body with padding, avoid header “peeking” edges */
    .bware-sticky-head thead th:first-child {
        border-top-left-radius: 10px;
    }

    .bware-sticky-head thead th:last-child {
        border-top-right-radius: 10px;
    }

/* --- Edit icon button (if you render it as a button/link)
   Keeps it compact and aligned nicely.
*/
.table .bware-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(34,101,154,.30);
    color: var(--bware-blue);
    background: var(--bware-bg);
    padding: 0;
}

    .table .bware-edit-btn:hover {
        background: rgba(34,101,154,.08);
    }

/* =======================================================================
   Keep / enhance conditional Renew colouring in org list
   (Does not override your existing classes; just polishes them)
   ======================================================================= */

.renew-past {
    color: #c92a2a;
    font-weight: 700;
}

.renew-soon {
    color: #b45309;
    font-weight: 700;
}

.renew-normal {
    color: #198754;
    font-weight: 700;
}

/* Make the Renew line slightly smaller + aligned */
.crm-left .item-info {
    font-size: .88rem;
    line-height: 1.2;
}
/* =======================================================================
   SaaS inputs + conditional date styling (drop-in)
   Applies ONLY to inputs you mark with .bware-input
   ======================================================================= */

:root {
    --bware-danger: #c92a2a;
    --bware-warning: #b45309;
    --bware-success: #198754;
    /* subtle tinted backgrounds */
    --bware-danger-bg: rgba(201,42,42,.08);
    --bware-warning-bg: rgba(180,83,9,.10);
    --bware-success-bg: rgba(25,135,84,.10);
}

/* Base “SaaS” control feel */
.bware-input.form-control,
.bware-input.form-select {
    border-radius: 10px;
    border-color: rgba(0,0,0,.15);
    background-clip: padding-box;
}

    /* Focus: consistent, not huge */
    .bware-input.form-control:focus,
    .bware-input.form-select:focus {
        border-color: rgba(34,101,154,.45);
        box-shadow: 0 0 0 .18rem rgba(34,101,154,.16);
    }

/* Keep select arrow looking clean */
.bware-input.form-select {
    padding-right: 2rem; /* gives arrow breathing room */
}

/* -----------------------------------------------------------------------
   Conditional highlight: wrap the FIELD container with renew-past/soon/normal
   Example:
     <div class="col-12 col-xl-6 renew-soon"> ... <InputDate class="... bware-input" />
   ----------------------------------------------------------------------- */

/* PAST (red) */
.renew-past .bware-input.form-control,
.renew-past .bware-input.form-select {
    border-color: rgba(201,42,42,.55);
    background: var(--bware-danger-bg);
}

    .renew-past .bware-input.form-control:focus,
    .renew-past .bware-input.form-select:focus {
        border-color: rgba(201,42,42,.75);
        box-shadow: 0 0 0 .18rem rgba(201,42,42,.18);
    }

/* SOON (amber) */
.renew-soon .bware-input.form-control,
.renew-soon .bware-input.form-select {
    border-color: rgba(180,83,9,.55);
    background: var(--bware-warning-bg);
}

    .renew-soon .bware-input.form-control:focus,
    .renew-soon .bware-input.form-select:focus {
        border-color: rgba(180,83,9,.75);
        box-shadow: 0 0 0 .18rem rgba(180,83,9,.18);
    }

/* NORMAL (green) */
.renew-normal .bware-input.form-control,
.renew-normal .bware-input.form-select {
    border-color: rgba(25,135,84,.55);
    background: var(--bware-success-bg);
}

    .renew-normal .bware-input.form-control:focus,
    .renew-normal .bware-input.form-select:focus {
        border-color: rgba(25,135,84,.75);
        box-shadow: 0 0 0 .18rem rgba(25,135,84,.18);
    }

/* Optional: make the label echo the same state slightly */
.renew-past label.form-label {
    color: rgba(201,42,42,.85);
}

.renew-soon label.form-label {
    color: rgba(180,83,9,.85);
}

.renew-normal label.form-label {
    color: rgba(25,135,84,.85);
}

/* Subscription Cost row: align Update with right-side field column */
.bware-cost-actions {
    display: flex;
    justify-content: flex-start; /* left-align within the right column */
}

@media (max-width: 1199.98px) {
    .bware-cost-actions {
        justify-content: flex-end; /* on smaller screens, keep it to the right */
        margin-top: 6px;
    }
}
.bware-sub-btn {
    margin-left: 0; /* ensures perfect left alignment */
}
/* =============================
   BWARE Modal (fixed overlay)
   Keeps underlying page layout untouched
============================= */

.bware-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.bware-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1990;
}

.bware-modal-dialog {
    width: 100%;
    max-width: 900px; /* default */
}

    .bware-modal-dialog.modal-sm {
        max-width: 420px;
    }

    .bware-modal-dialog.modal-md {
        max-width: 620px;
    }

    .bware-modal-dialog.modal-lg {
        max-width: 900px;
    }

    .bware-modal-dialog.modal-xl {
        max-width: 1140px;
    }

    .bware-modal-dialog.modal-crm-action {
        max-width: min(60rem, calc(100vw - 2rem));
    }

.bware-modal-dialog.is-draggable {
    will-change: transform;
}

.bware-modal-dialog.is-draggable .modal-header {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.bware-modal-dialog.is-draggable.is-dragging .modal-header {
    cursor: grabbing;
}

.bware-modal-dialog.is-draggable .modal-header button,
.bware-modal-dialog.is-draggable .modal-header a,
.bware-modal-dialog.is-draggable .modal-header input {
    cursor: default;
}

.bware-modal-content {
    background: var(--bware-surface);
    border-radius: var(--bware-radius);
    box-shadow: var(--bware-shadow);
    overflow: hidden;
}

.bware-modal-body {
    max-height: calc(100vh - 220px); /* header + footer + padding allowance */
    overflow: auto;
}

/* optional: subtle SaaS touch */
.bware-modal-content {
    border: 1px solid var(--bware-border);
}
/* Renew/Email/Phone/etc content inside BwareModal */
.bware-modal-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Summary bar (replaces alert-light look) */
.bware-summary-bar {
    border: 1px solid var(--bware-border);
    background: rgba(0,0,0,.02);
    border-radius: 10px;
    padding: 10px 12px;
}

/* Outer card */
.bware-summary-card {
    background: var(--bware-surface);
    border: 1px solid var(--bware-border);
    border-radius: 8px;
    padding: 12px 14px;
}

/* Title row inside card (Org + Version) */
.bware-summary-meta {
    display: flex;
    align-items: center;
    font-size: .85rem;
    color: var(--bware-muted);
    padding-bottom: 6px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--bware-border);
}

    .bware-summary-meta strong {
        color: var(--bware-text);
    }

/* Grid of the 4 values */
.bware-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 18px 12px;
}

    .bware-summary-grid .label {
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .5px;
        color: var(--bware-muted);
        margin-bottom: 2px;
    }

    .bware-summary-grid .value {
        font-size: .95rem;
        font-weight: 600;
        color: var(--bware-text);
    }


@media (min-width: 992px) {
    .bware-summary-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.bware-summary-label {
    display: block;
    font-size: .82rem;
    color: var(--bware-muted);
    line-height: 1.1;
}

.bware-summary-value {
    font-weight: 650;
    font-size: .92rem;
}

/* Pill buttons for month selectors */
.bware-pill {
    border: 1px solid rgba(34,101,154,.35);
    color: rgb(34,101,154);
    background: var(--bware-surface);
    padding: .28rem .55rem;
    border-radius: 999px;
    font-size: .86rem;
    line-height: 1;
    font-weight: 650;
    user-select: none;
}

    .bware-pill:hover {
        background: rgba(34,101,154,.06);
    }

    .bware-pill.is-active {
        background: rgb(34,101,154);
        border-color: rgb(34,101,154);
        color: var(--bware-surface);
    }

/* No “sticky blue” focus for tiny action buttons/links */
.bware-nofocus:focus,
.bware-nofocus:active,
.bware-nofocus:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Renewal months row */
.bware-pillrow {
    display: flex;
    align-items: flex-end; /* aligns Custom with the input baseline */
    gap: 12px;
}

.bware-pillrow-left {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bware-pillrow-right {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

    .bware-pillrow-right .form-label {
        font-size: .85rem;
        line-height: 1;
        color: var(--bware-muted);
    }

.bware-modal-section {
    padding: 0 18px 14px; /* left/right padding + a little bottom */
}

/* Content rendered inside BwareModal must not create a second modal shell. */
.bware-modal-form {
    display: block;
    min-width: 0;
    margin: 0;
}

.bware-modal-form .bware-summary-card {
    background: var(--bs-tertiary-bg, var(--bware-surface-alt));
    border-radius: 8px;
    box-shadow: none;
}

.bware-modal-form .bware-modal-section {
    padding: 0 0 .875rem;
}
.badge-neutral {
    background: var(--bware-surface-2);
    color: var(--bware-text);
    border: 1px solid var(--bware-border);
}

/* Stronger card headers in both light & dark mode */
.bware-card-title,
.card-header,
.bware-summary-card .title {
    color: var(--bware-text) !important;
    font-weight: 600;
    opacity: 0.9;
}

html[data-theme="dark"] .card-title {
    color: rgba(233, 238, 245, 0.95) !important; /* almost white */
}



/* CRM component styles: DetailTickets.razor */
.priority-done {
        background: #6c757d;
        color: #fff;
    }

    .priority-archived {
        background: #495057;
        color: #fff;
    }

    .notification-badge {
        display: inline-block;
        min-width: 78px;
        padding: 0.25rem 0.6rem;
        border-radius: 0.45rem; /* less pill-like */
        font-size: 0.78rem;
        font-weight: 700;
        text-align: center;
        line-height: 1.2;
        border: 1px solid transparent;
    }

    .detail-notification-table .notification-badge {
        min-width: 68px;
        padding: 0.22rem 0.45rem;
        font-size: 0.72rem;
    }

    .detail-notification-table .notification-open-btn {
        padding: 0.18rem 0.4rem;
    }

    .status-unread {
        background: #0d6efd;
        color: #fff;
    }

    .status-read {
        background: #6c757d;
        color: #fff;
    }

    .status-deferred {
        background: #6f42c1;
        color: #fff;
    }

    .status-complete {
        background: #198754;
        color: #fff;
    }

    .priority-urgent {
        background: #dc3545;
        color: #fff;
    }

    .priority-high {
        background: #fd7e14;
        color: #fff;
    }

    .priority-medium {
        background: #ffc107;
        color: #212529;
    }

    .priority-low {
        background: #198754;
        color: #fff;
    }
.detail-notification-list .list-group-item {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

.detail-notification-list .list-group-item:nth-child(odd) {
    background: rgba(255,255,255,0.05);
}

.detail-notification-list .list-group-item:nth-child(even) {
    background: rgba(0,0,0,0.08);
}

.detail-notification-list .list-group-item:hover {
    background: rgba(255,255,255,0.10);
    color: var(--bs-body-color);
}
.detail-notification-table {
    table-layout: fixed;
    width: 100%;
}

.detail-notification-table th,
.detail-notification-table td {
    overflow: hidden;
    vertical-align: middle;
}

.detail-notification-table .detail-notification-terminal-header > th {
    background: var(--bware-surface-2);
    color: var(--bware-text);
    border-top: 1px solid var(--bware-border);
    border-bottom: 1px solid var(--bware-border);
}

.detail-notification-table .notification-title-cell,
.detail-notification-table .notification-assigned-cell,
.detail-notification-table .notification-type-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-notification-table .notification-title-main,
.detail-notification-table .notification-title-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-notification-table .notification-date-cell,
.detail-notification-table .notification-badge-cell,
.detail-notification-table .notification-open-cell {
    white-space: nowrap;
}
.bware-table-scroll {
    overflow-x: hidden;
}
    .detail-notification-scroll {
        overflow-x: hidden;
    }

    .detail-notification-table-wrap {
        max-height: 360px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .detail-notification-table {
        table-layout: fixed;
        width: 100%;
        margin-bottom: 0;
    }

/* Accounts workspace */
.accounts-workspace {
    min-width: 0;
}

.accounts-header-card,
.accounts-card {
    border-radius: var(--bware-radius-lg, 14px);
    background: var(--bware-surface);
    color: var(--bware-text);
}

.accounts-header-card {
    background: var(--bware-surface-2);
}

.accounts-card > .card-body,
.accounts-workspace .bware-tabs-host,
.accounts-workspace .bware-tab-panel,
.accounts-section {
    min-width: 0;
}

.accounts-workspace .bware-tab-panel {
    min-height: 20rem;
}

.accounts-workspace .bware-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.accounts-workspace .bware-tab-item {
    flex: 0 0 auto;
}

.accounts-section-header,
.bware-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--bware-gap-sm, 10px);
    padding: 0.65rem 0.9rem;
    background: var(--bware-surface-2);
    border-bottom: 1px solid var(--bware-border-color);
}

.accounts-section,
.accounts-section > .card-body {
    background: var(--bware-surface);
    color: var(--bware-text);
}

.accounts-section-summary,
.accounts-toolbar-controls,
.bware-section-summary,
.bware-toolbar-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--bware-gap-sm, 10px);
    min-width: 0;
}

.accounts-meta {
    color: var(--bware-muted);
    font-size: 0.85rem;
}

.accounts-search,
.bware-toolbar-search {
    flex: 1 1 15rem;
    width: 15rem;
    max-width: 21rem;
}

.accounts-select {
    flex: 0 1 10.625rem;
    width: 10.625rem;
}

.accounts-table-frame {
    max-height: 70dvh;
    overflow: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    background: var(--bware-surface);
    border: 1px solid var(--bware-border-color);
    border-radius: var(--bware-radius-sm);
}

.accounts-table {
    min-width: 60rem;
}

.accounts-table-wide {
    min-width: 72rem;
}

.accounts-table thead th {
    background: var(--bware-surface-2) !important;
    color: var(--bware-text) !important;
    border-bottom-color: var(--bware-border-color) !important;
}

.accounts-sort-button {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    text-align: inherit;
}

.accounts-table th.text-center .accounts-sort-button {
    justify-content: center;
}

.accounts-table th.text-end .accounts-sort-button {
    justify-content: flex-end;
}

.accounts-sort-button:hover {
    text-decoration: underline;
}

.accounts-sort-button:focus-visible {
    border-radius: var(--bware-radius-sm, 6px);
    outline: 2px solid var(--bware-focus-ring, var(--bs-primary));
    outline-offset: 3px;
}

.accounts-sort-glyph {
    color: var(--bware-muted);
}

.accounts-renew-custom {
    width: 6.875rem;
}

.accounts-renew-lines {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}

.accounts-client-cell {
    max-width: 30rem;
}

.accounts-col-xs {
    width: 5rem;
}

.accounts-col-sm {
    width: 7.5rem;
}

.accounts-col-md {
    width: 8.75rem;
}

.accounts-col-action {
    width: 5rem;
}

.accounts-sticky-action {
    position: sticky;
    right: 0;
    z-index: 1;
    background: var(--bware-surface) !important;
    box-shadow: -0.375rem 0 0.75rem -0.625rem rgba(0, 0, 0, 0.55);
}

.accounts-table thead .accounts-sticky-action {
    z-index: 4;
    background: var(--bware-surface-2) !important;
}

.accounts-table tbody tr:hover > .accounts-sticky-action {
    background: var(--bware-surface-2) !important;
}

@media (max-width: 767.98px) {
    .accounts-section-header,
    .bware-section-header {
        align-items: flex-start;
    }

    .accounts-toolbar-controls,
    .bware-toolbar-controls {
        width: 100%;
    }

    .accounts-search,
    .accounts-select,
    .bware-toolbar-search {
        flex: 1 1 100%;
        width: 100%;
        max-width: none;
    }

    .accounts-toolbar-controls > .btn,
    .bware-toolbar-controls > .btn {
        flex: 1 1 100%;
    }

    .accounts-card > .card-body,
    .accounts-section > .card-body,
    .accounts-workspace .bware-tab-panel {
        padding: 0.75rem;
    }

    .accounts-table-frame {
        max-height: 65dvh;
    }
}

@media (max-width: 575.98px) {
    .bware-modal-overlay {
        padding: 0.5rem;
    }

    .bware-modal-dialog {
        max-height: calc(100dvh - 1rem);
    }

    .bware-modal-content {
        max-height: calc(100dvh - 1rem);
    }

    .bware-modal-body {
        flex: 1 1 auto;
        max-height: none;
        min-height: 0;
    }

    .bware-summary-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .bware-pillrow {
        align-items: stretch;
        flex-direction: column;
    }

    .bware-pillrow-right {
        align-items: stretch;
        margin-left: 0;
    }

    .accounts-renew-custom {
        flex: 1 1 auto;
        width: 100%;
    }
}

        .detail-notification-table thead th {
            position: sticky;
            top: 0;
            z-index: 2;
            background: var(--bs-tertiary-bg);
        }

        .detail-notification-table th,
        .detail-notification-table td {
            vertical-align: middle;
            overflow: hidden;
        }

    .notification-member-strip-table {
        display: flex;
        align-items: center;
        gap: 0.15rem;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .detail-notification-table .notification-member-avatar {
        width: 22px;
        height: 22px;
        border-radius: 999px;
        border: 1px solid transparent;
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.58rem;
        font-weight: 800;
        line-height: 1;
        flex: 0 0 auto;
    }

    .notification-member-more {
        background: #6c757d;
        border-color: #6c757d;
        color: #fff;
    }

    .detail-notification-table-wrap {
        max-height: 360px;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: 0.5rem;
    }

    .detail-notification-table {
        table-layout: fixed;
        width: 100%;
        margin-bottom: 0;
    }

        .detail-notification-table thead th {
            position: sticky;
            top: 0;
            z-index: 2;
            background: var(--bs-tertiary-bg);
        }

        .detail-notification-table th,
        .detail-notification-table td {
            vertical-align: middle;
            overflow: hidden;
        }

    .detail-notification-table-wrap {
        max-height: 330px;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: 0.5rem;
    }

    .detail-notification-table {
        table-layout: fixed;
        width: 100%;
        margin-bottom: 0;
    }

        .detail-notification-table thead th {
            position: sticky;
            top: 0;
            z-index: 2;
            background: var(--bs-tertiary-bg);
        }

        .detail-notification-table th,
        .detail-notification-table td {
            vertical-align: middle;
            overflow: hidden;
        }


/* CRM component styles: DetailLook.razor */
.access-header-card {
        border-radius: 14px;
        background: linear-gradient(180deg, rgba(34,101,154,.06), rgba(34,101,154,.02));
    }

    /* Make readonly inputs readable (Bootstrap 5.1 can grey them too much) */
    .bware-readonly[readonly] {
        background-color: #fff; /* or var(--bs-body-bg) */
        color: var(--bs-body-color);
        opacity: 1; /* key: prevents faded text */
    }

        /* If your theme applies a different style, this also helps */
        .bware-readonly[readonly]:focus {
            box-shadow: none;
        }


/* CRM component styles: History.razor */
th[role="button"] {
        cursor: pointer;
        user-select: none;
    }

    .history-page {
        --bware: #22659A;
        --bware-ink: #0f2e45;
        --surface: var(--bs-body-bg);
        --border: rgba(15,23,42,.10);
        --shadow: 0 10px 30px rgba(2,6,23,.08);
        --radius: 14px;
        font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    }

    .history-toolbar h5 {
        font-weight: 650;
        letter-spacing: .2px;
        color: var(--bware-ink);
    }

    .history-page .form-control, .history-page .form-select {
        border-radius: 12px;
        border-color: var(--border);
        box-shadow: none;
    }

        .history-page .form-control:focus, .history-page .form-select:focus {
            border-color: rgba(34,101,154,.55);
            box-shadow: 0 0 0 .2rem rgba(34,101,154,.15);
        }

    .history-page .btn {
        border-radius: 12px;
        font-weight: 600;
    }

    .history-page .btn-primary {
        background: var(--bware);
        border-color: var(--bware);
    }

    .history-card {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        overflow: hidden;
    }

    .history-card-header {
        background: linear-gradient(180deg, rgba(34,101,154,.08), rgba(34,101,154,.02));
        border-bottom: 1px solid var(--border);
        padding: .75rem .9rem;
    }

    .history-header-card {
        border-radius: 14px;
        background: linear-gradient(180deg, rgba(34,101,154,.06), rgba(34,101,154,.02));
    }


    /* Make the history card a single cohesive surface */
    .history-card {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        overflow: hidden;
        /* key: prevents page scroll fighting the internal scroll */
        display: flex;
        flex-direction: column;
    }

        /* card-body becomes the scroll container */
        .history-card .card-body {
            /* keep footer visible */
            overflow: hidden;
            display: flex;
            flex-direction: column;
            padding: 0 !important;
        }

    /* ONLY this area scrolls */
    .history-table-wrap {
        overflow: auto;
        max-height: 70vh; /* keep your preferred size */
        scrollbar-gutter: stable;
    }

    .history-table {
        font-size: 14px;
    }

        .history-table td, .history-table th {
            padding: .65rem .85rem;
            border-color: rgba(15,23,42,.08);
        }

    /* Prevent sticky header + table borders from overlapping/bleeding */
    .history-table {
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    /* Make sticky header a clean solid bar */
    .history-thead th {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bs-body-bg) !important;
        background-clip: padding-box;
        box-shadow: 0 2px 0 rgba(15,23,42,.08);
        /* keeps the header looking "floating" and hides content passing under */
        box-shadow: 0 2px 0 rgba(15,23,42,.08);
        backdrop-filter: blur(6px);
        text-transform: none;
        letter-spacing: .02em;
        font-size: 13px;
        font-weight: 700;
    }

    /* If you’re in dark mode / using BS vars, you can do this instead:
    .history-thead th { background: var(--bs-body-bg) !important; }
    */



    .history-table th[role="button"]:hover {
        background: rgba(34,101,154,.06);
    }

    .history-table tbody tr:hover {
        background: rgba(34,101,154,.04);
    }

    .history-table tbody tr.table-warning {
        background: rgba(34,101,154,.10) !important;
        box-shadow: inset 3px 0 0 var(--bware);
    }

    .history-table textarea.form-control {
        border-radius: 12px;
        resize: vertical;
        min-height: 52px;
        line-height: 1.25rem;
    }

    .history-tag {
        display: inline-flex;
        align-items: center;
        padding: .22rem .55rem;
        border-radius: 999px;
        background: rgba(34,101,154,.10);
        color: rgba(34,101,154,.95);
        font-weight: 800;
        font-size: 12.5px;
        cursor: pointer;
    }

        .history-tag:hover {
            background: rgba(34,101,154,.16);
        }

    .history-type-badge {
        cursor: pointer;
        font-weight: 600;
        color: #212529 !important;
        background-color: #f8f9fa !important;
        border: 1px solid #ced4da !important;
        padding: .25rem .5rem;
    }

        .history-type-badge:hover {
            background-color: #eef2f6 !important;
        }

        .history-split-layout {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
            gap: 1rem;
            align-items: start;
        }

        .history-main-column,
        .history-notifications-column {
            min-width: 0;
        }

        .history-completed-card {
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            overflow: hidden;
        }

        .history-completed-list {
            max-height: 70vh;
            overflow-y: auto;
            overflow-x: hidden;
        }

        .history-completed-item {
            width: 100%;
            border: 0;
            border-bottom: 1px solid var(--bs-border-color);
            background: var(--bs-body-bg);
            color: var(--bs-body-color);
            text-align: left;
            padding: 0.75rem 0.85rem;
        }

            .history-completed-item:nth-child(odd) {
                background: rgba(127, 127, 127, 0.06);
            }

            .history-completed-item:hover {
                background: rgba(127, 127, 127, 0.12);
            }

        .history-completed-title-row {
            display: flex;
            justify-content: space-between;
            align-items: start;
            gap: 0.75rem;
        }

        .history-completed-title {
            min-width: 0;
            font-size: 0.92rem;
            line-height: 1.2;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .history-completed-message {
            color: var(--bs-secondary-color);
            font-size: 0.82rem;
            line-height: 1.25;
            margin-top: 0.15rem;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .history-completed-meta {
            color: var(--bs-secondary-color);
            font-size: 0.78rem;
            line-height: 1.25;
            margin-top: 0.35rem;
            display: flex;
            flex-wrap: wrap;
            gap: 0.25rem;
        }

        @media (max-width: 1200px) {
            .history-split-layout {
                grid-template-columns: 1fr;
            }

            .history-completed-list {
                max-height: 360px;
            }
        }

    .notification-member-strip {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    .notification-member-avatar {
        width: 24px;
        height: 24px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.72rem;
        font-weight: 700;
        line-height: 1;
        border: 1px solid rgba(255,255,255,0.08);
        flex: 0 0 auto;
    }

    .notification-member-more {
        background: rgba(127,127,127,0.18);
        color: var(--bs-body-color);
    }

    .history-list {
        display: flex;
        flex-direction: column;
    }

    .history-list-sortbar {
        position: sticky;
        top: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.45rem 0.7rem;
        background: var(--bs-tertiary-bg);
        border-bottom: 1px solid var(--bs-border-color);
    }

    .history-sort-btn {
        padding: 0.15rem 0.35rem;
        font-size: 0.78rem;
        font-weight: 700;
        color: var(--bs-body-color);
        text-decoration: none;
    }

        .history-sort-btn:hover {
            color: var(--bs-primary);
        }

    .history-list-item {
        padding: 0.7rem 0.85rem;
        border-bottom: 1px solid var(--bs-border-color);
        background: var(--bs-body-bg);
    }

        .history-list-item:nth-child(odd) {
            background: rgba(127, 127, 127, 0.04);
        }

        .history-list-item:hover {
            background: rgba(127, 127, 127, 0.10);
        }

    .history-list-item-editing {
        background: rgba(255, 193, 7, 0.14) !important;
        box-shadow: inset 4px 0 0 var(--bs-warning);
    }

    .history-list-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .history-list-left {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        min-width: 0;
    }

    .history-list-date {
        color: var(--bs-secondary-color);
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .history-row-actions {
        display: flex;
        align-items: center;
        gap: 0.15rem;
        flex: 0 0 auto;
    }

    .history-list-text {
        margin-top: 0.45rem;
        color: var(--bs-body-color);
        line-height: 1.3;
        font-size: 0.92rem;
    }

    .history-list-comments {
        margin-top: 0.45rem;
        padding: 0.45rem 0.6rem;
        border-left: 4px solid var(--bs-primary);
        background: rgba(127, 127, 127, 0.08);
        border-radius: 0.35rem;
        color: var(--bs-body-color);
        font-size: 0.86rem;
        line-height: 1.3;
        white-space: pre-wrap;
    }

    .history-edit-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 170px;
        gap: 0.75rem;
    }

    @media (max-width: 900px) {
        .history-edit-grid {
            grid-template-columns: 1fr;
        }

        .history-list-sortbar {
            flex-wrap: wrap;
        }
    }
/* CRM component styles: Details.razor */
.detail-notification-card-body {
    overflow: visible !important;
    max-height: none !important;
    padding-bottom: 0.75rem;
}

/* CRM component styles: DetailLibrary.razor */
.library-section,
.library-section > .card-body {
    background: var(--bware-surface);
    color: var(--bware-text);
}

.library-upload-toolbar {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--bware-gap-sm, 10px);
    margin-bottom: .75rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--bware-border-color);
}

.library-file-picker {
    flex: 1 1 20rem;
    min-width: 0;
    max-width: 40rem;
}

.library-selected-count {
    align-self: center;
}

.library-upload-error {
    flex: 1 1 100%;
}

.library-selection-panel {
    margin-bottom: .75rem;
    padding: .65rem .75rem;
    border: 1px solid var(--bware-border-color);
    border-radius: var(--bware-radius-sm);
    background: var(--bware-surface-2);
    color: var(--bware-text);
}

.library-selection-header,
.library-selection-item {
    display: flex;
    align-items: center;
    gap: var(--bware-gap-sm, 10px);
}

.library-selection-header {
    justify-content: space-between;
    margin-bottom: .25rem;
}

.library-selection-list {
    display: grid;
    gap: .25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.library-selection-item {
    min-width: 0;
    padding: .25rem .4rem;
    border-top: 1px solid var(--bware-border-color);
}

.library-selection-file {
    display: flex;
    align-items: center;
    gap: var(--bware-gap-sm, 10px);
    flex: 1 1 18rem;
    min-width: 0;
}

.library-selection-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-selection-remove {
    flex: 0 0 auto;
    padding-block: 0;
}

.library-conflict {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .35rem;
}

@media (max-width: 575.98px) {
    .library-selection-item {
        flex-wrap: wrap;
    }

    .library-selection-name {
        flex-basis: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .library-conflict {
        justify-content: flex-start;
        flex-basis: 100%;
    }
}

.lib-toolbar {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

.lib-search { width: 260px; }
.lib-table-scroll { max-height: 70vh; overflow: auto; }
.lib-file-icon { width: 2rem; height: 2rem; display: inline-block; vertical-align: middle; }
.lib-col-type { width: 56px; }
.lib-col-group { width: 160px; }
.lib-col-description { min-width: 260px; }
.lib-col-size { width: 120px; }
.lib-col-modified { width: 180px; }
.lib-col-action { width: 110px; }
.lib-description-cell { max-width: 420px; }

.detail-notification-col-type { width: 12%; }
.detail-notification-col-members { width: 16%; }
.detail-notification-col-date,
.detail-notification-col-status,
.detail-notification-col-priority { width: 11%; }
.detail-notification-col-open { width: 6%; }

.history-search { min-width: 240px; max-width: 320px; }
.history-page-size { width: 90px; }
.history-edit-action { color: midnightblue; }
[data-theme="dark"] .history-edit-action { color: #9ec5fe; }

.detail-contacts-table {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: auto;
    scrollbar-gutter: stable;
}

.detail-contacts-card-body {
    padding: 0;
    overflow: hidden;
}

.detail-contacts-state {
    margin: .75rem;
}

.detail-contacts-table thead th {
    background-color: var(--bware-surface-2) !important;
    background-image: none !important;
}

.detail-contacts-table table {
    width: 100%;
    table-layout: fixed;
}

.contact-col-worker { width: 24%; }
.contact-col-email { width: auto; }
.contact-col-phone { width: 170px; }

.contact-value {
    display: flex;
    align-items: center;
    gap: .25rem;
    min-width: 0;
}

.contact-value > a {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-phone-cell,
.contact-phone-cell .contact-value > a {
    white-space: nowrap;
}

.contact-copy-action {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    padding: 0;
    color: var(--bs-secondary-color);
    line-height: 26px;
}

.contact-copy-action:hover,
.contact-copy-action:focus-visible {
    color: var(--bs-primary);
}

.lib-table td,
.lib-table th {
    vertical-align: middle;
}

.icon-image {
    width: 28px;
    height: 28px;
    display: inline-block;
    vertical-align: middle;
}

.lib-table thead.sticky-top th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bs-table-bg, var(--bware-surface-alt)) !important;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.12);
    white-space: nowrap;
}

.lib-table .badge.group-badge {
    padding: .25rem .5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .25rem;
    background: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color) !important;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.2;
}

/* CRM History workspace: full-width records with a secondary activity panel */
.history-workspace {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-width: 100%;
    padding: .65rem;
    overflow-x: hidden;
}

.history-workspace .history-header-card {
    flex: 0 0 auto;
    margin-bottom: 0 !important;
    border: 1px solid var(--bs-border-color) !important;
    border-radius: var(--bware-radius);
    box-shadow: var(--bware-shadow-sm);
}

.history-search {
    width: clamp(230px, 24vw, 360px);
    min-width: 0;
    max-width: none;
}

.history-split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
    gap: .75rem;
    align-items: stretch;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
}

.history-main-column,
.history-notifications-column {
    display: flex;
    min-width: 0;
    min-height: 0;
}

.history-card,
.history-completed-card {
    width: 100%;
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bware-radius);
    background: var(--bs-body-bg);
    box-shadow: var(--bware-shadow-sm);
}

.history-card {
    display: flex;
    flex-direction: column;
}

.history-card .card-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.history-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100dvh - 225px);
    overflow: auto;
    scrollbar-gutter: stable;
}

.history-list-sortbar,
.history-row-grid {
    display: grid;
    grid-template-columns: minmax(90px, 120px) 112px minmax(240px, 1.4fr) minmax(190px, 1fr) 68px;
    gap: .75rem;
    align-items: start;
}

.history-list-sortbar {
    position: sticky;
    top: 0;
    z-index: 20;
    isolation: isolate;
    align-items: center;
    min-height: 38px;
    padding: .55rem .75rem;
    background-color: var(--bware-surface-2) !important;
    background-image: none !important;
    background-clip: border-box;
    border-bottom: 1px solid var(--bs-border-color);
    box-shadow: 0 3px 7px rgba(0, 0, 0, .18);
}

.history-sort-btn {
    justify-self: start;
    padding: .1rem 0;
    color: var(--bware-text);
    text-align: left;
}

.history-actions-heading {
    color: var(--bs-secondary-color);
    font-size: .78rem;
    font-weight: 700;
    text-align: right;
}

.history-list-item {
    padding: .7rem .75rem;
}

.history-row-type,
.history-list-date,
.history-list-text,
.history-list-comments {
    min-width: 0;
}

.history-list-date {
    padding-top: .2rem;
    color: var(--bs-secondary-color);
    font-size: .84rem;
}

.history-list-text,
.history-list-comments {
    margin: 0;
    padding: .15rem 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: .88rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.history-row-actions {
    justify-content: flex-end;
}

.history-type-badge {
    max-width: 100%;
    color: var(--bs-body-color) !important;
    background: var(--bs-tertiary-bg) !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-completed-card {
    display: flex;
    flex-direction: column;
}

.history-completed-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100dvh - 176px);
    overflow-y: auto;
}

@media (max-width: 1200px) {
    .history-workspace {
        overflow-y: auto;
        scrollbar-gutter: stable;
    }

    .history-workspace .crm-detail-header-inner {
        align-items: stretch;
        flex-direction: column;
    }

    .history-workspace .crm-detail-actions {
        justify-content: flex-start;
        width: 100%;
        margin-left: 0;
    }

    .history-search {
        flex: 1 1 18rem;
        width: auto;
    }

    .history-split-layout {
        flex: 0 0 auto;
        grid-template-columns: 1fr;
    }

    .history-table-wrap {
        flex: 0 0 auto;
        height: clamp(18rem, 60dvh, 34rem);
        max-height: none;
    }

    .history-completed-list {
        max-height: 320px;
    }

    .history-workspace {
        padding: .5rem;
    }

    .history-workspace .history-header-card .card-body {
        align-items: stretch !important;
    }

    .history-search {
        width: 100%;
    }

    .history-pager {
        align-items: flex-start !important;
        flex-direction: column;
        gap: .5rem;
    }

    .history-pager-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .history-list-sortbar {
        display: none;
    }

    .history-row-grid {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .45rem .75rem;
    }

    .history-row-type {
        grid-column: 1;
        grid-row: 1;
    }

    .history-list-date {
        grid-column: 1;
        grid-row: 2;
        padding-top: 0;
    }

    .history-row-actions {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .history-list-text,
    .history-list-comments {
        grid-column: 1 / -1;
    }

    .history-list-text {
        padding-top: .35rem;
        border-top: 1px solid var(--bs-border-color);
    }

    .history-list-comments:not(:has(.text-muted)) {
        padding: .45rem .55rem;
        border-left: 3px solid var(--bs-primary);
        border-radius: .25rem;
        background: var(--bs-tertiary-bg);
    }
}

/* CRM page header contract */
.crm-detail-header {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bware-radius);
    background: var(--bware-surface);
    box-shadow: var(--bware-shadow-sm);
}

.crm-detail-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: 48px;
    padding: .55rem .75rem;
}

.crm-detail-title {
    flex: 0 1 auto;
    min-width: 0;
    color: var(--bware-text);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
}

.crm-detail-title > span {
    color: var(--bware-muted);
    font-weight: 400;
}

.crm-detail-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    min-width: 0;
    margin-left: auto;
    flex-wrap: wrap;
}

.crm-detail-count {
    color: var(--bware-muted);
    font-size: .8rem;
    white-space: nowrap;
}

.crm-detail-header .badge.bg-white {
    color: var(--bware-text) !important;
    background: var(--bware-surface-2) !important;
    border-color: var(--bs-border-color) !important;
}

/* The 300px CRM rail leaves two Details columns cramped on laptop viewports. */
@media (max-width: 1399.98px) {
    .details-content {
        flex-direction: column;
    }

    .left-column,
    .right-column {
        flex: 0 0 auto;
        width: 100%;
        grid-template-rows: auto;
    }

    .details-content .card-item {
        min-height: 300px;
    }

    .details-content .left-column .card-item:first-child {
        min-height: 500px;
    }

    .details-content .detail-contacts-card-body {
        padding: 0;
        overflow: hidden;
    }
}

@media (max-width: 900px) {
    .crm-detail-header-inner {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-detail-actions {
        justify-content: flex-start;
        width: 100%;
        margin-left: 0;
    }
}
