:root {
    --gemma-green: rgb(82, 174, 50);
    --gemma-deep-green: #007a44;
    --gemma-blue: rgb(0, 117, 191);
    --gemma-page-bg: #f4f9f6;
    --gemma-bg: var(--gemma-page-bg);
    --gemma-surface: #ffffff;
    --gemma-nav-bg: var(--gemma-surface);
    --gemma-surface-soft: #f8fbf9;
    --gemma-surface-muted: #eef3f0;
    --gemma-text: #263238;
    --gemma-heading: #1f2d3d;
    --gemma-muted: #6c757d;
    --gemma-border: #d7e2dc;
    --gemma-border-soft: #edf2ef;
    --gemma-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    --gemma-shadow-strong: 0 22px 70px rgba(19, 57, 41, 0.12);
    --gemma-input-bg: #ffffff;
    --gemma-input-border: #dce8e1;
    --gemma-focus: rgba(82, 174, 50, 0.16);
}

/* Shared portal header. Keep navigation usable on desktop and touch screens. */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 24px;
    margin-bottom: 24px;
    background: var(--gemma-surface);
    border-bottom: 1px solid var(--gemma-border-soft);
    box-shadow: var(--gemma-shadow);
}

.top-navbar > div {
    min-width: 0;
}

.top-navbar > div:first-child,
.top-navbar > div:last-child {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.top-navbar > div:first-child {
    flex: 1 1 auto;
}

.top-navbar > div:last-child {
    flex: 0 1 auto;
    justify-content: flex-end;
}

.top-navbar .btn-top,
.top-navbar .btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    box-sizing: border-box;
    padding: 8px 13px;
    border: 1px solid var(--gemma-border);
    border-radius: 7px;
    background: var(--gemma-surface-soft);
    color: var(--gemma-text);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
}

.top-navbar .btn-top:hover,
.top-navbar .btn-back:hover {
    background: var(--gemma-surface-muted);
    border-color: var(--gemma-deep-green);
    color: var(--gemma-deep-green);
}

.top-navbar img {
    display: block;
    width: auto;
    height: 35px !important;
    max-width: 180px;
    object-fit: contain;
}

.top-navbar .top-navbar-avatar {
    width: 34px;
    height: 34px !important;
    max-width: 34px;
    flex: 0 0 34px;
    border: 2px solid var(--gemma-deep-green);
    border-radius: 50%;
    background: var(--gemma-surface-soft);
    object-fit: cover;
}

