:root {
    --primary-green: #10B981;
    --dark-green: #059669;
    --bg-green: #f0fdf4;
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    background: #f8fafc;
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    color: var(--text-dark);
}

.header-green {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    padding: 2rem 1rem 6rem;
    color: white;
}

.main-content {
    margin-top: -5rem;
    padding-bottom: 3rem;
}

.summary-compact-row {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-md);
}

.summary-compact-row .label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.summary-compact-row .value {
    font-weight: 700;
    font-size: 0.95rem;
    margin-left: 5px;
}

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-top: 1rem;
    margin-bottom: 2rem;
    overflow: hidden;
}

.month-section {
    padding-top: 1.5rem;
}

.month-selector-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

.month-selector-title i {
    color: var(--primary-green);
}

.table-responsive {
    overflow-x: auto;
    /* Hide native scrollbar to prevent double scroll at bottom */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE 10+ */
}

.table-responsive::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
}

table th,
table td {
    white-space: nowrap;
}

thead th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 20;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.sticky-col {
    position: sticky;
    z-index: 10;
    background: inherit;
}

/* Fix: Top-left sticky headers should have highest priority */
thead th.sticky-col {
    z-index: 30;
}

.col-shop-id {
    left: 0;
    min-width: 80px;
}

.col-shop-name {
    left: 80px;
    min-width: 280px;
}

.col-store-type {
    left: 360px;
    min-width: 100px;
}

.col-sales {
    left: 460px;
    min-width: 110px;
    text-align: right;
    color: var(--primary-green);
    font-weight: 700;
}

.col-debt {
    left: 570px;
    min-width: 100px;
    text-align: right;
}

.col-due {
    left: 670px;
    min-width: 100px;
    text-align: right;
}

.col-planned {
    left: 770px;
    min-width: 105px;
    text-align: right;
}

.col-actual {
    left: 875px;
    min-width: 95px;
    text-align: right;
    color: var(--dark-green);
    background: inherit;
}

.summary-row-total {
    background-color: #f0fdf4 !important;
    /* Greenish/Mint */
    font-weight: 800 !important;
    font-size: 0.8rem !important;
}

.summary-row-total .sticky-col {
    background-color: #f0fdf4 !important;
}

.summary-row-statement {
    background-color: #fff !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
}

.summary-row-statement .sticky-col {
    background-color: #fff !important;
}

.summary-row-statement .col-actual,
.summary-row-statement .text-actual {
    color: var(--primary-green) !important;
}

.text-pending {
    color: #818cf8 !important;
    /* Indigo/Purple for Pending Orders */
}

.text-deduction {
    color: #e11d48 !important;
    /* Rose-600 (Reddish) */
    font-size: 0.625rem !important;
    font-weight: 500;
}


.category-row .sticky-col {
    background: #f8fafc !important;
}

.category-row:hover {
    background: #f1f5f9;
}

.pointer-link {
    cursor: pointer;
    transition: color 0.2s;
}

.pointer-link:hover {
    color: #059669 !important;
    text-decoration: underline !important;
}

.actual-val {
    font-size: 0.75rem;
    color: #059669;
    font-weight: 600;
}

/* Modal Styling */
#imagePreviewContainer {
    border: 2px dashed #ddd;
    padding: 10px;
    border-radius: 8px;
    background: #f9f9f9;
}

#imagePreview {
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

.btn-xs {
    padding: 1px 5px;
    font-size: 0.75rem;
}

.shop-row .sticky-col {
    background: white !important;
}

.col-debt:hover {
    background-color: rgba(220, 53, 69, 0.1) !important;
}

.shop-row .sticky-col {
    background: white !important;
}

#planningTable {
    table-layout: fixed;
    width: max-content;
}

.day-header-main {
    padding: 0.2rem 0 !important;
    border-left: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    width: 140px;
    min-width: 140px;
}

.day-num {
    font-size: 0.85rem;
    font-weight: 800;
    line-height: 1.2;
}

