:root {
    --bg-dark: #070718;
    --accent: #47c4fa;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --rgb-gradient: linear-gradient(145deg, #ff00ea, #00d2ff, #7a00ff, #ff0055);
    --amber-gradient: linear-gradient(135deg, #ffbf00, #ff8c00, #ff4500);
    --highlight: #f8fafc;
    --text-gray: #c9c9c9;
    --glass-bg: rgba(15, 23, 42, 0.4);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    --surface-blur: 35px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #010102;
    background-image: linear-gradient(0deg, #1a1a2e 0%, #000000 40%);
    background-attachment: fixed;
    color: white;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

#usersView {
    z-index: 1000;
}

#loginScreen {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    /* iOS safe area */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.login-box {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--surface-blur));
    -webkit-backdrop-filter: blur(var(--surface-blur));
    padding: 40px;
    border-radius: 30px;
    width: 300px;
    text-align: center;
    box-shadow: var(--glass-shadow);
    border-top: 1px solid var(--glass-highlight);
    border-left: 1px solid var(--glass-highlight);
}

.login-box input {
    width: 100%;
    padding: 12px 18px;
    margin: 12px 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: white;
    border-radius: 12px;
    box-sizing: border-box;
    outline: none;
    transition: all 0.3s ease;
}

.login-box input:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.login-box button {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    font-size: 16px;
    letter-spacing: 1px;
}

#appContent {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: row;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    /* iOS: use fixed height to avoid rubber-band overflow */
    height: 100%;
    height: -webkit-fill-available;
    flex-shrink: 0;
    background: transparent;
    backdrop-filter: blur(var(--surface-blur));
    -webkit-backdrop-filter: blur(var(--surface-blur));
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
    z-index: 100;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
}

.sidebar-menu li {
    padding: 10px 15px;
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    border-radius: 14px;
    margin: 4px 16px;
}

.sidebar-menu li:hover {
    color: var(--accent);
}

.sidebar-menu li.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    font-weight: 600;
    position: relative;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.sidebar-menu li.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 4px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px var(--accent);

}

.sidebar.collapsed .hide-on-collapse {
    display: none !important;
}

.sidebar-section {
    padding: 20px;
    color: var(--text-gray);
    border-top: 1px solid var(--glass-highlight);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-section .section-title {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: bold;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.sidebar.collapsed .sidebar-section {
    display: none;
}

.main-content {
    flex: 1;
    min-width: 0;
    /* Prevent flex overflow */
    padding-right: 24px;
    padding-left: 24px;
    flex-wrap: wrap;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dashboard {
    display: flex;
    gap: 10px;
    width: 100%;
}

.main-wrapper {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


.layout-left {
    flex: 6;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding-top: 20px;
    gap: 10px;
    align-content: start;
}

.layout-right {
    flex: 2;
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    padding-top: 20px;
    gap: 10px;
    align-content: start;
    align-items: start;
}

/* chart1 — prevent card from stretching to full grid height */
#chart1Container>.card {
    height: auto;
    align-self: start;
}

#chart1Section {
    flex: 0 0 auto;
}


#chartsView {
    display: none;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.charts-view-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: transparent;
    border-radius: 30px;
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
    min-width: 200px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}


.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #5c74fc, transparent);
    box-shadow: 0 5px 40px rgba(80, 103, 231, 0.8),
        0 10px 60px rgba(80, 103, 231, 0.4);
    z-index: 2;
    transition: all 0.4s ease;
}


.card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, rgba(80, 103, 231, 0.2), transparent);
    pointer-events: none;
    z-index: 1;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}


.card.scrollable {
    height: 200px;
}

.card-body {
    flex: 1;
    overflow-y: auto;
    margin: 8px 0;
    padding-right: 5px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-weight: bold;
    margin-bottom: 5px;
}

/* Custom scrollbar */
.card-body::-webkit-scrollbar {
    width: 4px;
}

.card-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.card-body::-webkit-scrollbar-track {
    background: transparent;
}

.card--col-1 {
    grid-column: span 1;
}

.card--col-2 {
    grid-column: span 2;
}

.card.clickable {
    cursor: pointer;
    transition: 0.3s;
}

.card.clickable:hover {
    transform: translateY(-8px);
    background: rgba(80, 103, 231, 0.05);

}