/* Shared identity controls for protected Portal headers. */
.gemma-header-meta { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.gemma-header-name { color: var(--gemma-text); font-weight: 700; white-space: nowrap; }
.gemma-header-menu { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 13px; border: 1px solid var(--gemma-border); border-radius: 7px; background: var(--gemma-surface-soft); color: var(--gemma-text); font-size: 14px; font-weight: 800; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.gemma-header-menu:hover, .gemma-header-menu:focus-visible { border-color: var(--gemma-deep-green); background: var(--gemma-surface-muted); color: var(--gemma-deep-green); }
.gemma-header-avatar-link { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; text-decoration: none; }
.gemma-header-avatar-link:focus-visible { outline: 3px solid var(--gemma-deep-green); outline-offset: 3px; }
.gemma-header-meta .gemma-header-avatar { display: block; width: 34px !important; height: 34px !important; max-width: 34px; flex: 0 0 34px; border: 2px solid var(--gemma-deep-green); border-radius: 50%; background: var(--gemma-surface-soft); object-fit: cover; }
.gemma-header-meta .gemma-header-logo { display: block; width: auto; height: 35px !important; max-width: 118px; object-fit: contain; }
.gemma-generated-header { position: relative; z-index: 30; }
@media print { .gemma-generated-header { display: none !important; } }

.gemma-active-task-timer {
    position: fixed;
    right: 18px;
    bottom: 18px;
    left: auto;
    top: auto;
    z-index: 2147482500;
    width: min(266px, calc(100vw - 36px));
    background:
        linear-gradient(135deg, rgba(0, 117, 191, .08), rgba(82, 174, 50, .10)),
        var(--gemma-surface);
    color: var(--gemma-text);
    border: 1px solid var(--gemma-border);
    border-left: 0;
    border-top: 4px solid var(--gemma-blue);
    border-radius: 14px;
    box-shadow: var(--gemma-shadow-strong);
    padding: 14px;
    font-family: "Segoe UI", Arial, sans-serif;
    overflow: hidden;
}

.gemma-active-task-timer::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(82, 174, 50, .08);
}

body.has-gemma-active-task-timer .gemma-view-as-switcher:not(.is-open) {
    bottom: 112px !important;
}

body.has-gemma-active-task-timer .gemma-view-as-switcher.is-open {
    bottom: 260px !important;
}

.gemma-active-task-timer.is-warning {
    border-top-color: #ffc107;
}

.gemma-active-task-timer.is-danger {
    border-top-color: #dc3545;
}

.gemma-active-quick-task-timer {
    z-index: 2147482501;
    border-top-color: #0d6efd;
    background:
        linear-gradient(135deg, rgba(13, 110, 253, .13), rgba(0, 117, 191, .06)),
        var(--gemma-surface);
    transition: bottom .16s ease;
}

.gemma-active-quick-task-timer__label {
    color: #0b63ce;
}

.gemma-active-quick-task-timer__label::before {
    content: "\1F4CB";
}

body.has-gemma-active-quick-task-timer .gemma-view-as-switcher:not(.is-open) {
    bottom: 112px !important;
}

body.has-gemma-active-quick-task-timer .gemma-view-as-switcher.is-open {
    bottom: 260px !important;
}

.gemma-active-crm-activity-timer {
    bottom: 32px;
    width: min(360px, calc(100vw - 36px));
    padding: 10px 56px 10px 12px;
    border-top-color: var(--gemma-green);
    transition: right .18s ease, width .18s ease, padding .18s ease, box-shadow .18s ease;
}

body.has-gemma-active-task-timer .gemma-active-crm-activity-timer {
    bottom: 142px;
}

.gemma-active-crm-activity-timer.is-hidden {
    right: 0;
    bottom: 72px;
    width: 86px;
    max-width: 86px;
    height: 62px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.gemma-active-crm-activity-timer.is-hidden .gemma-active-task-timer__top,
.gemma-active-crm-activity-timer.is-hidden .gemma-active-task-timer__actions {
    display: none !important;
}

.gemma-active-crm-activity-timer__handle {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--gemma-border);
    border-radius: 999px;
    background: var(--gemma-surface);
    color: var(--gemma-green);
    box-shadow: 0 12px 28px rgba(0,0,0,.22);
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gemma-active-crm-activity-timer.is-hidden .gemma-active-crm-activity-timer__handle {
    left: auto;
    right: 0;
    top: 0;
    transform: none;
    width: 100%;
    height: 100%;
    border-right: 0;
    border-radius: 14px 0 0 14px;
    background: var(--gemma-green);
    color: #fff;
    font-size: 12px;
    line-height: 1.1;
    padding: 0 8px;
    text-align: center;
    white-space: pre-line;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}

.gemma-active-crm-activity-timer:not(.is-hidden) .gemma-active-crm-activity-timer__handle {
    color: var(--gemma-green);
}

.gemma-active-crm-activity-timer .gemma-active-task-timer__top {
    display: block;
}

.gemma-active-crm-activity-timer__content {
    width: 100%;
}

.gemma-active-crm-activity-timer__heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.gemma-active-crm-activity-timer__title,
.gemma-active-crm-activity-timer__account {
    color: var(--gemma-heading);
    font-size: 15px;
    font-weight: 900;
    line-height: 1.2;
}

.gemma-active-crm-activity-timer__account {
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 48%;
}

.gemma-active-crm-activity-timer .gemma-active-task-timer__meta {
    margin-top: 5px;
}

.gemma-active-crm-activity-timer .gemma-active-task-timer__actions {
    margin-top: 8px;
}

.gemma-active-crm-activity-timer .gemma-active-task-timer__button {
    padding: 7px 11px;
}

.gemma-active-task-timer__top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

.gemma-active-task-timer__top > div {
    min-width: 0;
    width: 100%;
}

.gemma-active-task-timer__label {
    color: var(--gemma-deep-green);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.gemma-active-task-timer__label::before {
    content: "⏱";
    font-size: 13px;
}

.gemma-active-task-timer__title {
    color: var(--gemma-heading);
    font-weight: 900 !important;
    font-size: 15px;
    line-height: 1.25;
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.gemma-active-task-timer__duration-label {
    color: var(--gemma-heading);
    font-weight: 900 !important;
    margin-left: 8px;
}

.gemma-active-task-timer__time {
    color: var(--gemma-heading);
    background: transparent;
    border-radius: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 900 !important;
    white-space: nowrap;
    line-height: inherit;
    margin-left: 3px;
}

.gemma-active-task-timer__meta {
    color: var(--gemma-muted);
    font-size: 12px;
    font-weight: 700;
    margin-top: 4px;
}

.gemma-active-task-timer__meta-row + .gemma-active-task-timer__meta-row {
    margin-top: 2px;
}

.gemma-active-task-timer__meta-row .gemma-active-task-timer__duration-label {
    margin-left: 0;
}

.gemma-active-task-timer__notice {
    margin-top: 9px;
    padding: 8px 9px;
    border-radius: 8px;
    background: rgba(255, 193, 7, .15);
    color: #7a5100;
    font-size: 12px;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.gemma-active-task-timer.is-danger .gemma-active-task-timer__notice {
    background: rgba(220, 53, 69, .14);
    color: #8a1f2d;
}

.gemma-active-task-timer__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    position: relative;
    z-index: 1;
}

.gemma-active-task-timer__button {
    border: 0;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.gemma-active-task-timer__button--end {
    background: #dc3545;
    color: #fff;
}

.gemma-active-task-timer__button--profile {
    background: var(--gemma-surface-soft);
    border: 1px solid var(--gemma-border);
    color: var(--gemma-heading);
    text-decoration: none;
}

.gemma-active-task-timer__button:hover {
    filter: brightness(.96);
}

.gemma-active-task-timer__button:disabled { opacity: .6; cursor: wait; }
.gemma-task-completion {
    width: min(480px, calc(100vw - 28px));
    max-height: calc(100dvh - 32px);
    box-sizing: border-box;
    overflow-y: auto;
    border: 1px solid var(--gemma-border);
    border-radius: 16px;
    padding: 20px;
    background: var(--gemma-surface);
    color: var(--gemma-text);
}
.gemma-task-completion::backdrop { background: rgba(0, 0, 0, .5); }
.gemma-task-completion h2 { font-size: 18px; overflow-wrap: anywhere; }
.gemma-task-completion__badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.gemma-task-completion__badges span { border: 1px solid var(--gemma-border); border-radius: 20px; padding: 3px 8px; font-size: 12px; font-weight: 700; }
.gemma-task-completion__description { white-space: pre-line; overflow-wrap: anywhere; margin: 14px 0; line-height: 1.5; }
.gemma-task-completion__knowledge { display: inline-block; color: var(--gemma-heading); margin-bottom: 8px; }
/* Responsibility-card completion keeps its content/POST, using the compact dialog UI. */
.responsibility-modal .modal-dialog { max-width: 480px; margin: 16px auto; width: calc(100% - 28px); min-height: calc(100% - 32px); }
.responsibility-modal .modal-content { border-radius: 16px; padding: 20px; max-height: calc(100dvh - 32px); background: var(--gemma-surface); color: var(--gemma-text); }
.responsibility-modal .modal-header { padding: 0 0 12px; border-bottom: 0; gap: 12px; }
.responsibility-modal .responsibility-modal-title { font-size: 18px !important; font-weight: 700; overflow-wrap: anywhere; }
.responsibility-modal .modal-body { padding: 0; }
.responsibility-modal .alert-success { background: transparent; border: 0; color: var(--gemma-text); padding: 0; margin-bottom: 12px; font-weight: 400 !important; }
.responsibility-modal textarea { background: var(--gemma-surface-soft); color: var(--gemma-text); border-color: var(--gemma-border); border-radius: 8px; }
.responsibility-modal .close-panel { border: 0; background: transparent; padding: 0; }
.responsibility-modal .task-meta .chip i,
.responsibility-modal .alert-success > i,
.responsibility-modal .close-panel button[type="submit"] i { display: none; }
.gemma-task-completion label { display: block; margin: 14px 0; font-weight: 700; }
.gemma-task-completion input, .gemma-task-completion select, .gemma-task-completion textarea {
    display: block; width: 100%; box-sizing: border-box; margin-top: 5px; padding: 8px;
    border: 1px solid var(--gemma-border); border-radius: 8px;
    background: var(--gemma-surface-soft); color: var(--gemma-text); font: inherit;
}
.gemma-task-completion [role="alert"], .gemma-task-completion-error { color: var(--gemma-danger, #b42339); font-size: 13px; }
.gemma-task-completion-error:empty { display: none; }
.gemma-task-completion .gemma-active-task-timer__actions { position: sticky; bottom: -20px; background: var(--gemma-surface); padding: 10px 0; }
.gemma-responsibility-completed {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
    z-index: 1080; display: flex; align-items: center; gap: 14px;
    width: max-content; max-width: min(440px, calc(100vw - 24px)); box-sizing: border-box;
    padding: 14px 16px; border: 1px solid var(--gemma-border); border-left: 4px solid #00854b;
    border-radius: 12px; background: var(--gemma-surface); color: var(--gemma-text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: 14px; font-weight: 700;
}
.gemma-responsibility-completed button {
    flex-shrink: 0; border: 0; background: transparent; color: inherit;
    padding: 4px 8px; font-size: 22px; cursor: pointer;
}

@media (max-width: 640px) {
    .gemma-active-task-timer {
        left: auto;
        right: 10px;
        top: auto;
        bottom: 10px;
        width: min(252px, calc(100vw - 20px));
        padding: 10px 11px;
        border-radius: 12px;
    }

    .gemma-active-task-timer__title {
        font-size: 14px;
        line-height: 1.2;
    }

    .gemma-active-task-timer__label {
        font-size: 10px;
    }

    .gemma-active-task-timer__meta {
        margin-top: 3px;
        font-size: 11px;
        line-height: 1.25;
    }

    .gemma-active-task-timer__actions {
        gap: 6px;
        margin-top: 7px;
    }

    .gemma-active-task-timer__button {
        padding: 6px 9px;
        border-radius: 7px;
        font-size: 11px;
    }

    body.has-gemma-active-task-timer .gemma-view-as-switcher:not(.is-open) {
        bottom: 96px !important;
    }

    body.has-gemma-active-task-timer .gemma-view-as-switcher.is-open {
        bottom: 236px !important;
    }

    body.has-gemma-active-quick-task-timer .gemma-view-as-switcher:not(.is-open) {
        bottom: 96px !important;
    }

    body.has-gemma-active-quick-task-timer .gemma-view-as-switcher.is-open {
        bottom: 236px !important;
    }

    .gemma-active-crm-activity-timer {
        left: 10px;
        right: 10px;
        bottom: 32px;
        width: auto;
        padding: 10px 56px 10px 12px;
    }

    .gemma-active-crm-activity-timer.is-hidden {
        left: auto;
        right: 0;
        bottom: 72px;
        width: 86px;
        max-width: 86px;
        height: 62px;
    }

    body.has-gemma-active-task-timer .gemma-active-crm-activity-timer {
        bottom: 126px;
    }

    .gemma-active-crm-activity-timer__heading {
        align-items: flex-start;
    }

    .gemma-active-crm-activity-timer__title,
    .gemma-active-crm-activity-timer__account {
        font-size: 14px;
    }

    .gemma-active-crm-activity-timer__account {
        max-width: 50%;
    }
}

:root[data-gemma-theme="night"] {
    --gemma-page-bg: #0d1512;
    --gemma-surface: #15211c;
    --gemma-surface-soft: #101b17;
    --gemma-surface-muted: #1d2b25;
    --gemma-text: #e7f0eb;
    --gemma-heading: #f4fbf7;
    --gemma-muted: #a6b7ae;
    --gemma-border: #2b3f36;
    --gemma-border-soft: #22352d;
    --gemma-shadow: 0 10px 30px rgba(0, 0, 0, 0.30);
    --gemma-shadow-strong: 0 24px 80px rgba(0, 0, 0, 0.42);
    --gemma-input-bg: #0f1b16;
    --gemma-input-border: #30473c;
    --gemma-focus: rgba(82, 174, 50, 0.24);
}

:root[data-gemma-theme="night"] body {
    background: var(--gemma-page-bg) !important;
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] .text-muted {
    color: var(--gemma-muted) !important;
}

:root[data-gemma-theme="night"] .text-dark {
    color: var(--gemma-heading) !important;
}

:root[data-gemma-theme="night"] h1,
:root[data-gemma-theme="night"] h2,
:root[data-gemma-theme="night"] h3,
:root[data-gemma-theme="night"] h4,
:root[data-gemma-theme="night"] h5,
:root[data-gemma-theme="night"] h6,
:root[data-gemma-theme="night"] .portal-title,
:root[data-gemma-theme="night"] .menu-title,
:root[data-gemma-theme="night"] .tool-title,
:root[data-gemma-theme="night"] .menu-header-title,
:root[data-gemma-theme="night"] .summary-value,
:root[data-gemma-theme="night"] .order-customer {
    color: var(--gemma-heading) !important;
}

:root[data-gemma-theme="night"] .menu-subtitle,
:root[data-gemma-theme="night"] .tool-desc,
:root[data-gemma-theme="night"] .menu-header-subtitle,
:root[data-gemma-theme="night"] .summary-label,
:root[data-gemma-theme="night"] .form-label,
:root[data-gemma-theme="night"] .form-text,
:root[data-gemma-theme="night"] .small {
    color: var(--gemma-muted) !important;
}

:root[data-gemma-theme="night"] .bg-white,
:root[data-gemma-theme="night"] .modal-content,
:root[data-gemma-theme="night"] .card,
:root[data-gemma-theme="night"] .tab-content,
:root[data-gemma-theme="night"] .alert.bg-white,
:root[data-gemma-theme="night"] .top-navbar,
:root[data-gemma-theme="night"] .welcome-card,
:root[data-gemma-theme="night"] .menu-card,
:root[data-gemma-theme="night"] .tool-card,
:root[data-gemma-theme="night"] .menu-header,
:root[data-gemma-theme="night"] .card-custom,
:root[data-gemma-theme="night"] .container,
:root[data-gemma-theme="night"] .container-fluid,
:root[data-gemma-theme="night"] .dashboard-container,
:root[data-gemma-theme="night"] .panel,
:root[data-gemma-theme="night"] .content-panel,
:root[data-gemma-theme="night"] .search-card,
:root[data-gemma-theme="night"] .table-container,
:root[data-gemma-theme="night"] .summary-card,
:root[data-gemma-theme="night"] .kpi-card,
:root[data-gemma-theme="night"] .filter-section,
:root[data-gemma-theme="night"] .chart-container,
:root[data-gemma-theme="night"] .add-form,
:root[data-gemma-theme="night"] .stats-box,
:root[data-gemma-theme="night"] .stat-badge,
:root[data-gemma-theme="night"] .year-selector,
:root[data-gemma-theme="night"] .table-responsive,
:root[data-gemma-theme="night"] .filters-panel,
:root[data-gemma-theme="night"] .table-panel,
:root[data-gemma-theme="night"] .order-block,
:root[data-gemma-theme="night"] .empty-state,
:root[data-gemma-theme="night"] .attendance-card {
    background-color: var(--gemma-surface) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .schedule-card {
    background-color: var(--gemma-surface) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .day-box {
    background-color: var(--gemma-surface-soft) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .badge.text-bg-light,
:root[data-gemma-theme="night"] .text-bg-light {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] hr,
:root[data-gemma-theme="night"] .border,
:root[data-gemma-theme="night"] .border-top,
:root[data-gemma-theme="night"] .border-bottom,
:root[data-gemma-theme="night"] .border-start,
:root[data-gemma-theme="night"] .border-end {
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .btn-close {
    filter: invert(1) grayscale(100%);
    opacity: .75;
}

:root[data-gemma-theme="night"] .bg-light,
:root[data-gemma-theme="night"] .table-light,
:root[data-gemma-theme="night"] .input-group-text,
:root[data-gemma-theme="night"] .card-header-custom,
:root[data-gemma-theme="night"] .card-header,
:root[data-gemma-theme="night"] .card-header-custom,
:root[data-gemma-theme="night"] .enter-btn-wrapper,
:root[data-gemma-theme="night"] .tool-content,
:root[data-gemma-theme="night"] .tool-icon-wrapper,
:root[data-gemma-theme="night"] .modal-footer,
:root[data-gemma-theme="night"] .order-head,
:root[data-gemma-theme="night"] .filter-checks,
:root[data-gemma-theme="night"] .date-band {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .drag-cell,
:root[data-gemma-theme="night"] .drag-handle,
:root[data-gemma-theme="night"] .page-drag-cell,
:root[data-gemma-theme="night"] .lookup-drag-handle,
:root[data-gemma-theme="night"] td[style*="background-color: #f8f9fa"],
:root[data-gemma-theme="night"] td[style*="background: #fafafa"],
:root[data-gemma-theme="night"] tr[style*="background-color: #e9ecef"] {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-muted) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .panel-title {
    color: var(--gemma-heading) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] tr:hover {
    background-color: color-mix(in srgb, var(--gemma-green) 10%, transparent) !important;
}

:root[data-gemma-theme="night"] .sn-text,
:root[data-gemma-theme="night"] a:not(.btn):not(.btn-top):not(.btn-back) {
    color: #6bb8ff !important;
}

:root[data-gemma-theme="night"] .btn-top,
:root[data-gemma-theme="night"] .btn-back,
:root[data-gemma-theme="night"] .btn-outline-secondary,
:root[data-gemma-theme="night"] .btn-outline-primary {
    background-color: var(--gemma-surface-soft) !important;
    border-color: var(--gemma-border) !important;
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] .btn-top:hover,
:root[data-gemma-theme="night"] .btn-back:hover,
:root[data-gemma-theme="night"] .btn-outline-secondary:hover,
:root[data-gemma-theme="night"] .btn-outline-primary:hover {
    background-color: var(--gemma-surface-muted) !important;
    border-color: var(--gemma-green) !important;
    color: var(--gemma-green) !important;
}

:root[data-gemma-theme="night"] .form-control,
:root[data-gemma-theme="night"] .form-select,
:root[data-gemma-theme="night"] textarea,
:root[data-gemma-theme="night"] .choices__inner,
:root[data-gemma-theme="night"] .choices__input,
:root[data-gemma-theme="night"] .choices__list--dropdown,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] {
    background-color: var(--gemma-input-bg) !important;
    border-color: var(--gemma-input-border) !important;
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] input[type="file"].form-control {
    padding: 0 !important;
}

:root[data-gemma-theme="night"] input[type="file"].form-control::file-selector-button {
    height: 100%;
    min-height: 36px;
    margin: 0 12px 0 0;
    padding: 0 14px;
    border: 0;
    border-right: 1px solid var(--gemma-input-border);
    background-color: var(--gemma-surface-muted);
    color: var(--gemma-heading);
    font-weight: 700;
}

:root[data-gemma-theme="night"] input[type="file"].form-control:hover::file-selector-button {
    background-color: rgba(82, 174, 50, 0.18);
    color: #9ee48a;
}

:root[data-gemma-theme="night"] .form-control:focus,
:root[data-gemma-theme="night"] .form-select:focus {
    border-color: var(--gemma-green) !important;
    box-shadow: 0 0 0 .2rem var(--gemma-focus) !important;
}

:root[data-gemma-theme="night"] .form-control::placeholder {
    color: #80958b !important;
}

:root[data-gemma-theme="night"] .choices__placeholder,
:root[data-gemma-theme="night"] .choices__item,
:root[data-gemma-theme="night"] .choices__list--dropdown .choices__item,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] .choices__item {
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] .choices__list--dropdown .choices__item--selectable.is-highlighted,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted,
:root[data-gemma-theme="night"] .choices__list--dropdown .choices__item.is-highlighted,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] .choices__item.is-highlighted,
:root[data-gemma-theme="night"] .choices__list--dropdown .choices__item--choice.is-highlighted,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] .choices__item--choice.is-highlighted,
:root[data-gemma-theme="night"] .employee-picker .choices__item--selectable.is-highlighted,
:root[data-gemma-theme="night"] .employee-picker .choices__item--choice.is-highlighted {
    background: #0f7f4b !important;
    background-color: #0f7f4b !important;
    color: #ffffff !important;
}

:root[data-gemma-theme="night"] .choices__list--dropdown .choices__item--selectable.is-highlighted *,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted *,
:root[data-gemma-theme="night"] .choices__list--dropdown .choices__item--choice.is-highlighted *,
:root[data-gemma-theme="night"] .choices__list[aria-expanded] .choices__item--choice.is-highlighted *,
:root[data-gemma-theme="night"] .employee-picker .choices__item--selectable.is-highlighted *,
:root[data-gemma-theme="night"] .employee-picker .choices__item--choice.is-highlighted * {
    color: #ffffff !important;
}

:root[data-gemma-theme="night"] .choices__input {
    background-color: var(--gemma-input-bg) !important;
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] .dropdown-menu {
    background-color: var(--gemma-surface) !important;
    border-color: var(--gemma-border) !important;
    color: var(--gemma-text) !important;
    box-shadow: var(--gemma-shadow) !important;
}

:root[data-gemma-theme="night"] .dropdown-item,
:root[data-gemma-theme="night"] .dropdown-menu label {
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] .dropdown-item:hover,
:root[data-gemma-theme="night"] .dropdown-menu .form-check:hover {
    background-color: var(--gemma-surface-muted) !important;
}

:root[data-gemma-theme="night"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--gemma-text);
    --bs-table-border-color: var(--gemma-border);
    --bs-table-hover-bg: rgba(82, 174, 50, 0.08);
    color: var(--gemma-text);
    border-color: var(--gemma-border);
}

:root[data-gemma-theme="night"] table:not(.swal2-table) {
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .table th,
:root[data-gemma-theme="night"] .table td,
:root[data-gemma-theme="night"] table:not(.swal2-table) th,
:root[data-gemma-theme="night"] table:not(.swal2-table) td,
:root[data-gemma-theme="night"] .orders-table th,
:root[data-gemma-theme="night"] .orders-table td {
    background-color: transparent !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .table th,
:root[data-gemma-theme="night"] table:not(.swal2-table) th,
:root[data-gemma-theme="night"] .orders-table th {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-muted) !important;
}

:root[data-gemma-theme="night"] .table-menus,
:root[data-gemma-theme="night"] .table-perms {
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] .table-menus th,
:root[data-gemma-theme="night"] .table-perms th {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-heading) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .table-menus td,
:root[data-gemma-theme="night"] .table-perms td {
    background-color: transparent !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .group-row td,
:root[data-gemma-theme="night"] .section-row.menu td {
    background-color: rgba(82, 174, 50, 0.14) !important;
    color: #9ee48a !important;
    border-color: rgba(82, 174, 50, 0.25) !important;
}

:root[data-gemma-theme="night"] .section-row.unassigned td {
    background-color: rgba(255, 193, 7, 0.16) !important;
    color: #ffe08a !important;
    border-color: rgba(255, 193, 7, 0.28) !important;
}

:root[data-gemma-theme="night"] .sales-owner-mismatch td {
    background-color: rgba(82, 174, 50, 0.14) !important;
}

:root[data-gemma-theme="night"] .sales-owner-missing td {
    background-color: rgba(166, 183, 174, 0.16) !important;
}

:root[data-gemma-theme="night"] .device-row-pending,
:root[data-gemma-theme="night"] .device-row-pending td {
    background-color: rgba(255, 193, 7, 0.12) !important;
    color: var(--gemma-text) !important;
}

:root[data-gemma-theme="night"] strong[style*="color:#2c3e50"],
:root[data-gemma-theme="night"] strong[style*="color: #2c3e50"],
:root[data-gemma-theme="night"] .protected-label,
:root[data-gemma-theme="night"] .page-path {
    color: var(--gemma-heading) !important;
}

:root[data-gemma-theme="night"] .system-key {
    background-color: var(--gemma-surface-muted) !important;
    border: 1px solid var(--gemma-border) !important;
    color: #ff8fcb !important;
}

:root[data-gemma-theme="night"] .badge.bg-light {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .alert-info,
:root[data-gemma-theme="night"] .alert-warning,
:root[data-gemma-theme="night"] .alert-success,
:root[data-gemma-theme="night"] .alert-danger {
    background-color: var(--gemma-surface-muted) !important;
    color: var(--gemma-text) !important;
    border-color: var(--gemma-border) !important;
}

:root[data-gemma-theme="night"] .modal-header.bg-primary,
:root[data-gemma-theme="night"] .modal-header.bg-success,
:root[data-gemma-theme="night"] .modal-header.bg-dark {
    background-color: #0f5132 !important;
}

:root[data-gemma-theme="night"] img[src*="gemma-since-logo"] {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.10));
}

.gemma-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--gemma-border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--gemma-surface) 92%, transparent);
    box-shadow: var(--gemma-shadow);
    color: var(--gemma-text);
}

.gemma-theme-switch.is-floating {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 20;
}

.gemma-theme-switch button {
    min-width: 38px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--gemma-muted);
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.gemma-theme-switch button:hover {
    color: var(--gemma-deep-green);
}

.gemma-theme-switch button.is-active {
    background: var(--gemma-deep-green);
    color: #ffffff;
}

.gemma-notifications {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    font-family: "Segoe UI", Arial, sans-serif;
}

.gemma-notifications.is-floating {
    position: fixed;
    top: 16px;
    right: 210px;
    z-index: 1045;
}

.gemma-notifications__button {
    position: relative;
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--gemma-border);
    border-radius: 50%;
    background: var(--gemma-surface);
    color: var(--gemma-text);
    font-size: 19px;
    cursor: pointer;
}

.gemma-notifications .gemma-notifications__button { width: 42px !important; height: 42px !important; min-height: 42px !important; padding: 0 !important; border: 1px solid var(--gemma-border) !important; border-radius: 50% !important; background: var(--gemma-surface) !important; color: var(--gemma-text) !important; font-size: 19px !important; line-height: 1 !important; }
.gemma-notifications .gemma-notifications__button:hover, .gemma-notifications .gemma-notifications__button:focus-visible { border-color: var(--gemma-deep-green) !important; color: var(--gemma-deep-green) !important; }

.gemma-notifications__button:hover,
.gemma-notifications__button:focus-visible {
    border-color: var(--gemma-deep-green);
    color: var(--gemma-deep-green);
}

.gemma-notifications__badge {
    position: absolute;
    top: -5px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border: 2px solid var(--gemma-surface);
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
}

.gemma-notifications__panel {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 1080;
    width: min(390px, calc(100vw - 24px));
    overflow: hidden;
    border: 1px solid var(--gemma-border);
    border-radius: 12px;
    background: var(--gemma-surface);
    box-shadow: var(--gemma-shadow-strong);
    color: var(--gemma-text);
}

.gemma-notifications__panel[hidden] {
    display: none !important;
}

.gemma-notifications__head {
    min-height: 48px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--gemma-border);
}

.gemma-notifications__mark-all {
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--gemma-deep-green);
    font-size: 12px;
    font-weight: 800;
}

.gemma-notifications .gemma-notifications__mark-all { padding: 4px !important; border: 0 !important; background: transparent !important; color: var(--gemma-deep-green) !important; font-size: 12px !important; }

.gemma-notifications__list {
    max-height: min(480px, 65vh);
    overflow-y: auto;
}

.gemma-notifications__item {
    padding: 11px 12px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--gemma-border-soft);
    color: var(--gemma-text) !important;
    text-decoration: none;
}

.gemma-notifications__item.is-unread {
    background: color-mix(in srgb, var(--gemma-green) 8%, var(--gemma-surface));
    box-shadow: inset 4px 0 var(--gemma-deep-green);
}

.gemma-notifications__item:hover {
    background: var(--gemma-surface-soft);
}

.gemma-notifications__icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--gemma-surface-soft);
    color: var(--gemma-deep-green);
    font-size: 17px;
}

