/* Sales Intellect — application styles
 *
 * Warm-slate editorial theme: warm off-white canvas, near-black text,
 * neutral stone palette, Fraunces serif headings, Inter sans body.
 * Overrides Bootstrap 5.3 CSS variables in :root so most components
 * (buttons, cards, inputs, alerts) pick up the new look automatically.
 */

/* ---- Bootstrap variable overrides -------------------------------- */
:root {
    /* Sans + serif stacks. Fraunces gives headings an editorial feel. */
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto,
                          'Helvetica Neue', Arial, sans-serif;
    --is-font-serif:      'Fraunces', 'Iowan Old Style', 'New York', Georgia,
                          'Times New Roman', serif;

    /* Warm off-white canvas, cream-tinted cards, stone borders. */
    --bs-body-bg:        #faf8f3;
    --bs-body-color:     #1c1917;
    --bs-emphasis-color: #18181b;
    --bs-secondary-color: #6b6660;
    --bs-tertiary-color:  #a8a29e;
    --bs-tertiary-bg:     #f2efe8;

    --bs-border-color:             #e7e3d8;
    --bs-border-color-translucent: rgba(28, 25, 23, .08);
    --bs-border-radius:    .375rem;
    --bs-border-radius-sm: .25rem;
    --bs-border-radius-lg: .5rem;

    /* Near-black primary — buttons, links, focus rings. */
    --bs-primary:     #292524;
    --bs-primary-rgb: 41, 37, 36;
    --bs-link-color:        #292524;
    --bs-link-color-rgb:    41, 37, 36;
    --bs-link-hover-color:  #57534e;

    /* Subtle warm secondary for ghost buttons. */
    --bs-secondary:     #78716c;
    --bs-secondary-rgb: 120, 113, 108;

    /* Backwards-compat with the legacy custom var some code still reads. */
    --is-accent: #292524;
    --is-accent-soft: rgba(41, 37, 36, .08);
    --is-warm-bg: #faf8f3;

    /* The theme's dark tone, used by the "Always use dark header" preference
       (.header-dark below). Every theme MUST define this — a theme without one
       falls back to this warm-slate value and will look off-palette. It has to
       be dark enough for white text and the on-dark logo to sit on it. */
    --is-header-dark: #292524;   /* near-black stone */
}

html, body {
    font-family: var(--bs-font-sans-serif);
}
body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv11"; /* nicer Inter forms */
}

/* Serif headings — editorial accent on top-of-page titles. */
h1, h2, h3, h4, h5,
.h1, .h2, .h3, .h4, .h5 {
    font-family: var(--is-font-serif);
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--bs-emphasis-color);
}
h6, .h6 { /* keep h6 in sans — used in card titles as a label */
    font-family: var(--bs-font-sans-serif);
    font-weight: 600;
    letter-spacing: 0;
}

/* Inputs / forms / focus rings. */
.form-control, .form-select {
    border-color: var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background-color: #ffffff;
}
.form-control:focus, .form-select:focus {
    border-color: #57534e;
    box-shadow: 0 0 0 .2rem rgba(41, 37, 36, .12);
}
.form-control::placeholder { color: var(--bs-tertiary-color); }

/* ---- Buttons ------------------------------------------------------ */
.btn {
    --bs-btn-border-radius: var(--bs-border-radius);
    font-weight: 500;
    letter-spacing: .005em;
}
.btn-primary {
    --bs-btn-bg:         #292524;
    --bs-btn-border-color: #292524;
    --bs-btn-hover-bg:   #1c1917;
    --bs-btn-hover-border-color: #1c1917;
    --bs-btn-active-bg:  #18181b;
    --bs-btn-active-border-color: #18181b;
    --bs-btn-color:      #faf8f3;
    --bs-btn-hover-color: #ffffff;
    /* Disabled state: muted warm stone instead of Bootstrap's blue. */
    --bs-btn-disabled-bg:           #d6d3c9;
    --bs-btn-disabled-border-color: #c7c2b3;
    --bs-btn-disabled-color:        #78716c;
}
/* Skip Bootstrap's extra .65 opacity fade on disabled — our disabled colour
   tokens above are already muted enough to read as inactive. */
.btn-primary:disabled,
.btn-primary.disabled { opacity: 1; }
.btn-outline-primary {
    --bs-btn-color:        #292524;
    --bs-btn-border-color: #d6d3c9;
    --bs-btn-hover-bg:     #f2efe8;
    --bs-btn-hover-border-color: #292524;
    --bs-btn-hover-color:  #292524;
    --bs-btn-active-bg:    #292524;
    --bs-btn-active-border-color: #292524;
    --bs-btn-active-color: #ffffff;
}
.btn-outline-secondary {
    --bs-btn-color:        #57534e;
    --bs-btn-border-color: #e0dccf;
    --bs-btn-hover-bg:     #f2efe8;
    --bs-btn-hover-color:  #1c1917;
    --bs-btn-hover-border-color: #c7c2b3;
}
.btn-success {
    --bs-btn-bg:         #15803d;
    --bs-btn-border-color: #15803d;
    --bs-btn-hover-bg:   #166534;
    --bs-btn-hover-border-color: #166534;
}

/* Subtle pill chips for badges that read as labels. */
.badge {
    font-weight: 500;
    letter-spacing: .01em;
    border-radius: 999px;
    padding: .25em .6em;
}

/* ---- Navbar ------------------------------------------------------- */
.app-navbar {
    background-color: rgba(250, 248, 243, .85);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--bs-border-color);
    box-shadow: none;
    position: relative;
    z-index: 1020;
}
.app-navbar .navbar-brand {
    font-family: var(--is-font-serif);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--bs-emphasis-color);
}
.app-navbar .nav-link {
    font-weight: 500;
    color: #57534e;
    border-radius: var(--bs-border-radius);
    padding: .35rem .8rem;
    transition: background-color .12s ease, color .12s ease;
}
.app-navbar .nav-link:hover {
    color: var(--is-accent);
    background-color: var(--is-accent-soft);
}
.app-navbar .nav-link.active {
    color: var(--is-accent);
    background-color: var(--is-accent-soft);
}

/* Sales Mode — split nav item: text goes to last process, caret opens menu. */
.app-navbar .sales-mode-split {
    display: flex;
    align-items: center;
}
.app-navbar .sales-mode-split > .nav-link { padding-right: .45rem; padding-left: .45rem; }
.app-navbar .sales-mode-split > #salesModeLink { padding-right: .25rem; }
.app-navbar .sales-mode-split > .dropdown-toggle-split {
    padding-left: .35rem;
    padding-right: .55rem;
    border-left: 1px solid transparent;
}
.app-navbar .sales-mode-split:hover > .dropdown-toggle-split,
.app-navbar .sales-mode-split > .dropdown-toggle-split[aria-expanded="true"] {
    border-left-color: var(--bs-border-color);
}
/* Suppress Bootstrap's default ::after when the toggle has no text inside. */
.app-navbar .dropdown-toggle-split::after {
    margin-left: 0;
}

.app-main {
    min-height: calc(100vh - 56px);
}

/* ---- Cards -------------------------------------------------------- */
.card {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    background-color: #ffffff;
    box-shadow: 0 1px 0 rgba(28, 25, 23, .025);
}
.card-header {
    background-color: #ffffff !important;
    border-bottom-color: var(--bs-border-color);
    font-weight: 500;
}
.card-footer {
    background-color: #ffffff !important;
    border-top-color: var(--bs-border-color);
}
.mode-card {
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    color: var(--bs-emphasis-color);
}
.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(28, 25, 23, .06);
    border-color: #c7c2b3;
}

/* ---- Tables ------------------------------------------------------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--bs-body-color);
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-hover-bg: rgba(41, 37, 36, .035);
    --bs-table-striped-bg: rgba(41, 37, 36, .02);
}
.table > :not(caption) > * > * {
    border-bottom-color: var(--bs-border-color);
}
.table-light, .table-light > th, .table-light > td {
    --bs-table-bg: #f5f1e8;
    --bs-table-color: #57534e;
}
.table > thead th {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: #57534e;
}

/* ---- Tabs --------------------------------------------------------- */
.nav-tabs {
    border-bottom: 1px solid var(--bs-border-color);
}
.nav-tabs .nav-link {
    color: #6b6660;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: .55rem 1rem;
    font-weight: 500;
    background: transparent;
}
.nav-tabs .nav-link:hover {
    color: var(--is-accent);
    border-color: transparent transparent #d6d3c9;
    background: transparent;
}
.nav-tabs .nav-link.active {
    color: var(--is-accent);
    background: transparent;
    border-color: transparent transparent var(--is-accent);
}

/* Nav pills (admin sub-nav): use the theme accent for the active pill.
   Bootstrap's CDN build bakes a literal blue into the active-bg variable, so
   the per-theme --bs-primary override never reaches it — redefine the pill
   variables here (app.css loads after Bootstrap, so this wins). */
.nav-pills {
    --bs-nav-pills-link-active-bg: var(--is-accent);
    --bs-nav-pills-link-active-color: #fff;
}
.nav-tabs .badge {
    background-color: #e7e3d8 !important;
    color: #57534e !important;
}

