/* ============================================================
   EEVAA CRM — MOBILE RESPONSIVENESS SUPPLEMENT
   mobile.css — täiendab style.css mobiili parandusi
   Loodud: 2026-02-18
   Breakpoint standard: max-width: 768px (standardised 2026-03-01,
   all former 767px values have been updated to 768px for consistency)
   ============================================================
   NB: style.css sisaldab juba:
   - Sidebar overlay + open/close (@1024px)
   - Mobile menu btn
   - Full-screen modals (@768px)
   - Sticky modal footer
   - Bottom nav + FAB
   - Calendar year grid responsive
   - Stats grid 1fr @768px
   - Form rows single column @768px
   - Top bar compact, hide search
   - Quote items table → card layout
   ============================================================
   See fail lisab PUUDUVA:
   - Touch targets 44px
   - iOS zoom prevention (font-size 16px)
   - Calendar header mobile layout
   - Reports layout 1-col mobile
   - Revenue chart scrollable
   - Gantt scroll hint
   - Font size minimums
   - Form inputs 48px height
   - Clients table card layout
   - Z-index corrections
   - Safe area (iPhone X+)
   - Inventory table mobile
   ============================================================ */

/* ============================================================
   0. GLOBAL OVERFLOW CONTAINMENT
   Prevents horizontal scroll on narrow viewports.
   ============================================================ */
@media (max-width: 768px) {
    #page-content {
        overflow-x: clip !important;
        max-width: 100vw !important;
    }
}

/* ============================================================
   0a. TOUCH DEVICE TARGETS — kõikidele puutetundlikele seadmetele
   sõltumata viewport laiusest. Eraldi reegel laiusepõhisest
   @media (max-width: 768px), et catch'iks ka:
   - iPhone landscape (844x390 — laiem kui 768)
   - iPad portrait (820x1180 — laiem kui 768)
   - Android tablet landscape
   - Surface Pro / 2-in-1 touch režiimis
   Lisatud 2026-05-04 mobiili-auditi käigus.
   ============================================================ */
@media (pointer: coarse), (max-width: 1024px) {
    .btn,
    button:not(.calendar-day-btn):not(.fc-button),
    .nav-item,
    select,
    [role="button"]:not(.calendar-day-btn) {
        min-height: 44px;
    }
    .btn-icon,
    .action-btn {
        min-width: 44px;
        min-height: 44px;
    }
    /* Top-bar nupud (☰ menu, 🌙 dark mode, 🔔 notifications) — eraldi
       sest neil on spetsiifilised CSS reeglid mis ülerda min-height. */
    .mobile-menu-btn,
    .dark-mode-toggle,
    .notification-bell,
    [data-action="toggleNotificationsPanel"] {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ============================================================
   0b. iOS ZOOM PREVENTION — font-size 16px up to 1024px
   Prevents iOS Safari from zooming on input focus for tablets too.
   ============================================================ */
@media (max-width: 1024px) {
    input, select, textarea, .form-control, .eevaa-form-input, .eevaa-form-select, .eevaa-form-textarea {
        font-size: 16px !important;
    }
}

/* ============================================================
   1. TOUCH TARGETS & FONT SIZES — <768px
   ============================================================ */
@media (max-width: 768px) {
    /* Min touch target kõikidele interaktiivsetele */
    .btn,
    button:not(.calendar-day-btn),
    .nav-item,
    select {
        min-height: 44px;
    }

    /* Ikoon-nupud */
    .btn-icon,
    .action-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile typography override */
    :root {
        --text-page-title: 1.25rem; /* 20px on mobile */
    }

    /* Body font min 14px */
    body {
        font-size: 14px;
    }

    /* Secondary text ei lähe alla 12px */
    small,
    .text-sm,
    .text-xs {
        font-size: max(12px, 0.75rem);
    }

    /* Form inputs min height + iOS zoom prevention */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="password"],
    textarea,
    select {
        min-height: 48px;
        font-size: 16px !important; /* Hoiab ära iOS zoom */
    }

    textarea {
        min-height: 80px;
    }

    /* Table action buttons */
    table .btn-icon,
    table button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ============================================================
   2. CALENDAR HEADER — Mobile layout
   ============================================================ */
@media (max-width: 768px) {
    /* Calendar header must not exceed viewport */
    .calendar-container .calendar-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: stretch !important;
        max-width: 100vw !important;
        width: calc(100vw - 2rem) !important;
        position: sticky !important;
        left: 0 !important;
        z-index: 10;
    }

    /* Nav rida — täna + prev/next */
    .calendar-nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        max-width: 100%;
    }

    /* Vaate nupud — horisontaalselt keritav */
    .calendar-views {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 0.25rem !important;
        margin: 0 !important;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
    }

    .calendar-views::-webkit-scrollbar {
        display: none;
    }

    .calendar-views .btn {
        white-space: nowrap;
        flex-shrink: 0;
        /* min-height eemaldatud 2026-05-04 mobiili-auditist —
           lubame global @media (max-width: 768px) .btn { min-height: 44px }
           rakendumast (Apple HIG touch target soovitus). */
        font-size: var(--text-secondary);
        padding: 0.25rem 0.625rem;
    }

    /* Eraldajoon vaate nuppude sees — peida */
    .calendar-views span[style*="border-left"] {
        display: none !important;
    }

    /* "Lisa üritus" nupp — täislaiusega */
    .calendar-header > .btn-primary {
        width: 100%;
        justify-content: center;
    }

    /* Kuuvaate päevade lahtrid — väiksem */
    .calendar-month-grid > div,
    .calendar-day-cell {
        min-height: 60px;
    }

    /* Ürituse nupud kalendris */
    .calendar-event,
    [onclick*="openEvent"],
    [onclick*="viewEvent"],
    [onclick*="jumpToMonth"] {
        min-height: 28px;
        cursor: pointer;
    }

    /* Päeva lahtrid aasta vaates */
    .calendar-year-grid [onclick*="jumpToMonthDay"] {
        min-width: 28px;
        min-height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius);
    }

    /* Kuu päise klikitav ala */
    .calendar-year-grid [onclick*="jumpToMonth"] {
        min-height: 44px;
        cursor: pointer;
    }
}

/* ============================================================
   3. CLIENTS — Complete mobile redesign
   ============================================================ */
@media (max-width: 768px) {

    /* === Toolbar: column layout === */
    .client-filter-bar {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
        align-items: stretch !important;
    }

    /* Search wrapper: full width */
    .client-filter-bar > div:first-child {
        width: 100% !important;
    }

    /* Search input: full width */
    #client-search {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* Status filter: full width */
    #client-status-filter {
        width: 100% !important;
        box-sizing: border-box !important;
        flex: none !important;
    }

    /* Secondary controls stay available behind a named disclosure. */
    .client-filter-bar:not(.filters-open) #client-tag-filter,
    .client-filter-bar:not(.filters-open) #client-sort,
    .client-filter-bar:not(.filters-open) .client-filter-icons,
    .client-filter-bar:not(.filters-open) > .dropdown {
        display: none !important;
    }

    .client-filter-bar .client-filter-toggle { display: flex; justify-content: center; min-height: 44px; }
    .client-filter-bar select { width: 100%; min-height: 44px; font-size: 16px !important; }
    .client-filter-icons { flex-wrap: wrap; }
    .client-filter-icons .btn, #client-columns > .btn { min-width: 44px; min-height: 44px; }
    #client-columns #columns-dropdown { position: static !important; margin-top: 0.5rem; }
    #client-columns label { min-height: 44px; }

    /* + Lisa button: full width */
    .client-filter-bar > .btn-sm.btn-primary,
    .client-filter-bar > button.btn-primary {
        width: 100%;
        justify-content: center;
        text-align: center;
        min-height: 44px;
    }

    /* Card header: stack title + toolbar vertically */
    .card-header[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.625rem !important;
    }

    /* === Table header: hidden === */
    #clients-table thead {
        display: none;
    }

    /* Table container: no horizontal scroll */
    .table-container {
        overflow-x: visible !important;
    }

    /* === Rows as clean tappable cards === */
    #clients-table tbody tr {
        display: block !important;
        border: 1px solid var(--gray-200) !important;
        border-radius: 10px !important;
        margin: 0 0 0.5rem 0 !important;
        padding: 0.75rem 0.875rem !important;
        background: var(--bg-surface) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
        position: relative !important;
        overflow: hidden !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(255, 86, 0, 0.06);
        transition: background 0.1s;
    }

    #clients-table tbody tr:active {
        background: var(--gray-50);
    }

    /* Show only the name cell */
    #clients-table tbody td:first-child {
        display: block !important;
        padding: 0 !important;
        border: none !important;
    }

    /* Company name: bolder + slightly larger */
    #clients-table tbody td:first-child strong {
        font-size: 0.9375rem !important;
        font-weight: 600 !important;
        color: var(--gray-900) !important;
        line-height: 1.3 !important;
    }

    /* Contact name / secondary line */
    #clients-table tbody td:first-child > div > div:not(:first-child) {
        margin-top: 0.125rem !important;
        font-size: var(--text-micro) !important;
        color: var(--gray-500) !important;
    }

    /* Contact links stay visible in the compact table view. */
    #clients-table tbody td:not(:first-child):not(.client-contact-cell) {
        display: none !important;
    }

    #clients-table tbody .client-contact-cell {
        display: block !important;
        padding: 0.25rem 0 0 !important;
        border: none !important;
    }
    #clients-table .client-contact-link, .client-card-link {
        display: flex;
        align-items: center;
        min-height: 44px;
        overflow-wrap: anywhere;
    }

    /* Quotes/invoices tabel — kompaktsem */
    #quotes-table td,
    #invoices-table td {
        padding: 0.5rem;
        font-size: var(--text-data);
    }

    /* Peida vähem olulised veerud quotes/invoices */
    #quotes-table th:nth-child(4),
    #quotes-table td:nth-child(4),
    #invoices-table th:nth-child(4),
    #invoices-table td:nth-child(4) {
        display: none;
    }
}