.card.clickable:hover::before {
    box-shadow: 0 5px 40px rgba(80, 103, 231, 0.9),
        0 10px 60px rgba(80, 103, 231, 0.5);
}

.card.clickable:hover::after {
    height: 100%;
    background: radial-gradient(ellipse at 50% 0%, rgba(80, 103, 231, 0.5) 0%, transparent 70%);
}

.title {
    font-size: 14px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 1px;
    text-transform: uppercase;
}

.big {
    font-size: 24px;
    font-weight: bold;
}

.guest-tag {
    color: var(--highlight);
    font-weight: bold;
    font-size: 14px;
    background: rgba(206, 241, 6, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.row {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
    font-size: 13px;
    color: var(--text-gray);
}

.row-1 {
    grid-row: 1;
}

.row-2 {
    grid-row: 2;
}

.row-3 {
    grid-row: 3;
    grid-column: span 2;
}

.total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    text-align: right;
    border-top: 1px solid var(--glass-highlight);
    padding-top: 6px;
    font-weight: bold;
    color: white;
}

.detail-card {
    grid-column: span 4;
    display: none;
    flex-direction: column;
}

.tab {
    padding: 10px 20px;
    border-radius: 30px;
    border: none;
    background: transparent;
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
}

.tab.active {
    background: transparent;
    color: var(--accent);
    box-shadow: 0 2px 10px var(--accent-glow);
    border: 1px solid var(--accent-glow);
    font-weight: 600;
}

.tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    color: rgb(255, 255, 255);
}

.detail-table th {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--glass-highlight);
    color: var(--accent);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detail-table td {
    padding: 6px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.9);
}

.btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    border: none;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.2);
    text-transform: uppercase;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.4);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(0);
}

.flatpickr-day {
    position: relative;
}

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.24);
    border-radius: 10px;
}


.data-dot {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background-color: rgb(8, 248, 0);
    border-radius: 50%;
    pointer-events: none;
}


#detailSearch:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(106, 166, 255, 0.3);
}

/* Mode Toggle Switch */
.mode-toggle {
    position: relative;
    display: flex;
    background: transparent;
    border-radius: 30px;
    padding: 1px;
    width: 60px;
    height: 24px;
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    align-items: center;
}

.mode-toggle input {
    display: none;
}

.mode-toggle label {
    flex: 1;
    z-index: 1;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    line-height: 20px;
    color: var(--text-gray);
    transition: all 0.3s ease;
    margin: 0;
}

.mode-toggle input:checked+label {
    color: #020c1b;
}

.mode-toggle .toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 18px;
    background: var(--accent);
    border-radius: 47%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;

}

.mode-toggle input#modeMonth:checked~.toggle-slider,
.mode-toggle input#modeMonthM:checked~.toggle-slider {
    transform: translateX(30px);
}

/* Weekly Day Tabs */
.wbw-tabs-container,
#detailTabs,
.scrollable-tabs-container {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 2px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#detailTabs {
    background: transparent;
    border: none;
    padding: 0;
}

.scrollable-tabs-container {
    background: transparent;
    border: none;
    padding: 0;
}

.wbw-tabs-container::-webkit-scrollbar,
#detailTabs::-webkit-scrollbar,
.scrollable-tabs-container::-webkit-scrollbar {
    display: none;
}

.wbw-tab {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.wbw-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.03);
}

.wbw-tab.active {
    background: var(--accent);
    color: #0f172a;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.user-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .user-edit-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ============================================================
   MOBILE HEADER
   ============================================================ */
#mobileHeader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(1, 1, 2, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    /* Top margin 10pt */
    border-bottom: 1px solid rgba(71, 196, 250, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.mobile-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 6px;
}

.mobile-logo {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 1px;
    text-shadow: 0 0 12px var(--accent-glow);
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-size: 18px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.mobile-user-badge {
    font-size: 10px;
    color: var(--text-gray);
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 6px;
    border-radius: 6px;
    display: block;
}

.mobile-user-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.mobile-logout-link {
    background: none;
    border: none;
    color: #fd9898;
    font-size: 10px;
    padding: 0;
    text-decoration: underline;
    cursor: pointer;
    line-height: 1;

}

.mobile-datepicker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 10px;
}

.mobile-date-input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.07);
    color: white;
    font-size: 16px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    /* allows shrinking */
}