.day-name {
    font-size: 0.55rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.sub-header-cell {
    font-size: 0.65rem !important;
    padding: 0.25rem 0 !important;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0 !important;
    border-bottom: 2px solid #e2e8f0 !important;
    width: 70px;
    min-width: 70px;
    font-weight: 700;
    text-align: center;
}

.day-sat {
    background-color: #fef9c3 !important;
    /* Amber-100 */
    color: #a16207 !important;
    /* Amber-700 */
}

.day-sun {
    background-color: #fee2e2 !important;
    /* Red-100 */
    color: #b91c1c !important;
    /* Red-700 */
}

.day-sat .day-name,
.day-sun .day-name {
    color: inherit;
    opacity: 0.7;
}

.cell-plan,
.cell-actual,
.cell-daily {
    width: 70px;
    min-width: 70px;
    border-left: 1px solid #f1f5f9 !important;
    text-align: right;
}

.cell-actual {
    border-right: 1px solid #e2e8f0 !important;
}

.category-row {
    background: #f8fafc;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
}

.category-row .sticky-col {
    background: #f8fafc !important;
}

.category-row:hover {
    background: #f1f5f9;
}

.shop-row td {
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    border-bottom: 1px solid #f1f5f9;
}

.cell-daily {
    transition: all 0.2s;
}

.cell-daily:hover {
    background-color: rgba(16, 185, 129, 0.1) !important;
    cursor: pointer;
}

.cell-daily .actual-val {
    font-size: 0.7rem;
    color: var(--dark-green);
    display: block;
    margin-top: 2px;
}

.btn-green {
    background: var(--primary-green);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-green:hover {
    background: var(--dark-green);
    color: white;
}

.badge-count {
    background: #e5e7eb;
    color: #4b5563;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    margin-left: 8px;
}

.floating-scroller {
    overflow-x: auto;
    overflow-y: hidden;
    position: fixed;
    bottom: 0;
    left: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    background: #fff;
    border: 2px solid var(--primary-green);
    border-bottom: none;
    display: none;
    height: 18px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px 8px 0 0;
}

#floatingScrollerContent {
    height: 1px;
    pointer-events: none;
}

.original-plan-hint {
    font-size: 0.6rem;
    color: #6c757d;
    font-weight: normal;
    margin-top: -2px;
}

.text-warning {
    color: #f39c12 !important;
}

.bg-unconfirmed {
    background-color: rgba(243, 156, 18, 0.05) !important;
}

/* Dashboard Legend */
.dashboard-legend {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 2rem;
}

.legend-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-dark);
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 10px;
    margin-top: 3px;
    flex-shrink: 0;
}

.legend-text {
    font-size: 0.75rem;
    line-height: 1.4;
}

.legend-label {
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

.legend-desc {
    color: var(--text-muted);
}

/* Tablet Optimization (iPad) */
@media screen and (max-width: 1250px) {
    .header-green {
        padding: 1.5rem 1rem 4rem;
    }

    .main-content {
        margin-top: -3rem;
    }

    .summary-compact-row {
        gap: 0.8rem !important;
        padding: 0.4rem 0.6rem;
    }

    /* Filters Header - Vertically stack on tablet but maintain space */
    .table-container .row>div {
        display: flex;
        justify-content: center !important;
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .d-flex.align-items-center.flex-wrap {
        justify-content: center !important;
        gap: 0.75rem !important;
    }

    /* RESTORE ORIGINAL TABLE WIDTHS - No more squeezing */
    #planningTable {
        width: max-content !important;
        table-layout: auto !important;
        /* Allow natural growth */
    }

    .col-shop-id {
        min-width: 80px !important;
    }

    .col-shop-name {
        left: 80px !important;
        min-width: 280px !important;
        max-width: none !important;
    }

    .col-store-type {
        left: 360px !important;
        min-width: 100px !important;
    }

    .col-sales {
        left: 460px !important;
        min-width: 110px !important;
    }

    .col-debt {
        left: 570px !important;
        min-width: 100px !important;
    }

    .col-due {
        left: 670px !important;
        min-width: 100px !important;
    }

    .col-planned {
        left: 770px !important;
        min-width: 105px !important;
    }

    .col-actual {
        left: 875px !important;
        min-width: 95px !important;
    }

    .day-header-main {
        width: 140px !important;
        min-width: 140px !important;
    }

    .sub-header-cell,
    .cell-plan,
    .cell-actual,
    .cell-daily {
        width: 70px !important;
        min-width: 70px !important;
    }

    .shop-row td {
        font-size: 0.75rem;
    }

    .day-num {
        font-size: 0.8rem;
    }

    .day-name {
        font-size: 0.5rem;
    }

    #currentMonthYear {
        font-size: 1rem !important;
    }
}