/* Tablet: peida kõige vähem olulised kliendi veerud */
@media (min-width: 768px) and (max-width: 1023px) {
    #clients-table th:nth-child(5),
    #clients-table td:nth-child(5),
    #clients-table th:nth-child(7),
    #clients-table td:nth-child(7) {
        display: none !important;
    }
}

/* ============================================================
   4. MODALS — Täiendavad mobile fixes (lisaks style.css-ile)
   ============================================================ */
@media (max-width: 768px) {
    /* Modal close nupp — 44x44px touch target */
    .modal-close {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        border-radius: 50% !important;
    }

    .modal-close svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Modal body iOS smooth scroll */
    .modal-body {
        -webkit-overflow-scrolling: touch;
        min-height: 0 !important;
    }

    /* Modali inputs — iOS zoom prevention */
    .modal input[type="text"],
    .modal input[type="email"],
    .modal input[type="number"],
    .modal input[type="tel"],
    .modal input[type="date"],
    .modal input[type="datetime-local"],
    .modal input[type="password"],
    .modal select,
    .modal textarea {
        min-height: 48px;
        font-size: 16px;
    }

    /* Modal footer nupud — flex */
    .modal-footer .btn,
    .eevaa-modal-footer .btn {
        flex: 1;
        min-height: 48px;
    }

    /* Modal input focus scroll margin */
    .modal input:focus,
    .modal select:focus,
    .modal textarea:focus {
        scroll-margin-top: 80px;
    }

    /* Modal tables — horisontaalne kerimine */
    .modal table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Modal forms — single column */
    .modal .form-row,
    .modal .form-row-2,
    .modal .form-row-3,
    .modal .eevaa-form-grid.cols-2 {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   5. TEAM GANTT — Mobile scroll + affordance
   ============================================================ */
@media (max-width: 768px) {
    /* Gantt toolbar — stack */
    .planning-toolbar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .planning-toolbar > div {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .planning-toolbar .btn {
        flex: 1;
        min-height: 44px;
        font-size: var(--text-data);
    }

    /* Gantt konteiner — scroll hint */
    .gantt-container {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Scroll hint gradient paremal */
    .gantt-container::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to right, transparent, rgba(0,0,0,0.4));
        pointer-events: none;
        border-radius: 0 8px 8px 0;
    }

    /* Gantt grid min-width */
    .gantt-grid {
        min-width: 700px;
    }

    /* Tiimiliikme nimi — sticky */
    .gantt-user {
        position: sticky;
        left: 0;
        z-index: 5;
        background: var(--bg-surface);
        min-width: 120px;
        max-width: 120px;
        font-size: var(--text-secondary);
    }

    .gantt-header:first-child {
        position: sticky;
        left: 0;
        z-index: 6;
        background: var(--bg-surface);
        min-width: 120px;
        max-width: 120px;
    }

    /* Legend — wrap */
    .planning-legend {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        font-size: var(--text-secondary);
    }
}

/* ============================================================
   6. REPORTS — Mobile layout fixes
   ============================================================ */
@media (max-width: 768px) {
    .report-month-table { min-width: 280px; }
    .report-month-table th, .report-month-table td { padding: 0.5rem 0.25rem; }

    /* Reports 2-column grid → 1 column */
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Stats row (reports) — 2 cols mobile */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   7. FORMS — General mobile (väljaspool modaalid)
   ============================================================ */
@media (max-width: 768px) {
    /* Kõik grid-formid → single column */
    .eevaa-form-grid {
        grid-template-columns: 1fr;
    }

    /* Labels ülemine asend */
    .form-group label,
    .eevaa-form-group label {
        display: block !important;
        margin-bottom: 0.25rem !important;
    }

    /* Inline forms — stack */
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    /* Card body padding */
    .card-body {
        padding: 0.875rem !important;
    }
}

/* ============================================================
   8. INVENTORY TABLE — Mobile
   ============================================================ */
@media (max-width: 768px) {
    #inventory-table th:nth-child(n+4):nth-child(-n+6),
    #inventory-table td:nth-child(n+4):nth-child(-n+6) {
        display: none;
    }

    #inventory-table {
        font-size: var(--text-data);
    }
}

/* ============================================================
   9. Z-INDEX CORRECTIONS — Mobile only (use design tokens)
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        z-index: var(--z-sidebar, 300);
    }

    .sidebar-overlay {
        z-index: calc(var(--z-sidebar, 300) - 1);
    }

    .modal-overlay {
        z-index: var(--z-modal-backdrop, 1000);
    }

    .notifications-panel {
        z-index: calc(var(--z-sidebar, 300) + 50);
    }
}

/* ============================================================
   10. SAFE AREA — iPhone X+ notch
   ============================================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .modal-footer,
        .eevaa-modal-footer {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
        }

        .content-area {
            padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
        }

        .bottom-nav {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ============================================================
   11. NAV ITEMS — Sidebar close on click (visual feedback)
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar .nav-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ============================================================
   12. CALENDAR MOBILE — Full responsive fix
   ============================================================ */
@media (max-width: 768px) {
    .calendar-month-wrapper {
        scroll-snap-type: x mandatory;
    }

    .calendar-month-wrapper > * {
        scroll-snap-align: start;
    }

    /* Kalender: kuu ja nädala grid peab olema horisontaalselt keritav */
    #page-content > div > div[style*="grid-template-columns: repeat(7"] {
        min-width: 600px;
    }

    /* Wrapper mis lubab keri */
    #page-content > div {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Aasta vaade: 2 kuud reas, mitte 4 */
    #page-content > div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* Aasta vaate kuu ruudud — kompaktsemad */
    #page-content [style*="grid-template-columns: repeat(7, 1fr); gap: 2px"] {
        font-size: var(--text-micro);
    }

    /* Calendar navigation — always visible */
    #page-content .calendar-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--white);
        padding-bottom: 0.5rem;
    }

    /* Navigation arrows ja title rida */
    #page-content .calendar-header .calendar-nav {
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: nowrap;
        min-width: 0;
    }

    /* Täna-nupp alati nähtav */
    #page-content .calendar-header [data-action="goToToday"] {
        flex-shrink: 0;
    }

    /* Calendar view buttons — scroll horisontaalselt */
    #page-content .calendar-header .calendar-views {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        display: flex;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }

    #page-content .calendar-header .calendar-views::-webkit-scrollbar {
        display: none;
    }

    /* Sündmuse nimed kalendris — lühemad */
    [onclick*="viewEvent"] > div,
    [onclick*="openEvent"] > div {
        font-size: var(--text-micro);
        line-height: 1.2;
    }
}

