:root {
    --dashboard-tabs-offset: 0px;
    --call-center-search-offset: 0px;
    --call-center-table-header-offset: 0px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: linear-gradient(120deg,
        var(--accent-cyan)   0%,
        var(--accent-sky)   35%,
        var(--accent-dodger) 65%,
        var(--accent-deep)  100%);
    background-size: 300% 300%;
    animation: bg-shift 90s ease-in-out infinite;
    margin: 0; /* remove default spacing */
}

.connectivity-icon {
    font-size: 1.3em;
    line-height: 1;
    vertical-align: text-bottom;
}

.connectivity-icon-wifi {
    text-shadow:
        0 0 1px currentColor,
        0.6px 0 currentColor,
        -0.6px 0 currentColor,
        0 0.6px currentColor,
        0 -0.6px currentColor,
        0.45px 0.45px currentColor,
        -0.45px 0.45px currentColor,
        0.45px -0.45px currentColor,
        -0.45px -0.45px currentColor;
}

.password-toggle-input {
    padding-right: 3rem;
}

.password-visibility-toggle.btn-link {
    padding: 0;
}

.password-visibility-toggle:focus {
    box-shadow: none;
}

.connection-cell {
    background-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.connection-cell.connection-fresh {
    background-color: #e9f7ef; /* light green */
}

.connection-cell.connection-stale {
    background-color: #fdecea; /* light red */
}

.dashboard-container {
    padding-top: 1rem;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100%;
}

.dashboard-header {
    z-index: 1030;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin: 0 !important;
    width: 100%;
}

#pwa-action-center {
    min-width: 220px;
}

#pwa-action-center .btn {
    white-space: nowrap;
}

#notification-settings-button #notification-unread-dot {
    font-size: 0.65rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    min-height: 1.25rem;
}

#pwa-install-hint {
    border-left: 4px solid var(--bs-primary);
}

#notification-preference-section {
    border-color: rgba(13, 110, 253, 0.3);
}

#notification-status-pill {
    min-width: 110px;
    text-align: center;
}

.nav-tabs {
    border-bottom: 1px solid #dee2e6;
    background-color: #e9ecef;
    padding: 0.5rem 1rem 0 1rem;
    border-top-left-radius: 0.25rem;
    border-top-right-radius: 0.25rem;

}

.nav-tabs .nav-link {
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-top-left-radius: .25rem;
    border-top-right-radius: .25rem;
    color: #495057;
    transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
    padding: 0.5rem 1rem;
    position: relative;
    overflow: hidden;
    font-size: 0.95rem;
    margin-right: 0.5rem;
}

.nav-tabs .nav-link .bi {
    flex-shrink: 0;
    vertical-align: -0.125em;
}

#mainTab .nav-link.tab-has-error {
    color: var(--bs-danger);
}

#mainTab .nav-link.tab-has-error::after {
    background-color: var(--bs-danger);
}

/* Small red dot indicator used for notifications */
.notification-dot {
    display: none;
    position: absolute;
    top: 4px;
    right: 6px;
    width: 8px;
    height: 8px;
    background-color: #dc3545;
    border-radius: 50%;
}

.notification-dot.active {
    display: block;
}

.main-tabs-wrapper {
    position: sticky;
    top: var(--dashboard-tabs-offset, 0);
    z-index: 1015;
    background-color: #e9ecef;
    box-shadow: 0 0.25rem 0.75rem rgba(15, 23, 42, 0.08);
}

.call-center-role-search-bar {
    position: sticky;
    top: var(--call-center-search-offset, 0);
    z-index: 1020;
    background-color: #ffffff;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 0.5rem 1.5rem rgba(33, 37, 41, 0.05);
}

.call-center-role-search-inner {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    position: relative;
}

.call-center-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.35rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.5rem;
    background-color: #ffffff;
    box-shadow: 0 0.75rem 1.5rem rgba(15, 23, 42, 0.12);
    padding: 0.5rem;
    max-height: 16rem;
    overflow-y: auto;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform-origin: top;
    z-index: 1051;
}

.call-center-search-section + .call-center-search-section {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.call-center-search-section-title {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.call-center-search-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.call-center-search-item {
    border-radius: 0.5rem;
    padding: 0.5rem;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.call-center-search-item:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.call-center-search-item:hover {
    background-color: rgba(13, 110, 253, 0.08);
}

.call-center-search-item-title {
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.call-center-search-item-meta {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 0.15rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.call-center-search-owner {
    font-size: 0.8rem;
    color: #495057;
    margin-top: 0.25rem;
}

.call-center-search-more {
    font-size: 0.8rem;
    color: #868e96;
    margin-top: 0.35rem;
}

.call-center-search-empty,
.call-center-search-loading {
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
    padding: 1rem 0.5rem;
}

.call-center-search-badge {
    font-size: 0.65rem;
    letter-spacing: 0.02em;
}

.call-center-role-search-inner .input-group > .form-control {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.call-center-form-fields .form-label {
    font-weight: 500;
}

.call-center-table thead th,
.plan-table thead th {
    position: sticky;
    top: var(--call-center-table-header-offset, 0);
    z-index: 12;
    background-color: #f8f9fa;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.nav-tabs .nav-link::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 3px;
    background-color: currentColor;
    transition: width 0.3s ease, left 0.3s ease;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
    border-color: #e9ecef #e9ecef #dee2e6;
    isolation: isolate;
    color: #0d6efd;
    outline: none;
}

#mainTab .nav-link.tab-has-error:hover,
#mainTab .nav-link.tab-has-error:focus {
    color: var(--bs-danger);
    border-color: #e9ecef #e9ecef #dee2e6;
    outline: none;
}

.nav-tabs .nav-link:hover::after,
.nav-tabs .nav-link.active::after {
    width: 100%;
    left: 0;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: #0b5ed7;
    background-color: #f8f9fa;
    border-color: #dee2e6 #dee2e6 #f8f9fa;
    font-weight: 500;
}

#mainTab .nav-link.tab-has-error.active,
#mainTab .nav-item.show .nav-link.tab-has-error {
    color: var(--bs-danger);
    background-color: #f8f9fa;
    border-color: #dee2e6 #dee2e6 #f8f9fa;
}

.tab-content > .tab-pane {
    padding: 1.5rem;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-top: none;
    border-bottom-left-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, .075);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.tab-content > .tab-pane:not(.active) {
    opacity: 0;
    transform: translateY(20px);
}

.tab-content > .tab-pane.active {
    opacity: 1;
    transform: translateY(0);
}

.data-table thead th {
    background-color: #e9ecef;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
    opacity: 1;
    position: relative; /* needed so dropdown menus appear above neighbours */
    z-index: 1;
}

.data-table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.07);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

.call-center-table,
.plan-table {
    table-layout: fixed;
    width: 100%;
}

.call-center-table th,
.call-center-table td,
.plan-table th,
.plan-table td {
    white-space: normal;
    word-break: break-word;
    vertical-align: middle;
}

.call-center-table tbody tr {
    cursor: pointer;
}

.call-center-table tbody tr .call-center-actions-cell {
    cursor: default;
}

.inn-copy-btn {
    line-height: 1;
    color: dodgerblue;
}

.inn-copy-btn i {
    font-size: 1.2em;
    vertical-align: middle;
}

.inn-copy-btn:focus-visible {
    box-shadow: none;
}

.inn-copy-btn i {
    pointer-events: none;
}

.call-center-select-column {
    width: 2.75rem;
    text-align: center;
}

#call-center-table .call-center-select-column,
#call-center-table th.call-center-select-column {
    display: none;
}

body.role-call-center-admin #call-center-table .call-center-select-column,
body.role-call-center-admin #call-center-table th.call-center-select-column {
    display: table-cell;
}

.call-center-row-checkbox {
    cursor: pointer;
}

.plan-select-column {
    width: 2.75rem;
    text-align: center;
}

.plan-table.plan-selection-enabled .plan-select-column,
.plan-table.plan-selection-enabled th.plan-select-column {
    display: table-cell;
}

.plan-table .plan-select-column,
.plan-table th.plan-select-column {
    display: none;
}

body.role-call-center-admin .plan-table .plan-select-column,
body.role-call-center-admin .plan-table th.plan-select-column {
    display: table-cell;
}

.plan-row-checkbox {
    cursor: pointer;
}

.call-center-bulk-actions {
    position: sticky;
    top: var(--call-center-table-header-offset, 0);
    z-index: 1018;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
}

.plan-bulk-actions {
    /* Inherits all sticky properties from .call-center-bulk-actions */
}

.plan-table tbody tr {
    cursor: pointer;
}

.plan-table tbody tr .plan-actions-cell {
    cursor: default;
}

.call-center-details-form .form-label {
    font-weight: 600;
}

.call-center-details-form textarea {
    resize: vertical;
}

.call-center-detail-field {
    border: 1px solid rgba(13, 110, 253, 0.12);
    border-radius: 0.75rem;
    padding: 0.75rem 0.85rem;
    background-color: #ffffff;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.call-center-detail-field:hover {
    box-shadow: 0 0.75rem 1.65rem rgba(13, 110, 253, 0.12);
    border-color: rgba(13, 110, 253, 0.25);
}

.call-center-details-empty {
    text-align: center;
    padding: 1.25rem;
}

.table-pagination {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.table-pagination .pagination {
    margin-bottom: 0;
}

.call-center-actions-cell .btn {
    white-space: nowrap;
}

.call-center-table-wrapper,
.plan-table-wrapper {
    overflow-x: visible;
    width: 100%;
}

.plan-table .plan-actions-cell {
    min-width: 220px;
    vertical-align: middle;
}

.plan-table .plan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
}

.plan-table .plan-actions .btn {
    flex: 0 0 auto;
}

.plan-table .plan-actions .plan-alarm-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 130px;
}