.gemma-notifications__copy strong,
.gemma-notifications__copy small,
.gemma-notifications__copy time {
    display: block;
}

.gemma-notifications__copy {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.gemma-notifications__copy strong {
    color: var(--gemma-heading);
    font-size: 13px;
}

.gemma-notifications__copy small {
    margin-top: 2px;
    color: var(--gemma-text);
    line-height: 1.35;
}

.gemma-notifications__copy time {
    margin-top: 4px;
    color: var(--gemma-muted);
    font-size: 11px;
}

.gemma-notifications__empty {
    padding: 28px 14px;
    color: var(--gemma-muted);
    text-align: center;
    font-weight: 700;
}

.gemma-notifications__footer {
    padding: 11px;
    display: block;
    color: var(--gemma-deep-green) !important;
    text-align: center;
    text-decoration: none;
    font-weight: 850;
}

@media (max-width: 575px) {
    .top-navbar {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 10px 12px !important;
    }

    .top-navbar > div {
        min-width: 0 !important;
    }

    .top-navbar > div:first-child {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        flex: 1 1 auto !important;
    }

    .top-navbar > div:last-child {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .top-navbar .btn-top,
    .top-navbar .btn-back {
        min-height: 36px !important;
        padding: 7px 10px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
        line-height: 1.25 !important;
    }

    .top-navbar img {
        max-height: 34px !important;
        width: auto !important;
    }

    .top-navbar .fw-bold.text-muted {
        max-width: calc(100vw - 34px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-right: 0 !important;
    }

    .gemma-theme-switch {
        flex: 0 0 auto;
        box-shadow: none;
    }

    .gemma-theme-switch button {
        min-width: 34px;
        padding: 6px 7px;
        font-size: 11px;
    }

    .gemma-notifications.is-floating {
        top: 12px;
        right: 12px;
    }

    .gemma-notifications__panel {
        position: fixed;
        top: var(--gemma-notifications-panel-top, 72px);
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - var(--gemma-notifications-panel-top, 72px) - 12px);
        display: flex;
        flex-direction: column;
        overscroll-behavior: contain;
    }

    .gemma-notifications__list {
        min-height: 0;
        max-height: none;
        flex: 1 1 auto;
        overflow-y: auto;
    }
}
/* Responsibility dock only: do not restyle Quick Tasks, CRM or View-as controls. */
[data-gemma-active-task-timer] {
    box-sizing: border-box;
    width: min(300px, calc(100vw - 36px));
    background: var(--gemma-surface);
    border: 1px solid var(--gemma-border);
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(22, 48, 39, .10), 0 2px 5px rgba(22, 48, 39, .04);
    padding: 13px 14px;
    font-family: "Segoe UI", Arial, sans-serif;
}
[data-gemma-active-task-timer]::before { display: none; }
[data-gemma-active-task-timer] .gemma-active-task-timer__title {
    font-family: inherit; font-size: 12px; font-weight: 600 !important;
    letter-spacing: -.01em; line-height: 1.35; margin: 0;
}
[data-gemma-active-task-timer] .gemma-active-task-timer__meta { font-size: 11px; font-weight: 400; margin-top: 4px; }
[data-gemma-active-task-timer] .gemma-active-task-timer__footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
[data-gemma-active-task-timer] .gemma-active-task-timer__running { display: flex; align-items: center; gap: 8px; margin: 0; }
[data-gemma-active-task-timer] .gemma-active-task-timer__duration-label { display: none; }
[data-gemma-active-task-timer] .gemma-active-task-timer__time {
    font-family: inherit; font-size: 20px; line-height: 1.2; font-weight: 600 !important;
    letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin: 0;
}
[data-gemma-active-task-timer] .gemma-active-task-timer__status {
    display: inline-flex; align-items: center; order: -1; font-size: 0;
    font-weight: 500; white-space: nowrap; color: var(--gemma-muted);
}
[data-gemma-active-task-timer] .gemma-active-task-timer__status::before {
    content: ""; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #249561;
}
[data-gemma-active-task-timer].is-warning { border-color: #b8892d; }
[data-gemma-active-task-timer].is-warning .gemma-active-task-timer__status::before { background: #c79629; }
[data-gemma-active-task-timer].is-danger { border-color: #dc3545; }
[data-gemma-active-task-timer].is-danger .gemma-active-task-timer__status::before { background: #dc3545; }
[data-gemma-active-task-timer] .gemma-active-task-timer__actions { gap: 12px; margin: 0 0 0 auto; flex: 0 0 auto; }
[data-gemma-active-task-timer] .gemma-active-task-timer__button {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 34px; box-sizing: border-box; padding: 8px 13px; margin: 0;
    font: 600 12px/1.2 "Segoe UI", Arial, sans-serif; border-radius: 10px;
}
[data-gemma-active-task-timer] .gemma-active-task-timer__button--profile {
    border: 0; padding: 0; background: transparent; color: var(--gemma-deep-green) !important; font-weight: 400;
}
[data-gemma-active-task-timer] .gemma-active-task-timer__button--end { border: 0; gap: 7px; background: #c93e4b; color: #fff; }
[data-gemma-active-task-timer] .gemma-active-task-timer__button--end::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
[data-gemma-active-task-timer] .gemma-active-task-timer__button:focus-visible { outline: 2px solid var(--gemma-text); outline-offset: 2px; }
:root[data-gemma-theme="night"] [data-gemma-active-task-timer] { box-shadow: 0 8px 28px rgba(0, 0, 0, .24); }
@media (max-width: 640px) {
    [data-gemma-active-task-timer] { width: min(300px, calc(100vw - 20px)); }
}
@media (max-width: 360px) {
    [data-gemma-active-task-timer] .gemma-active-task-timer__time { font-size: 18px; }
    [data-gemma-active-task-timer] .gemma-active-task-timer__actions { gap: 8px; }
}
@media (pointer: coarse) {
    [data-gemma-active-task-timer] .gemma-active-task-timer__button { min-height: 44px; }
}