/* Tablet: 3 kuud reas aasta vaates */
@media (min-width: 768px) and (max-width: 1023px) {
    #page-content > div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================
   13. FAB — ei tohi katta sisu
   ============================================================ */
@media (max-width: 768px) {
    /* Lisa padding alla et FAB ei kata sisu */
    #page-content {
        padding-bottom: 80px !important;
    }

    /* FAB z-index kõrgem kui sisu */
    .fab-container {
        z-index: 50;
    }
}

/* ============================================================
   14. DASHBOARD STAT CARDS — Mobile wrap
   ============================================================ */
@media (max-width: 768px) {
    /* Stat card grid — 2 veergu mobiilil */
    #page-content > div[style*="display: flex"][style*="gap"] {
        flex-wrap: wrap !important;
    }

    #page-content > div[style*="display: flex"][style*="gap"] > div[style*="min-width: 150px"] {
        min-width: calc(50% - 0.5rem);
        flex: 1 1 calc(50% - 0.5rem);
    }

    /* Top summary cards (Kinnitatud, Ootel, Potentsiaalne) — stack */
    #page-content > div[style*="display: grid"][style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr;
    }

    /* Event filter buttons rida — wrap */
    #page-content .calendar-views {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
    }

    #page-content div[style*="display: flex"][style*="flex-wrap: wrap"]::-webkit-scrollbar {
        display: none;
    }

    /* Pakkumised/Arved toolbar: opt out of the scroll-nowrap rule above — it also
       matched this container's inline flex-wrap:wrap and squeezed the search input
       and status select onto one line instead of letting them wrap. */
    #page-content div[style*="display: flex"][style*="flex-wrap: wrap"]:has(> #quote-search),
    #page-content div[style*="display: flex"][style*="flex-wrap: wrap"]:has(> #invoice-search) {
        flex-wrap: wrap !important;
        overflow-x: visible !important;
    }
}

/* Clients table mobile — hide extra columns, keep name + status */
@media (max-width: 768px) {
    .col-mobile-hide {
        display: none;
    }

    /* Client toolbar: wrap filters */
    #client-search {
        width: 100% !important;
        min-width: 0 !important;
    }

    .client-toolbar-filters {
        flex-wrap: wrap;
    }
}

/* Mobile search overlay */
.mobile-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
    align-items: flex-start;
    padding-top: 1rem;
}
.mobile-search-overlay.open {
    display: flex;
}
.mobile-search-box {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin: 0 1rem;
    width: calc(100% - 2rem);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.mobile-search-input {
    width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 16px; /* prevent iOS zoom */
    outline: none;
    box-sizing: border-box;
}
.mobile-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 86, 0, 0.25); /* matches --shadow-focus opacity */
}

/* Client header toolbar: full width on mobile */
@media (max-width: 768px) {
    .card-header[style*="justify-content: space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .card-header[style*="justify-content: space-between"] > div:last-child {
        width: 100%;
    }

    .card-header[style*="justify-content: space-between"] select,
    .card-header[style*="justify-content: space-between"] input[type="text"] {
        flex: 1;
        min-width: 0;
    }
}

/* === TIME TRACKING PAGE (mobile) === */
@media (max-width: 768px) {
    /* Hide all columns except date, description, hours and actions */
    #time-entries-body tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.125rem 0.5rem;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--gray-100);
    }
    #time-entries-body td {
        display: block;
        border: none;
        padding: 0.125rem 0;
        font-size: 0.8125rem;
    }
    /* Hide category and amount columns on mobile */
    #time-entries-body td:nth-child(4),
    #time-entries-body td:nth-child(6) {
        display: none;
    }
    /* Actions column: span full width */
    #time-entries-body td:last-child {
        grid-column: 1 / -1;
        display: flex;
        gap: 0.5rem;
    }
    /* Hours column: highlight */
    #time-entries-body td:nth-child(5) {
        font-weight: 600;
        color: var(--primary);
    }
    /* Table header: hide on mobile */
    .data-table thead {
        display: none;
    }
}

/* === SUBCONTRACTOR PAGE (mobile) === */
@media (max-width: 768px) {
    .table-responsive .data-table thead {
        display: none;
    }
    .table-responsive .data-table tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid var(--gray-200);
        border-radius: 8px;
        padding: 0.75rem;
    }
    .table-responsive .data-table td {
        display: flex;
        justify-content: space-between;
        border: none;
        padding: 0.25rem 0;
        font-size: 0.875rem;
    }
    .table-responsive .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-500);
        font-size: 0.75rem;
    }
    /* Last td (actions): center */
    .table-responsive .data-table td:last-child {
        justify-content: flex-end;
        gap: 0.5rem;
    }
}

/* === HANKED / PROCUREMENT PAGE (mobile) === */
@media (max-width: 768px) {
    /* Hanked filter bar: stack vertically */
    #hanked-search {
        width: 100%;
        box-sizing: border-box;
    }
    #hanked-prioriteet,
    #hanked-staatus {
        width: 100%;
        box-sizing: border-box;
    }
    /* Hanked stat cards: 2 per row */
    .stats-row[style*="auto-fit"] {
        grid-template-columns: 1fr 1fr;
    }
}