/* ---- Modals & offcanvas ------------------------------------------ */
.modal-content, .offcanvas {
    background-color: #ffffff;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 24px 48px rgba(28, 25, 23, .12);
}
.modal-header, .offcanvas-header { border-bottom-color: var(--bs-border-color); }
.modal-footer { border-top-color: var(--bs-border-color); }
.modal-title, .offcanvas-title {
    font-family: var(--is-font-serif);
    font-weight: 600;
}

/* ---- Flash messages ---- */
.flash-stack { position: relative; }
.alert {
    border-radius: var(--bs-border-radius);
    border-width: 1px;
}

/* ---- Inline editing (M3) ----------------------------------------- */
.editable {
    cursor: pointer;
    border-radius: var(--bs-border-radius-sm);
    padding: .1rem .35rem;
    transition: background-color .1s ease, outline-color .1s ease;
}
.editable:hover {
    background-color: var(--is-accent-soft);
    outline: 1px dashed #c7c2b3;
}
.editable.is-empty {
    color: var(--bs-tertiary-color);
    font-style: italic;
}

/* ---- Goal cells (M7) --------------------------------------------- */
.goal-cell {
    text-align: center;
    font-weight: 500;
}
.goal-cell.is-clickable { cursor: pointer; }
.goal-cell.is-locked {
    cursor: not-allowed;
    color: var(--bs-tertiary-color);
    opacity: .65;
}
.goal-cell .goal-pill {
    display: inline-block;
    padding: .12rem .6rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: border-color .12s ease, background-color .12s ease;
}
.goal-cell.is-clickable:hover .goal-pill {
    border-color: #a8a29e;
}
/* Status backgrounds — desaturated, paper-friendly. */
.goal-done     { background-color: #e7f3ea; color: #14532d; }
.goal-not-done { background-color: #fee2e2; color: #dc2626; }
.goal-todo     { background-color: #fdf1d8; color: #854d0e; }
.goal-overdue  { background-color: #fbe6e1; color: #7f1d1d; }

/* ---- Tag pills (single source of truth — see App\Core\TagRenderer) -- */
.tag-pill {
    font-weight: 500;
    letter-spacing: .01em;
    padding-inline: .55em;
}
.tag-pill.is-inactive { opacity: .55; }
.tag-pill .bi-x       { margin-left: .15em; opacity: .8; }
.tag-pill:hover .bi-x { opacity: 1; }

/* Force the pill's text color so Bootstrap's table/text rules don't win. */
.goal-cell.goal-not-done .goal-pill { color: #dc2626; font-weight: 700; }
.goal-cell.goal-done     .goal-pill { color: #14532d; }
.goal-cell.goal-todo     .goal-pill { color: #854d0e; }
.goal-cell.goal-overdue  .goal-pill { color: #7f1d1d; }
.goal-anytime { background-color: transparent; }
.goal-future  { background-color: transparent; color: #78716c; }
.goal-waiting { background-color: transparent; color: var(--bs-tertiary-color); }

/* Lead-detail field value row: span + optional action button on one line.
   `min-width: 0` lets the editable span actually shrink and ellipsise. */
.field-value           { min-width: 0; }
.editable.is-url {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* URL field cells — ellipsised, single line, clickable. */
.url-ellipsis {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    color: var(--bs-link-color);
    text-decoration: underline;
    text-decoration-color: #d6d3c9;
    text-underline-offset: 2px;
}
.url-ellipsis:hover { text-decoration-color: var(--bs-link-color); }

/* ---- Lead page in Sales Mode (M10) ------------------------------- */
.field-target {
    background-color: #fdf5d8;          /* warm amber-100 */
    box-shadow: inset 3px 0 0 #b45309;   /* amber-700 stripe */
    border-radius: var(--bs-border-radius-sm);
    padding-left: .4rem;
}

.goal-sidebar .goal-item {
    display: flex;
    gap: .65rem;
    align-items: center;
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
    transition: background-color .12s ease;
}
.goal-sidebar .goal-item:last-child { border-bottom: none; }
.goal-sidebar .goal-item:hover:not(.is-locked) {
    background-color: #faf6ec;
}
.goal-sidebar .goal-item.is-locked {
    cursor: not-allowed;
    color: var(--bs-tertiary-color);
}
.goal-sidebar .goal-item .goal-bullet {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
    flex-shrink: 0;
    background-color: #ece8de;
    color: #78716c;
}
.goal-sidebar .goal-item.state-done     .goal-bullet { background:#dcefe1; color:#14532d; }
.goal-sidebar .goal-item.state-not_done .goal-bullet { background:#fee2e2; color:#dc2626; }
.goal-sidebar .goal-item.state-todo     .goal-bullet { background:#fbe7c1; color:#854d0e; }
.goal-sidebar .goal-item.state-overdue  .goal-bullet { background:#f8d6cd; color:#7f1d1d; }
.goal-sidebar .goal-item.state-anytime  .goal-bullet { background:#e3e0d2; color:#3f3f46; }

/* Offcanvas goal panel + drag-to-resize handle. */
.offcanvas-goal {
    width: 50%;
    min-width: 320px;
    max-width: 95vw;
}
.offcanvas-goal .resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: linear-gradient(to right, rgba(41, 37, 36, 0), rgba(41, 37, 36, .12));
    z-index: 5;
}
.offcanvas-goal .resize-handle:hover,
.offcanvas-goal.is-resizing .resize-handle {
    background: rgba(41, 37, 36, .3);
}
body.offcanvas-resizing { cursor: col-resize; user-select: none; }

/* Goal offcanvas — instructions block (preserves line breaks). */
#gaInstructions {
    white-space: pre-wrap;
    line-height: 1.5;
    background-color: #fdfaf0;
    border-color: #ece8da;
    color: #1c1917;
}

/* ---- Lead history (M13) ----------------------------------------- */
.history-block-header {
    padding: .65rem .9rem;
    background-color: #faf6ec;
    border-bottom: 1px solid var(--bs-border-color);
}
.history-block-header + .history-events { border-bottom: 1px solid var(--bs-border-color); }
.history-events { padding: .25rem 0; }
.history-event {
    display: flex;
    gap: .65rem;
    padding: .55rem .9rem;
    border-bottom: 1px solid #f1ede2;
}
.history-event:last-child { border-bottom: none; }
.history-event-icon {
    font-size: 1.05rem;
    line-height: 1.2;
    flex-shrink: 0;
    margin-top: .12rem;
}
.history-event-body { flex-grow: 1; min-width: 0; }
.history-event-meta { font-size: .72rem; white-space: nowrap; }
.history-event-notes {
    margin-top: .25rem;
    font-size: .82rem;
    line-height: 1.45;
    color: #3f3f46;
    background-color: #fdfaf0;
    border-left: 3px solid #d6d3c9;
    padding: .35rem .55rem;
    border-radius: 0 .25rem .25rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Booking-event pills (used in lead history). Calendar icon + colour-coded
   pill replaces the plain text label for booking_* actions. */
.history-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.1;
    padding: .2rem .55rem;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
    vertical-align: middle;
}
.history-pill i { font-size: .9rem; }
.history-pill--created    { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.history-pill--rescheduled { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.history-pill--cancelled  { background: #fee2e2; color: #7f1d1d; border-color: #fecaca; }
.history-pill--note       { background: #ffedd5; color: #7c2d12; border-color: #fed7aa; }
.history-event-detail { color: var(--bs-body-color); margin-left: .35rem; }

/* Attachments shown against a history event. */
.history-attachments {
    margin-top: .35rem;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.history-attachment {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    max-width: 100%;
    font-size: .78rem;
    text-decoration: none;
    color: var(--bs-body-color);
    background: #f8f9fa;
    border: 1px solid var(--bs-border-color);
    border-radius: .4rem;
    padding: .2rem .5rem;
}
.history-attachment:hover { background: #eef0f2; }
.history-attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 14rem;
}
.history-attachment-size { color: var(--bs-secondary-color); flex-shrink: 0; }

/* Note composer dropzone for drag-and-drop document attachments. */
.note-composer { transition: background-color .15s ease, box-shadow .15s ease; }
.note-composer--dragover {
    background-color: #eef5ff;
    box-shadow: inset 0 0 0 2px var(--bs-primary);
    border-radius: .25rem;
}
.note-dropzone {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--bs-secondary-color);
    border: 1px dashed var(--bs-border-color);
    border-radius: .4rem;
    padding: .4rem .6rem;
    margin-bottom: .5rem;
    cursor: pointer;
    user-select: none;
}
.note-dropzone:hover,
.note-dropzone:focus-visible {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
    outline: none;
}
.note-dropzone-browse { color: var(--bs-primary); text-decoration: underline; }
.note-attach-list:empty { display: none; }
.note-attach-item {
    font-size: .78rem;
    background: #f8f9fa;
    border: 1px solid var(--bs-border-color);
    border-radius: .35rem;
    padding: .25rem .5rem;
    margin-bottom: .3rem;
}
.note-attach-item-name { min-width: 0; }
.btn-close-sm { width: .55em; height: .55em; }

.theme-midnight .history-pill--created    { background: rgba(34,197,94,.15);  color: #86efac; border-color: rgba(34,197,94,.35); }
.theme-midnight .history-pill--rescheduled { background: rgba(96,165,250,.15); color: #93c5fd; border-color: rgba(96,165,250,.35); }
.theme-midnight .history-pill--cancelled  { background: rgba(248,113,113,.15); color: #fca5a5; border-color: rgba(248,113,113,.35); }
.theme-midnight .history-pill--note       { background: rgba(251,146,60,.15); color: #fdba74; border-color: rgba(251,146,60,.35); }

/* Status tile grid — used inside the lead-status offcanvas. */
.status-tile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .55rem;
}
.status-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .85rem .55rem;
    background-color: #ffffff;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    color: #57534e;
    text-align: center;
    transition: border-color .12s ease, background-color .12s ease, color .12s ease;
    cursor: pointer;
    font-size: .82rem;
    line-height: 1.15;
    min-height: 5.2rem;
}
.status-tile i { font-size: 1.35rem; line-height: 1; }
.status-tile:hover {
    border-color: #c7c2b3;
    background-color: #faf8f3;
    color: var(--bs-emphasis-color);
}
.status-tile.is-active {
    color: var(--bs-emphasis-color);
    border-color: var(--bs-emphasis-color);
    background-color: #fdfaf0;
    box-shadow: inset 0 0 0 1px var(--bs-emphasis-color);
}
/* Per-tone accent — only visible on the active tile, kept very subtle. */
.status-tile[data-tone="success"].is-active { border-color: #15803d; box-shadow: inset 0 0 0 1px #15803d; color: #14532d; }
.status-tile[data-tone="warning"].is-active { border-color: #b45309; box-shadow: inset 0 0 0 1px #b45309; color: #7c2d12; }
.status-tile[data-tone="danger"].is-active  { border-color: #b91c1c; box-shadow: inset 0 0 0 1px #b91c1c; color: #7f1d1d; }
.status-tile[data-tone="info"].is-active    { border-color: #1d4ed8; box-shadow: inset 0 0 0 1px #1d4ed8; color: #1e3a8a; }

@media (max-width: 575.98px) {
    .status-tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Allocation page fixed footer (M10) ------------------------- */
.allocate-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(250, 248, 243, .92);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-top: 1px solid var(--bs-border-color);
    box-shadow: 0 -2px 14px rgba(28, 25, 23, .05);
    padding: .75rem 1.25rem;
    z-index: 1030;
}
body.has-allocate-footer .app-main { padding-bottom: 6rem; }

/* ---- Auth screens ------------------------------------------------- */
/* The centred .auth-wrap / .auth-card shell was replaced by the two-pane
   .auth-split layout further down this file. */

/* ---- Drag handles ---- */
.drag-handle {
    cursor: grab;
    color: var(--bs-tertiary-color);
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; }

/* ---- Subtle helpers ---- */
.text-muted { color: var(--bs-secondary-color) !important; }
hr { border-color: var(--bs-border-color); opacity: 1; }

/* Bulk-select checkbox column on the /leads listing — keep it tight. */
.leads-check-col { width: 2.25rem; text-align: center; }

/* ---- Tag filter dropdown (M16) ------------------------------------ */
.tag-filter-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tag-filter-item {
    border-radius: var(--bs-border-radius-sm);
    cursor: pointer;
    font-size: .875rem;
    padding: .25rem .5rem !important;
}
.tag-filter-item:hover {
    background-color: var(--bs-tertiary-bg);
}

/* ---- Field customisation offcanvas (M16) -------------------------- */
.field-sort-item {
    font-size: .875rem;
    padding: .4rem .6rem !important;
    border-radius: var(--bs-border-radius-sm) !important;
    margin-bottom: 2px;
    border: 1px solid var(--bs-border-color);
    transition: border-color .12s ease;
    cursor: default;
}
.field-sort-item:hover {
    border-color: #c7c2b3;
}
.field-sort-item .drag-handle {
    cursor: grab;
    color: var(--bs-tertiary-color);
    font-size: 1rem;
}
.field-sort-item .drag-handle:active {
    cursor: grabbing;
}
.field-sort-item .field-visibility-toggle {
    cursor: pointer;
}
.field-sort-item.sortable-ghost {
    opacity: .4;
    border-style: dashed;
}
.field-sort-item.is-indented {
    margin-left: 1.5rem;
    border-left: 2px solid var(--bs-primary);
}
.field-sort-item .field-indent-toggle {
    color: var(--bs-tertiary-color);
    line-height: 1;
}
.field-sort-item .field-indent-toggle:hover {
    color: var(--bs-primary);
}
.field-sort-item .field-indent-toggle:disabled,
.field-sort-item .field-indent-toggle.disabled {
    color: var(--bs-border-color);
    cursor: not-allowed;
}

/* Sub-lines for indented child fields rendered inside a parent's cell. */
.lead-cell-sub {
    margin-top: .15rem;
    font-size: .8125rem;
    color: var(--bs-secondary-color);
    line-height: 1.3;
}
.lead-cell-sub-label {
    font-weight: 500;
    margin-right: .25rem;
}
.lead-cell-sub-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

/* ---- Theme fixes for dark mode (M16) ------------------------------ */
.theme-midnight .field-sort-item {
    background-color: var(--bs-tertiary-bg);
    border-color: #334155;
}
.theme-midnight .field-sort-item:hover {
    border-color: #818cf8;
}
.theme-midnight .tag-filter-item:hover {
    background-color: rgba(129, 140, 248, .08);
}

/* ---- Theme: Ocean (cool blue) ------------------------------------ */
.theme-ocean {
    --bs-body-bg:        #f0f4f8;
    --bs-body-color:     #0f172a;
    --bs-emphasis-color: #0c4a6e;
    --bs-secondary-color: #475569;
    --bs-tertiary-color:  #94a3b8;
    --bs-tertiary-bg:     #e2e8f0;

    --bs-border-color:             #cbd5e1;
    --bs-border-color-translucent: rgba(15, 23, 42, .08);

    --bs-primary:     #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color:        #0f766e;
    --bs-link-color-rgb:    15, 118, 110;
    --bs-link-hover-color:  #115e59;

    --bs-secondary:     #64748b;
    --bs-secondary-rgb: 100, 116, 139;

    --is-accent: #0f766e;
    --is-accent-soft: rgba(15, 118, 110, .08);
    --is-warm-bg: #f0f4f8;
    --is-header-dark: #0c4a6e;   /* deep ocean blue — the theme's emphasis tone */
}
.theme-ocean .btn-primary {
    --bs-btn-bg:         #0f766e;
    --bs-btn-border-color: #0f766e;
    --bs-btn-hover-bg:   #115e59;
    --bs-btn-hover-border-color: #115e59;
    --bs-btn-active-bg:  #134e4a;
    --bs-btn-active-border-color: #134e4a;
    --bs-btn-color:      #f0fdfa;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-disabled-bg:           #cbd5e1;
    --bs-btn-disabled-border-color: #94a3b8;
    --bs-btn-disabled-color:        #64748b;
}
.theme-ocean .btn-outline-primary {
    --bs-btn-color:        #0f766e;
    --bs-btn-border-color: #cbd5e1;
    --bs-btn-hover-bg:     #e2e8f0;
    --bs-btn-hover-border-color: #0f766e;
    --bs-btn-hover-color:  #0f766e;
    --bs-btn-active-bg:    #0f766e;
    --bs-btn-active-border-color: #0f766e;
    --bs-btn-active-color: #ffffff;
}
.theme-ocean .btn-outline-secondary {
    --bs-btn-color:        #475569;
    --bs-btn-border-color: #cbd5e1;
    --bs-btn-hover-bg:     #e2e8f0;
    --bs-btn-hover-color:  #0f172a;
    --bs-btn-hover-border-color: #94a3b8;
}
.theme-ocean .app-navbar {
    background-color: rgba(240, 244, 248, .85);
}
.theme-ocean .goal-done     { background-color: #d1fae5; color: #065f46; }
.theme-ocean .goal-not-done { background-color: #fee2e2; color: #dc2626; }
.theme-ocean .goal-todo     { background-color: #fef3c7; color: #92400e; }
.theme-ocean .goal-overdue  { background-color: #fbe6e1; color: #7f1d1d; }
.theme-ocean .table {
    --bs-table-hover-bg:   rgba(15, 23, 42, .035);
    --bs-table-striped-bg: rgba(15, 23, 42, .02);
}
.theme-ocean .table-light,
.theme-ocean .table-light > th,
.theme-ocean .table-light > td {
    --bs-table-bg:    #e2e8f0;
    --bs-table-color: #475569;
}
.theme-ocean .table > thead th {
    color: #475569;
}
.theme-ocean .nav-tabs .badge {
    background-color: #cbd5e1 !important;
    color: #475569 !important;
}

/* ---- Theme: Forest (natural green) -------------------------------- */
.theme-forest {
    --bs-body-bg:        #f4f7f2;
    --bs-body-color:     #1a2e1a;
    --bs-emphasis-color: #14532d;
    --bs-secondary-color: #4a7c59;
    --bs-tertiary-color:  #8ba888;
    --bs-tertiary-bg:     #e6ede3;

    --bs-border-color:             #cfe0cf;
    --bs-border-color-translucent: rgba(26, 46, 26, .08);

    --bs-primary:     #2d6a4f;
    --bs-primary-rgb: 45, 106, 79;
    --bs-link-color:        #2d6a4f;
    --bs-link-color-rgb:    45, 106, 79;
    --bs-link-hover-color:  #1b4332;

    --bs-secondary:     #5a8f6a;
    --bs-secondary-rgb: 90, 143, 106;

    --is-accent: #2d6a4f;
    --is-accent-soft: rgba(45, 106, 79, .08);
    --is-warm-bg: #f4f7f2;
    --is-header-dark: #14532d;   /* deep forest green — the theme's emphasis tone */
}
.theme-forest .btn-primary {
    --bs-btn-bg:         #2d6a4f;
    --bs-btn-border-color: #2d6a4f;
    --bs-btn-hover-bg:   #1b4332;
    --bs-btn-hover-border-color: #1b4332;
    --bs-btn-active-bg:  #143a26;
    --bs-btn-active-border-color: #143a26;
    --bs-btn-color:      #f0fdf4;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-disabled-bg:           #cfe0cf;
    --bs-btn-disabled-border-color: #8ba888;
    --bs-btn-disabled-color:        #5a8f6a;
}
.theme-forest .btn-outline-primary {
    --bs-btn-color:        #2d6a4f;
    --bs-btn-border-color: #cfe0cf;
    --bs-btn-hover-bg:     #e6ede3;
    --bs-btn-hover-border-color: #2d6a4f;
    --bs-btn-hover-color:  #2d6a4f;
    --bs-btn-active-bg:    #2d6a4f;
    --bs-btn-active-border-color: #2d6a4f;
    --bs-btn-active-color: #ffffff;
}
.theme-forest .btn-outline-secondary {
    --bs-btn-color:        #4a7c59;
    --bs-btn-border-color: #cfe0cf;
    --bs-btn-hover-bg:     #e6ede3;
    --bs-btn-hover-color:  #1a2e1a;
    --bs-btn-hover-border-color: #8ba888;
}
.theme-forest .app-navbar {
    background-color: rgba(244, 247, 242, .85);
}
.theme-forest .goal-done     { background-color: #d1fae5; color: #065f46; }
.theme-forest .goal-not-done { background-color: #fee2e2; color: #dc2626; }
.theme-forest .goal-todo     { background-color: #fef3c7; color: #92400e; }
.theme-forest .goal-overdue  { background-color: #fbe6e1; color: #7f1d1d; }
.theme-forest .table {
    --bs-table-hover-bg:   rgba(26, 46, 26, .035);
    --bs-table-striped-bg: rgba(26, 46, 26, .02);
}
.theme-forest .table-light,
.theme-forest .table-light > th,
.theme-forest .table-light > td {
    --bs-table-bg:    #e6ede3;
    --bs-table-color: #4a7c59;
}
.theme-forest .table > thead th {
    color: #4a7c59;
}
.theme-forest .nav-tabs .badge {
    background-color: #cfe0cf !important;
    color: #4a7c59 !important;
}

/* ---- Theme: Midnight (dark mode) ---------------------------------- */
.theme-midnight {
    --bs-body-bg:        #0f1117;
    --bs-body-color:     #e2e8f0;
    --bs-emphasis-color: #f1f5f9;
    --bs-secondary-color: #94a3b8;
    --bs-tertiary-color:  #64748b;
    --bs-tertiary-bg:     #1e293b;

    --bs-border-color:             #334155;
    --bs-border-color-translucent: rgba(226, 232, 240, .08);

    --bs-primary:     #818cf8;
    --bs-primary-rgb: 129, 140, 248;
    --bs-link-color:        #818cf8;
    --bs-link-color-rgb:    129, 140, 248;
    --bs-link-hover-color:  #a5b4fc;

    --bs-secondary:     #64748b;
    --bs-secondary-rgb: 100, 116, 139;

    --is-accent: #818cf8;
    --is-accent-soft: rgba(129, 140, 248, .1);
    --is-warm-bg: #0f1117;
    /* Midnight's navbar is already this colour, so the dark-header flag is a
       no-op here rather than a visual change. Defined anyway so the variable is
       never missing on any theme. */
    --is-header-dark: #0f1117;

    color-scheme: dark;
}
.theme-midnight .form-control,
.theme-midnight .form-select {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
.theme-midnight .form-control:focus,
.theme-midnight .form-select:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 .2rem rgba(129, 140, 248, .15);
}
.theme-midnight .card {
    background-color: #1a1d27;
    border-color: #334155;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}
.theme-midnight .card-header,
.theme-midnight .card-footer {
    background-color: #1a1d27 !important;
    border-color: #334155;
}
.theme-midnight .btn-primary {
    --bs-btn-bg:         #6366f1;
    --bs-btn-border-color: #6366f1;
    --bs-btn-hover-bg:   #4f46e5;
    --bs-btn-hover-border-color: #4f46e5;
    --bs-btn-active-bg:  #4338ca;
    --bs-btn-active-border-color: #4338ca;
    --bs-btn-color:      #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-disabled-bg:           #334155;
    --bs-btn-disabled-border-color: #475569;
    --bs-btn-disabled-color:        #94a3b8;
}
.theme-midnight .btn-outline-primary {
    --bs-btn-color:        #818cf8;
    --bs-btn-border-color: #475569;
    --bs-btn-hover-bg:     rgba(129, 140, 248, .08);
    --bs-btn-hover-border-color: #818cf8;
    --bs-btn-hover-color:  #818cf8;
    --bs-btn-active-bg:    #6366f1;
    --bs-btn-active-border-color: #6366f1;
    --bs-btn-active-color: #ffffff;
}
.theme-midnight .btn-outline-secondary {
    --bs-btn-color:        #94a3b8;
    --bs-btn-border-color: #475569;
    --bs-btn-hover-bg:     rgba(148, 163, 184, .08);
    --bs-btn-hover-color:  #e2e8f0;
    --bs-btn-hover-border-color: #94a3b8;
}
.theme-midnight .app-navbar {
    background-color: rgba(15, 17, 23, .85);
    border-bottom-color: #334155;
}
.theme-midnight .app-navbar .nav-link {
    color: #94a3b8;
}
.theme-midnight .app-navbar .nav-link:hover,
.theme-midnight .app-navbar .nav-link.active {
    color: #f1f5f9;
    background-color: rgba(129, 140, 248, .1);
}
.theme-midnight .table {
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
    --bs-table-border-color: #334155;
    --bs-table-hover-bg: rgba(129, 140, 248, .04);
    --bs-table-striped-bg: rgba(129, 140, 248, .025);
}
.theme-midnight .table-light,
.theme-midnight .table-light > th,
.theme-midnight .table-light > td {
    --bs-table-bg: #1e293b;
    --bs-table-color: #94a3b8;
}
.theme-midnight .table > thead th {
    color: #94a3b8;
}
.theme-midnight .nav-tabs {
    border-bottom-color: #334155;
}
.theme-midnight .nav-tabs .nav-link {
    color: #94a3b8;
}
.theme-midnight .nav-tabs .nav-link:hover {
    color: #f1f5f9;
    border-color: transparent transparent #64748b;
}
.theme-midnight .nav-tabs .nav-link.active {
    color: #f1f5f9;
    border-color: transparent transparent #818cf8;
}
.theme-midnight .nav-tabs .badge {
    background-color: #334155 !important;
    color: #94a3b8 !important;
}
.theme-midnight .modal-content,
.theme-midnight .offcanvas {
    background-color: #1a1d27;
    border-color: #334155;
}
.theme-midnight .modal-header,
.theme-midnight .offcanvas-header {
    border-bottom-color: #334155;
}
.theme-midnight .modal-footer {
    border-top-color: #334155;
}
.theme-midnight .goal-done     { background-color: #064e3b; color: #6ee7b7; }
.theme-midnight .goal-not-done { background-color: #450a0a; color: #fca5a5; }
.theme-midnight .goal-todo     { background-color: #451a03; color: #fcd34d; }
.theme-midnight .goal-overdue  { background-color: #450a0a; color: #fca5a5; }
.theme-midnight .goal-anytime  { background-color: transparent; }
.theme-midnight .goal-future   { background-color: transparent; color: #64748b; }
.theme-midnight .goal-waiting  { background-color: transparent; color: #64748b; }
.theme-midnight .goal-sidebar .goal-item .goal-bullet {
    background-color: #334155;
    color: #94a3b8;
}
.theme-midnight .goal-sidebar .goal-item.state-done     .goal-bullet { background: #064e3b; color: #6ee7b7; }
.theme-midnight .goal-sidebar .goal-item.state-not_done .goal-bullet { background: #450a0a; color: #fca5a5; }
.theme-midnight .goal-sidebar .goal-item.state-todo     .goal-bullet { background: #451a03; color: #fcd34d; }
.theme-midnight .goal-sidebar .goal-item.state-overdue  .goal-bullet { background: #450a0a; color: #fca5a5; }
.theme-midnight .goal-sidebar .goal-item.state-anytime  .goal-bullet { background: #334155; color: #94a3b8; }
/* No .auth-* overrides here: auth screens always render Theme::DEFAULT, so the
   midnight theme never reaches them. */
.theme-midnight .allocate-footer {
    background-color: rgba(15, 17, 23, .92);
    border-top-color: #334155;
}
.theme-midnight .history-block-header {
    background-color: #1e293b;
}
.theme-midnight .history-event {
    border-bottom-color: #1e293b;
}
.theme-midnight .field-target {
    background-color: #1e293b;
    box-shadow: inset 3px 0 0 #818cf8;
}
.theme-midnight .status-tile {
    background-color: #1a1d27;
    border-color: #334155;
    color: #94a3b8;
}
.theme-midnight .status-tile:hover {
    border-color: #818cf8;
    background-color: #1e293b;
    color: #f1f5f9;
}
.theme-midnight .status-tile.is-active {
    border-color: #818cf8;
    background-color: rgba(129, 140, 248, .08);
    box-shadow: inset 0 0 0 1px #818cf8;
    color: #f1f5f9;
}
.theme-midnight .goal-cell.goal-not-done .goal-pill { color: #fca5a5; }
.theme-midnight .goal-cell.goal-done     .goal-pill { color: #6ee7b7; }
.theme-midnight .goal-cell.goal-todo     .goal-pill { color: #fcd34d; }
.theme-midnight .goal-cell.goal-overdue  .goal-pill { color: #fca5a5; }
.theme-midnight #gaInstructions {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
.theme-midnight .history-event-notes {
    background-color: #1e293b;
    border-left-color: #818cf8;
    color: #cbd5e1;
}
.theme-midnight .alert {
    border-color: #334155;
}
.theme-midnight .alert-success { background-color: #064e3b; color: #6ee7b7; }
.theme-midnight .alert-danger  { background-color: #450a0a; color: #fca5a5; }
.theme-midnight .alert-warning { background-color: #451a03; color: #fcd34d; }
.theme-midnight .alert-info    { background-color: #1e293b; color: #93c5fd; }
/* Slightly darker dropdown border across light themes (default/ocean/forest). */
.dropdown-menu {
    border-color: #aaa;
}
#processMenu {
    z-index: 1100;
}
.theme-midnight .dropdown-menu {
    background-color: #1a1d27;
    border-color: #858e9b;
}
.theme-midnight .dropdown-item {
    color: #e2e8f0;
}
.theme-midnight .dropdown-item:hover {
    background-color: rgba(129, 140, 248, .1);
    color: #f1f5f9;
}
.theme-midnight .dropdown-divider {
    border-color: #334155;
}
.theme-midnight .dropdown-item-text.text-muted {
    color: #64748b !important;
}
.theme-midnight .text-muted {
    color: var(--bs-secondary-color) !important;
}

/* ---- Theme preview cards on settings page ------------------------- */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}
.theme-option {
    cursor: pointer;
    border: 2px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    padding: .75rem;
    text-align: center;
    transition: border-color .15s ease, box-shadow .15s ease;
    background: var(--bs-body-bg);
}
.theme-option:hover {
    border-color: var(--bs-primary);
}
.theme-option.is-selected {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px var(--bs-primary);
}
.theme-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.theme-label {
    display: block;
    margin-top: .5rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--bs-body-color);
}
.theme-preview {
    width: 100%;
    height: 90px;
    border-radius: calc(var(--bs-border-radius-sm) - 1px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--bs-border-color);
}

/* Preview navbar bar */
.tp-navbar {
    height: 16px;
    display: flex;
    align-items: center;
    padding: 0 6px;
}
.tp-navbar::before {
    content: '';
    width: 40%;
    height: 5px;
    border-radius: 3px;
}
.tp-body {
    flex: 1;
    display: flex;
}
.tp-sidebar {
    width: 20%;
    height: 100%;
}
.tp-content {
    flex: 1;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tp-line {
    height: 4px;
    border-radius: 2px;
}
.tp-line-short { width: 55%; }
.tp-line-med   { width: 75%; }

/* Preview: Default (warm slate) */
.theme-preview-default .tp-navbar {
    background: rgba(41, 37, 36, .85);
}
.theme-preview-default .tp-navbar::before {
    background: #faf8f3;
}
.theme-preview-default .tp-sidebar {
    background: #f2efe8;
}
.theme-preview-default .tp-content {
    background: #faf8f3;
}
.theme-preview-default .tp-line {
    background: #d6d3c9;
}

/* Preview: Ocean */
.theme-preview-ocean .tp-navbar {
    background: rgba(15, 118, 110, .85);
}
.theme-preview-ocean .tp-navbar::before {
    background: #f0f4f8;
}
.theme-preview-ocean .tp-sidebar {
    background: #e2e8f0;
}
.theme-preview-ocean .tp-content {
    background: #f0f4f8;
}
.theme-preview-ocean .tp-line {
    background: #cbd5e1;
}

/* Preview: Forest */
.theme-preview-forest .tp-navbar {
    background: rgba(45, 106, 79, .85);
}
.theme-preview-forest .tp-navbar::before {
    background: #f4f7f2;
}
.theme-preview-forest .tp-sidebar {
    background: #e6ede3;
}
.theme-preview-forest .tp-content {
    background: #f4f7f2;
}
.theme-preview-forest .tp-line {
    background: #cfe0cf;
}

/* Preview: Midnight */
.theme-preview-midnight .tp-navbar {
    background: rgba(129, 140, 248, .85);
}
.theme-preview-midnight .tp-navbar::before {
    background: #0f1117;
}
.theme-preview-midnight .tp-sidebar {
    background: #1e293b;
}
.theme-preview-midnight .tp-content {
    background: #0f1117;
}
.theme-preview-midnight .tp-line {
    background: #334155;
}

/* ====================================================================
   M17 — Individual user calendar
   ==================================================================== */

.calendar-page { min-height: calc(100vh - 100px); }

/* Header: title on the left, actions (Link / Settings) on the right.
   Month navigation lives inside the month pane now. */
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.cal-header-left   { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.cal-header-right  { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; }

.calendar-layout {
    display: flex;
    gap: .75rem;
    align-items: stretch;
    /* Cap the whole layout to the available viewport so each pane stops
       growing past it and its internal scroll container kicks in. */
    height: calc(100vh - 160px);
    min-height: 500px;
}
.cal-pane {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: .75rem;
    display: flex;
    flex-direction: column;
    transition: flex-basis .25s ease, max-width .25s ease, opacity .2s ease;
    overflow: hidden;
}

/* Dual mode: month 3/4, day 1/4, entry hidden. All panes fill the layout
   height; the month grid below scrolls when a busy week exceeds its room. */
[data-mode="dual"] .cal-pane-month  { flex: 0 0 75%; max-width: 75%; }
[data-mode="dual"] .cal-pane-day    { flex: 0 0 25%; max-width: 25%; }
[data-mode="dual"] .cal-pane-entry  { flex: 0 0 0;   max-width: 0;   padding: 0; border: 0; opacity: 0; }

/* Tri mode: month 1/4 (list layout), day 1/4, entry 2/4. */
[data-mode="tri"] .cal-pane-month   { flex: 0 0 25%; max-width: 25%; }
[data-mode="tri"] .cal-pane-day     { flex: 0 0 25%; max-width: 25%; }
[data-mode="tri"] .cal-pane-entry   { flex: 0 0 50%; max-width: 50%; opacity: 1; overflow-y: auto; }

/* In tri mode swap month grid for vertical list. */
[data-mode="tri"] .cal-pane-month .cal-month-grid,
[data-mode="tri"] .cal-pane-month .cal-weekday-row { display: none; }
[data-mode="tri"] .cal-pane-month .cal-month-list  { display: block; }

/* ---- Month grid ---------------------------------------------------- */
.cal-month-header {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .5rem;
}
.cal-month-title {
    font-weight: 600;
    font-size: 1rem;
    min-width: 10rem;
    text-align: center;
}
.cal-month-nav-btn { padding: .15rem .45rem; }
.cal-weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    font-size: .75rem;
    color: var(--bs-secondary-color);
    text-align: center;
    padding-bottom: .25rem;
    font-weight: 500;
}
.cal-weekday-row span { padding: .15rem 0; }
.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* The JS always renders 6 weeks (42 cells). Each row floors at 86px
       (room for date + 3 chips) and otherwise takes a 1fr share of the
       available pane height, so light months spread to fill. A busy week
       can still push past its share via content; the grid scrolls inside
       the pane when total height exceeds the room available. */
    grid-template-rows: repeat(6, minmax(86px, 1fr));
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}
.cal-day-cell {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    padding: .25rem;
    background: #ffffff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    overflow: hidden;
    transition: background-color .12s ease, border-color .12s ease;
}
.cal-day-cell:hover { background: var(--bs-tertiary-bg); }
.theme-midnight .cal-day-cell { background: #1a1d27; }
.theme-midnight .cal-day-cell:hover { background: #232838; }
.cal-day-cell.is-other-month { opacity: .45; }
.cal-day-cell.is-selected { border-color: var(--bs-primary); border-width: 2px; padding: calc(.25rem - 1px); }
.cal-day-cell.is-drop-target {
    border-color: var(--bs-primary);
    background: var(--is-accent-soft);
    box-shadow: inset 0 0 0 1px var(--bs-primary);
}
.cal-day-chip.is-dragging { opacity: .4; }

.cal-day-num {
    font-size: .8rem;
    font-weight: 500;
    line-height: 1;
    text-align: right;
    color: var(--bs-secondary-color);
}
.cal-day-cell.is-today .cal-day-num {
    background: var(--bs-primary);
    color: #fff;
    border-radius: 999px;
    padding: .15rem .35rem;
    align-self: flex-end;
    font-weight: 600;
}

.cal-day-chips { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-day-chip {
    font-size: .7rem;
    line-height: 1.2;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--is-accent-soft, rgba(41,37,36,.08));
    color: var(--bs-emphasis-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background-color .12s ease, box-shadow .12s ease;
}
.cal-day-chip:hover {
    background: var(--bs-primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.cal-day-chip.is-done     { text-decoration: line-through; opacity: .55; }
.cal-day-chip.is-cancelled { text-decoration: line-through; opacity: .4; background: transparent; }
.cal-day-chip-more {
    font-size: .7rem;
    color: var(--bs-secondary-color);
    cursor: pointer;
}

/* ---- Month-as-list (tri mode) ------------------------------------- */
.cal-month-list { display: none; overflow-y: auto; flex: 1; }
.cal-month-list-day {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
    font-size: .85rem;
    background: #ffffff;
}
.cal-month-list-day:hover { background: var(--bs-tertiary-bg); }
.theme-midnight .cal-month-list-day { background: #1a1d27; }
.theme-midnight .cal-month-list-day:hover { background: #232838; }
.cal-month-list-day.is-selected { background: var(--is-accent-soft); }
.cal-month-list-day.is-today .cal-mll-date {
    background: var(--bs-primary);
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-weight: 600;
}
.cal-mll-date { font-weight: 500; min-width: 2.5rem; }
.cal-mll-weekday { color: var(--bs-secondary-color); font-size: .75rem; min-width: 2.5rem; }
.cal-mll-count {
    margin-left: auto;
    background: var(--is-accent-soft);
    color: var(--bs-emphasis-color);
    border-radius: 999px;
    padding: 0 .45rem;
    font-size: .7rem;
}
.cal-mll-count.is-zero { background: transparent; color: var(--bs-tertiary-color); }

/* ---- Day view 30-min slots ----------------------------------------- */
.cal-day-header {
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: .5rem;
    text-align: center;
}
.cal-day-grid-wrap {
    flex: 1;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
}
.cal-day-grid {
    position: relative;
    min-height: 100%;
}
/* Absolute-positioned event blocks live inside this column so their
   percentages don't include the 42px time-label gutter on the left.
   z-index lifts events above the (now solid-bg) slot rows. */
.cal-day-events {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 42px;
    right: 4px;
    pointer-events: none;
    z-index: 2;
}
.cal-day-events > * { pointer-events: auto; }
.cal-slot {
    display: flex;
    align-items: flex-start;
    height: 28px;
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
    padding: 0 0 0 38px;
    position: relative;
    box-sizing: border-box;
    background: #ffffff;
}
.cal-slot:hover { background: var(--bs-tertiary-bg); }
.theme-midnight .cal-slot { background: #1a1d27; }
.theme-midnight .cal-slot:hover { background: #232838; }
/* Subtle shade over slots that fall inside the user's declared booking
   availability — helps see at a glance when public bookings can land. */
.cal-slot.is-available { background: var(--is-accent-soft); }
.cal-slot.is-available:hover { background: var(--bs-tertiary-bg); }
.theme-midnight .cal-slot.is-available { background: rgba(129, 140, 248, .08); }
.theme-midnight .cal-slot.is-available:hover { background: #232838; }
.cal-slot.is-half { border-bottom-style: dashed; }
.cal-slot-label {
    position: absolute;
    left: 4px;
    top: -7px;
    font-size: .65rem;
    color: var(--bs-tertiary-color);
    font-variant-numeric: tabular-nums;
    background: #ffffff;
    padding: 0 2px;
}
.theme-midnight .cal-slot-label { background: #1a1d27; }
.cal-slot.is-half .cal-slot-label { display: none; }

/* Event blocks absolutely positioned over the slots. */
.cal-event-block {
    position: absolute;
    background: #ffffff;
    border: 1px solid var(--bs-border-color);
    border-left: 3px solid var(--bs-primary);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: .75rem;
    color: var(--bs-emphasis-color);
    cursor: pointer;
    overflow: hidden;
    box-sizing: border-box;
    transition: box-shadow .12s ease, border-color .12s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.cal-event-block:hover { box-shadow: 0 0 0 2px var(--bs-primary); }
.cal-event-block.is-done {
    text-decoration: line-through;
    opacity: .65;
}
.cal-event-block.is-cancelled {
    text-decoration: line-through;
    opacity: .5;
    border-left-color: var(--bs-tertiary-color);
}
.cal-event-block.is-selected { box-shadow: 0 0 0 2px var(--bs-primary); }
.cal-event-block.is-dragging { opacity: .6; pointer-events: none; }

/* Locked event (linked lead is receiving emails about it). */
.cal-event-block.is-locked {
    border-left-color: #2d6a4f;
    background: #f0fdf4;
}
/* Lock indicator now lives inside the shared .cal-event-badges row;
   see the .cal-event-badge rules below. */
.theme-midnight .cal-event-block.is-locked {
    background: rgba(45,106,79,.18);
    border-left-color: #6ba94a;
}

/* Locked chip on the month grid: small lock icon prefix. */
.cal-day-chip.is-locked {
    padding-left: 16px;
    position: relative;
}
.cal-day-chip.is-locked::before {
    content: '\F47F'; /* bi-lock-fill */
    font-family: 'bootstrap-icons';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .65rem;
    color: #2d6a4f;
}
.theme-midnight .cal-event-block {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

.cal-event-title { font-weight: 500; }
.cal-event-time { font-size: .68rem; color: var(--bs-secondary-color); }

/* Top-right indicator row for an event block. Any number of badges line
   up horizontally so they don't overlap. */
.cal-event-badges {
    position: absolute;
    top: 5px;
    right: 4px;
    display: flex;
    gap: 3px;
    align-items: center;
    pointer-events: none;
}
.cal-event-badge {
    color: #2d6a4f;
    font-size: .8rem;
    line-height: 1;
    display: inline-flex;
}
.theme-midnight .cal-event-badge { color: #6ba94a; }

/* Top/bottom resize handles. */
.cal-event-resize {
    position: absolute;
    left: 0; right: 0;
    height: 6px;
    cursor: ns-resize;
}
.cal-event-resize-top    { top: 0; }
.cal-event-resize-bottom { bottom: 0; }

.cal-now-line {
    position: absolute;
    left: 38px; right: 0;
    height: 1px;
    background: #dc2626;
    pointer-events: none;
}
.cal-now-line::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 7px; height: 7px;
    background: #dc2626;
    border-radius: 50%;
}

/* ---- Entry pane ---------------------------------------------------- */
.cal-pane-entry .form-label-sm {
    margin-bottom: .15rem;
    color: var(--bs-secondary-color);
}

/* Status button group — modelled on the lead-status offcanvas tiles. */
.cal-status-group {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.cal-status-btn {
    flex: 1 1 auto;
    border: 1px solid var(--bs-border-color);
    background: #ffffff;
    color: var(--bs-secondary-color);
    border-radius: var(--bs-border-radius-sm);
    padding: .35rem .55rem;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease, color .12s ease;
}
.cal-status-btn:hover { border-color: var(--bs-primary); color: var(--bs-emphasis-color); }
.cal-status-btn.is-active {
    border-color: var(--bs-primary);
    background: var(--is-accent-soft);
    color: var(--bs-emphasis-color);
}
.cal-status-btn-cancel.is-active {
    border-color: #dc2626;
    background: #fee2e2;
    color: #7f1d1d;
}
.cal-status-btn[hidden] { display: none !important; }
.theme-midnight .cal-status-btn { background: #1a1d27; }
.theme-midnight .cal-status-btn-cancel.is-active { background: rgba(248,113,113,.15); color: #fca5a5; border-color: rgba(248,113,113,.6); }
.cal-entry-notes-wrap textarea { resize: vertical; min-height: 160px; }
.cal-lead-results {
    position: absolute;
    left: 0; right: 0;
    z-index: 5;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
    max-height: 240px;
    overflow-y: auto;
    display: none;
    margin-top: 2px;
}
.cal-lead-results.is-open { display: block; }
.cal-lead-result {
    padding: .3rem .55rem;
    cursor: pointer;
    font-size: .85rem;
}
.cal-lead-result:hover { background: var(--bs-tertiary-bg); }

#cal-entry-save-status.is-saving { color: var(--bs-secondary-color); }
#cal-entry-save-status.is-saved  { color: #166534; }
#cal-entry-save-status.is-error  { color: #dc2626; }

/* ---- Booking settings page (M18) ---------------------------------- */
.bk-day-row {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: .35rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}
.bk-day-row:last-of-type { border-bottom: 0; }
.bk-day-label { font-weight: 500; }
.bk-day-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}
.bk-range {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    background: var(--bs-tertiary-bg);
    border-radius: var(--bs-border-radius-sm);
    padding: .15rem .35rem;
    border: 1px solid transparent;
    transition: background-color .2s ease, border-color .2s ease;
}
.bk-range.is-unsaved {
    background: #fff8e1;
    border-color: #f0d678;
}
.theme-midnight .bk-range.is-unsaved {
    background: #3a3315;
    border-color: #8a6f1a;
}
.bk-range.is-flash {
    background: #c8e6a0;
    border-color: #4a7c30;
}
.theme-midnight .bk-range.is-flash {
    background: #2e4a1a;
    border-color: #6ba94a;
}
.bk-range-clone {
    color: var(--bs-secondary-color);
}
.bk-range-clone:hover {
    color: var(--bs-primary);
}
.bk-range input[type="time"] {
    width: 6.5em;
    background: #fff;
}
.theme-midnight .bk-range input[type="time"] {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

/* Two-select 30-min time picker — only :00 and :30 are ever selectable. */
.bk-time-pick {
    display: inline-flex;
    align-items: center;
    gap: .15rem;
}
.bk-time-pick .bk-tp-hour,
.bk-time-pick .bk-tp-min {
    padding: .15rem .3rem;
    font-size: .85rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: #fff;
    line-height: 1.1;
}
.bk-time-pick .bk-tp-sep { color: var(--bs-secondary-color); }
.theme-midnight .bk-time-pick .bk-tp-hour,
.theme-midnight .bk-time-pick .bk-tp-min {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.bk-exception {
    padding: .65rem .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    margin-bottom: .5rem;
    background: #fff;
}
.theme-midnight .bk-exception { background: #1a1d27; }

/* Exception modal day editor: label / mode / ranges in one row each. */
.bk-ex-day {
    display: grid;
    grid-template-columns: 110px 130px 1fr auto;
    align-items: center;
    gap: .5rem;
    padding: .35rem 0;
    border-bottom: 1px dashed var(--bs-border-color);
}
.bk-ex-day:last-of-type { border-bottom: 0; }
.bk-ex-day-label { font-weight: 500; font-size: .9rem; }
.bk-ex-day-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.bk-ex-range {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    background: var(--bs-tertiary-bg);
    border-radius: var(--bs-border-radius-sm);
    padding: .15rem .35rem;
}
.bk-ex-range input[type="time"] { width: 6em; background: #fff; }
.theme-midnight .bk-ex-range input[type="time"] {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

#bk-slug-status { background: #fff; min-width: 38px; justify-content: center; }
.theme-midnight #bk-slug-status { background: var(--bs-tertiary-bg); }

/* ---- Public booking page (/meetwith/...) -------------------------- */
.public-page { background: var(--bs-body-bg); min-height: 100vh; }

.bk-day-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .35rem;
}
.bk-day-cell {
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    padding: .5rem .25rem;
    cursor: pointer;
    text-align: center;
    transition: border-color .12s ease, background-color .12s ease;
}
.bk-day-cell:hover { border-color: var(--bs-primary); }
.bk-day-cell.is-selected {
    border-color: var(--bs-primary);
    background: var(--is-accent-soft);
}
.bk-day-cell.is-today .bk-day-cell-num {
    color: var(--bs-primary);
    font-weight: 700;
}
.bk-day-cell.is-empty {
    opacity: .3;
    background: var(--bs-tertiary-bg);
    color: var(--bs-tertiary-color);
}
.bk-day-cell.is-empty:hover { border-color: var(--bs-border-color); }
.bk-day-cell-weekday { font-size: .72rem; color: var(--bs-secondary-color); text-transform: uppercase; }
.bk-day-cell-num     { font-size: 1.4rem; font-weight: 600; line-height: 1.1; }
.bk-day-cell-month   { font-size: .72rem; color: var(--bs-secondary-color); }

.bk-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .5rem;
}
.bk-slot-btn {
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    padding: .5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease, transform .08s ease;
}
.bk-slot-btn:hover {
    border-color: var(--bs-primary);
    background: var(--is-accent-soft);
}
.bk-slot-btn:active { transform: translateY(1px); }
.bk-slot-time { font-weight: 600; }
.bk-slot-btn.is-current {
    border-color: var(--bs-primary);
    background: var(--is-accent-soft);
    cursor: default;
}
.bk-slot-current-tag {
    font-size: .65rem;
    color: var(--bs-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-top: .1rem;
}

.bk-tz-row {
    display: block;
    width: 100%;
    padding: .35rem .5rem;
    border: 0;
    background: transparent;
    text-align: left;
    border-radius: var(--bs-border-radius-sm);
    font-size: .9rem;
}
.bk-tz-row:hover { background: var(--bs-tertiary-bg); }

/* Responsive: stack panes vertically on small screens. */
@media (max-width: 992px) {
    .calendar-layout { flex-direction: column; }
    [data-mode="dual"] .cal-pane-month,
    [data-mode="dual"] .cal-pane-day,
    [data-mode="tri"]  .cal-pane-month,
    [data-mode="tri"]  .cal-pane-day,
    [data-mode="tri"]  .cal-pane-entry { flex: 1 1 auto; max-width: 100%; }
    [data-mode="dual"] .cal-pane-entry { display: none; }
}

/* ---- Brand logos ---- */
/* The <img> carries width/height attributes to reserve space and avoid layout
   shift; these rules scale it down while keeping the intrinsic aspect ratio.
   Light/dark variants are trimmed to identical dimensions, so a theme switch
   never changes the rendered size. */
.app-logo {
    width: auto;
    height: auto;
    max-width: 100%;
}
.app-logo--long {
    height: 30px;
    width: auto;
}
/* The stacked lockup is sized by .auth-logo in the auth-split rules below. */
.app-navbar .navbar-brand {
    display: flex;
    align-items: center;
    padding-top: .25rem;
    padding-bottom: .25rem;
}
@media (max-width: 575.98px) {
    .app-logo--long { height: 26px; }
}

/* ---- Theme: Intellect (default) ----------------------------------
 * The Sales Intellect brand system: brand blues as anchors, soft blue tints
 * and neutrals for everyday surfaces, calm accents. Deliberately no amber —
 * in a CRM full of statuses it competes with real alerts, so "todo"/"on hold"
 * use Lilac and alerts use Rose.
 *
 * Source of truth: newfiles/claude-sales-intellect-crm-system-v3.html
 *   brand   light-blue #00c8ff · dark-blue #004499 · bg-blue #00317c
 *   tints   blue-50 #eef6fd · blue-100 #d9ecfa · blue-200 #b3d7f2
 *   neutral ink #1a2230 · graphite #45505f · slate #6b7686 · mist #e4e9f0
 *           cloud #f0f3f7 · paper #f7f9fc
 *   accents teal #17a2a8 · sage #4fb286 · lilac #7c83db · rose #e06c78
 *
 * Per the system's working rules the app canvas stays Paper/White with Dark
 * Blue as the single primary action — the navbar is therefore light, which is
 * also why this theme uses the on-light logo (see Theme::isDark).
 */
.theme-intellect {
    /* The system specifies one Segoe UI display/body stack — no serif. */
    --bs-font-sans-serif: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue',
                          Arial, sans-serif;
    --is-font-serif:      'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

    --bs-body-bg:         #f7f9fc;  /* paper */
    --bs-body-color:      #1a2230;  /* ink */
    --bs-emphasis-color:  #004499;  /* dark blue — "headings, key structure" */
    --bs-secondary-color: #45505f;  /* graphite */
    --bs-tertiary-color:  #6b7686;  /* slate */
    --bs-tertiary-bg:     #f0f3f7;  /* cloud */

    --bs-border-color:             #e4e9f0;  /* mist / stroke */
    --bs-border-color-translucent: rgba(26, 34, 48, .08);
    --bs-border-radius:    .5rem;   /* --r-sm 8px  */
    --bs-border-radius-sm: .375rem;
    --bs-border-radius-lg: .75rem;  /* --r 12px    */

    --bs-primary:     #004499;
    --bs-primary-rgb: 0, 68, 153;
    --bs-link-color:       #004499;
    --bs-link-color-rgb:   0, 68, 153;
    --bs-link-hover-color: #0052b8;

    --bs-secondary:     #6b7686;
    --bs-secondary-rgb: 107, 118, 134;

    /* Focus rings: light blue at ~16% — on-brand and visible for keyboard users. */
    --bs-focus-ring-color: rgba(0, 200, 255, .16);

    --is-accent: #004499;
    --is-accent-soft: #eef6fd;  /* blue-50 — the system's hover fill */
    --is-warm-bg: #f7f9fc;
    /* BG Blue. The design system reserves this exact colour for "header bars,
       deep gradients, sidebars" — so it is literally what a dark header wants. */
    --is-header-dark: #00317c;
}
.theme-intellect .btn-primary {
    --bs-btn-bg:         #004499;
    --bs-btn-border-color: #004499;
    --bs-btn-hover-bg:   #0052b8;
    --bs-btn-hover-border-color: #0052b8;
    --bs-btn-active-bg:  #00317c;
    --bs-btn-active-border-color: #00317c;
    --bs-btn-color:      #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-disabled-bg:           #cdd6e2;
    --bs-btn-disabled-border-color: #cdd6e2;
    --bs-btn-disabled-color:        #6b7686;
}
.theme-intellect .btn-outline-primary {
    --bs-btn-color:        #004499;
    --bs-btn-border-color: #cdd6e2;  /* stroke-strong */
    --bs-btn-hover-bg:     #eef6fd;
    --bs-btn-hover-border-color: #004499;
    --bs-btn-hover-color:  #004499;
    --bs-btn-active-bg:    #004499;
    --bs-btn-active-border-color: #004499;
    --bs-btn-active-color: #ffffff;
}
.theme-intellect .btn-outline-secondary {
    --bs-btn-color:        #45505f;
    --bs-btn-border-color: #cdd6e2;
    --bs-btn-hover-bg:     #f0f3f7;
    --bs-btn-hover-color:  #1a2230;
    --bs-btn-hover-border-color: #6b7686;
}
/* Soft destructive: rose outline, filled only on confirm. */
.theme-intellect .btn-danger {
    --bs-btn-bg:         #e06c78;
    --bs-btn-border-color: #e06c78;
    --bs-btn-hover-bg:   #c9525f;
    --bs-btn-hover-border-color: #c9525f;
    --bs-btn-color:      #ffffff;
}
.theme-intellect .btn-outline-danger {
    --bs-btn-color:        #c04552;
    --bs-btn-border-color: #f0cdd1;
    --bs-btn-hover-bg:     #fbeef0;
    --bs-btn-hover-color:  #c04552;
    --bs-btn-hover-border-color: #e06c78;
}
.theme-intellect .btn-success {
    --bs-btn-bg:         #4fb286;
    --bs-btn-border-color: #4fb286;
    --bs-btn-hover-bg:   #3f9d74;
    --bs-btn-hover-border-color: #3f9d74;
    --bs-btn-color:      #ffffff;
    --bs-btn-hover-color: #ffffff;
}
.theme-intellect .app-navbar {
    background-color: rgba(247, 249, 252, .85);
    border-bottom-color: #e4e9f0;
}
.theme-intellect .app-navbar .nav-link { color: #45505f; }
.theme-intellect .form-control:focus,
.theme-intellect .form-select:focus {
    border-color: #00c8ff;
    box-shadow: 0 0 0 3px rgba(0, 200, 255, .16);
}
/* Status colours — sage / rose / lilac. No amber, by design. */
.theme-intellect .goal-done     { background-color: #e6f6f2; color: #0d7a5f; }
.theme-intellect .goal-not-done { background-color: #fbeef0; color: #c04552; }
.theme-intellect .goal-todo     { background-color: #eef0fb; color: #4b52b3; }
.theme-intellect .goal-overdue  { background-color: #f7dfe3; color: #a3323f; }
.theme-intellect .history-pill--created     { background: #e6f6f2; color: #0d7a5f; border-color: #c4e8dc; }
.theme-intellect .history-pill--rescheduled { background: #eef6fd; color: #004499; border-color: #b3d7f2; }
.theme-intellect .history-pill--cancelled   { background: #fbeef0; color: #c04552; border-color: #f0cdd1; }
.theme-intellect .history-pill--note        { background: #eef0fb; color: #4b52b3; border-color: #d5d8f3; }
.theme-intellect .table {
    --bs-table-hover-bg:   rgba(0, 49, 124, .035);
    --bs-table-striped-bg: rgba(0, 49, 124, .02);
}
.theme-intellect .table-light,
.theme-intellect .table-light > th,
.theme-intellect .table-light > td {
    --bs-table-bg:    #f0f3f7;
    --bs-table-color: #45505f;
}
.theme-intellect .table > thead th { color: #45505f; }
.theme-intellect .nav-tabs .badge {
    background-color: #d9ecfa !important;
    color: #004499 !important;
}
/* The auth canvas now lives in the .auth-split rules further down. */

/* Preview: Intellect (default) — swatch for the Settings theme picker.
   Mirrors .theme-preview-* above: navbar tint, canvas, sidebar, text lines. */
.theme-preview-intellect .tp-navbar {
    background: rgba(0, 68, 153, .85);
}
.theme-preview-intellect .tp-navbar::before {
    background: #f7f9fc;
}
.theme-preview-intellect .tp-sidebar {
    background: #eef6fd;
}
.theme-preview-intellect .tp-content {
    background: #f7f9fc;
}
.theme-preview-intellect .tp-line {
    background: #cdd6e2;
}

/* ---- Auth split (sign in / setup / invites) -----------------------
 * Two 50/50 panes: product summary left, form right. Below 820px it stacks
 * and the hero degrades to a slim banner so the form stays above the fold.
 *
 * Colours come from the active theme's variables rather than hard-coded brand
 * hexes, so this survives a change of default theme; .theme-intellect then
 * layers the brand's soft blue wash over the top.
 *
 * The hero is deliberately LIGHT: it carries the on-light logo, which is dark
 * artwork and would disappear on a dark panel.
 */
.auth-page { margin: 0; }
.auth-split {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}
.auth-split > section { flex: 1 1 50%; }

.auth-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--bs-body-color);
    background: linear-gradient(150deg, var(--bs-tertiary-bg) 0%, var(--bs-body-bg) 100%);
    border-right: 1px solid var(--bs-border-color);
}
.auth-hero-inner { max-width: 30rem; width: 100%; }
.auth-logo {
    display: block;
    width: min(360px, 85%);
    height: auto;
    margin-bottom: 2.5rem;
}
.auth-headline {
    font-size: clamp(1.7rem, 3.2vw, 2.6rem);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
    color: var(--bs-emphasis-color);
}
.auth-sub {
    font-size: 1.02rem;
    line-height: 1.6;
    color: var(--bs-secondary-color);
    margin: 0 0 2rem;
}
.auth-points {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: .75rem;
}
.auth-points li {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .98rem;
    line-height: 1.5;
    color: var(--bs-body-color);
}
.auth-tick {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: .7rem;
    margin-top: .15rem;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--bs-body-bg);
}
.auth-panel-inner { max-width: 26rem; width: 100%; }

/* Brand hero — deep navy gradient, bg-blue → dark-blue. The design system
   reserves BG Blue for "header bars, deep gradients, sidebars", which is
   exactly this panel.
   Because it is dark, everything on it inverts: the layout uses the on-DARK
   logo (see layouts/auth.php) and the text colours below. Change the gradient
   back to a light one and these all have to come with it, or the panel goes
   white-on-white. */
.theme-intellect .auth-hero {
    background: linear-gradient(150deg, #00317c 0%, #004499 100%);
    border-color: rgba(255, 255, 255, .12);
    color: #ffffff;
}
.theme-intellect .auth-headline  { color: #ffffff; }
.theme-intellect .auth-sub       { color: #b3d7f2; }  /* blue-200 */
.theme-intellect .auth-points li { color: #d9ecfa; }  /* blue-100 */
.theme-intellect .auth-tick {
    background: #00c8ff;  /* light blue — the system's accent/active colour */
    color: #00317c;
}

@media (max-width: 820px) {
    .auth-split { flex-direction: column; }
    .auth-hero {
        padding: 2.25rem 1.5rem;
        border-right: 0;
        border-bottom: 1px solid var(--bs-border-color);
    }
    .auth-hero-inner { max-width: 34rem; margin: 0 auto; }
    .auth-logo { margin-bottom: 1.5rem; width: min(300px, 75%); }
    .auth-headline { font-size: 1.6rem; }
    .auth-sub { margin-bottom: 0; }
    .auth-points { display: none; }  /* keep the form above the fold */
    .auth-panel { padding: 2.25rem 1.5rem; }
    .auth-panel-inner { margin: 0 auto; }
}

/* ---- Dark header ("Always use dark header", per user) -------------
 * Applied as .header-dark on <html> when users.dark_header is set. Paints the
 * navbar with the active theme's --is-header-dark and inverts everything
 * sitting on it. Works with every theme; on Midnight it is a no-op because that
 * navbar is already the same colour.
 *
 * The navbar is the only dark surface here — the page body stays as the theme
 * defines it, and data-bs-theme is untouched, so dropdowns opened FROM the
 * navbar remain light panels on light themes. That is intentional.
 *
 * The long logo is switched to the on-dark file in views/partials/navbar.php —
 * CSS cannot swap it, so the two must stay in step.
 */
.header-dark .app-navbar {
    background-color: var(--is-header-dark);
    border-bottom-color: rgba(255, 255, 255, .12);
}
.header-dark .app-navbar .navbar-brand { color: #ffffff; }
.header-dark .app-navbar .nav-link { color: rgba(255, 255, 255, .75); }
.header-dark .app-navbar .nav-link:hover,
.header-dark .app-navbar .nav-link.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, .14);
}
.header-dark .app-navbar .sales-mode-split:hover > .dropdown-toggle-split,
.header-dark .app-navbar .sales-mode-split > .dropdown-toggle-split[aria-expanded="true"] {
    border-left-color: rgba(255, 255, 255, .25);
}
/* Muted text (tenant name / user email) would drop to ~2:1 on a dark bar. */
.header-dark .app-navbar .navbar-text,
.header-dark .app-navbar .text-muted {
    color: rgba(255, 255, 255, .6) !important;
}
/* Bootstrap's toggler icon is a dark SVG chosen by data-bs-theme, which stays
   "light" here — without this it is a dark glyph on a dark bar, i.e. invisible. */
.header-dark .app-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, .25);
}
.header-dark .app-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .18);
}
.header-dark .app-navbar .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