.plan-table .plan-assigned-at-col {
    min-width: 120px;
    width: 120px;
    white-space: normal;
}

.plan-table .plan-assigned-at-cell {
    min-width: 120px;
    white-space: nowrap;
}

.plan-table .plan-assigned-at {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    font-weight: 600;
    color: #0d6efd;
    line-height: 1.1;
}

.plan-table .plan-assigned-at-cell .text-muted {
    font-weight: 500;
}

.plan-table .plan-assigned-at-date {
    display: block;
}

.plan-table .plan-assigned-at-time {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6c757d;
    letter-spacing: 0.03em;
}

.call-center-calendar-shell {
    padding: 0.5rem;
    min-height: calc(100vh - 6rem);
    display: flex;
}

.call-center-calendar-card {
    border-radius: 1.5rem;
    border: 1px solid rgba(13, 110, 253, 0.08);
    background: linear-gradient(140deg, rgba(13, 110, 253, 0.05), rgba(25, 135, 84, 0.04));
    flex: 1;
    display: flex;
    flex-direction: column;
}

.call-center-calendar-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

.call-center-calendar-toolbar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 1rem;
}

.call-center-calendar-month-controls {
    flex-wrap: wrap;
}

.btn-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.call-center-calendar-title .h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.call-center-calendar-title .text-muted {
    font-weight: 500;
}

#call-center-calendar-month-input {
    max-width: 11rem;
}

.call-center-calendar-user {
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.call-center-calendar-grid-wrapper {
    position: relative;
    border-radius: 1.25rem;
    background: #fff;
    padding: 1.25rem;
    box-shadow: 0 1.25rem 2.5rem rgba(15, 34, 67, 0.08);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.75rem;
}

.call-center-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.75rem;
}

.call-center-calendar-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: minmax(10rem, 1fr);
    gap: 0.75rem;
}

.call-center-calendar-weekday {
    text-transform: uppercase;
    font-size: 0.72rem;
    color: #6c757d;
    letter-spacing: 0.12em;
    font-weight: 600;
    text-align: center;
}

.call-center-calendar-day {
    border: 1px solid rgba(13, 110, 253, 0.12);
    border-radius: 1rem;
    padding: 0.75rem;
    width: 100%;
    min-height: 10.5rem;
    background: #ffffff;
    box-shadow: 0 1rem 2rem rgba(15, 34, 67, 0.07);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
    text-align: left;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
    color: inherit;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
}

.call-center-calendar-day:hover,
.call-center-calendar-day:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 1.25rem 2.25rem rgba(13, 110, 253, 0.18);
    border-color: rgba(13, 110, 253, 0.4);
    outline: none;
}

.call-center-calendar-day.is-other-month {
    opacity: 0.45;
}

.call-center-calendar-day.is-weekend .call-center-calendar-day-number {
    color: #dc3545;
}

.call-center-calendar-day.is-today {
    border-width: 2px;
    border-color: rgba(25, 135, 84, 0.6);
    box-shadow: 0 1.25rem 2rem rgba(25, 135, 84, 0.18);
}

.call-center-calendar-day.has-note {
    background: linear-gradient(180deg, rgba(13, 110, 253, 0.08), rgba(13, 110, 253, 0.02));
    border-color: rgba(13, 110, 253, 0.35);
}

.call-center-calendar-day-number {
    font-size: 1rem;
    font-weight: 700;
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.08);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
}

.call-center-calendar-day.has-note .call-center-calendar-day-number {
    background: rgba(255, 255, 255, 0.85);
}

.call-center-calendar-note-preview {
    font-size: 0.92rem;
    color: #212529;
    line-height: 1.35;
    overflow: hidden;
    width: 100%;
}

.call-center-calendar-note-preview p {
    margin-bottom: 0.25rem;
}

.call-center-calendar-note-preview p:last-child {
    margin-bottom: 0;
}

.call-center-calendar-note-indicator {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: #0d6efd;
    font-weight: 600;
}

.call-center-calendar-loader,
.call-center-calendar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.call-center-calendar-loader {
    position: absolute;
    inset: 0;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    z-index: 2;
}

.call-center-calendar-empty {
    margin-top: 0.5rem;
    border-radius: 1rem;
    border: 1px dashed rgba(13, 110, 253, 0.35);
    background: rgba(248, 249, 250, 0.9);
    color: #6c757d;
    font-weight: 500;
}

.call-center-calendar-empty p {
    max-width: 420px;
    margin-bottom: 0;
}

@media (max-width: 991.98px) {
    .call-center-calendar-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    .call-center-calendar-grid-wrapper {
        padding: 0.75rem;
    }

    .call-center-calendar-weekdays,
    .call-center-calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .call-center-calendar-day {
        min-height: 8.5rem;
    }
}

.plan-details-layout .plan-history-card {
    background: #ffffff;
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1.25rem 2.75rem rgba(13, 110, 253, 0.12);
    max-height: 420px;
    overflow-y: auto;
    scrollbar-color: rgba(13, 110, 253, 0.35) transparent;
}

.plan-history-title {
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #0b2a4a;
}

.plan-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.plan-history-entry {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(32, 201, 151, 0.05));
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(13, 110, 253, 0.15);
    box-shadow: 0 0.75rem 1.5rem rgba(13, 110, 253, 0.08);
    backdrop-filter: blur(3px);
}

.plan-history-entry .plan-history-header {
    gap: 0.5rem;
}

.plan-history-entry .plan-history-status .badge {
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    box-shadow: 0 0.35rem 0.75rem rgba(13, 110, 253, 0.18);
}

.plan-history-entry .plan-history-date {
    color: #516172;
}

.plan-history-entry .plan-history-meta {
    color: #5c6c7c;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.plan-history-entry .plan-history-comment {
    margin: 0.75rem 0 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 0.6rem;
    padding: 0.65rem 0.75rem;
    color: #12324a;
    font-size: 0.95rem;
    line-height: 1.55;
    border: 1px solid rgba(13, 110, 253, 0.12);
}

.plan-history-card::-webkit-scrollbar {
    width: 6px;
}

.plan-history-card::-webkit-scrollbar-thumb {
    background-color: rgba(13, 110, 253, 0.35);
    border-radius: 3px;
}

.plan-history-card::-webkit-scrollbar-track {
    background-color: transparent;
}

@media (max-width: 991.98px) {
    .plan-details-layout .plan-history-card {
        max-height: none;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 576px) {
    body.role-call-center #mainTabContent .tab-pane:not(#settings) .call-center-table-wrapper,
    body.role-call-center #mainTabContent .tab-pane:not(#settings) .plan-table-wrapper,
    body.role-call-center #mainTabContent .tab-pane:not(#settings) .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.role-call-center #mainTabContent .tab-pane:not(#settings) table {
        table-layout: auto;
        width: auto;
        min-width: 100%;
    }

    body.role-call-center #mainTabContent .tab-pane:not(#settings) th,
    body.role-call-center #mainTabContent .tab-pane:not(#settings) td {
        white-space: nowrap;
    }

    body.role-call-center #mainTabContent .tab-pane:not(#settings) table th:last-child,
    body.role-call-center #mainTabContent .tab-pane:not(#settings) table td:last-child {
        min-width: 10.5rem;
    }

    body.role-call-center #mainTabContent .tab-pane:not(#settings) .plan-table .plan-actions {
        flex-wrap: nowrap;
    }
}

#details-sidebar table tbody tr:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}



#details-sidebar {
    width: 90%;
    max-width: 550px;
    box-shadow: -0.5rem 0 1rem rgba(0,0,0,0.15);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-left: 1px solid #dee2e6;
    background-color: #fdfdfd;
}

/* Offcanvas animations improvements */
.offcanvas-end {
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.offcanvas.showing,
.offcanvas.show {
    transform: none;
}

.offcanvas.hiding {
    transform: translateX(100%);
}

#details-sidebar .offcanvas-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
}

#details-sidebar-label {
    font-weight: 600;
    color: #343a40;
    font-size: 1.25rem;
}

#details-sidebar .offcanvas-body {
    padding: 1.5rem;
}