/* === BRANDBOOK PAGE (mobile) === */
@media (max-width: 768px) {
    /* Brandbook color grid: force single column */
    #brand-colors-grid {
        grid-template-columns: 1fr;
    }
    /* Asset grids (logos, fonts, files): single column */
    #brand-colors-grid + div [style*="auto-fit"],
    .card-body [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   TOAST — Mobile responsiveness
   ============================================================ */
@media (max-width: 768px) {
    .toast-container {
        right: 0.5rem;
        left: 0.5rem;
    }

    .toast {
        min-width: 0;
        width: 100%;
        max-width: calc(100vw - 1rem);
    }
}

/* ============================================================
   DARK MODE — Mobile-specific overrides
   ============================================================ */
[data-theme="dark"] .mobile-search-box {
    background: #1a1a2e;
    border: 1px solid #253352;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .bottom-nav {
    background: #1a1a2e;
    border-top-color: #253352;
}

[data-theme="dark"] .bottom-nav-item {
    color: #8da2c4;
}

[data-theme="dark"] .bottom-nav-item.active {
    color: var(--primary);
}

[data-theme="dark"] .fab-container .fab-button {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .top-bar {
    background: #1a1a2e;
    border-bottom-color: #253352;
    color: #c9d8ef;
}

[data-theme="dark"] .top-bar-title {
    color: #c9d8ef;
}

[data-theme="dark"] .top-bar-btn {
    color: #8da2c4;
}

[data-theme="dark"] .top-bar-btn:hover {
    color: #c9d8ef;
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================================
   MOBILE VIEW FIXES — 2026-02-27
   iPhone 13 Pro Max audit fixes
   ============================================================ */

/* Base display rules (needed because display: flex was moved out of inline styles) */
.status-filter-cards {
    display: flex;
}

@media (max-width: 768px) {

    /* --------------------------------------------------------
       1. DASHBOARD SUMMARY CARDS (Kinnitatud/Ootel/Potentsiaalne)
       Force proper 2-column wrap instead of horizontal overflow
       -------------------------------------------------------- */
    .dashboard-summary-cards {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.375rem !important;
    }
    .dashboard-summary-cards > div {
        min-width: 0 !important;
        flex: none !important;
    }

    /* --------------------------------------------------------
       2. STATUS FILTER CARDS (Arved/Pakkumised top cards)
       Horizontal scroll instead of broken wrap
       -------------------------------------------------------- */
    .status-filter-cards {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        gap: 0.5rem !important;
        padding-bottom: 0.25rem !important;
    }
    .status-filter-cards::-webkit-scrollbar {
        display: none;
    }
    .status-filter-cards > div {
        flex: 0 0 auto !important;
        min-width: 90px !important;
        max-width: 130px !important;
        padding: 0.5rem 0.625rem !important;
        font-size: 0.75rem !important;
    }
    .status-filter-cards > div > div:first-child {
        font-size: 0.7rem !important;
    }
    .status-filter-cards > div > div:nth-child(2) {
        font-size: 0.875rem !important;
    }

    /* --------------------------------------------------------
       3. INVOICE / QUOTE LIST ITEMS — Mobile card layout
       Restructure from 4-column flex to stacked card
       -------------------------------------------------------- */
    .doc-list-item {
        flex-wrap: wrap !important;
        padding: 0.625rem 0.75rem !important;
        gap: 0 !important;
        position: relative;
    }
    /* Color strip — full left border instead of thin element */
    .doc-list-item > div:first-child {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 4px !important;
        flex: none !important;
    }
    /* Number/date cell — left side, shrink */
    .doc-list-item .doc-num-cell,
    .doc-list-item > div:nth-child(2) {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 80px !important;
        max-width: 100px !important;
        padding: 0 0 0 0.75rem !important;
        background: transparent !important;
        font-size: 0.8rem !important;
        text-align: left !important;
        justify-content: flex-start !important;
    }
    /* Amount/status cell — right side, push right */
    .doc-list-item > div:nth-last-child(2) {
        flex: 1 !important;
        padding: 0 0.5rem 0 0 !important;
        align-items: flex-end !important;
    }
    /* PDF button cell */
    .doc-list-item > div:last-child {
        flex: 0 0 auto !important;
        padding: 0 !important;
    }
    /* Content cell (company name, dates) — full width row below */
    .doc-list-item > div:nth-child(3) {
        flex: 0 0 100% !important;
        padding: 0.375rem 0.75rem 0 0.75rem !important;
        min-width: 0 !important;
    }
    .doc-list-item > div:nth-child(3) > div:first-child {
        font-size: 0.875rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    /* Hide verbose date text on mobile, keep short */
    .doc-list-item > div:nth-child(3) > div:nth-child(2) {
        font-size: 0.7rem !important;
    }

    /* --------------------------------------------------------
       4. CLIENT TOOLBAR — Responsive sizing
       -------------------------------------------------------- */
    .client-filter-bar {
        flex-wrap: wrap !important;
        gap: 0.375rem !important;
    }
    /* Search takes full width on first row */
    .client-filter-bar > div:first-child {
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }
    .client-filter-bar > div:first-child input {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 16px !important; /* prevent iOS zoom */
    }
    /* Status filter and + Lisa take remaining space */
    #client-status-filter {
        flex: 1 !important;
        font-size: 16px !important;
    }
    /* + Lisa button stays visible */
    .client-filter-bar > button:last-child {
        flex: 0 0 auto;
    }

    /* --------------------------------------------------------
       5. ADMIN TABS — Horizontal scroll on mobile
       -------------------------------------------------------- */
    #admin-tabs,
    .tab-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #admin-tabs::-webkit-scrollbar,
    .tab-bar::-webkit-scrollbar {
        display: none;
    }
}

/* --------------------------------------------------------
   DASHBOARD EVENT LIST — Hide location + team on mobile
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-event-location,
    .dash-event-team,
    .dash-event-invoices {
        display: none !important;
    }
    /* Also hide the 1px dividers next to them */
    .dash-event-location + div[style*="width: 1px"],
    .dash-event-team + div[style*="width: 1px"],
    .dash-event-invoices + div[style*="width: 1px"] {
        display: none !important;
    }
}

/* --------------------------------------------------------
   DASHBOARD MINI STAT CARDS — Hide financial cards on mobile
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-stat-financial {
        display: none !important;
    }
}

/* --------------------------------------------------------
   DASHBOARD — Year stat cards stack vertically on mobile
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-stat-year-cards {
        flex-direction: column !important;
    }
    .dash-stat-year-cards > div {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }
}

/* --------------------------------------------------------
   DASHBOARD — Event filter bar: horisontaalselt kerritav
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-event-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.375rem !important;
    }
    .dash-event-filter-bar {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 0.25rem !important;
        overflow: visible !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding-right: 0 !important;
    }
    .dash-event-filter-bar::-webkit-scrollbar {
        display: none;
    }
    /* Flatten inner button group so kõik nupud kerrivad ühes reas */
    .dash-event-filter-bar > .dash-event-status-filters {
        display: contents !important;
    }
    .dash-event-filter-bar > .dash-event-actions {
        display: flex;
        gap: 0.375rem;
        flex-basis: 100%;
    }
    .dash-event-actions > * {
        flex: 1;
    }
    .dash-event-actions .lisa-dropdown > summary {
        width: 100%;
    }
    .dash-event-filter-bar .btn,
    .dash-event-filter-bar a.btn {
        flex: 0 0 auto !important;
        padding: 0.5rem 0.625rem !important;
        font-size: 0.6875rem !important;
        white-space: nowrap !important;
        text-align: center !important;
        justify-content: center !important;
        /* min-height: 36px eemaldatud 2026-05-04 — global 44px touch target */
        min-height: 44px !important;
    }
}

/* --------------------------------------------------------
   DASHBOARD — Event row name+client spacing
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-event-info {
        gap: 3px !important;
        padding: 0.375rem 0.5rem !important;
    }
    .dash-event-info > div:first-child {
        font-size: 0.8125rem !important;
        line-height: 1.3 !important;
    }
    .dash-event-info > div:last-child {
        font-size: 0.6875rem !important;
        line-height: 1.3 !important;
    }
}

/* --------------------------------------------------------
   FAB — Move up from where bottom nav was
   -------------------------------------------------------- */
/* A modal owns the interaction area; quick actions must not cover its footer. */
body:has(#quote-page-form) .fab-button,
body:has(#quote-page-form) .fab-menu,
body:has(.modal-overlay.active) .fab-button,
body:has(.modal-overlay.active) .fab-menu,
body:has(.sidebar.open) .fab-button,
body:has(.sidebar.open) .fab-menu {
    display: none !important;
}

@media (max-width: 768px) {
    .fab-button {
        bottom: 1rem;
        right: 1rem;
    }
    .fab-menu {
        bottom: 4.5rem;
        right: 1rem;
    }
    /* Nende oma sisemine scroll (max-height:65vh) ei saa #page-content 5rem
       padding't — FAB katab viimased read ilma selleta */
    #quotes-list-container,
    #invoices-list-container {
        padding-bottom: 5rem;
    }

    /* Event-vaate salvestusriba jääb ekraani põhja kinni, et 💾 nupp
       oleks alati nähtav ilma kerimiseta. Parem padding hoiab FAB-i eest. */
    /* NB: sticky ei tööta, sest .main-content on overflow:auto (kerib aken, mitte konteiner) → fixed. */
    #event-save-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
        z-index: 500;
        padding: 0.6rem 4.5rem 0.6rem 0.75rem;
    }
    /* FAB üles, kui Salvesta-riba on ekraani all (muidu katab nupu parema serva) */
    body:has(#event-save-bar) .fab-button {
        bottom: 5.5rem;
    }
    /* Ruum kleepuva riba alla, et viimased väljad ei jääks selle taha */
    #event-save-bar ~ *, form:has(> #event-save-bar), #page-content:has(#event-save-bar) {
        padding-bottom: 5.5rem;
    }
}

/* --------------------------------------------------------
   DASHBOARD — Hide desktop quick-add row on mobile (FAB does same)
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-quickadd-row {
        display: none !important;
    }
}

/* --------------------------------------------------------
   DASHBOARD — Year stat cards: 2-column grid (2+1 layout)
   -------------------------------------------------------- */
@media (max-width: 768px) {
    /* Override the stacked-vertical layout we set earlier */
    .dash-stat-year-cards {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }
    .dash-stat-year-cards > div {
        flex: 1 1 calc(50% - 0.25rem) !important;
        min-width: 0 !important;
    }
    /* Third card (Potentsiaalne) takes full width */
    .dash-stat-year-cards > div:nth-child(3) {
        flex: 1 1 100% !important;
    }
}

/* --------------------------------------------------------
   DASHBOARD — Fix white space: let dashboard scroll on mobile
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .content-area.dashboard-compact {
        height: auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }
    #dashboard-flex-container {
        height: auto !important;
        overflow: visible !important;
    }
}

/* ============================================================
   DASHBOARD MOBILE REDESIGN — Revenue card + event rows
   2026-02-27
   ============================================================ */

