/**
 * Mobile-First Responsive CSS for client.expert
 *
 * This stylesheet implements a mobile-first responsive design approach
 * with breakpoints at: 576px (sm), 768px (md), 992px (lg), 1200px (xl)
 *
 * Minimum supported viewport: 375px
 */

/* ==========================================================================
   CSS Custom Properties (Mobile-First Base Values)
   ========================================================================== */
:root {
    /* Touch target sizes - iOS/Android guidelines recommend 44px minimum */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;

    /* Spacing scale (mobile-first) */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Typography scale (mobile-first) */
    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-base: 1rem;     /* 16px - prevents iOS zoom on focus */
    --font-size-lg: 1.125rem;   /* 18px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.875rem;  /* 30px */

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Z-index scale - Modals must be above all navigation */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-sidebar: 1035;
    /*
     * Below the drawer (1035) and its backdrop (1034), not above them. At 1040 the
     * fixed bottom bar painted over the open menu's backdrop and stayed tappable:
     * elementFromPoint() at the bar's own centre still returned the bar, so a
     * mis-tap on what looked like dimmed background navigated away instead of
     * closing the menu.
     */
    --z-bottom-nav: 1029;
    --z-modal-backdrop: 1050;
    --z-modal: 1055;
    --z-popover: 1060;
    --z-tooltip: 1070;

    /* Bottom navigation height */
    --bottom-nav-height: 64px;
    --bottom-nav-height-with-safe: calc(64px + env(safe-area-inset-bottom, 0px));

    /* Sidebar width */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 0px;
}

/* ==========================================================================
   Base Mobile Styles (No Media Query - Default)
   ========================================================================== */

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Improve text rendering on mobile */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Ensure inputs don't zoom on iOS (16px minimum) */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    font-size: var(--font-size-base) !important;
}

/* ==========================================================================
   Touch-Friendly Elements
   ========================================================================== */

/* Buttons - ensure minimum touch target */
.btn {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    padding: var(--spacing-sm) var(--spacing-md);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Small buttons on mobile should still be tappable */
.btn-sm {
    min-height: 38px;
    padding: var(--spacing-xs) var(--spacing-sm);
}

/* Form controls - touch-friendly */
.form-control,
.form-select {
    min-height: var(--touch-target-min);
    padding: var(--spacing-sm) var(--spacing-md);
    touch-action: manipulation;
}

/* Checkboxes and radio buttons */
.form-check-input {
    width: 22px;
    height: 22px;
    margin-top: 0;
}

.form-check-label {
    padding-left: var(--spacing-xs);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
}

/* Links in lists/tables should have adequate touch targets */
.list-group-item,
.nav-link,
.dropdown-item {
    min-height: var(--touch-target-min);
    padding: var(--spacing-sm) var(--spacing-md);
}

/* Table rows - ensure tappable area */
.table td,
.table th {
    padding: var(--spacing-sm);
    vertical-align: middle;
}

/* ==========================================================================
   Sidebar Mobile Styles
   ========================================================================== */

/* Mobile sidebar - off-canvas by default */
.sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    /* A fixed 280px drawer leaves only a 40px strip to tap-to-dismiss on a 320px
       screen, below the 44px touch minimum. Capping at 85vw keeps the escape
       strip at 48px there and changes nothing on wider phones. */
    width: min(var(--sidebar-width), 85vw);
    height: 100vh;
    height: 100dvh;
    z-index: var(--z-sidebar);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    background: var(--pastel-sidebar-bg, #e8f4f8);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Ensure visibility - sidebar is positioned off-screen, not display:none */
    visibility: visible;
}

.sidebar-wrapper.show {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    z-index: calc(var(--z-sidebar) - 1);
    transition: opacity var(--transition-base), visibility var(--transition-base);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Sidebar toggle button (FAB style) */
.sidebar-toggle {
    position: fixed;
    /* Two spacing units clear of the bottom bar, not one. The 56px FAB and the
       64px bar do not overlap, but 16px between two targets that size is inside
       the same thumb sweep — a mis-tap on the menu button navigated instead. */
    bottom: calc(var(--bottom-nav-height-with-safe) + var(--spacing-lg));
    right: var(--spacing-md);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    z-index: var(--z-fixed);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(125, 169, 233, 0.4);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

/* Sidebar navigation items */
.sidebar .nav-link {
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-xs);
    min-height: var(--touch-target-comfortable);
    display: flex;
    align-items: center;
}

/* ==========================================================================
   Bottom Navigation Bar
   ========================================================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height-with-safe);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-top: 1px solid rgba(125, 169, 233, 0.2);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: var(--spacing-sm);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: var(--z-bottom-nav);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target-comfortable);
    min-height: var(--touch-target-comfortable);
    padding: var(--spacing-xs);
    text-decoration: none;
    color: var(--pastel-dark, #495057);
    transition: color var(--transition-fast), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
    transition: transform var(--transition-fast);
}

.bottom-nav-item span {
    font-size: var(--font-size-xs);
    font-weight: 500;
    white-space: nowrap;
}

.bottom-nav-item.active {
    color: var(--pastel-primary-dark, #7da9e9);
}

.bottom-nav-item.active i {
    transform: scale(1.1);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: linear-gradient(90deg, var(--pastel-primary, #a5d8ff), var(--pastel-info, #b8c0ff));
    border-radius: 0 0 3px 3px;
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

/* Badge on bottom nav items */
.bottom-nav-item .badge {
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(50%);
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    padding: 2px 5px;
    border-radius: 9px;
}

/* ==========================================================================
   Page Header Mobile Styles
   ========================================================================== */

.page-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.page-header h1,
.page-header .h2 {
    font-size: var(--font-size-xl);
    margin-bottom: 0;
}

.page-header .btn-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    width: 100%;
}

.page-header .btn-group {
    flex: 1;
    min-width: fit-content;
}

/* ==========================================================================
   Stat Cards - Mobile-First Compact Design
   ========================================================================== */

.stat-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: var(--spacing-sm);
}