#details-sidebar .form-label {
    font-weight: 500 !important;
    color: #495057;
    font-size: 0.875rem;
    margin-bottom: 0.3rem;
}

/* Style for form controls inside the sidebar */
#details-sidebar .form-control,
#details-sidebar .form-select {
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
    font-size: 0.95rem;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

#details-sidebar .form-control:focus,
#details-sidebar .form-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.35);
    transform: scale(1.03);
}

#details-related-tables h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #0d6efd;
    border-bottom: 2px solid #a1c4fd;
    padding-bottom: 0.25rem;
    display: inline-block;
    font-weight: 600;
    font-size: 1.1rem;
}

.btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    animation: btn-pop 0.3s ease-out forwards;
}

@keyframes btn-pop {
    0%   { transform: translateY(-2px) scale(1);   box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
    50%  { transform: translateY(-4px) scale(1.05); box-shadow: 0 6px 12px rgba(0,0,0,0.12); }
    100% { transform: translateY(-2px) scale(1.02); box-shadow: 0 4px 10px rgba(0,0,0,0.11); }
}

.btn:active {
    transform: translateY(0) scale(1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: none;
}

.archive-filter-btn.active {
    background-color: #6c757d;
    color: white;
}

.devices-h2-count {
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1;
    display: inline-block;
}

#devices-table td:last-child {
    vertical-align: middle;
}

#devices-table th[data-column-id="water-level"],
#devices-table td[data-column-id="water-level"] {
    text-align: center;
    vertical-align: middle;
}

/* ================================================== */
/* === MOBILE RESPONSIVE IMPROVEMENTS === */
/* ================================================== */

/* Tablet and below */
@media (max-width: 991px) {
    /* Header adjustments */
    .dashboard-header {
        flex-wrap: wrap !important;
        padding: 0.5rem 1rem !important;
    }

    #site-title {
        font-size: 1.25rem !important;
        padding: 0.5rem !important;
    }

    /* Search bar - take full width below header on mobile */
    .dashboard-header .flex-grow-1 {
        order: 3;
        width: 100%;
        margin-top: 0.5rem;
    }

    /* Tables become scrollable - CRITICAL FIX */
    .table-responsive {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        display: block;
        position: static !important;
    }

    .data-table {
        min-width: 800px;
        width: max-content;
    }

    /* Devices table specific fix */
    .devices-table-wrapper {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        position: static !important;
    }

    #devices-table {
        min-width: 900px;
        width: max-content;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 0.9rem;
    }

    .dashboard-header {
        position: relative;
    }

    /* Compact tabs */
    .nav-tabs {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding: 0.25rem 0.5rem 0 0.5rem;
    }

    .nav-tabs .nav-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .nav-tabs .nav-link .bi {
        font-size: 0.9rem;
    }

    /* Tab content padding */
    .tab-content > .tab-pane {
        padding: 0.75rem;
    }

    /* Flexible layouts stack on mobile */
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .d-flex.justify-content-between > div {
        margin-top: 0;
        width: 100%;
    }

    /* Buttons stack vertically */
    .d-flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem !important;
    }

    /* Full width buttons on mobile */
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Mobile optimization for sticky bulk actions */
    .call-center-bulk-actions {
        padding: 0.5rem 0.75rem;
    }

    /* Restore row layout for buttons in bulk actions bar so they don't consume huge vertical space */
    .call-center-bulk-actions .d-flex.gap-2 {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    .call-center-bulk-actions .btn {
        flex: 1 1 auto;
        min-width: fit-content;
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Filter buttons wrap and are smaller */
    #manager-type-filters,
    #clinic-contract-status-filters,
    #device-state-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    #manager-type-filters .btn,
    #clinic-contract-status-filters .btn,
    #device-state-filters .btn {
        flex: 1 1 auto;
        min-width: fit-content;
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
        margin-right: 0 !important;
    }

    /* Modals full screen on mobile - ENHANCED */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .modal-content {
        max-height: calc(100vh - 1rem);
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        padding: 0.75rem 1rem;
        flex-shrink: 0;
    }

    .modal-header .modal-title {
        font-size: 1rem;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1rem 0.75rem;
        flex: 1 1 auto;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-shrink: 0;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    /* Form controls in modals */
    .modal-body .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }

    .modal-body .form-control,
    .modal-body .form-select {
        font-size: 1rem; /* Prevent iOS zoom */
        padding: 0.6rem 0.75rem;
    }

    .modal-body .form-control-sm {
        font-size: 0.9rem;
        padding: 0.4rem 0.6rem;
    }

    .modal-body textarea.form-control {
        min-height: 80px;
    }

    /* Two-column layouts in modals stack */
    .modal-body .row.g-3 {
        row-gap: 0.75rem !important;
    }

    .modal-body .col-md-6,
    .modal-body .col-md-4,
    .modal-body .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Form switches - CRITICAL FIX */
    .form-check-input[type="checkbox"],
    .form-switch .form-check-input {
        width: 2.5rem;
        height: 1.25rem;
        cursor: pointer;
        background-size: contain;
    }

    .form-check-input[type="radio"] {
        width: 1.25rem;
        height: 1.25rem;
    }

    .form-check {
        min-height: 1.5rem;
        padding-left: 2rem;
        margin-bottom: 0.5rem;
    }

    .form-check-label {
        font-size: 0.9rem;
        padding-left: 0.5rem;
        line-height: 1.5;
    }

    /* Document flow radio buttons */
    .doc-flow-options .form-check-inline {
        display: block;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    /* Position relative for suggestion dropdowns in modals */
    .modal-body .position-relative {
        margin-bottom: 1rem;
    }

    .modal-body .assign-suggestions {
        max-height: 150px;
        font-size: 0.85rem;
    }

    /* Offcanvas sidebar full width and optimized */
    #details-sidebar {
        width: 100% !important;
        max-width: 100% !important;
    }

    #details-sidebar .offcanvas-body {
        padding: 1rem 0.75rem;
    }

    #details-sidebar .form-label {
        font-size: 0.85rem !important;
        margin-bottom: 0.25rem;
    }

    #details-sidebar .form-control,
    #details-sidebar .form-select {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }

    /* Contract status section in sidebar */
    #details-sidebar .contract-status-options {
        margin-top: 0.5rem;
    }

    #details-sidebar .form-check {
        margin-bottom: 0.75rem;
        padding-left: 1.75rem;
    }

    #details-sidebar .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0.125rem;
    }

    #details-sidebar .form-check-label {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* Contract date input groups */
    #details-sidebar .contract-date-input {
        margin-left: 0.5rem !important;
        margin-top: 0.5rem;
    }

    #details-sidebar .contract-date-input .form-control {
        font-size: 0.85rem;
    }

    #details-sidebar .contract-date-input .row {
        margin-left: 0;
        margin-right: 0;
    }

    #details-sidebar .contract-date-input .col {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    /* Related tables in sidebar */
    #details-related-tables {
        margin-top: 1rem;
    }

    #details-related-tables table {
        font-size: 0.8rem;
    }

    #details-related-tables th,
    #details-related-tables td {
        padding: 0.4rem 0.3rem;
    }

    /* Action buttons at bottom of sidebar */
    #details-sidebar .mt-4 {
        margin-top: 1rem !important;
        flex-direction: column;
        gap: 0.5rem;
    }

    #details-sidebar .mt-4 .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    #details-sidebar .mt-4 .btn:last-child {
        margin-bottom: 0;
    }

    /* Period selectors stack */
    #custom-period-container,
    #clients-custom-period-container,
    #accruals-custom-period-container {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    #custom-period-container input,
    #clients-custom-period-container input,
    #accruals-custom-period-container input {
        width: 100%;
    }

    /* Sort containers */
    #clinics-sort-container,
    #clients-sort-container,
    #devices-sort-container {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.25rem;
    }

    /* Table headers smaller */
    .data-table thead th {
        font-size: 0.8rem;
        padding: 0.5rem 0.4rem;
    }

    .data-table tbody td {
        font-size: 0.85rem;
        padding: 0.5rem 0.4rem;
    }

    /* Dropdown menus */
    .dropdown-menu {
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    /* Extra small devices - COMPREHENSIVE POLISH */
    body {
        font-size: 0.85rem;
        overflow-x: hidden;
    }

    /* Very compact header */
    #site-title {
        font-size: 1.1rem !important;
        padding: 0.25rem !important;
    }

    /* Header search */
    .dashboard-header .position-relative {
        max-width: 100% !important;
    }

    #global-search-input {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }

    .nav-tabs .nav-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }
    .nav-tabs .nav-link .bi {
        display: inline-block;
        margin-right: 0.3rem;
        font-size: 0.85rem;
    }

    /* Minimal tab padding */
    .tab-content > .tab-pane {
        padding: 0.5rem;
    }

    /* Action rows and button groups - SELECTIVE STACKING */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .d-flex.justify-content-between.align-items-center > div {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .d-flex.justify-content-between.align-items-center > div:last-child {
        margin-bottom: 0;
    }

    /* Action buttons in headers */
    .d-flex.justify-content-between > div > .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .d-flex.justify-content-between > div > .btn:last-child {
        margin-bottom: 0;
    }

    /* Even more compact bulk actions for small screens */
    .call-center-bulk-actions {
        padding: 0.4rem 0.5rem;
    }

    .call-center-bulk-actions .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        min-height: 36px; /* Override global 44px for compactness in sticky header */
    }

    /* Form controls - prevent zoom */
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 0.6rem 0.75rem;
    }

    .form-control-sm {
        font-size: 0.9rem;
        padding: 0.4rem 0.6rem;
    }

    /* Compact form groups */
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    /* Card headers */
    .card-header h5,
    .card-header h4 {
        font-size: 0.95rem;
    }

    /* Smaller headings */
    .h4, h4 {
        font-size: 1.1rem;
    }

    .h5, h5 {
        font-size: 1rem;
    }

    /* Input groups */
    .input-group {
        flex-wrap: nowrap;
    }

    .input-group-text {
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    /* Pills and badges - FIXED */
    .btn-group:not(#manager-type-filters):not(#clinic-contract-status-filters):not(#device-state-filters) {
        flex-direction: column;
        width: 100%;
    }

    .btn-group:not(#manager-type-filters):not(#clinic-contract-status-filters):not(#device-state-filters) .btn {
        width: 100%;
        border-radius: 0.4rem !important;
        margin-bottom: 0.3rem;
    }

    /* Touch-friendly tap targets */
    .btn {
        min-height: 44px;
    }

    .form-check-input {
        min-width: 20px;
        min-height: 20px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
    }

    .nav-link {
        min-height: 40px;
    }

    /* Compact table actions */
    .data-table .dropdown-toggle {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
        min-height: 36px;
    }

    .data-table .btn-sm {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }

    /* Archive filter buttons */
    #archive .btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }

    #archive .btn-group .btn {
        flex: 1 1 auto;
        min-width: fit-content;
        margin-bottom: 0.25rem;
    }

    /* Period and sort selectors */
    #period-selector,
    #clients-period-selector,
    #reports-period-selector,
    #accruals-period-selector,
    #sort-clinics-select,
    #sort-clients-select,
    #sort-devices-select {
        font-size: 0.85rem;
        width: 100% !important;
        max-width: 100%;
    }

    /* Date inputs */
    input[type="date"],
    input[type="month"],
    input[type="datetime-local"] {
        font-size: 16px !important;
        padding: 0.5rem;
    }

    /* Tariff inputs in Add Clinic modal */
    .modal-body input[type="number"] {
        font-size: 16px !important;
    }

    /* Manual accrual card */
    .manual-accrual-card .card-body {
        padding: 0.75rem;
    }

    .manual-accrual-card .row {
        flex-direction: column;
    }

    .manual-accrual-card .col-auto {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* User access section in edit user modal */
    #editUserModal .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    #edit-user-clinics,
    #edit-user-devices {
        font-size: 0.85rem;
    }

    /* Kassa and accruals tables */
    #kassa-table th,
    #kassa-table td,
    #accruals-clinics-table th,
    #accruals-clinics-table td,
    #accruals-managers-table th,
    #accruals-managers-table td {
        font-size: 0.75rem;
        padding: 0.4rem 0.3rem;
    }

    /* Report clinic search */
    #report4-clinic-search {
        font-size: 0.9rem;
        width: 100%;
    }

    /* Export buttons */
    .btn-success,
    .btn-secondary,
    .btn-info {
        font-size: 0.85rem;
    }

    /* Refresh button */
    #refresh-clinics-data,
    #refresh-reports-data,
    #refresh-archive-btn {
        padding: 0.4rem 0.6rem;
    }

    /* Toggle switches in header */
    .form-switch {
        padding-left: 2.5rem;
    }

    .form-switch .form-check-input {
        width: 2rem;
        height: 1rem;
        margin-left: -2.5rem;
    }

    .form-switch .form-check-label {
        font-size: 0.8rem;
    }

    /* Notification dot */
    .notification-dot {
        width: 6px;
        height: 6px;
    }

    /* Dropdown menus */
    .dropdown-menu {
        font-size: 0.85rem;
        min-width: 10rem;
    }

    .dropdown-item {
        padding: 0.5rem 1rem;
    }

    /* Spinner sizes */
    .spinner-border-sm {
        width: 0.9rem;
        height: 0.9rem;
    }

    /* Alert messages */
    .alert {
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }

    /* Badge and text utilities */
    .badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    small, .small {
        font-size: 0.8rem;
    }

    /* Prevent horizontal scroll on body */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Fix for wrapping text */
    .text-nowrap {
        white-space: normal !important;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    /* Maximum compactness */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .card {
        border-radius: 0.25rem;
    }

    /* Minimal spacing */
    .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    /* Very small text for space */
    .small,
    small {
        font-size: 0.75rem;
    }
}