/* Desktop year stat cards: flex on desktop, hidden on mobile */
.dash-year-stat-desktop {
    display: flex;
}

@media (max-width: 768px) {
    .dash-year-stat-desktop {
        display: none !important;
    }
}

/* Mobile revenue card: show only on mobile */
.dash-year-stat-mobile {
    display: none;
}

@media (max-width: 768px) {
    .dash-year-stat-mobile {
        display: block !important;
        background: var(--white);
        border: 1px solid var(--card-border);
        border-radius: var(--radius);
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.375rem;
    }
}

@media (max-width: 768px) {
    .dash-year-stat-mobile--unused {
        display: block;
        background: var(--white);
        border: 1px solid var(--card-border);
        border-radius: var(--radius);
        margin-bottom: 0.375rem;
        overflow: hidden;
    }

    .dam-header {
        font-size: 0.6875rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--gray-500);
        padding: 0.5rem 0.875rem 0.125rem;
    }

    .dam-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.3rem 0.875rem;
    }

    .dam-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .dam-label {
        font-size: 0.8125rem;
        color: var(--gray-600);
        flex: 1;
    }

    .dam-count {
        font-size: 0.6875rem;
        color: var(--gray-500);
        background: var(--gray-100);
        border-radius: 99px;
        padding: 0 0.375rem;
        font-weight: 600;
        min-width: 1.25rem;
        text-align: center;
        line-height: 1.6;
    }

    .dam-amount {
        font-size: 0.875rem;
        font-weight: 700;
        color: var(--gray-900);
        text-align: right;
        min-width: 80px;
    }

    .dam-muted {
        color: var(--gray-500) !important;
        font-weight: 500 !important;
    }

    .dam-pipeline {
        display: flex;
        height: 4px;
        margin-top: 0.375rem;
        overflow: hidden;
    }

    .dam-segment {
        height: 4px;
        min-width: 3px;
        transition: flex 0.3s ease;
    }
}

/* Event rows: hide the three 1px dividers on mobile */
@media (max-width: 768px) {
    /* Dividers are at positions 3, 5, 7 in the event row */
    .dash-event-row > div:nth-child(3),
    .dash-event-row > div:nth-child(5),
    .dash-event-row > div:nth-child(7) {
        display: none !important;
    }

    /* Date column: tighter width */
    .dash-event-row > div:nth-child(2) {
        flex: 0 0 52px !important;
    }

    /* Status badge column: compact auto width */
    .dash-event-row > div:nth-last-child(1) {
        width: auto !important;
        min-width: 60px !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* Each row: minimum touch target */
    .dash-event-row {
        min-height: 50px;
    }
}

/* ============================================================
   ALL-PAGES MOBILE REDESIGN — 2026-02-27
   Kliendid · Pakkumised · Arved · Aruanded
   Ülesanded · Inventar · Tööaeg · Tiim · Admin
   ============================================================ */

/* -----------------------------------------------------------
   INVOICES + QUOTES — Toolbar + doc rows
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Search inputs: full width, own row (flex-basis beats the generic
       .card-header select/input flex:1 rule above, which has flex-basis:0
       and was letting the browser squeeze this onto the same line) */
    #invoice-search,
    #quote-search {
        flex: 1 1 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    /* Sort selects: hide on mobile (status filter stays) */
    #invoice-sort,
    #quote-sort {
        display: none;
    }
    /* CSV button: hide on mobile (selector matched a legacy onclick attr
       that no longer exists — buttons use data-action) */
    .card-header button[data-action="exportCSV"]:not(.client-export-button) {
        display: none;
    }
    /* Status/sort filter selects: grow to fill space */
    #invoice-status-filter,
    #quote-status-filter {
        flex: 1 !important;
        min-width: 0 !important;
    }
    /* Doc-list-item: hide PDF button on mobile */
    .doc-list-item > div:last-child {
        display: none !important;
    }
    /* Doc-list-item amount cell: slightly more padding */
    .doc-list-item > div:nth-last-child(1) {
        padding: 0.5rem 0.75rem 0.5rem 0 !important;
    }
    /* Status filter cards: tighter on mobile */
    .status-filter-cards > div {
        padding: 0.5rem 0.75rem !important;
    }
    .status-filter-cards > div > div:nth-child(2) {
        font-size: var(--text-data) !important;
        font-weight: 700 !important;
    }
    /* Status filter cards row: max 3 visible, rest scroll */
    .status-filter-cards {
        max-height: none !important;
    }
}

/* -----------------------------------------------------------
   INVENTORY — Mobile layout
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Tab bar: horizontal scroll */
    .inv-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
    }
    .inv-tabs::-webkit-scrollbar { display: none; }
    .inv-tab {
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        padding: 0.625rem 1rem !important;
        min-height: 44px !important;
    }
    /* Toolbar: stack */
    .inv-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }
    .inv-search {
        width: 100% !important;
    }
    .inv-search input {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 16px !important;
    }
    .inv-add-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    /* Table: horizontal scroll */
    .inv-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .inv-table {
        min-width: 0 !important;
    }
    /* Hide description column (least critical) */
}

/* -----------------------------------------------------------
   TEAM — 1-column grid on mobile
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    .team-grid {
        grid-template-columns: 1fr !important;
        gap: 0.625rem !important;
    }
    /* Team header row: stack */
    .team-grid + div,
    [style*="justify-content: space-between"][style*="margin-bottom: 1.5rem"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }
}

/* -----------------------------------------------------------
   ADMIN — Tab bar scroll + form layout
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    .admin-tabs-bar {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
    }
    .admin-tabs-bar::-webkit-scrollbar { display: none; }
    .admin-tab {
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        padding: 0.625rem 0.875rem !important;
        min-height: 44px !important;
        font-size: 0.8125rem !important;
    }
    /* Settings form: single column */
    #admin-tab-content .eevaa-form-grid,
    #admin-tab-content .form-row {
        grid-template-columns: 1fr;
    }
    /* Settings section header: smaller */
    #admin-tab-content h4,
    #admin-tab-content h3 {
        font-size: var(--text-data) !important;
    }
    /* Stat cards in admin (system tab) */
    #admin-tab-content [style*="display: grid"][style*="repeat(4"] {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Admin toolbar buttons: stack */
    #admin-tab-content .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    /* Admin inline grids (Pank/IBAN, Arve pref/Pakk pref) — force stack */
    #admin-tab-content [style*="grid-template-columns: 1fr 2fr"],
    #admin-tab-content [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    /* Contain admin tab content within viewport */
    #admin-tab-content {
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    #admin-tab-content .card,
    #admin-tab-content form {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    /* Long inputs overflow */
    #admin-tab-content input[type="text"],
    #admin-tab-content input[type="email"],
    #admin-tab-content input[type="tel"],
    #admin-tab-content input[name*="iban"],
    #admin-tab-content input[name*="bank"],
    #admin-tab-content select,
    #admin-tab-content textarea {
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    /* Settings edit button */
    #settings-edit-btn {
        max-width: 100% !important;
    }
}

/* -----------------------------------------------------------
   FAB BUTTON — Bottom padding to prevent content overlap
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    .content-area,
    #page-content {
        padding-bottom: 5rem !important;
    }
}

/* -----------------------------------------------------------
   TODOS/TASKS — Mobile layout
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    .todo-page {
        padding: 0 !important;
    }
    .todo-header {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    .todo-header h2 {
        font-size: var(--text-section);
    }
    /* Filter tabs: horizontal scroll */
    .todo-filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }
    .todo-filter-tabs::-webkit-scrollbar { display: none; }
    .todo-filter-tabs > * {
        flex-shrink: 0;
        white-space: nowrap;
    }
    /* Todo controls: stack to 2 rows */
    .todo-controls {
        flex-wrap: wrap;
        gap: 0.375rem;
    }
    /* Todo item: better touch targets */
    .todo-item-header,
    .todo-item > div:first-child {
        min-height: 44px !important;
    }
}

/* -----------------------------------------------------------
   REPORTS — Chart height + grid
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Reports year selector: center */
    #reports-year-label {
        min-width: 2rem !important;
    }
    /* KPI flex grid: force 2 columns by reducing min-width */
    [style*="display:flex"][style*="flex-wrap:wrap"] > [style*="min-width:140px"] {
        min-width: calc(50% - 0.25rem) !important;
        flex: 1 1 calc(50% - 0.25rem) !important;
    }
}