.mobile-generate-btn {
    padding: 8px 10px !important;
    font-size: 10px !important;
    border-radius: 10px !important;
    white-space: nowrap;
    min-height: unset !important;
    height: auto;
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */
#mobileBottomNav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(1, 1, 2, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    /* Bottom margin + safe space */
    flex-direction: row;
    align-items: stretch;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: #5a6a7a;
    gap: 3px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
    touch-action: manipulation;
    position: relative;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 8px var(--accent-glow);
}

.mobile-nav-icon {
    font-size: 20px;
    line-height: 1;
}

.mobile-nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================================
   MOBILE UPLOAD OVERLAY (Bottom Sheet)
   ============================================================ */
#mobileUploadOverlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.mobile-upload-sheet {
    background: #0d1526;
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 480px;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================================
   GLOBAL TOUCH OPTIMIZATIONS
   ============================================================ */
* {
    -webkit-tap-highlight-color: transparent;
}

button,
a,
[role="button"] {
    touch-action: manipulation;
}

/* ============================================================
   TABLET RESPONSIVE (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .layout-left {
        grid-template-columns: repeat(3, 1fr);
    }

    .card--col-2 {
        grid-column: span 3;
    }

    .detail-card {
        grid-column: span 3;
    }

    .sidebar {
        width: 70px;
    }

    .sidebar .hide-on-collapse {
        display: none !important;
    }

    .sidebar .sidebar-section {
        display: none;
    }
}

/* ============================================================
   MOBILE RESPONSIVE (≤ 768px) — iOS Priority
   ============================================================ */