.placeholder-glow .placeholder {
    animation: glow 1.2s ease-in-out infinite alternate;
}

@keyframes glow {
    0%   { opacity: 0.45; }
    100% { opacity: 0.8; }
}

.dropdown-menu {
    position: absolute !important;
    z-index: 9999 !important;
    transform-origin: top center;
    animation: dropdown-fade 0.25s cubic-bezier(0.22,1,0.36,1);
}

/* Ensure dropdown menus appended to body are positioned correctly */
body > .dropdown-menu {
    position: absolute !important;
    z-index: 9999 !important;
}

@keyframes dropdown-fade {
    from { opacity: 0; margin-top: -10px; }
    to   { opacity: 1; margin-top: 0; }
}

.login-page-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-card {
    border: none;
    border-radius: 0.5rem;
    overflow: hidden;
}

.login-card .card-header {
    border-bottom: none;
}

.login-card .card-body {
    background-color: #ffffff;
}

.login-card .form-floating > .form-control:focus ~ label,
.login-card .form-floating > .form-control:not(:placeholder-shown) ~ label {
    opacity: .65;
    transform: scale(.85) translateY(-.5rem) translateX(.15rem);
}

.login-card .form-floating > label {
    padding: 1rem .75rem;
}

#login-button .spinner-border {
    vertical-align: text-bottom;
}

/* --- Global Search Styles --- */
#global-search-input {
    border-radius: 0 0.25rem 0.25rem 0;
}

#global-search-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, .25);
    border-color: #86b7fe;
}

#search-suggestions .list-group-item,
#accruals-search-suggestions .list-group-item {
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-out;
    opacity: 0;
    animation: fadeInSuggestion 0.3s ease forwards;
}

#search-suggestions .list-group-item:hover,
#accruals-search-suggestions .list-group-item:hover {
    background-color: #e9ecef;
    transform: translateX(5px);
}

#search-suggestions .suggestion-type,
#accruals-search-suggestions .suggestion-type {
    font-size: 0.8em;
    padding: 0.1em 0.4em;
    border-radius: 0.2em;
    margin-right: 0.5em;
}