/* -----------------------------------------------------------
   CALENDAR — Mobile fixes
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Peida Aasta ja Nädal nupud (kasutatamatud mobiilil) */
    .calendar-views button[onclick*="'year'"],
    .calendar-views button[onclick*="'timeline'"] {
        display: none;
    }

    /* Calendar month grid: compact dots-only view on mobile */
    .calendar-day-cell {
        min-height: 44px;
        padding: 0.125rem;
        font-size: 11px;
    }

    /* Calendar event chips: show as colored dots on mobile */
    .calendar-event {
        font-size: 0;
        padding: 0;
        margin: 0 1px 1px 0;
        width: 8px;
        height: 8px;
        min-height: 0;
        border-radius: 50%;
        display: inline-block;
        overflow: hidden;
        box-shadow: none;
        vertical-align: top;
    }
    .calendar-event * {
        display: none;
    }

    /* Calendar LIST VIEW — compact event rows */

    /* Date column: narrower on mobile */
    .hover-row > div[style*="flex: 0 0 100px"] {
        flex: 0 0 68px !important;
        width: 68px !important;
        padding: 0.5rem 0.25rem !important;
        font-size: 0.75rem !important;
    }

    /* Event title: truncate instead of wrapping */
    .hover-row > div[style*="flex: 1"] > div:first-child {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 0.875rem !important;
    }

    /* Sub-line info (client, team, location): hide team on mobile to save space */
    .hover-row > div[style*="flex: 1"] > div:last-child span[title="Meeskond"] {
        display: none !important;
    }

    /* Right badges column: stack vertically if needed */
    .hover-row > div[style*="flex: 0 0 auto"] {
        padding: 0.5rem 0.375rem !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
        align-items: flex-end !important;
    }

    /* Badge font size */
    .hover-row .badge {
        font-size: 0.6875rem !important;
        white-space: nowrap !important;
    }
}

/* -----------------------------------------------------------
   ADMIN — Tabs scrollable on mobile (merged into block above)
   ----------------------------------------------------------- */

/* -----------------------------------------------------------
   TÖÖAEG (Time tracking) — Toolbar + table (supplements existing)
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Time tracking toolbar: full width inputs */
    #time-tracking-search,
    #time-period-filter {
        width: 100%;
        box-sizing: border-box;
    }
    /* Stats row in time tracking */
    [id*="time"][style*="display: grid"],
    [id*="time-tracking"][style*="display: grid"] {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* -----------------------------------------------------------
   CALENDAR LIST VIEW — Mobile text overflow fix
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Calendar list items: better wrapping */
    #page-content table td,
    #page-content table th {
        word-break: break-word;
    }
    /* Calendar list event rows — allow text wrap */
    #page-content .calendar-container [style*="display: flex"][style*="gap"] {
        flex-wrap: wrap;
    }
}

/* -----------------------------------------------------------
   INVENTORY TABS — Wrap on small screens
   ----------------------------------------------------------- */
@media (max-width: 480px) {
    .inventory-tabs {
        flex-wrap: wrap !important;
        gap: 0.25rem !important;
    }
    .inventory-tabs > button,
    .inventory-tabs > div {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}

/* -----------------------------------------------------------
   EVENT DETAIL — Mobile two-column to single-column
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    /* Event detail: stack columns */
    #page-content [style*="display: grid"][style*="1fr 1fr"],
    #page-content [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    /* Event detail: tab bar scroll */
    #page-content [style*="border-bottom"][style*="display: flex"][style*="gap"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
    }
    #page-content [style*="border-bottom"][style*="display: flex"][style*="gap"]::-webkit-scrollbar {
        display: none;
    }
}

/* -----------------------------------------------------------
   QUOTE/INVOICE FULL PAGE — Mobile adjustments
   ----------------------------------------------------------- */
@media (max-width: 768px) {

    /* ---- Header ---- */
    /* Back button + title: keep inline but shrink gap */
    #page-content > div:first-child > div[style*="align-items: flex-start"] {
        gap: 0.5rem;
    }
    /* Subtitle metadata: smaller font, tighter gap */
    #page-content > div:first-child [style*="font-size: var(--text-secondary)"] {
        font-size: 0.75rem !important;
        gap: 0.35rem !important;
    }
    /* Hide bullet separators on mobile */
    #page-content > div:first-child [style*="font-size: var(--text-secondary)"] > span:only-of-type {
        /* keep */
    }

    /* ---- Invoice: Saatja / Klient cards ---- */
    /* Already handled by the generic 1fr 1fr → 1fr rule */

    /* ---- Invoice: Status cards — 2 per row via grid ---- */
    #page-content > div[style*="display: flex"][style*="flex-wrap: wrap"][style*="margin-bottom: 1.5rem"] {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    #page-content > div[style*="display: flex"][style*="flex-wrap: wrap"][style*="margin-bottom: 1.5rem"] > div[style*="min-width"] {
        min-width: 0;
        padding: 0.75rem;
    }

    /* ---- Invoice: Items table — horizontal scroll ---- */
    #page-content .eevaa-section .table {
        min-width: 500px;
    }
    #page-content .eevaa-section [style*="overflow-x"],
    #page-content .eevaa-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---- Quote: Totals box — full width ---- */
    #quote-page-form [style*="justify-content: flex-end"][style*="margin-top: 1rem"] {
        justify-content: stretch;
    }
    #quote-page-form [style*="justify-content: flex-end"][style*="margin-top: 1rem"] > div[style*="width: 300px"] {
        width: 100%;
    }

    /* ---- Invoice: Payments + totals — stack vertically ---- */
    #page-content > div[style*="justify-content: space-between"][style*="gap: 2rem"] {
        flex-direction: column;
        gap: 1rem;
    }
    #page-content > div[style*="justify-content: space-between"][style*="gap: 2rem"] > div[style*="width: 300px"] {
        width: 100%;
    }

    /* ---- Action buttons bar ---- */
    #quote-page-form > div[style*="sticky"],
    #page-content > div[style*="sticky"] {
        flex-direction: column;
        gap: 0.5rem;
        margin: 0;
        padding: 0.75rem 0;
    }
    #quote-page-form > div[style*="sticky"] > div,
    #page-content > div[style*="sticky"] > div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.375rem;
        width: 100%;
        justify-content: center;
    }
    #quote-page-form > div[style*="sticky"] .btn,
    #quote-page-form > div[style*="sticky"] .btn-eevaa,
    #page-content > div[style*="sticky"] .btn,
    #page-content > div[style*="sticky"] .btn-eevaa {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 44px;
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
    /* Make primary action full width on mobile */
    #quote-page-form > div[style*="sticky"] button[type="submit"] {
        flex: 0 0 100%;
        order: 10;
    }

    /* ---- Sections: reduce padding ---- */
    #quote-page-form .eevaa-section,
    #page-content .eevaa-section {
        padding: 1rem;
    }

    /* ---- Quote: section title + add buttons ---- */
    #quote-page-form [style*="justify-content: space-between"][style*="margin-bottom: 1rem"] {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

/* =============================================
   PREFERS-REDUCED-MOTION — mobile-specific reinforcement
   Mobile sidebar slide, bottom nav, pull-to-refresh — ära transitionida
   ============================================= */
@media (prefers-reduced-motion: reduce) and (max-width: 768px) {
    .sidebar {
        transition: none;
    }
    .sidebar-overlay,
    #sidebar-overlay,
    .mobile-menu-overlay {
        transition: none;
    }
    .fab,
    .floating-action-button {
        transition: none;
    }
    /* Pull-to-refresh spinner — staatiline */
    .ptr-element .ptr-icon {
        animation: none;
    }
    /* Mobile search slide-in */
    .mobile-search-wrapper {
        transition: none;
    }
}

/* ============================================================
   URGENT BANNER — Mobile-only compact replacement
   2026-05-20: Asendab desktop 5-kaarti Ülioluline sektsiooni
   1-rea banneriga (~50px). Klikk → /todos täisleht.
   Desktop ≥769px näeb endistviisi täiskaardid.

   NB: Kalendri reeglid `#page-content .calendar-header .calendar-nav`
   bleed'ivad dashboardile (eraldi tehniline võlg). Banner ise on
   :nth-child(2) nii et seda see ei mõjuta, kuid desktop-section
   vajab `#dashboard-flex-container` prefix'i kõrgemaks specifity'ks.
   ============================================================ */