@media (max-width: 768px) {

    /* Body adjustments */
    body {
        position: fixed;
        width: 100%;
        height: 100dvh;
        height: -webkit-fill-available;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Hide desktop sidebar completely */
    .sidebar {
        display: none !important;
    }

    /* Show mobile UI elements */
    #mobileHeader {
        display: block;
    }

    #mobileBottomNav {
        display: flex !important;
    }

    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevents iOS auto-zoom on focus */
    }

    /* App content containment */
    #appContent {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        margin: 0;
        overflow: hidden;
        background: var(--bg-dark);
        position: relative;
        max-width: 100%;
        /* Ensure it doesn't overflow */
    }

    .main-wrapper {
        width: 100%;
        flex: 1;
        min-height: 0;
        /* Dynamic padding based on header density */
        padding-top: calc(env(safe-area-inset-top, 0px) + 105px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
        /* 64px nav + safe area + margin */
        box-sizing: border-box;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .main-content {
        padding: 0 10px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    /* Fix stwines card height on mobile */
    #stwinesView {
        height: 100% !important;
        max-height: none !important;
        padding-bottom: 0px;
    }

    /* ── Dashboard View ── */
    .dashboard {
        flex-direction: column;
        gap: 12px;
    }

    .layout-left {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        flex: none;
    }

    .layout-right {
        flex: none;
    }

    .card--col-2 {
        grid-column: span 2;
    }

    .card--col-1 {
        grid-column: span 1;
    }

    .detail-card {
        grid-column: span 2;
        height: auto !important;
        max-height: 90vh;
        border: 1px solid rgba(71, 196, 250, 0.1);
    }

    .card {
        border-radius: 20px;
        min-width: 0;
    }

    /* Revenue big numbers smaller on mobile */
    .big {
        font-size: 18px;
    }

    /* Donut cards taller for readability */
    #wgbkCard,
    #couponCard,
    #pubcrawlCard,
    #focCard {
        height: 180px !important;
    }

    /* ── Charts View ── */
    #chartsView>div {
        flex-direction: column !important;
        height: auto !important;
    }

    #chartsView>div>div {
        flex: none !important;
        width: 100% !important;
        padding: 0 !important;
    }

    /* Chu kỳ theo tuần chart taller */
    #chartsView .card.chart-container[style*="380px"] {
        height: 260px !important;
    }

    /* Mini chart cards — 2 per row */
    #chartsView .card.chart-container.clickable {
        height: 180px !important;
    }

    /* WBW tabs scroll instead of wrap */
    .wbw-tabs-container {
        flex-wrap: nowrap !important;
        gap: 2px;
        overflow-x: auto;
    }

    .wbw-tab {
        padding: 5px 10px;
        font-size: 12px;
        min-width: 36px;
        min-height: 32px;
    }

    /* Right column charts full width */
    #chartsView>div>div:last-child {
        gap: 10px;
    }

    /* Detail panels full screen */
    #detailSection {
        height: auto !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    #chartsDetailSection {
        max-height: 90vh !important;
        overflow-y: auto;
    }

    /* Users panel on mobile */
    #usersView {
        position: relative !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 20px !important;
        z-index: 100 !important;
        background: transparent !important;
        border: none !important;
        flex: 1;
        /* allow it to grow and fill the main-content */
    }

    /* Welcome message */
    #welcomeMessage h2 {
        font-size: 22px;
    }

    /* Buttons touch targets */
    .btn {
        min-height: 44px;
    }

    /* Tab buttons */
    .tab {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Detail search */
    #detailSearch {
        font-size: 16px !important;
        /* prevents iOS zoom */
    }

    #chartsDetailSearch {
        font-size: 16px !important;
    }

    /* Prevents iOS zoom on stwines search */
    #stwinesSearch {
        font-size: 14px !important;
        width: 130px !important;
    }

    #usersView input {
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.07);
        border: 1px solid rgba(255, 255, 255, 0.1);
        padding: 12px;
        font-size: 16px !important;
    }

    #addUserBtn {
        width: 100%;
        margin-top: 5px;
    }

    /* Flatpickr mobile fix - display as fixed centered modal to prevent iOS height stretch */
    .flatpickr-calendar {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        width: 300px !important;
        max-width: 90vw !important;
        font-size: 13px !important;
        zoom: 1 !important;
        /* Dùng zoom 1 để ghi đè, tránh lỗi Safari */
        z-index: 10000 !important;
        margin: 0 !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8) !important;
    }

    /* 2. Cố định chiều cao của vùng chứa ngày */
    .flatpickr-innerContainer {
        height: auto !important;
        display: block !important;
        width: 100% !important;
    }

    .flatpickr-rContainer {
        width: 100% !important;
    }

    .flatpickr-days {
        width: 100% !important;
    }

    /* 3. Thu nhỏ từng ô ngày để giảm chiều cao tổng */
    .dayContainer {
        width: 100% !important;
        min-width: unset !important;
        max-width: unset !important;
    }

    .flatpickr-day {
        max-width: 14.28% !important;
        /* Chia đều 7 cột */
        height: 36px !important;
        line-height: 36px !important;
        margin: 0 !important;
    }

    /* 4. Loại bỏ animation mở để tránh cảm giác to rồi thu lại */
    .flatpickr-calendar.animate.open {
        animation: none !important;
    }

    /* Revenue segment chart */
    #chart1Container {
        width: 100% !important;
    }

    #chart1Section>div:last-child {
        height: 280px !important;
    }

    /* Scrollbar thinner on mobile */
    ::-webkit-scrollbar {
        width: 4px;
    }
}

/* ============================================================
   VERY SMALL SCREENS (≤ 375px — iPhone SE)
   ============================================================ */
@media (max-width: 375px) {
    .layout-left {
        grid-template-columns: 1fr;
    }

    .card--col-2 {
        grid-column: span 1;
    }

    .detail-card {
        grid-column: span 1;
    }

    .mobile-logo {
        font-size: 14px;
    }

    .big {
        font-size: 16px;
    }
}

/* ============================================================
   STWINES VIEW
   ============================================================ */
#stwinesView {
    padding: 15px 0;
}

#stwinesView .card {
    min-height: 0;
}

#stwinesDetailSection {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

#stwinesDetailSection::-webkit-scrollbar {
    width: 6px;
}

#stwinesDetailSection::-webkit-scrollbar-thumb {
    background: rgba(71, 196, 250, 0.3);
    border-radius: 10px;
}

#stwinesDetailSection::-webkit-scrollbar-track {
    background: transparent;
}

#stwinesSearch:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 10px var(--accent-glow);
}

#stwinesThead tr th {
    white-space: nowrap;
    font-size: 11px;
    letter-spacing: 0.5px;
}

#stwinesTbody tr:hover {
    background: rgba(71, 196, 250, 0.05);
}