.suggestion-type-clients { background-color: #cfe2ff; color: #084298; }
.suggestion-type-clinics { background-color: #d1e7dd; color: #0f5132; }
.suggestion-type-devices { background-color: #f8d7da; color: #842029; }

@keyframes fadeInSuggestion {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
/* Make suggestions appear one by one */
#search-suggestions .list-group-item:nth-child(1),
#accruals-search-suggestions .list-group-item:nth-child(1) { animation-delay: 0.02s; }
#search-suggestions .list-group-item:nth-child(2),
#accruals-search-suggestions .list-group-item:nth-child(2) { animation-delay: 0.04s; }
#search-suggestions .list-group-item:nth-child(3),
#accruals-search-suggestions .list-group-item:nth-child(3) { animation-delay: 0.06s; }
#search-suggestions .list-group-item:nth-child(4),
#accruals-search-suggestions .list-group-item:nth-child(4) { animation-delay: 0.08s; }
#search-suggestions .list-group-item:nth-child(5),
#accruals-search-suggestions .list-group-item:nth-child(5) { animation-delay: 0.1s; }
/* Add more if expecting more suggestions */

/* --- Row Highlight Animation --- */
/* Increased Specificity */
.data-table tbody tr.table-highlight {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

.data-table tbody tr.table-selected,
.plan-table tbody tr.table-selected,
.call-center-table tbody tr.table-selected {
    background-color: rgba(13, 110, 253, 0.12) !important;
}

.data-table tbody tr.table-selected > *,
.plan-table tbody tr.table-selected > *,
.call-center-table tbody tr.table-selected > * {
    background-color: rgba(13, 110, 253, 0.12) !important;
}

/* Device row highlight states */
.device-row-error > * {
    background-color: rgba(255, 0, 0, 0.2) !important;
}

.device-row-ipad-error > * {
    background-color: rgba(255, 255, 0, 0.2) !important;
}

.device-row-running > * {
    background-color: rgba(30, 144, 255, 0.2) !important;
}

.device-row-maintenance > * {
    background-color: rgba(111, 66, 193, 0.2) !important;
}

/* Inspector role: green device name when inhalation is running (no row background) */
.device-row-running-inspector .editable-device-name {
    color: #28a745 !important;
    font-weight: 600 !important;
}

/* Inspector role: selected device row */
.device-row.inspector-selected {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

.device-row.inspector-selected > * {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

.device-row.inspector-selected:hover {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

.device-row.inspector-selected:hover > * {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

/* Inspector role: selected data row */
.inspector-data-row.inspector-selected,
.inspector-data-row.inspector-selected > * {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

.inspector-data-row.inspector-selected:hover,
.inspector-data-row.inspector-selected:hover > * {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

.superuser-selectable-cell {
    cursor: pointer;
}

.user-row.superuser-selected,
.user-row.superuser-selected > * {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

.user-row.superuser-selected:hover,
.user-row.superuser-selected:hover > * {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

/* Device detail action grid */
.device-actions-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.device-action-card {
    background-color: var(--paper-bg);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 0.75rem;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.device-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}

.device-action-card h6 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.device-action-card .device-action-subtitle {
    margin-bottom: 0.75rem;
}

.device-action-card .btn {
    flex: 0 0 auto;
}

.device-state-buttons .btn {
    min-width: 0;
}

/* Legend styles for superuser device table */
#devices-legend {
    font-size: 0.875rem;
}

#devices-legend .legend-item {
    display: inline-flex;
    align-items: center;
    margin-right: 1rem;
}

#devices-legend .legend-color {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    margin-right: 0.25rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

#devices-legend .legend-color.error {
    background-color: rgba(255, 0, 0, 0.2);
}

#devices-legend .legend-color.ipad-error {
    background-color: rgba(255, 255, 0, 0.2);
}

#devices-legend .legend-color.running {
    background-color: rgba(30, 144, 255, 0.2);
}

#devices-legend .legend-color.maintenance {
    background-color: rgba(111, 66, 193, 0.2);
}

/* Remove unused animation */
/* 
@keyframes highlight-row-shadow {
    0%   { box-shadow: inset 0 0 0 3px rgba(13, 110, 253, 0.5); }
    70%  { box-shadow: inset 0 0 0 3px rgba(13, 110, 253, 0.5); }
    100% { box-shadow: inset 0 0 0 0px rgba(13, 110, 253, 0); }
}
*/
/* --- End Global Search Styles --- */

/* --- Table Sorting Styles --- */
.data-table thead th {
    position: relative; /* Needed for absolute positioning of indicator? Maybe not */
    cursor: pointer; /* Always show pointer if potentially sortable */
    transition: background-color 0.2s ease;
}

.data-table thead th:hover {
    background-color: #d1d9e1; /* Slightly darker on hover */
}

.data-table thead th .sort-indicator {
    display: inline-block;
    margin-left: 0.5em;
    color: #6c757d; /* Grey color */
    font-size: 0.9em;
    vertical-align: middle;
}

/* Style for headers that cannot be sorted */
.data-table thead th.no-sort {
    cursor: default;
}
.data-table thead th.no-sort:hover {
    background-color: inherit; /* Don't highlight on hover */
}
.data-table thead th.no-sort .sort-indicator {
    display: none; /* Hide indicator */
}
/* --- End Table Sorting Styles --- */

/* Period Selection Styles */
#custom-period-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#period-selector {
    min-width: 180px;
}

#clinics-period-display {
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background-color: #e9f0fd;
    color: #0d6efd;
}

#period-start-date, #period-end-date {
    width: 150px;
}

@media (max-width: 768px) {
    #custom-period-container {
        margin-top: 0.5rem;
        width: 100%;
    }
    
    #clinics-period-display {
        margin-top: 0.5rem;
        width: 100%;
        text-align: center;
    }
}
/* End Period Selection Styles */

/* Spinner transitions */
#details-spinner {
    opacity: 0;
    transition: opacity 0.2s ease;
}

#details-spinner:not(.d-none) {
    opacity: 1;
}

#details-form, #details-related-tables {
    transition: opacity 0.2s ease;
}

#details-form.d-none, #details-related-tables.d-none {
    opacity: 0;
}

/* Device history timeline styles */
.device-history-timeline {
    position: relative;
    max-height: 350px;
    overflow-y: auto;
    padding-left: 20px;
    margin-bottom: 15px;
    z-index: 0;
}

/* Remove the pseudo-element for the line and create it as a separate div */
.device-history-timeline:before {
    display: none; /* Hide the original line */
}

/* Add this new class for the actual timeline */
.device-history-timeline .timeline-line {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #dee2e6;
    z-index: -10 !important;
    pointer-events: none;
}

.history-event {
    position: relative;
    z-index: 2;
    isolation: isolate;
    padding-bottom: 15px;
    margin-bottom: 5px;
    padding-left: 10px;
    animation: fadeInHistory 0.5s ease forwards;
    opacity: 0;
}

.history-event:last-child {
    padding-bottom: 0;
}

.history-event:before {
    content: '';
    position: absolute;
    left: -17px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 2px solid #6c757d;
    z-index: 99999 !important;
    box-shadow: 0 0 0 3px white;
    transform: translateZ(0);
}

.history-event.event-created:before {
    border-color: #198754;
    background-color: #d1e7dd;
}

.history-event.event-assigned:before, 
.history-event.event-reassigned:before {
    border-color: #0d6efd;
    background-color: #cfe2ff;
}

.history-event.event-unassigned:before {
    border-color: #dc3545;
    background-color: #f8d7da;
}

.history-event.event-archived:before {
    border-color: #fd7e14;
    background-color: #fff3cd;
}

.history-event.event-restored:before {
    border-color: #0dcaf0;
    background-color: #cff4fc;
}

.history-event.event-updated:before {
    border-color: #6c757d;
    background-color: #e2e3e5;
}

.history-event-date {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 2px;
}

.history-event-type {
    font-weight: 600;
    display: inline-block;
    margin-right: 5px;
    font-size: 0.95rem;
}

.history-event-details {
    font-size: 0.9rem;
}

.history-event-meta {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 3px;
}

@keyframes fadeInHistory {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.history-event:nth-child(1) { animation-delay: 0.05s; }
.history-event:nth-child(2) { animation-delay: 0.10s; }
.history-event:nth-child(3) { animation-delay: 0.15s; }
.history-event:nth-child(4) { animation-delay: 0.20s; }
.history-event:nth-child(5) { animation-delay: 0.25s; }
.history-event:nth-child(6) { animation-delay: 0.30s; }
.history-event:nth-child(7) { animation-delay: 0.35s; }
.history-event:nth-child(8) { animation-delay: 0.40s; }
.history-event:nth-child(9) { animation-delay: 0.45s; }
.history-event:nth-child(10) { animation-delay: 0.50s; }

#details-sidebar label[for='detail-device-production-date'] {
    font-weight: bold !important; /* Target specific label */
}

#details-sidebar .form-label {
    font-weight: bold !important; /* Use standard 'bold' and keep !important for testing */
    color: #495057;
}

/* --- Document Flow Row Coloring --- */
.doc-flow-electronic, .doc-flow-electronic > td {
    background-color: #e7f6ff !important; /* light blue */
}
.doc-flow-paper, .doc-flow-paper > td {
    background-color: #fff9e6 !important; /* light yellow */
}
.doc-flow-electronic:hover, .doc-flow-paper:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}
/* --- End Document Flow Row Coloring --- */



/* --- Letters Panel Styles & Animations --- */
#activation-letters .d-flex {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    overflow: hidden;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.05);
}

#letters-list {
    width: 280px;
    overflow-y: auto;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    transition: background-color 0.3s ease;
}

/* Custom scrollbar */
#letters-list::-webkit-scrollbar {
    width: 8px;
}
#letters-list::-webkit-scrollbar-track {
    background: transparent;
}
#letters-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    transition: background 0.2s ease;
}
#letters-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

#letters-list .list-group-item {
    transition: background-color 0.25s ease, transform 0.2s ease;
    border: none;
    background: transparent;
}
#letters-list .list-group-item:hover {
    background: #e9ecef;
    transform: translateX(6px);
}
#letters-list .list-group-item.active {
    background: #0d6efd;
    color: #ffffff;
    transform: translateX(0);
}
#letters-list .list-group-item.active small {
    color: rgba(255, 255, 255, 0.8);
}

#letter-content {
    position: relative;
    overflow-y: auto;
    max-height: 70vh;
    animation: fadeSlideIn 0.4s ease-out both;
}

/* triggered class for re-animation */
.animate-letter-in {
    animation: fadeSlideIn 0.4s ease-out both;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* --- End Letters Panel Styles --- */

/* --- Email System Styles --- */
#emails-inbox-list, #emails-outbox-list {
    width: 320px;
    overflow-y: auto;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
}