/* Compact stat card for mobile */
.stat-card {
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat-card .card-body {
    padding: 8px 6px !important;
}

.stat-card .stat-value,
.stat-card .card-title,
.stat-card h3,
.stat-card h4,
.stat-card .h3,
.stat-card .h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1.2;
}

.stat-card .stat-label,
.stat-card .card-text,
.stat-card p {
    font-size: 0.7rem;
    opacity: 0.9;
    margin-bottom: 0;
    line-height: 1.2;
}

.stat-card .stat-icon {
    font-size: 1rem;
    margin-bottom: 4px;
    opacity: 0.8;
}

.stat-card .stat-icon i,
.stat-card i.fa-2x {
    font-size: 1rem !important;
}

/* Task stats specific - 6 cards in 3x2 grid on mobile */
.task-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

/* Invoice/Payment stat cards - compact horizontal layout */
.stat-card-horizontal {
    padding: 10px 12px;
}

.stat-card-horizontal .card-body {
    padding: 10px 12px !important;
}

.stat-card-horizontal h3,
.stat-card-horizontal .h3 {
    font-size: 1rem;
    margin-bottom: 0;
}

.stat-card-horizontal h6 {
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.stat-card-horizontal i.fa-2x {
    font-size: 1.25rem !important;
}

/* ==========================================================================
   Filter Bar - Mobile (Modal-based)
   ========================================================================== */

/* Mobile filter trigger button */
.filter-trigger {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-md);
    background: #fff;
    border: 1px solid rgba(125, 169, 233, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    min-height: var(--touch-target-comfortable);
}

.filter-trigger i {
    color: var(--pastel-primary-dark, #7da9e9);
}

.filter-trigger .filter-count {
    margin-left: auto;
    background: var(--pastel-primary, #a5d8ff);
    color: var(--pastel-primary-dark, #7da9e9);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
    font-weight: 600;
}

/* Active filter chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--spacing-xs);
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--pastel-primary, #a5d8ff);
    color: var(--pastel-primary-dark, #7da9e9);
    border-radius: 16px;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    min-height: 32px;
}

.filter-chip .chip-remove {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
    cursor: pointer;
    margin-left: var(--spacing-xs);
}

/* Filter modal on mobile */
.filter-modal .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100%;
}

.filter-modal .modal-content {
    height: 100%;
    border-radius: 0;
    border: none;
}

.filter-modal .modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: var(--spacing-md);
}

.filter-modal .modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
}

.filter-modal .modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: var(--spacing-md);
    gap: var(--spacing-sm);
}

.filter-modal .filter-group {
    margin-bottom: var(--spacing-lg);
}

.filter-modal .filter-group-label {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--pastel-dark, #495057);
}

/* ==========================================================================
   Kanban Board - Mobile (Vertical Stack)
   ========================================================================== */

.kanban-board {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding-bottom: calc(var(--bottom-nav-height-with-safe) + var(--spacing-xl));
}

.kanban-column {
    flex: none;
    width: 100%;
    min-height: auto;
    background: #f8f9fa;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.kanban-column-header {
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.kanban-column-title {
    font-weight: 600;
    margin: 0;
}

.kanban-column-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
}

.kanban-tasks {
    padding: var(--spacing-sm);
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.kanban-task {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    border-left: 4px solid #ced4da;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    touch-action: pan-y;
    min-height: var(--touch-target-comfortable);
}

.kanban-task-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
}

.kanban-task-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-xs);
    color: #6c757d;
}

/* ==========================================================================
   Data Tables - Mobile Responsive
   ========================================================================== */

/* Hide low-priority columns on mobile */
.table-responsive {
    margin: 0 calc(-1 * var(--spacing-md));
    padding: 0 var(--spacing-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* DataTables responsive child rows */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    top: 50%;
    transform: translateY(-50%);
    margin-right: var(--spacing-sm);
}

/* Card-style rows for mobile tables */
.table-mobile-cards tbody tr {
    display: block;
    margin-bottom: var(--spacing-md);
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: var(--spacing-md);
}

.table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
    border: none;
}

.table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6c757d;
}

.table-mobile-cards thead {
    display: none;
}

/* ==========================================================================
   Modal - Z-Index Override (Ensure modals appear above all navigation)
   ========================================================================== */

.modal {
    z-index: var(--z-modal) !important;
}