/* Desktop ≥769px: peida mobile banner */
@media (min-width: 769px) {
    .urgent-section-mobile {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Peita desktop variant mobiilis (vajab kahe-ID prefix calendar-bleed'i tõttu —
       calendar reegel `#page-content .calendar-header .calendar-nav` võidab muidu) */
    #page-content #dashboard-flex-container .urgent-section-desktop {
        display: none;
    }

    /* Banner mobiilis nähtav */
    .urgent-section-mobile {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: var(--danger-light);
        border: 1px solid var(--danger);
        border-left-width: 3px;
        border-radius: var(--radius);
        padding: 0.625rem 0.75rem;
        margin-bottom: 0.5rem;
        cursor: pointer;
        min-height: 44px; /* WCAG AA touch target */
        color: var(--danger-text);
        font-weight: 600;
        font-size: var(--text-data);
        transition: background 0.15s ease, color 0.15s ease;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .urgent-section-mobile:hover,
    .urgent-section-mobile:focus-visible {
        background: var(--danger);
        color: var(--white);
        outline: none;
    }

    .urgent-section-mobile:active {
        transform: scale(0.99);
    }

    .urgent-banner-icon {
        font-size: 1.15em;
        flex-shrink: 0;
        line-height: 1;
    }

    .urgent-banner-text {
        flex: 1;
        line-height: 1.3;
    }

    .urgent-banner-arrow {
        font-size: 1.25em;
        opacity: 0.7;
        flex-shrink: 0;
        line-height: 1;
    }
}


/* Audit 2026-09-10: nime ja dokumendi sisu ei tohi kitsal ekraanil kaduda. */
@media (max-width: 768px) {
    #clients-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }
    #clients-table tbody {
        display: block;
        width: 100%;
    }
    #clients-table tbody tr,
    #clients-table tbody td:first-child {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    #clients-table tbody td:first-child,
    #clients-table tbody td:first-child strong {
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
    #clients-table tbody td:first-child > div:last-child > div:first-child {
        flex-wrap: nowrap;
    }
    #clients-table tbody td:first-child strong {
        flex: 1 1 0;
        min-width: 0;
    }
    #clients-table tbody td:first-child > div:last-child > div:first-child > span {
        flex-shrink: 0;
    }
    .doc-list-item > div:nth-child(3) > .doc-list-title {
        white-space: normal !important;
        overflow: visible !important;
        justify-content: flex-start !important;
    }
    .doc-list-title .doc-list-title-text {
        display: block;
        flex: 1 1 100%;
        min-width: 0;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
    .doc-list-title .doc-list-event-link {
        max-width: 100%;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
}

/* 2026-09-10: constrain the audited planning, task and settings layouts. */
#settings-form,
#settings-form .card,
#settings-form .card-body,
#settings-form .form-group,
#settings-form .admin-settings-grid,
#settings-form .admin-settings-grid > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
#settings-form input,
#settings-form select,
#settings-form textarea {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.todo-page .todo-filter-bar {
    min-width: 0;
    max-width: 100%;
}
@media (max-width: 1024px) {
    .team-planning .gantt-grid {
        grid-template-columns: 160px repeat(7, minmax(110px, 1fr)) !important;
        min-width: 930px !important;
    }
    .team-planning .gantt-user,
    .team-planning .gantt-header:first-child {
        min-width: 0;
        max-width: none;
    }
    .team-planning .gantt-user > div:last-child {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}
@media (max-width: 768px) {
    .todo-page .todo-filter-bar {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        flex-basis: 100% !important;
        width: 100%;
    }
    .todo-page .todo-filter-bar .event-filter-select {
        grid-column: 1 / -1;
        width: 100%;
    }
    .todo-page .todo-filter-bar .search-input {
        min-width: 0 !important;
        width: 100%;
    }
    .todo-page .todo-header > .add-btn {
        margin-left: 0 !important;
    }
    .subcontractor-table td[data-label] {
        gap: 1rem;
        text-align: right;
        overflow-wrap: anywhere;
    }
    .subcontractor-table td[data-label]::before {
        flex: 0 0 45%;
        text-align: left;
    }
    .subcontractor-table td[data-label="Tegevused"]::before {
        margin-right: auto;
    }
}

@media (max-width: 768px) {
    .client-detail-header { flex-wrap: wrap; }
    .client-detail-header > .btn { flex-basis: 100%; }
    .client-detail-actions { flex-basis: 100%; width: 100%; flex-wrap: wrap; }
    .client-detail-actions .btn, .client-detail-actions .btn-sm { flex: 1; min-height: 44px; white-space: nowrap; }
    .client-detail-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .client-detail-kpis > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .client-detail-columns { grid-template-columns: minmax(0, 1fr) !important; }
    .client-detail-columns > div { padding: 0 !important; border: 0 !important; }
    .client-detail-columns > div + div { margin-top: 1rem; padding-top: 1rem !important; border-top: 1px solid var(--gray-200) !important; }
    .client-detail-related { flex-wrap: wrap; min-height: 44px; }
    .client-detail-related > div:first-child { flex-basis: 100% !important; }
    .client-detail .timeline-content { flex-wrap: wrap; gap: 0.375rem 0.75rem; }
    .client-detail .timeline-content-main { flex-basis: 100%; }
    .client-detail .timeline-filter-btn { min-height: 44px; }
    .client-detail .eevaa-section { padding: 1rem; }
}

/* Lugemisvaate arveread mahuvad mobiilis ilma külgsuunas kerimiseta. */
@media (max-width: 768px) {
    #page-content .eevaa-section .invoice-lines-table { display: block; min-width: 0; width: 100%; }
    .invoice-lines-table colgroup { display: none; }
    .invoice-lines-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); }
    .invoice-lines-table tbody { display: block; }
    .invoice-lines-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--gray-200); padding: .75rem 0; }
    .invoice-lines-table tbody td { display: block; min-width: 0; border: 0; padding: .5rem; text-align: left !important; }
    .invoice-lines-table .invoice-line-description { grid-column: 1 / -1; font-weight: 600; }
    .invoice-lines-table td[data-label]::before { content: attr(data-label); display: block; color: var(--gray-600); font-size: var(--text-micro); font-weight: 400; margin-bottom: .2rem; }
    .invoice-lines-table .invoice-line-section th { grid-column: 1 / -1; }
    .invoice-payment-row { flex-wrap: wrap; gap: .5rem; }
    .invoice-page-actions > div { width: 100%; }
    .invoice-page-actions > div:empty { display: none; }
    .invoice-page-actions .btn,
    .invoice-page-actions .btn-eevaa { flex: 1 1 130px; white-space: normal; }
}

@media (max-width: 768px) {
    #page-content .eevaa-section .invoice-edit-table { display: block; min-width: 0; width: 100%; }
    .invoice-edit-table colgroup { display: none; }
    .invoice-edit-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .invoice-edit-table tbody { display: block; }
    .invoice-edit-table tr { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); border-bottom: 1px solid var(--gray-200); padding: 1rem 0; }
    .invoice-edit-table td { display: block; padding: .4rem; min-width: 0; border: 0; }
    .invoice-edit-table .ipe-description-cell { grid-column: 1 / -1; }
    .invoice-edit-table td:nth-child(2)::before { content: 'Kogus'; }
    .invoice-edit-table td:nth-child(3)::before { content: 'Ühik'; }
    .invoice-edit-table td:nth-child(4)::before { content: 'Hind'; }
    .invoice-edit-table td:nth-child(5)::before { content: 'Allahindlus %'; }
    .invoice-edit-table td:nth-child(6)::before { content: 'Summa'; }
    .invoice-edit-table td::before, .ipe-mobile-label { display: block; color: var(--gray-600); font-size: var(--text-micro); margin-bottom: .3rem; }
    .invoice-edit-table .ipe-line-total { text-align: left !important; }
    .invoice-edit-table td:last-child { text-align: right; }
    .invoice-edit-actions button { flex: 1; }
}