#emails-inbox-list::-webkit-scrollbar, #emails-outbox-list::-webkit-scrollbar {
    width: 8px;
}
#emails-inbox-list::-webkit-scrollbar-track, #emails-outbox-list::-webkit-scrollbar-track {
    background: transparent;
}
#emails-inbox-list::-webkit-scrollbar-thumb, #emails-outbox-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.email-list-item {
    transition: background-color 0.25s ease, transform 0.2s ease;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.75rem 1rem;
}
.email-list-item:hover {
    background: #e9ecef;
    transform: translateX(6px);
}
.email-list-item.active {
    background: #0d6efd;
    color: #ffffff;
    transform: translateX(0);
}
.email-list-item.active .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.email-list-item-unread {
    font-weight: 600;
    border-left: 3px solid #0d6efd;
}

.email-sender, .email-recipient {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-subject {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-date {
    font-size: 0.75rem;
    text-align: right;
}
.email-preview {
    font-size: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#email-detail-view, #email-outbox-detail-view {
    position: relative;
    overflow-y: auto;
    max-height: 70vh;
    padding: 1rem;
    background: #fff;
}

.email-detail-header {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.email-detail-subject {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.email-detail-body {
    line-height: 1.6;
    white-space: pre-wrap;
}
.email-detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

@media (max-width: 767.98px) {
    #emails-inbox .d-flex, #emails-outbox .d-flex {
        flex-direction: column;
    }
    #emails-inbox-list, #emails-outbox-list {
        width: 100% !important;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    #email-detail-view, #email-outbox-detail-view {
        border-start: none !important;
        border-top: 1px solid #dee2e6;
    }
    .email-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .email-search-input {
        max-width: 100% !important;
    }
}

/* Email Toolbar & Attachments */
.email-toolbar {
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
}

.email-sync-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.email-attachments {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.25rem;
}
.email-attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}
.email-attachment-item:last-child {
    border-bottom: none;
}
.email-attachment-icon {
    font-size: 1.5rem;
    color: #6c757d;
}
.email-attachment-name {
    flex: 1;
    font-weight: 500;
}
.email-attachment-size {
    color: #6c757d;
    font-size: 0.875rem;
}
/* --- End Email System Styles --- */

/* --- Contact Requests Styles --- */
#contactRequestsList {
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    padding: 0;
}

#contactRequestsList::-webkit-scrollbar {
    width: 8px;
}

#contactRequestsList::-webkit-scrollbar-thumb {
    background: rgba(13, 110, 253, 0.25);
    border-radius: 4px;
}

#contactRequestsList::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 110, 253, 0.45);
}

#contactRequestsList .contact-request-item {
    border: none;
    border-bottom: 1px solid #eef2f8;
    border-radius: 0;
    padding: 16px 18px;
    background: transparent;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#contactRequestsList .contact-request-item:hover {
    background: rgba(13, 110, 253, 0.08);
    transform: translateX(4px);
}

#contactRequestsList .contact-request-item.active {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.12), rgba(13, 110, 253, 0.22));
    box-shadow: 0 16px 32px rgba(13, 110, 253, 0.18);
    border-radius: 12px;
    transform: none;
    border-bottom-color: transparent;
}

#contactRequestsList .contact-request-item:last-child {
    border-bottom: none;
}

.contact-request-body {
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
}

@media (max-width: 991.98px) {
    #contactRequestsList {
        max-height: 280px;
    }
}

@media (max-width: 575.98px) {
    #contactRequestsList .contact-request-item {
        padding: 14px 12px;
    }
}
/* --- End Contact Requests Styles --- */

/* --- Search Suggestions Container --- */
#search-suggestions,
#accruals-search-suggestions,
.assign-suggestions {
    z-index: 1100;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

/* Smaller max-height for modal assignment suggestions */
.assign-suggestions {
    max-height: 150px;
    z-index: 1070;
}

/* -------------------------------------------------- */
/* --- Sleek Modern Enhancements (2025-05 update) --- */
/* -------------------------------------------------- */

/* 1. Tab switch: smooth fade & slide */
.tab-content > .tab-pane {
    transition: opacity 0.45s ease, transform 0.45s ease;
}
.tab-content > .tab-pane:not(.active) {
    opacity: 0;
    transform: translateY(20px);
}
.tab-content > .tab-pane.active {
    opacity: 1;
    transform: translateY(0);
}

/* 2. Fancy underline for nav tabs */
.nav-tabs .nav-link {
    position: relative;
    overflow: hidden;
}
.nav-tabs .nav-link::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 3px;
    background-color: currentColor;
    transition: width 0.3s ease, left 0.3s ease;
}
.nav-tabs .nav-link:hover::after,
.nav-tabs .nav-link.active::after {
    width: 100%;
    left: 0;
}

/* 3. Input focus lift */
.form-control,
.form-select {
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.form-control:focus,
.form-select:focus {
    transform: scale(1.03);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.35);
}

/* 4. Button pop animation */
.btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
    animation: btn-pop 0.3s ease-out forwards;
}
@keyframes btn-pop {
    0%   { transform: translateY(-2px) scale(1);   box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
    50%  { transform: translateY(-4px) scale(1.05); box-shadow: 0 6px 12px rgba(0,0,0,0.12); }
    100% { transform: translateY(-2px) scale(1.02); box-shadow: 0 4px 10px rgba(0,0,0,0.11); }
}
.btn:active {
    transform: translateY(0) scale(1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: none;
}

/* 5. Table row subtle shimmer on hover */
.data-table tbody tr {
    transition: background-color 0.25s ease, transform 0.18s ease, box-shadow 0.25s ease;
}
.data-table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.07);
    transform: scale(1.015);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

/* 6. Card / off-canvas gentle lift */
.card,
.offcanvas,
.modal-content {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.card:hover,
.offcanvas:hover,
.modal-content:hover {
    transform: translateY(-4px);
    box-shadow: 0 1rem 2rem rgba(0,0,0,0.08);
}

/* 7. Global fade utility (for JS toggles) */
.fade-enter-active,
.fade-leave-active {
    transition: opacity 0.45s ease;
}
.fade-enter, .fade-leave-to { /* .fade-leave-active in <=Vue2 syntax */
    opacity: 0;
}

/* 8. Smooth dropdown reveal */
.dropdown-menu {
    transform-origin: top center;
    animation: dropdown-fade 0.25s cubic-bezier(0.22,1,0.36,1);
}
@keyframes dropdown-fade {
    from { opacity: 0; margin-top: -10px; }
    to   { opacity: 1; margin-top: 0; }
}

/* 9. Placeholder pulse for loading states */
.placeholder-glow .placeholder {
    animation: glow 1.2s ease-in-out infinite alternate;
}
@keyframes glow {
    0%   { opacity: 0.45; }
    100% { opacity: 0.8; }
}

/* 10. Scrollbar styling (modern webkit) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* -------------------------------------------------- */
/* --- Visual Polish: Glass & Shadows (2025-05)  --- */
/* -------------------------------------------------- */
:root {
    --primary-color: #0d6efd;
    --primary-grad-start: #0d6efd;
    --primary-grad-end:   #0b5ed7;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.40);
    --glass-blur: 16px;
    --accent-pink: #ff6ec4;
    --accent-orange: #ff9472;
    --accent-purple: #845ec2;
    --accent-blue: #2c73d2;
    --paper-bg: #f4f6f8; /* slightly gray white */
}

/* Universal card-style components */
.card,
.offcanvas,
.modal-content {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur));
            backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* Elevated nav tabs */
.nav-tabs {
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(calc(var(--glass-blur) / 1.5));
            backdrop-filter: blur(calc(var(--glass-blur) / 1.5));
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.nav-tabs .nav-link {
    font-weight: 500;
    color: #495057;
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    background-color: transparent;
}

/* Refined Buttons */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.btn-primary {
    background-image: linear-gradient(135deg, var(--primary-grad-start) 0%, var(--primary-grad-end) 100%);
    border: none;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(13,110,253,0.32);
}
.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 8px 18px rgba(13,110,253,0.35);
}
.btn-primary:active {
    filter: brightness(0.97);
    box-shadow: 0 4px 10px rgba(13,110,253,0.25) !important;
}

/* Inputs with subtle depth */
.form-control,
.form-select {
    background-color: rgba(255,255,255,0.9);
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    border-radius: 0.5rem;
}
.form-control::placeholder {
    color: #adb5bd;
}

/* Table container polish */
/* Ensure action dropdowns are never clipped by table containers */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible !important;
    position: static !important;
}

.table-responsive .dropdown-menu {
    z-index: 4000;
}

.data-table {
    /* Allow dropdown menus to display outside table bounds */
    overflow: visible;
    border-radius: 0.5rem;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 6px 16px rgba(0,0,0,0.05);
    position: relative; /* required for pseudo-element shadow */
}