.modal-backdrop {
    z-index: var(--z-modal-backdrop) !important;
}

/* Shared modal form rows. Some newer modals do not use modal-mobile-first,
   so keep the grid behavior available to every modal form. */
.modal .form-row-2,
.modal .form-row-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.modal .form-row-2 > .form-floating,
.modal .form-row-3 > .form-floating {
    margin-bottom: 0;
}

.modal .optional-section-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    width: 100%;
    min-height: 34px;
    margin: var(--spacing-xs) 0;
    border: 0;
    background: transparent;
    color: var(--pastel-dark, #495057);
    font-size: var(--font-size-sm);
}

.modal .optional-section-toggle:hover,
.modal .optional-section-toggle:focus {
    color: var(--pastel-primary-dark, #7da9e9);
}

.modal .optional-section-toggle i {
    transition: transform var(--transition-fast);
}

.modal .optional-section-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.modal.show:not(.modal-mobile-fullscreen) .modal-content {
    max-height: calc(100dvh - 1rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.show:not(.modal-mobile-fullscreen) .modal-dialog {
    margin: 0.5rem;
    max-height: calc(100dvh - 1rem);
}

.modal.show:not(.modal-mobile-fullscreen) .modal-dialog-centered {
    min-height: calc(100dvh - 1rem);
}

.modal.show:not(.modal-mobile-fullscreen) .modal-content > form {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

.modal.show:not(.modal-mobile-fullscreen) .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.modal.show:not(.modal-mobile-fullscreen) .modal-header,
.modal.show:not(.modal-mobile-fullscreen) .modal-footer {
    flex: 0 0 auto;
}

/* ==========================================================================
   Modal - Mobile Fullscreen
   ========================================================================== */

.modal-mobile-fullscreen .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100%;
}

.modal-mobile-fullscreen .modal-content {
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
}

.modal-mobile-fullscreen .modal-header {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    padding: var(--spacing-md);
}

.modal-mobile-fullscreen .modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-mobile-fullscreen .modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom, 0px));
}

/* ==========================================================================
   Cards - Mobile Responsive
   ========================================================================== */

.card {
    margin-bottom: var(--spacing-md);
}

.card-header {
    padding: var(--spacing-md);
}

.card-body {
    padding: var(--spacing-md);
}

.financial-document.card {
    border: 1px solid rgba(125, 169, 233, 0.2);
    box-shadow: 0 10px 28px rgba(44, 62, 80, 0.08);
}

.financial-document.card:hover,
.financial-document .card:hover {
    transform: none;
}

.financial-document > .card-header {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f0fe 100%) !important;
    border-bottom: 1px solid #d4e3f4 !important;
}

.financial-document > .card-header h4 {
    color: #2c3e50;
    font-weight: 700;
}