/* Uue arve rea tabelipäis on telefonis peidetud. Väljade sildid ja kaks
   eraldi tegevusnuppu jäävad seetõttu nähtavaks ning puutealaga. */
@media (max-width: 768px) {
    #invoice-modal .eevaa-table tbody tr.invoice-item-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            'description description'
            'quantity unit'
            'price sum'
            'actions actions';
        gap: 0.75rem 0.5rem;
    }
    #invoice-modal .eevaa-table tbody tr.invoice-item-row .invoice-item-description { grid-area: description; }
    #invoice-modal .eevaa-table tbody tr.invoice-item-row .invoice-item-quantity { grid-area: quantity; }
    #invoice-modal .eevaa-table tbody tr.invoice-item-row .invoice-item-unit { grid-area: unit; }
    #invoice-modal .eevaa-table tbody tr.invoice-item-row .invoice-item-price { grid-area: price; }
    #invoice-modal .eevaa-table tbody tr.invoice-item-row .invoice-item-sum {
        grid-area: sum;
        align-self: end;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        font-weight: 600;
    }
    #invoice-modal .eevaa-table tbody tr.invoice-item-row .invoice-item-actions {
        grid-area: actions;
        position: static;
        display: flex;
        justify-content: flex-end;
    }
    #invoice-modal .invoice-item-description-controls {
        display: flex;
        flex-wrap: wrap;
        align-items: end;
        gap: 0.5rem;
        min-width: 0;
    }
    #invoice-modal .invoice-item-description-controls .eevaa-form-input {
        min-width: 0;
        width: auto !important;
        flex: 1 1 auto;
    }
    #invoice-modal .invoice-item-field-label.sr-only {
        position: static;
        width: auto;
        height: auto;
        padding: 0;
        margin: 0 0 0.25rem;
        overflow: visible;
        clip: auto;
        white-space: normal;
        border: 0;
        display: block;
        color: var(--gray-600);
        font-size: var(--text-micro);
        font-weight: 500;
    }
    #invoice-modal .invoice-item-description-controls .invoice-item-field-label { flex-basis: 100%; }
    #invoice-modal .invoice-item-inventory,
    #invoice-modal .invoice-item-remove {
        flex: 0 0 44px;
        width: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .invoice-list-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .invoice-stat-button { padding: .65rem; }
    .invoice-list-toolbar { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
    .invoice-list-toolbar label { grid-column: 1 / -1; }
    .invoice-list-toolbar button { padding: .5rem; white-space: normal; }
    #invoice-list-root #invoices-list-container { max-height: none; overflow: visible; }
    .invoice-list-row { grid-template-columns: minmax(0,1fr) auto; grid-template-areas: 'identity identity' 'client client' 'due pdf' 'amount amount'; gap: .75rem; }
    .invoice-row-identity { grid-area: identity; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: baseline; }
    .invoice-row-client { grid-area: client; }
    .invoice-row-due { grid-area: due; }
    .invoice-row-pdf { grid-area: pdf; }
    .invoice-row-amount { grid-area: amount; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; text-align: left; }
    .invoice-row-paid { flex-basis: 100%; }
}

/* Calendar controls must stay reachable rather than hiding in a scroll strip. */
@media (max-width: 768px) {
    #page-content .calendar-header .calendar-views {
        width: 100%;
        overflow: visible !important;
        flex-wrap: wrap !important;
        margin: 0;
    }

    #page-content .calendar-header .calendar-view-group,
    #page-content .calendar-header .calendar-filter-group {
        display: flex;
        flex: 1 1 100%;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    #page-content .calendar-header .calendar-view-group .btn,
    #page-content .calendar-header .calendar-filter-group .btn {
        flex: 1 1 auto;
        min-height: 44px;
    }

    .calendar-day-add {
        min-width: 1.25rem;
        min-height: 1.25rem;
    }

    /* Päeva koondnupp avab mobiilis kogu päeva sisu. Täiskaardid jäävad DOM-i
       töölaua laiuse jaoks, kuid ei jää väikeste värviribadena fookusesse. */
    .calendar-day-cell .calendar-event,
    .calendar-day-cell .calendar-block,
    .calendar-day-cell [data-action="showDayEvents"][role="button"] {
        display: none !important;
    }

    .calendar-day-cell .calendar-mobile-indicator {
        display: inline-block;
        width: 0.5rem;
        height: 0.5rem;
        margin: 0 0.125rem 0.125rem 0;
        border-radius: 50%;
        vertical-align: top;
    }

    .calendar-day-cell .calendar-mobile-block-indicator {
        border-radius: 2px;
    }
}

/* Ürituse detaili kiirvormid peavad jääma 390 px vaates sisestatavateks. */
@media (max-width: 600px) {
    #quick-task-input > div,
    #quick-team-input > div:first-child {
        flex-wrap: wrap;
        align-items: stretch !important;
    }
    #quick-task-input > div > div,
    #quick-team-input > div:first-child > div {
        flex: 1 1 100% !important;
        width: 100% !important;
        min-width: 0;
    }
    #quick-task-input > div > button,
    #quick-team-input > div:first-child > button {
        min-height: 44px;
    }
    #quick-note-input { padding-bottom: 5rem !important; }
}

/* Ürituse sisemine märkmekirjutus on mobiilis FAB-i kohal; ära kata tekstivälja. */
@media (max-width: 600px) {
    body:has(#page-content #quick-note-input[style*="display: block"]) #fab-button,
    body:has(#page-content #quick-note-input[style*="display: block"]) #fab-menu,
    body:has(#event-modal.active #quick-note-input[style*="display: block"]) #fab-button,
    body:has(#event-modal.active #quick-note-input[style*="display: block"]) #fab-menu,
    body:has(#page-content .note-edit-textarea) #fab-button,
    body:has(#page-content .note-edit-textarea) #fab-menu,
    body:has(#event-modal.active .note-edit-textarea) #fab-button,
    body:has(#event-modal.active .note-edit-textarea) #fab-menu,
    body:has(#page-content #new-team-member-form[style*="display: block"]) #fab-button,
    body:has(#page-content #new-team-member-form[style*="display: block"]) #fab-menu,
    body:has(#event-modal.active #new-team-member-form[style*="display: block"]) #fab-button,
    body:has(#event-modal.active #new-team-member-form[style*="display: block"]) #fab-menu {
        display: none !important;
    }
}

/* Flatpickr kuupäevavalija päis peab mobiilis jätma kuu/aasta valikutele
   vähemalt 44 px puuteala; üldine vormiväljade reegel ei tohi neid vanasse
   34 px päisesse lõigata. Avatud valija ajal ei kata FAB kalendrit. */
@media (pointer: coarse), (max-width: 1024px) {
    .flatpickr-calendar.open .flatpickr-months .flatpickr-month {
        height: 48px;
        min-height: 48px;
        overflow: visible;
    }

    .flatpickr-calendar.open .flatpickr-current-month {
        height: 48px;
        min-height: 48px;
        padding-top: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.125rem;
    }

    .flatpickr-calendar.open .flatpickr-current-month .flatpickr-monthDropdown-months,
    .flatpickr-calendar.open .flatpickr-current-month .numInputWrapper,
    .flatpickr-calendar.open .flatpickr-current-month input.cur-year {
        min-height: 44px;
        height: 44px;
        line-height: 44px;
    }

    .flatpickr-calendar.open .flatpickr-current-month .flatpickr-monthDropdown-months {
        padding-top: 0;
        padding-bottom: 0;
    }

    body:has(.flatpickr-calendar.open) #fab-button,
    body:has(.flatpickr-calendar.open) #fab-menu {
        display: none !important;
    }
}

/* Meeskonna planeerimise päris tabel säilib mobiilis tabelina, mitte varasema grid-reeglina. */
@media (max-width: 1024px) {
    .team-planning table.gantt-grid { display: table !important; min-width: 930px !important; }
    .team-planning table.gantt-grid thead { display: table-header-group !important; }
    .team-planning table.gantt-grid tbody { display: table-row-group !important; }
    .team-planning table.gantt-grid tr { display: table-row !important; }
    .team-planning table.gantt-grid th,
    .team-planning table.gantt-grid td { display: table-cell !important; }
}