/* Allow device actions dropdown to escape table container */
.devices-table-wrapper {
    overflow-x: auto;
    overflow-y: visible !important;
    position: static !important;
}
.devices-table-wrapper .dropdown-menu {
    /* keep dropdown above all table rows */
    z-index: 2100;
}
.data-table tbody tr.dropdown-open {
    /* raise row so neighbours don't cover the dropdown */
    z-index: 2050;
    /* keep highlight when dropdown is open */
    background-color: rgba(13, 110, 253, 0.07);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

/* Hover effect for superuser actions dropdown */
.devices-table-wrapper .dropdown-menu .dropdown-item:hover {
    background-color: var(--accent-blue);
    color: #fff;
}
.data-table thead th {
    background: linear-gradient(180deg, #f0f4f8 0%, #e2e8f0 100%);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.06);
}
.data-table::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.15), rgba(0,0,0,0) 80%);
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    pointer-events: none;
}

/* Utility reflection class (optional use) */
.reflect {
    position: relative;
}
.reflect::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 100%;
    background: linear-gradient(0deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 50%);
    transform: scaleY(-1);
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
    pointer-events: none;
}

/* -------------------------------------------------- */
/* --- Ambient Background & Rich Color Palette --- */
/* -------------------------------------------------- */
:root {
    --accent-pink: #ff6ec4;
    --accent-orange: #ff9472;
    --accent-purple: #845ec2;
    --accent-blue: #2c73d2;
}

/* Slow animated gradient background (applies site-wide) */
@keyframes bg-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ----------------------------------------------- */
/* Glowing button (e.g., "Create Clinic" action)  */
/* ----------------------------------------------- */
.btn-glow {
    position: relative;
    color: #fff;
    background-image: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-orange) 100%);
    border: none;
    box-shadow: 0 6px 12px rgba(255, 110, 196, 0.35);
}
.btn-glow::before {
    content: '';
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    background: inherit;
    filter: blur(12px);
    opacity: 0.6;
    z-index: -1;
    border-radius: inherit;
}
.btn-glow:hover {
    filter: brightness(1.05);
    box-shadow: 0 8px 20px rgba(255,110,196,0.45);
}

/* Glass effect for top navigation bars */
.navbar,
header,
.dashboard-header {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(calc(var(--glass-blur) / 1.3));
            backdrop-filter: blur(calc(var(--glass-blur) / 1.3));
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Replace pure white backgrounds with soft paper */
.tab-content > .tab-pane,
.login-card .card-body,
.offcanvas-body,
.modal-content,
#letter-content,
.dropdown-menu,
#letters-list,
#search-suggestions,
.assign-suggestions {
    background-color: var(--paper-bg) !important;
}

/* Ensure text still stands out on softer background */
.tab-content > .tab-pane {
    color: #222;
}

/* -------------------------------------------------- */
/* --- Glassier Tabs & Table-Button Separation      --- */
/* -------------------------------------------------- */

/* Even clearer glass for tabs bar */
.nav-tabs {
    background: rgba(255, 255, 255, 0.28) !important; /* more translucent */
    -webkit-backdrop-filter: blur(14px) !important;
            backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 4px 18px rgba(0,0,0,0.07);
}

/* Separation element: apply subtle shadow to any button containers above tables */
.tab-content .btn-toolbar,
.tab-content .btn-group,
.tab-content .action-bar,
.tab-content .table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: var(--paper-bg);
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Extra depth for tables to stand off from controls */
.data-table {
    box-shadow: 0 4px 14px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
}

/* Firmware comments responsive layout */
#firmwares .firmware-comment-content {
    width: 100%;
}

#firmwares .firmware-comment-text {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

#firmwares .firmware-comment-actions {
    flex-shrink: 0;
}

@media (max-width: 991.98px) {
    #firmwares .data-table {
        min-width: 100% !important;
        width: 100%;
    }

    #firmwares .firmware-comment-content {
        flex-direction: column;
        align-items: stretch;
    }

    #firmwares .firmware-comment-actions {
        width: 100%;
    }
}

@media (min-width: 992px) {
    #firmwares .firmware-comment-content {
        flex-direction: row;
        align-items: flex-start;
    }
}

/* -------------------------------------------------- */
/* --- Glass Transparency Tweaks (2025-05-10)      --- */
/* -------------------------------------------------- */

/* Lighter glass for header & nav bars */
.navbar,
header,
.dashboard-header {
    background: rgba(255, 255, 255, 0.16) !important;
    -webkit-backdrop-filter: blur(18px) !important;
            backdrop-filter: blur(18px) !important;
    border-bottom: 1px solid rgba(255,255,255,0.32) !important;
}

/* Ultra-transparent nav-tabs (inside header) */
.nav-tabs {
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
}

/* Ensure active nav links maintain low-opacity background */
.nav-tabs .nav-link.active {
    background-color: rgba(255, 255, 255, 0.20) !important;
}

/* -------------------------------------------------- */
/* --- Final Glass & Background Visibility Tweaks  --- */
/* -------------------------------------------------- */
:root {
    --paper-bg: #f9fafb; /* brighter but still off-white */
}

/* Glassy page tabs (e.g., Clinics, Devices) */
.dashboard-container .nav-tabs,
.dashboard-header .nav-tabs {
    background: rgba(255, 255, 255, 0.10) !important;
    -webkit-backdrop-filter: blur(20px) !important;
            backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 6px 18px rgba(0,0,0,0.05);
}

/* Ensure tab panes sit on lighter paper background */
.tab-content > .tab-pane {
    background-color: var(--paper-bg) !important;
}

/* -------------------------------------------------- */
/* --- Filter Buttons Size & Gap Tweaks (2025-05-10) --- */
/* -------------------------------------------------- */
#manager-type-filters .btn,
#clinic-contract-status-filters .btn,
#device-state-filters .btn,
#archive .btn-group .btn {
    padding: 0.25rem 0.75rem; /* slimmer buttons */
    font-size: 0.875rem;      /* slightly smaller text */
    margin-right: 0.6rem;      /* extra gap between buttons */
    border-radius: 0.4rem;    /* keep rounded corners when gaps appear */
}

/* Remove accidental right margin on last button in each group */
#manager-type-filters .btn:last-child,
#clinic-contract-status-filters .btn:last-child,
#device-state-filters .btn:last-child,
#archive .btn-group .btn:last-child {
    margin-right: 0;
}

/* Smaller pencil icon inside editable cells */
.editable-cell .bi-pencil {
  font-size: 0.75rem;
  vertical-align: middle;
}

/* Invoice Status Coloring */
.invoice-status-not_sent {
    background-color: #e2e3e5 !important; /* Soft gray */
    color: #212529;
}
.invoice-status-sent_not_received {
    background-color: #fff3cd !important; /* Soft yellow */
    color: #856404;
}
.invoice-status-sent_received {
    background-color: #d1e7dd !important; /* Soft green */
    color: #0f5132;
}

td.invoice-status-not_sent {
    background-color: #e2e3e5 !important;
}
td.invoice-status-sent_not_received {
    background-color: #fff3cd !important;
}
td.invoice-status-sent_received {
    background-color: #d1e7dd !important;
}

/* Card styling for manual accrual generation */
.manual-accrual-card {
    background-color: var(--paper-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

#device-av-chart {
    width: 100% !important;
    max-height: 60vh;
}

#device-av-preview {
    width: 100% !important;
    height: 200px;
}

/* ================================================== */
/* === MOBILE TOUCH & INTERACTION ENHANCEMENTS === */
/* ================================================== */

/* Smooth scrolling for mobile */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Better touch scrolling */
.table-responsive,
.nav-tabs,
#letters-list,
#letter-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Horizontal scroll indicator for tabs */
.nav-tabs {
    position: relative;
}

.nav-tabs::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(233, 236, 239, 0.9), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .nav-tabs::after {
        opacity: 1;
    }
}

/* Pull to refresh visual feedback */
@media (max-width: 768px) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* Better tap targets for mobile */
@media (max-width: 768px) {
    /* Action buttons in tables */
    .data-table .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
        min-height: 36px;
    }

    /* Checkbox and radio inputs */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }

    /* Dropdown toggles */
    .dropdown-toggle::after {
        margin-left: 0.5em;
    }
}

/* Scroll hint for tables - IMPROVED */
@media (max-width: 991px) {
    .table-responsive {
        position: relative;
        box-shadow: inset -15px 0 15px -15px rgba(0,0,0,0.1);
    }

    .table-responsive::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        padding: 0.5rem 0.25rem;
        background: linear-gradient(to left, rgba(248, 249, 250, 0.95), transparent);
        font-size: 1.2rem;
        color: #6c757d;
        pointer-events: none;
        opacity: 0.8;
        z-index: 5;
        height: 100%;
        display: flex;
        align-items: center;
        transition: opacity 0.3s;
    }

    .table-responsive.scroll-hint-hidden::after,
    .table-responsive.scrolled-end::after {
        opacity: 0;
    }

    /* Devices table wrapper specific */
    .devices-table-wrapper {
        box-shadow: inset -15px 0 15px -15px rgba(0,0,0,0.1);
    }

    .devices-table-wrapper::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        padding: 0.5rem 0.25rem;
        background: linear-gradient(to left, rgba(248, 249, 250, 0.95), transparent);
        font-size: 1.2rem;
        color: #6c757d;
        pointer-events: none;
        opacity: 0.8;
        z-index: 5;
        height: 100%;
        display: flex;
        align-items: center;
        transition: opacity 0.3s;
    }

    .devices-table-wrapper.scroll-hint-hidden::after,
    .devices-table-wrapper.scrolled-end::after {
        opacity: 0;
    }
}