.financial-document .card.bg-light {
    background: linear-gradient(135deg, #fafcff 0%, #f0f7ff 100%) !important;
    border: 1px solid #d4e3f4;
}

.financial-document .table {
    border: 1px solid #e1e8f0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.financial-document .table thead,
.financial-document .table thead th {
    background: linear-gradient(135deg, #e8f0fe 0%, #f0f7ff 100%) !important;
    color: #2c3e50;
    border-bottom: 1px solid #d4e3f4;
}

.financial-document .text-primary {
    color: #6b9bd1 !important;
}

/* Dashboard stat cards */
.dashboard-stats .col-md-3 {
    margin-bottom: var(--spacing-sm);
}

/* ==========================================================================
   Login Page - Mobile Optimized
   ========================================================================== */

.login-container {
    padding: var(--spacing-md);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-card {
    margin: 0 auto;
    max-width: 100%;
}

/* Reduce/optimize floating shapes on mobile */
.floating-shapes .shape {
    width: 200px;
    height: 200px;
    filter: blur(60px);
    animation-duration: 6s;
}

.floating-shapes .shape-1,
.floating-shapes .shape-3 {
    display: none;
}

/* ==========================================================================
   Content Area - Account for Bottom Nav
   ========================================================================== */

/* Main content wrapper adjustments */
.content-with-bottom-nav {
    padding: var(--spacing-md);
    /* Extra 80px clears the 56px FAB sidebar-toggle + its ~16px offset + breathing room.
       Desktop media query below resets padding-bottom since the FAB is hidden on desktop. */
    padding-bottom: calc(var(--bottom-nav-height-with-safe) + var(--spacing-xl) + 80px) !important;
}

/* ==========================================================================
   Utility Classes - Mobile
   ========================================================================== */

/* Hide on mobile, show on larger screens */
.hide-mobile {
    display: none !important;
}

/* Show only on mobile */
.show-mobile {
    display: block !important;
}

.show-mobile-flex {
    display: flex !important;
}

.show-mobile-inline {
    display: inline !important;
}

/* Touch-friendly spacing */
.touch-spacing {
    padding: var(--spacing-md);
}

/* Prevent text selection during touch interactions */
.no-select {
    -webkit-user-select: none;
    user-select: none;
}

/* ==========================================================================
   Small Devices (sm) - 576px and up
   ========================================================================== */
@media (min-width: 576px) {
    :root {
        --spacing-md: 20px;
        --spacing-lg: 28px;
    }

    .page-header h1,
    .page-header .h2 {
        font-size: var(--font-size-2xl);
    }

    /* Stat cards - slightly larger on small tablets */
    .stat-cards-grid {
        gap: 8px;
    }

    .stat-card {
        padding: 10px 8px;
    }

    .stat-card .card-body {
        padding: 10px 8px !important;
    }

    .stat-card .stat-value,
    .stat-card .card-title,
    .stat-card h3,
    .stat-card h4,
    .stat-card .h3,
    .stat-card .h4 {
        font-size: 1.25rem;
    }

    .stat-card .stat-label,
    .stat-card .card-text,
    .stat-card p {
        font-size: 0.75rem;
    }

    .stat-card .stat-icon i,
    .stat-card i.fa-2x {
        font-size: 1.25rem !important;
    }

    .task-stats-grid {
        gap: 8px;
    }

    /* Login card max-width */
    .login-card {
        max-width: 400px;
    }
}

/* ==========================================================================
   Medium Devices (md) - 768px and up (Tablets)
   ========================================================================== */
@media (min-width: 768px) {
    :root {
        --spacing-md: 24px;
        --spacing-lg: 32px;
    }

    /* Hide bottom nav on tablets and up */
    .bottom-nav {
        display: none;
    }

    /* Hide mobile-only elements */
    .show-mobile,
    .show-mobile-flex,
    .show-mobile-inline {
        display: none !important;
    }

    /* Show desktop-only elements */
    .hide-mobile {
        display: block !important;
    }

    .hide-mobile-flex {
        display: flex !important;
    }

    /* Main layout row - prevent sidebar/content from wrapping on desktop */
    .container-fluid > .row {
        flex-wrap: nowrap;
    }

    /* Sidebar - visible by default on desktop */
    .sidebar-wrapper {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: var(--sidebar-width, 280px) !important;
        height: 100vh !important;
        max-height: 100vh !important;
        z-index: 100;
        box-shadow: none;
        transform: none !important;
        transition: none !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
    }

    /* Offset content to prevent overlap with fixed sidebar */
    .col.content-with-bottom-nav,
    .col.px-3 {
        margin-left: var(--sidebar-width, 280px);
    }

    /* Constrain sidebar to viewport and let .sidebar-nav scroll internally */
    .sidebar,
    .sidebar-pastel {
        height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden !important;
        display: flex;
        flex-direction: column;
    }

    .sidebar .p-3 {
        padding: clamp(0.5rem, 1.1vh, 0.9rem) !important;
    }

    .sidebar-header {
        padding-bottom: clamp(0.2rem, 0.6vh, 0.45rem);
    }

    .sidebar-header h4 {
        font-size: 1rem;
        margin-bottom: clamp(0.25rem, 0.65vh, 0.5rem) !important;
    }

    .sidebar-header p,
    .sidebar-header .small {
        margin-bottom: clamp(0.2rem, 0.55vh, 0.45rem) !important;
    }

    .sidebar-nav {
        flex: 1 1 auto;
        min-height: 0;
        overflow: visible !important;
        margin-bottom: clamp(0.25rem, 0.75vh, 0.5rem);
        scrollbar-width: none;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar .nav-link {
        min-height: 0;
        padding: clamp(0.32rem, 0.72vh, 0.52rem) 0.65rem;
        margin-bottom: clamp(0.04rem, 0.2vh, 0.12rem);
        line-height: 1.15;
    }

    .sidebar .nav-link i {
        font-size: 0.82rem;
    }

    .sidebar-footer {
        padding-top: clamp(0.25rem, 0.7vh, 0.5rem);
    }

    .sidebar-footer .btn {
        min-height: 2.35rem;
        padding-block: 0.45rem;
    }

    .sidebar-toggle {
        display: none;
    }

    .sidebar-backdrop {
        display: none;
    }

    /* Content area - no bottom nav padding needed */
    .content-with-bottom-nav {
        padding-bottom: var(--spacing-xl);
        /* P1a fix: match sidebar sticky 100vh so background doesn't bleed on short pages */
        min-height: 100vh;
        /* Fill remaining space beside sidebar, allow shrinking for wide content (tables) */
        min-width: 0;
        overflow-x: auto;
    }

    /* Page header - horizontal layout */
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .page-header .btn-toolbar {
        width: auto;
    }

    /* Stat cards - 3 columns on tablets with larger padding */
    .stat-cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .card-body {
        padding: 12px !important;
    }

    .stat-card .stat-value,
    .stat-card .card-title,
    .stat-card h3,
    .stat-card h4,
    .stat-card .h3,
    .stat-card .h4 {
        font-size: 1.5rem;
    }

    .stat-card .stat-label,
    .stat-card .card-text,
    .stat-card p {
        font-size: 0.8rem;
    }

    .stat-card .stat-icon i,
    .stat-card i.fa-2x {
        font-size: 1.5rem !important;
    }

    .task-stats-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 12px;
    }

    /* Horizontal stat cards for invoices - full width on tablet */
    .stat-card-horizontal .card-body {
        padding: 16px !important;
    }

    .stat-card-horizontal h3,
    .stat-card-horizontal .h3 {
        font-size: 1.5rem;
    }

    .stat-card-horizontal h6 {
        font-size: 0.85rem;
    }

    .stat-card-horizontal i.fa-2x {
        font-size: 2rem !important;
    }

    /* Filter bar - inline on tablets */
    .filter-trigger {
        display: none;
    }

    .filter-bar-desktop {
        display: block;
    }

    /* Kanban - horizontal scroll */
    .kanban-board {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: var(--spacing-md);
    }

    .kanban-column {
        flex: 0 0 280px;
        min-height: 400px;
    }

    .kanban-tasks {
        max-height: none;
    }

    /* Modal - centered, not fullscreen */
    .modal-mobile-fullscreen .modal-dialog {
        margin: 1.75rem auto;
        max-width: 500px;
        min-height: auto;
    }

    .modal-mobile-fullscreen .modal-content {
        min-height: auto;
        border-radius: var(--radius-lg);
    }

    .modal .form-row-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .modal .form-row-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Responsive modals - use viewport-relative widths on desktop */
    .modal.show .modal-dialog.modal-lg {
        width: min(calc(100vw - 3rem), 72rem);
        max-width: min(calc(100vw - 3rem), 72rem) !important;
    }
    .modal.show .modal-dialog.modal-xl {
        width: min(calc(100vw - 3rem), 88rem);
        max-width: min(calc(100vw - 3rem), 88rem) !important;
    }
    .modal.show .modal-dialog {
        width: min(calc(100vw - 3rem), 56rem);
        max-width: min(calc(100vw - 3rem), 56rem) !important;
        margin: 1.75rem auto;
    }
    .modal.show:not(.modal-mobile-fullscreen) .modal-dialog {
        margin: 1.75rem auto;
        max-height: calc(100dvh - 3.5rem);
    }
    .modal.show:not(.modal-mobile-fullscreen) .modal-dialog-centered {
        min-height: calc(100dvh - 3.5rem);
    }
    .modal.show .modal-content {
        max-height: calc(100dvh - 3.5rem);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .modal.show .modal-body {
        min-height: 0;
        max-height: calc(100dvh - 11rem);
        overflow-y: auto;
    }
    /* Override modal-mobile-first cap on desktop */
    .modal-mobile-first.modal.show .modal-dialog {
        width: min(calc(100vw - 3rem), 56rem);
        max-width: min(calc(100vw - 3rem), 56rem) !important;
    }
    .modal-mobile-first.modal.show .modal-dialog.modal-lg {
        width: min(calc(100vw - 3rem), 72rem);
        max-width: min(calc(100vw - 3rem), 72rem) !important;
    }
    .modal-mobile-first.modal.show .modal-dialog.modal-xl {
        width: min(calc(100vw - 3rem), 88rem);
        max-width: min(calc(100vw - 3rem), 88rem) !important;
    }

    /* Table responsive - normal on tablets */
    .table-mobile-cards tbody tr {
        display: table-row;
        margin-bottom: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
    }

    .table-mobile-cards tbody td {
        display: table-cell;
        padding: var(--spacing-sm);
        border: inherit;
    }

    .table-mobile-cards tbody td::before {
        content: none;
    }

    .table-mobile-cards thead {
        display: table-header-group;
    }

    /* Login floating shapes */
    .floating-shapes .shape {
        width: 300px;
        height: 300px;
        filter: blur(40px);
    }

    .floating-shapes .shape-1,
    .floating-shapes .shape-3 {
        display: block;
    }
}

/* ==========================================================================
   Large Devices (lg) - 992px and up (Desktops)
   ========================================================================== */
@media (min-width: 992px) {
    :root {
        --font-size-xl: 1.5rem;
        --font-size-2xl: 1.75rem;
        --font-size-3xl: 2.25rem;
    }

    /* Stat cards - 4 columns on desktop */
    .stat-cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--spacing-md);
    }

    /* Task stats - 6 columns on desktop */
    .task-stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    /* Kanban columns slightly wider */
    .kanban-column {
        flex: 0 0 300px;
    }

    /* Login floating shapes full size */
    .floating-shapes .shape {
        filter: blur(40px);
        animation-duration: 3s;
    }

    .floating-shapes .shape-1 { width: 400px; height: 400px; }
    .floating-shapes .shape-2 { width: 350px; height: 350px; }
    .floating-shapes .shape-3 { width: 450px; height: 450px; }
    .floating-shapes .shape-4 { width: 300px; height: 300px; }
}

/* ==========================================================================
   Extra Large Devices (xl) - 1200px and up
   ========================================================================== */
@media (min-width: 1200px) {
    /* Kanban columns wider for more content */
    .kanban-column {
        flex: 0 0 320px;
    }

    /* More generous spacing */
    .card-body {
        padding: var(--spacing-lg);
    }
}

/* ==========================================================================
   Small Mobile Polish (≤ 380px) — P2 fixes
   ========================================================================== */
@media (max-width: 380px) {
    /* Stat card values: shrink further so amounts like ₹218,500 don't wrap */
    .stat-card .stat-value,
    .stat-card .card-title,
    .stat-card h3,
    .stat-card h4,
    .stat-card .h3,
    .stat-card .h4 {
        font-size: 0.95rem;
    }
}

/* ==========================================================================
   iPhone SE / Very Small Screens (≤ 320px)
   ========================================================================== */
@media (max-width: 320px) {
    /* Reduce padding globally */
    .content-wrapper {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Stat cards: single column, compact */
    .stat-card .stat-value,
    .stat-card h3,
    .stat-card h4 {
        font-size: 0.85rem;
    }
    .stat-card .stat-label,
    .stat-card p {
        font-size: 0.65rem;
    }

    /* Tables: smaller text */
    .table {
        font-size: 0.75rem;
    }
    .table th, .table td {
        padding: 4px 6px;
    }

    /* Buttons: smaller */
    .btn-sm {
        padding: 2px 6px;
        font-size: 0.7rem;
    }

    /* Modal: almost full screen */
    .modal-dialog {
        margin: 4px;
        max-width: calc(100% - 8px);
    }

    /* Form inputs: prevent iOS zoom */
    input[type="text"], input[type="email"], input[type="number"],
    input[type="password"], input[type="date"], select, textarea {
        font-size: 16px !important;
    }

    /* Bottom nav: tighter spacing */
    .bottom-nav .nav-link {
        padding: 6px 4px;
        font-size: 0.6rem;
    }
}

/* ==========================================================================
   Mobile Chart + Dense Table Polish (≤ 480px) — P2 fixes
   ========================================================================== */
@media (max-width: 480px) {
    /* Reports charts: reduce fixed desktop height so they take less screen real estate */
    .chart-container {
        height: 200px;
    }

}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .bottom-nav,
    .sidebar-wrapper,
    .sidebar-toggle,
    .sidebar-backdrop,
    .filter-trigger,
    .btn-toolbar {
        display: none !important;
    }

    .content-with-bottom-nav {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
}

/* ==========================================================================
   Accessibility - Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .floating-shapes .shape {
        animation: none;
    }
}

/* ==========================================================================
   Dark Mode Support (if system prefers)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    /* ==========================================================================
       Dark Mode — Pastel Theme
       Inverts surfaces & text while keeping accent hues recognisable.
       ========================================================================== */

    :root {
        /* Core surfaces */
        --pastel-light: #1a1d21;
        --pastel-dark: #e2e8f0;
        color-scheme: dark;
    }

    /* Body & global */
    body {
        background-color: #111318 !important;
        color: #d1d5db !important;
    }

    /* Cards */
    .card, .card-pastel, .card-pastel-light {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.08) !important;
        color: #d1d5db !important;
    }
    .card:hover {
        box-shadow: 0 6px 20px rgba(0,0,0,.35) !important;
    }

    /* Card headers */
    .card-header,
    .bg-pastel-primary,
    .bg-pastel-info,
    .bg-pastel-success,
    .bg-pastel-warning,
    .bg-pastel-danger,
    .bg-pastel-secondary,
    .bg-pastel-purple,
    .bg-pastel-orange {
        background-color: #252830 !important;
        border-color: rgba(255,255,255,.06) !important;
        color: #d1d5db !important;
    }
    .bg-pastel-light {
        background-color: rgba(30,33,40,.7) !important;
        border-color: rgba(255,255,255,.06) !important;
    }
    .bg-gradient-pastel {
        background: linear-gradient(135deg, #252830, #2a2d36) !important;
    }

    /* Text overrides */
    .text-muted { color: #8b95a5 !important; }
    .text-dark, h1, h2, h3, h4, h5, h6 { color: #e2e8f0 !important; }
    .card-title, .card-text { color: #d1d5db !important; }
    a { color: #93c5fd; }
    a:hover { color: #bfdbfe; }

    /* Tables */
    .table, .table-pastel, .dash-table {
        color: #d1d5db !important;
        --bs-table-bg: transparent;
        --bs-table-color: #d1d5db;
        --bs-table-border-color: rgba(255,255,255,.08);
    }
    .table thead th, .dash-table thead th {
        background-color: #252830 !important;
        color: #8b95a5 !important;
        border-color: rgba(255,255,255,.08) !important;
    }
    .table tbody tr, .dash-table tbody tr {
        border-color: rgba(255,255,255,.06) !important;
    }
    .table-hover tbody tr:hover, .table-pastel tbody tr:hover {
        background-color: rgba(255,255,255,.04) !important;
    }

    /* Forms */
    .form-control, .form-select, input, textarea, select {
        background-color: #252830 !important;
        border-color: rgba(255,255,255,.12) !important;
        color: #d1d5db !important;
    }
    .form-control:focus, .form-select:focus {
        background-color: #2a2d36 !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59,130,246,.2) !important;
        color: #e2e8f0 !important;
    }
    .form-control::placeholder { color: #6b7280 !important; }
    .form-label { color: #9ca3af !important; }
    .form-text { color: #6b7280 !important; }
    .form-check-input {
        background-color: #374151 !important;
        border-color: #4b5563 !important;
    }
    .form-check-input:checked {
        background-color: #3b82f6 !important;
        border-color: #3b82f6 !important;
    }

    /* Modals */
    .modal-content {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.08) !important;
        color: #d1d5db !important;
    }
    .modal-header, .modal-footer {
        border-color: rgba(255,255,255,.08) !important;
    }
    .modal-backdrop { background-color: rgba(0,0,0,.7) !important; }

    /* Sidebar */
    .sidebar-wrapper, .sidebar-nav, .sidebar {
        background-color: #161921 !important;
        border-color: rgba(255,255,255,.06) !important;
    }
    .sidebar-wrapper .nav-link {
        color: #9ca3af !important;
    }
    .sidebar-wrapper .nav-link:hover,
    .sidebar-wrapper .nav-link.active {
        color: #e2e8f0 !important;
        background-color: rgba(255,255,255,.06) !important;
    }

    /* Bottom nav (mobile) */
    .bottom-nav {
        background-color: #161921 !important;
        border-color: rgba(255,255,255,.08) !important;
    }
    .bottom-nav-item { color: #6b7280 !important; }
    .bottom-nav-item.active { color: #93c5fd !important; }

    /* Buttons — keep accent colors but darken surface buttons */
    .btn-pastel-secondary {
        background-color: #374151 !important;
        border-color: #4b5563 !important;
        color: #d1d5db !important;
    }
    .btn-pastel-secondary:hover {
        background-color: #4b5563 !important;
    }

    /* Badges */
    .badge-pastel-primary { background-color: rgba(59,130,246,.2) !important; color: #93c5fd !important; }
    .badge-pastel-success { background-color: rgba(16,185,129,.2) !important; color: #6ee7b7 !important; }
    .badge-pastel-warning { background-color: rgba(245,158,11,.2) !important; color: #fcd34d !important; }
    .badge-pastel-danger  { background-color: rgba(244,63,94,.2) !important;  color: #fca5a5 !important; }
    .badge-pastel-info    { background-color: rgba(139,92,246,.2) !important; color: #c4b5fd !important; }

    /* Alerts */
    .alert-pastel-success { background-color: rgba(16,185,129,.15) !important; color: #6ee7b7 !important; border-color: rgba(16,185,129,.2) !important; }
    .alert-pastel-danger  { background-color: rgba(244,63,94,.15) !important;  color: #fca5a5 !important; border-color: rgba(244,63,94,.2) !important; }

    /* Dashboard redesign tokens */
    .dashboard-redesign {
        --dash-bg: #111318;
        --dash-surface: #1e2128;
        --dash-surface-elevated: #252830;
        --dash-border: rgba(255,255,255,.06);
        --dash-border-strong: rgba(255,255,255,.12);
        --dash-text-primary: #e2e8f0;
        --dash-text-secondary: #8b95a5;
        --dash-text-tertiary: #6b7280;
        --shadow-xs: 0 1px 2px rgba(0,0,0,.2);
        --shadow-sm: 0 2px 4px rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.15);
        --shadow-md: 0 4px 12px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.15);
        --shadow-lg: 0 8px 24px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.2);
    }
    .dash-section {
        background-color: var(--dash-surface) !important;
        border-color: var(--dash-border) !important;
    }
    .dash-section__header {
        border-color: var(--dash-border) !important;
    }
    .dash-metric {
        background-color: var(--dash-surface) !important;
    }

    /* Login page */
    .glass-card {
        background: rgba(30,33,40,.85) !important;
        border-color: rgba(255,255,255,.08) !important;
    }

    /* Scrollbar */
    ::-webkit-scrollbar-track { background: #1a1d21; }
    ::-webkit-scrollbar-thumb { background: #374151; }
    ::-webkit-scrollbar-thumb:hover { background: #4b5563; }

    /* Dropdown */
    .dropdown-menu {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.1) !important;
    }
    .dropdown-item { color: #d1d5db !important; }
    .dropdown-item:hover { background-color: rgba(255,255,255,.06) !important; }
    .dropdown-divider { border-color: rgba(255,255,255,.08) !important; }

    /* List group */
    .list-group-item {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.06) !important;
        color: #d1d5db !important;
    }

    /* Mobile cards */
    .mobile-card {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.06) !important;
    }
    .mobile-filter-drawer {
        background-color: #1e2128 !important;
    }

    /* Notification bell dropdown */
    .notification-dropdown {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.1) !important;
    }

    /* DataTables pagination */
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        color: #9ca3af !important;
    }
    .dataTables_wrapper .dataTables_paginate .paginate_button.current {
        background: #3b82f6 !important;
        color: #fff !important;
        border-color: #3b82f6 !important;
    }
    .dataTables_wrapper .dataTables_info { color: #6b7280 !important; }

    /* Stat cards — explicit dark treatment */
    .stat-card {
        background-color: #1e2128 !important;
        color: #d1d5db !important;
    }
    .stat-card .stat-value,
    .stat-card .card-title,
    .stat-card h3, .stat-card h4,
    .stat-card .h3, .stat-card .h4 {
        color: #e2e8f0 !important;
    }
    .stat-card .stat-label,
    .stat-card .card-text,
    .stat-card p {
        color: #8b95a5 !important;
    }

    /* Sidebar pastel variant */
    .sidebar-pastel {
        background-color: #161921 !important;
    }
    .sidebar-pastel .nav-link {
        color: #9ca3af !important;
    }
    .sidebar-pastel .nav-link:hover,
    .sidebar-pastel .nav-link.active {
        color: #e2e8f0 !important;
        background-color: rgba(255,255,255,.06) !important;
    }

    /* Form floating labels */
    .form-floating label {
        color: #6b7280 !important;
    }
    .form-floating > .form-control:focus ~ label,
    .form-floating > .form-control:not(:placeholder-shown) ~ label,
    .form-floating > .form-select ~ label {
        color: #93c5fd !important;
    }

    /* Invoice / receipt views */
    .invoice-page, .receipt-page {
        background-color: #1e2128 !important;
        color: #d1d5db !important;
    }

    /* Navbar / top bar */
    .navbar, .top-bar, .topbar {
        background-color: #161921 !important;
        border-color: rgba(255,255,255,.06) !important;
    }
    .navbar .nav-link, .top-bar .nav-link {
        color: #9ca3af !important;
    }
    .navbar .nav-link:hover, .top-bar .nav-link:hover {
        color: #e2e8f0 !important;
    }

    /* Additional pastel button variants */
    .btn-pastel-primary {
        background: linear-gradient(to right, #2a4a6b, #3a5a7b) !important;
        border-color: #3a5a7b !important;
        color: #93c5fd !important;
    }
    .btn-pastel-primary:hover {
        background: linear-gradient(to right, #3a5a7b, #4a6a8b) !important;
        color: #bfdbfe !important;
    }
    .btn-pastel-success {
        background-color: rgba(16,185,129,.2) !important;
        border-color: rgba(16,185,129,.3) !important;
        color: #6ee7b7 !important;
    }
    .btn-pastel-success:hover {
        background-color: rgba(16,185,129,.3) !important;
        color: #a7f3d0 !important;
    }
    .btn-pastel-danger {
        background-color: rgba(244,63,94,.2) !important;
        border-color: rgba(244,63,94,.3) !important;
        color: #fca5a5 !important;
    }
    .btn-pastel-danger:hover {
        background-color: rgba(244,63,94,.3) !important;
        color: #fecdd3 !important;
    }
    .btn-pastel-warning {
        background-color: rgba(245,158,11,.2) !important;
        border-color: rgba(245,158,11,.3) !important;
        color: #fcd34d !important;
    }
    .btn-pastel-warning:hover {
        background-color: rgba(245,158,11,.3) !important;
        color: #fde68a !important;
    }
    .btn-pastel-info {
        background-color: rgba(139,92,246,.2) !important;
        border-color: rgba(139,92,246,.3) !important;
        color: #c4b5fd !important;
    }
    .btn-pastel-info:hover {
        background-color: rgba(139,92,246,.3) !important;
        color: #ddd6fe !important;
    }

    /* Charts — dark grid & labels */
    .chart-container canvas {
        filter: brightness(0.9);
    }

    /* Filter trigger button */
    .filter-trigger {
        background-color: #1e2128 !important;
        border-color: rgba(255,255,255,.12) !important;
        color: #d1d5db !important;
    }

    /* Kanban columns */
    .kanban-column {
        background-color: #1a1d21 !important;
    }
    .kanban-task {
        background-color: #252830 !important;
        border-left-color: #4b5563 !important;
        color: #d1d5db !important;
    }

    /* Toast / flash messages */
    .toast, .flash-message {
        background-color: #252830 !important;
        color: #d1d5db !important;
        border-color: rgba(255,255,255,.08) !important;
    }

    /* Print — always light */
    @media print {
        body { background: #fff !important; color: #000 !important; }
        .card, .modal-content { background: #fff !important; color: #000 !important; }
    }
}

/* ==========================================================================
   Touch ergonomics — added after the v0.1.0 mobile audit.

   Three measured defects, all invisible in a screenshot and all reproducible
   with getComputedStyle rather than by eye.
   ========================================================================== */

@media (max-width: 767.98px) {
    /*
     * S3 — iOS Safari zooms the page when a field smaller than 16px takes focus,
     * and does not zoom back: the user works magnified from that field onward.
     * Every other field on the site already measures 16px; these two Bootstrap
     * "-sm" variants compute 14px, on the Add Task file input and on the filter
     * selects for attendance, assessees and documents.
     */
    .form-control-sm,
    .form-select-sm {
        font-size: 16px;
    }

    /*
     * S2 — row action buttons measured 30x38px and card actions 24x24px, against
     * a 44px touch minimum, stacked two or three deep in the same cell. At 68% of
     * the minimum and adjacent to each other, a mis-tap edits or deletes the
     * neighbouring row. Padding rather than sizing, so the icons stay put.
     */
    .dash-table td .btn-sm,
    .dash-table td .btn,
    table.table td .btn-sm,
    table.table td .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .tb-card__action,
    .mobile-card__action {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /*
     * The notification counter measured 9.6px — the only thing on screen telling
     * a user something needs attention, below the 11px floor for legible text.
     */
    .notification-badge {
        font-size: 11px;
        line-height: 1;
    }
}