/* Mobile-friendly modals */
@media (max-width: 768px) {
    .modal-fullscreen-md-down {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    .modal-fullscreen-md-down .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Better form input focus on mobile */
@media (max-width: 768px) {
    .form-control:focus,
    .form-select:focus {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Sticky header on mobile */
@media (max-width: 768px) {
    .dashboard-header {
        position: sticky;
        top: 0;
        z-index: 1020;
    }

    .nav-tabs {
        position: sticky;
        top: 0;
        z-index: 1010;
    }
}

/* Floating action button style for mobile */
@media (max-width: 768px) {
    .fab-mobile {
        position: fixed;
        bottom: 1rem;
        right: 1rem;
        z-index: 1000;
        border-radius: 50%;
        width: 56px;
        height: 56px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Better spacing for mobile forms */
@media (max-width: 768px) {
    .modal-body .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    .modal-body .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .form-floating > label {
        font-size: 0.85rem;
    }
}

/* Swipe indicators */
@media (max-width: 768px) {
    .swipeable {
        position: relative;
    }

    .swipeable::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 30px;
        background: rgba(13, 110, 253, 0.3);
        border-radius: 3px;
    }
}

/* Compact notification badge on mobile */
@media (max-width: 768px) {
    .notification-dot {
        width: 6px;
        height: 6px;
        top: 2px;
        right: 4px;
    }
}

/* Better letter panel on mobile */
@media (max-width: 768px) {
    #activation-letters .d-flex {
        flex-direction: column;
    }

    #letters-list {
        width: 100% !important;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }

    #letter-content {
        max-height: none;
        padding: 1rem !important;
    }
}

/* Device history timeline mobile optimization */
@media (max-width: 768px) {
    .device-history-timeline {
        padding-left: 15px;
        font-size: 0.85rem;
    }

    .history-event {
        padding-left: 8px;
        padding-bottom: 12px;
    }

    .history-event:before {
        left: -13px;
        width: 10px;
        height: 10px;
    }

    .device-history-timeline .timeline-line {
        left: 6px;
    }
}

/* Reports table mobile layout */
@media (max-width: 768px) {
    #report1-table,
    #report2-table,
    #report3-table,
    #report4-table,
    #superuser-report-table {
        font-size: 0.8rem;
    }

    #superuser-report-table th {
        font-size: 0.7rem;
        padding: 0.3rem 0.2rem;
    }
}

/* Accruals tabs mobile */
@media (max-width: 768px) {
    #accrualsSubTab {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
    }

    #accrualsSubTab .nav-link {
        white-space: nowrap;
    }
}

/* Search suggestions on mobile */
@media (max-width: 768px) {
    #search-suggestions,
    #accruals-search-suggestions,
    .assign-suggestions {
        max-height: 50vh;
        font-size: 0.85rem;
    }

    #search-suggestions .list-group-item,
    #accruals-search-suggestions .list-group-item {
        padding: 0.75rem 0.5rem;
    }
}

/* Chart responsive on mobile */
@media (max-width: 768px) {
    #device-av-chart {
        max-height: 40vh !important;
    }

    .graph-period-start,
    .graph-period-end {
        font-size: 0.85rem;
    }
}

/* Cost input groups mobile */
@media (max-width: 768px) {
    .cost-input-cell .row {
        gap: 0.5rem;
    }

    .cost-input-cell .col-sm-6,
    .cost-input-cell .col-lg-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ================================================== */
/* === LOGIN PAGE MOBILE OPTIMIZATIONS === */
/* ================================================== */

@media (max-width: 576px) {
    .login-page-body {
        padding: 0.5rem;
        min-height: 100vh;
    }

    .login-container {
        max-width: 100%;
        width: 100%;
    }

    .login-card {
        border-radius: 0.5rem;
    }

    .login-card .card-header {
        padding: 0.75rem 1rem !important;
    }

    .login-card .card-header h3 {
        font-size: 1.25rem;
    }

    .login-card .card-body {
        padding: 1.5rem 1rem !important;
    }

    .login-card h4 {
        font-size: 1.1rem;
        margin-bottom: 1.25rem !important;
    }

    .login-card .form-floating {
        margin-bottom: 0.75rem !important;
    }

    .login-card .form-floating > .form-control {
        font-size: 1rem; /* Prevent iOS zoom */
        height: 50px;
        padding: 1rem 0.75rem;
    }

    .login-card .form-floating > label {
        font-size: 0.9rem;
        padding: 1rem 0.75rem;
    }

    .login-card .btn-lg {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        min-height: 50px;
    }

    .login-card .card-footer {
        padding: 0.75rem 1rem !important;
        font-size: 0.85rem;
    }

    .login-card .alert {
        font-size: 0.9rem;
        padding: 0.75rem;
    }

    .login-card a {
        font-size: 0.95rem;
    }
}

@media (max-width: 400px) {
    .login-card .card-header h3 {
        font-size: 1.1rem;
    }

    .login-card h4 {
        font-size: 1rem;
    }

    .login-card .card-body {
        padding: 1rem 0.75rem !important;
    }
}

/* Generate accruals page mobile */
@media (max-width: 576px) {
    .login-page-body .login-card {
        max-width: 100%;
    }

    #accrual-form .form-label {
        font-size: 0.9rem;
    }

    #accrual-form .form-control {
        font-size: 1rem; /* Prevent iOS zoom */
        padding: 0.75rem;
    }

    #accrual-form .btn {
        min-height: 50px;
        font-size: 1rem;
    }
}

/* Inspector GPS modal */
.gps-map-container {
    width: 100%;
    min-height: 320px;
    background-color: #f8f9fa;
}

.gps-search-results {
    max-height: 220px;
    overflow-y: auto;
    margin-top: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.gps-search-results .list-group-item {
    cursor: pointer;
    font-size: 0.95rem;
}

.gps-search-results .list-group-item small {
    color: #6c757d;
}

@media (max-width: 576px) {
    .gps-map-container {
        min-height: 260px;
    }
    .gps-search-results {
        max-height: 180px;
    }
}

/* ================================================== */
/* === SAFE AREA INSETS (iPhone X and newer) === */
/* ================================================== */

@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .dashboard-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .modal-content {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}
body.role-inspector #clients #export-clients-btn,
body.role-inspector #clients #clients-period-controls,
body.role-inspector #clients #clients-period-label,
body.role-inspector #clients #clients-period-display,
body.role-inspector #clients #clients-role-filter-container,
body.role-inspector #clients #manager-type-filters,
body.role-inspector #clients #clients-sort-container {
    display: none !important;
}

/* Make name columns bold for inspector role */
body.role-inspector .data-table tbody td[data-column-id="name"],
body.role-inspector #devices-table tbody td:nth-child(2),
body.role-inspector #codes-table tbody td:first-child,
body.role-inspector #inspector-devices-table tbody td:first-child,
body.role-inspector #inspector-managers-table tbody td:first-child,
body.role-inspector #inspector-gps-table tbody td:first-child {
    font-weight: bold;
}

.call-center-comment-btn {
    cursor: default;
}

.call-center-comment-btn:hover,
.call-center-comment-btn:focus {
    animation: none !important;
    transform: none !important;
}

.clinic-payment-cell {
    font-weight: bold;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clinic-payment-cell:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.clinic-payment-fixed {
    color: #0d6efd;
}

.clinic-payment-percent {
    color: #198754;
}

/* --- Web phone (Call-center → Телефон) --- */
.webcall-pinpad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.webcall-pinpad-btn {
    height: 56px;
    font-size: 1.25rem;
    font-weight: 600;
}

#webcall-number-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    letter-spacing: 0.03em;
}

#webcall-remote-audio {
    width: 100%;
    margin-top: 0.75rem;
}

@media (max-width: 576px) {
    .webcall-pinpad-btn {
        height: 48px;
        font-size: 1.1rem;
    }
}

.phone-call-comment, .editable-comment {
    display: block;
    min-height: 31px;
    padding: 0.25rem 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    cursor: pointer;
    background-color: #f8f9fa;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    white-space: pre-wrap;
    word-break: break-word;
}

.phone-call-comment:hover, .editable-comment:hover {
    border-color: #0d6efd;
    background-color: #fff;
}

.phone-call-comment:focus, .editable-comment:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: 0;
    background-color: #fff;
}

.phone-call-comment.text-muted, .editable-comment.text-muted {
    font-style: italic;
    color: #6c757d !important;
}

.phone-call-comment:empty:before, .editable-comment:empty:before {
    content: "Нажмите, чтобы добавить комментарий";
    color: #adb5bd;
    font-style: italic;
}
