body { font-family: Arial, sans-serif; max-width: 1000px; margin: 0 auto; padding: 0 20px 20px 20px; background: #f5f5f5; }
html { overflow-x: hidden; overflow-y: scroll; }
h1 {
    text-align: center;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 36px;
    font-weight: bold;
    color: #ffffff;
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    padding: 20px;
    margin: 0 -20px 25px -20px;
    border-radius: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9em;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    max-width: 90vw;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.success { background: #4CAF50; }
.toast.error { background: #f44336; }
.toast.info { background: #2196F3; }

/* ═══════════════════════════════════════════╗
 *  FOLDER TABS WITH OVERLAPPING CORNERS       ║
 *  ═══════════════════════════════════════════╝ */
.tab {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 12px;
}

.tab button {
    background: #cfcfcf;
    border: 1px solid #bbb;
    border-bottom: 1px solid #ccc;
    border-radius: 8px 8px 0 0;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: -8px;
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}

.tab button:first-child {
    margin-left: 0;
}

.tab button:last-child {
    margin-right: 0;
}

/* ACTIVE TAB - ON TOP, BLENDS, NO HARD CORNERS */
.tab button.active {
    background: #fff;
    border: 1px solid #ccc;
    border-bottom: 1px solid #fff;
    color: #333;
    z-index: 3;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.tab button:hover:not(.active) {
    background: #d9d9d9;
}

/* TAB CONTENT - MATCHES ACTIVE TAB BACKGROUND */
.tabcontent {
    display: none;
    background: #fff;
    padding: 10px 20px 20px 20px;
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #ccc;
    border-top: none;
    margin-bottom: 20px;
    z-index: 1;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* ═══════════════════════════════════════════╗
 *  MOBILE ADAPTATION (768px AND BELOW)        ║
 *  ═══════════════════════════════════════════╝ */
@media (max-width: 768px) {
    .tab button {
        padding: 10px 16px;
        font-size: 13px;
        margin-right: -5px;
        border-radius: 6px 6px 0 0;
    }
}

/* Even tighter on phones */
@media (max-width: 480px) {
    .tab button {
        padding: 8px 12px;
        font-size: 12px;
        margin-right: -3px;
        border-radius: 4px 4px 0 0;
    }
}

.corvus-banner-title {
    background: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: Verdana, Geneva, sans-serif !important;
    font-size: 36px !important;
    font-weight: bold !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
}

/* Mobile: smaller banner, smaller title */
@media (max-width: 768px) {
    .corvus-banner {
        padding: 15px !important;
        margin-left: -10px !important;
        margin-right: -10px !important;
    }
    .corvus-banner-title {
        font-size: 24px !important;
    }
    .corvus-banner-buttons {
        right: 15px !important;
    }
}

/* Corvus icon positioning */
#corvusIconImg {
width: 42px !important;
height: 42px !important;
border-radius: 50%;
object-fit: cover;
top: 50%;
transform: translateY(-50%);
left: 15px;
}

@media (max-width: 768px) {
    #corvusIconImg {
    left: 10px;
    }
}

@media (max-width: 480px) {
    #corvusIconImg {
    left: 8px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .corvus-banner-title {
        font-size: 20px !important;
    }
}

/* Mobile: Allow headers to wrap if too crowded */
@media (max-width: 480px) {
    .tabcontent > div[style*="justify-content:space-between"] {
        flex-wrap: wrap !important;
    }

    .tabcontent h2 {
        font-size: 1.3em !important;
    }

    .tab-tutorial-btn {
        font-size: 1.1em !important;
    }

    #terminalFilter {
    font-size: 0.75em !important;
    padding: 4px 8px !important;
    }
}

/* ═══════════════════════════════════════════╗
 *  DARK MODE COMPATIBILITY                     ║
 *  ═══════════════════════════════════════════╝ */
body.dark-mode .tab button {
    background: #444;
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .tab button.active {
    background: #2d2d2d;
    border-color: #444;
    border-bottom: 1px solid #2d2d2d;
    color: #4CAF50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

body.dark-mode .tab button:hover:not(.active) {
    background: #505050;
}

body.dark-mode .tabcontent {
    background: #2d2d2d;
    border-color: #444;
}

body.dark-mode #editTankBox {
    background: #2d2d2d !important;
    color: #e0e0e0 !important;
}

body.dark-mode #editTankBox h3 {
    color: #e0e0e0 !important;
}

body.dark-mode #editTankBox input[disabled] {
    background: #444 !important;
    color: #aaa !important;
    border: 1px solid #666 !important;
}

body.dark-mode #clearStoreSearch {
    color: #aaa !important;
}

body.dark-mode .manifold, body.dark-mode .tank-block {
    background-color: #2d2d2d;
    border-color: #444;
}

button { background: #4CAF50; color: white; border: none; border-radius: 4px; padding: 8px 12px; cursor: pointer; }
button:hover { background: #45a049; }
.btn-small { font-size: 0.8em; padding: 4px 8px; }
/* Edit tank button in delivery tab */
.tank-block button {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75em;
    cursor: pointer;
}

.tank-block button:hover {
    background: #1976d2;
}

.manifold button {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75em;
    cursor: pointer;
}

.manifold button:hover {
    background: #1976d2;
}

.result { background: #e8f5e9; padding: 15px; border-radius: 6px; margin-top: 10px; }
.manifold { background: #fff8e1; border-left: 5px solid #ffc107; padding: 10px 0 10px 15px; border-radius: 4px; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: center; }
th { background: #4CAF50; color: white; }
/* OLD: Removed — #chartTable no longer exists, tables are created dynamically */
#chartSelect { max-width: 340px; }
.cap-safe { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; border-radius: 4px; padding: 4px 10px; font-weight: bold; display: inline-block; margin-top: 4px; }
.cap-warn { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; border-radius: 4px; padding: 4px 10px; font-weight: bold; display: inline-block; margin-top: 4px; }
.cap-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; border-radius: 4px; padding: 4px 10px; font-weight: bold; display: inline-block; margin-top: 4px; }
.tank-block { border: 1px solid #ccc; padding: 15px; margin: 12px 0; border-radius: 6px; }
.tank-header {
    display: block;
    padding: 0;
    margin: 0;
}
h2:first-child {
    margin-top: 0 !important;
}
.tank-header > div:first-child {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 4px;
}
.tank-header > div:first-child > span:first-child {
    flex-shrink: 0;
    margin-right: 8px;
    margin-left: 0;  /* Ensure up arrow starts at left edge */
}
.tank-header > div:first-child > div:nth-child(2) {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}
.tank-header > div:first-child > span:last-child {
    flex-shrink: 0;
    margin-left: auto;
}
.tank-header > div:first-child {
    margin-bottom: 8px;
}
.tank-header > div:last-child {
    margin-left: 0px;
    line-height: 1.4;
}

.store-card { border: 1px solid #ddd; border-radius: 6px; margin: 10px 0; overflow: hidden; }
.store-card-header { background: #f0f0f0; padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.store-card-body { padding: 10px 12px; display: none; }

/* Franchise grouping */
.franchise-card {
    margin: 20px 0;
    border-left: 2px solid #999;
    border-bottom: 2px solid #999;
    border-top: none;
    border-right: none;
    border-radius: 4px 4px 0 0;
    overflow: hidden;
}

.franchise-header {
    background: #f0f0f0;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.dark-mode .franchise-header {
    background: #383838;
}

.franchise-arrow {
    margin-right: 8px;
}

.franchise-body {
    display: none;
    padding: 10px;
    background: #fff;
}

body.dark-mode .franchise-body {
    background: #2d2d2d;
}

.franchise-card.open .franchise-body {
    display: block;
}
.store-card.open .store-card-body { display: block; }
.collapse-icon { font-size: 1.2em; font-weight: bold; display: inline-block; }
.chart-note { background: #e8f5e9; padding: 12px; border-radius: 6px; margin: 15px 0; border-left: 4px solid #4CAF50; font-size: 0.9em; }
optgroup { font-weight: bold; }
optgroup option { font-weight: normal; }
/* Dark mode styles */
body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .tabcontent {
    background: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

body.dark-mode th {
    background: #4CAF50;
    color: white;
}

body.dark-mode td {
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .result {
    background: #1e3a1e;
    color: #e0e0e0;
}

body.dark-mode .manifold {
    background: #3a3a1e;
    border-left-color: #ffc107;
    color: #e0e0e0;
}

body.dark-mode input, body.dark-mode select, body.dark-mode textarea {
    background: #444;
    color: #e0e0e0;
    border: 1px solid #666;
}

body.dark-mode select option {
    background: #444;
    color: #e0e0e0;
}

body.dark-mode select option:checked {
    background: #444;
    color: #e0e0e0;
}

body.dark-mode #storeSuggestionList {
    background: #2d2d2d !important;
    border: 1px solid #555 !important;
    border-top: none !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5) !important;
}

body.dark-mode #storeSuggestionList > div {
    color: #e0e0e0 !important;
    border-bottom: 1px solid #444 !important;
}

body.dark-mode #storeSuggestionList > div:hover {
    background: #3a3a3a !important;
}

body.dark-mode #deliveryStoreInput {
    background: #444 !important;
    color: #e0e0e0 !important;
    border: 1px solid #666 !important;
}

body.dark-mode button:not(#darkModeToggle):not(.tablinks) {
    background: #4CAF50;
    color: white;
}

body.dark-mode button:hover:not(#darkModeToggle):not(.tablinks) {
    background: #45a049;
}

body.dark-mode h1, body.dark-mode h2, body.dark-mode h3 {
    color: #e0e0e0;
}
body.dark-mode .chart-note {
    background: #1b3a1b;
    border-left-color: #4CAF50;
    color: #e0e0e0;
}

body.dark-mode .store-card {
    border-color: #555;
}

body.dark-mode .store-card-header {
    background: #383838;
    color: #e0e0e0;
}

body.dark-mode .store-card-body {
    color: #e0e0e0;
}

/* Dark mode — Import popup */
body.dark-mode .import-popup-box {
    background: #2d2d2d !important;
    color: #e0e0e0 !important;
}

body.dark-mode .import-popup-box p,
body.dark-mode .import-popup-box div {
    color: #e0e0e0;
}

body.dark-mode .import-popup-box hr {
    border-top: 1px solid #555 !important;
}

body.dark-mode .import-popup-box h3 {
    color: #e0e0e0;
}

body.dark-mode .tank-block {
    border-color: #555;
}

body.dark-mode .cap-safe {
    background: #1b4a1b;
    color: #81c784;
    border-color: #2e7d32;
}

body.dark-mode .cap-warn {
    background: #4a3a00;
    color: #ffd54f;
    border-color: #665500;
}

body.dark-mode .cap-danger {
    background: #4a1a1a;
    color: #ef9a9a;
    border-color: #c62828;
}

body.dark-mode span[onclick*="moveTank"] {
    color: #e0e0e0 !important;
}

body.dark-mode .delivery-live-gal > div,
body.dark-mode .manifold .delivery-live-gal > div,
body.dark-mode [id^="combined_curr_"] > div {
    background: #1b3a1b !important;
    border-color: #81c784 !important;
    color: #81c784 !important;
}

body.dark-mode .manifold .delivery-live-gal {
    color: #81c784 !important;
}

.delivery-live-gal {
    display: inline-block;
    margin: 2px 0;
}

/* PRODUCT BADGES */
.badge-87 {
    background: white;
    color: #000;
    border: 2px solid #000;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-89 {
    background: #4a90d9;
    color: white;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-93 {
    background: #d32f2f;
    color: white;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-90 {
    background: #d32f2f;
    color: white;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-ulsd-clear {
    background: #ffeb3b;
    color: #000;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-ulsd-dyed {
    background: #ffeb3b;
    color: #000;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-e85 {
    background: #8d6e63;
    color: white;
    font-weight: bold;
    border-radius: 50%;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
    font-size: 0.7em;
    line-height: 1;
}

.badge-vapor {
    background: #ff9800;
    color: #000;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-right: 4px;
}

.vapor-section {
    background: #ff9800;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #f57c00;
}

.vapor-section h4 {
    margin: 0;
    font-size: 0.9em;
    color: #000;
}

body.dark-mode .vapor-section {
    background: #ff9800 !important;
    border-color: #f57c00 !important;
}

body.dark-mode .vapor-section h4 {
    color: #000 !important;
}

body.dark-mode #finalResult div[style*="color:#1b5e20"],
body.dark-mode .store-card-body div[style*="color:#1b5e20"] {
    color: #66bb6a !important;
}

#deliveryStore {
font-size: 1.2em !important;
padding: 8px 12px !important;
}

/* Manage Stores - Tighter spacing, buttons centered */
@media (max-width: 480px) {
    /* Make the whole toolbar flex with reduced gaps */
    #storeList > div:first-of-type {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;  /* Reduced from 8px */
    justify-content: flex-start;
    }

    /* Keep the checkbox and label text on the same line */
    #storeList > div:first-of-type label {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    margin-right: 0;
    }

    /* Shrink action buttons with even tighter spacing */
    #storeList > div:first-of-type button[onclick^="exportSelected"],
    #storeList > div:first-of-type button[onclick^="deleteSelected"] {
    padding: 6px 8px !important;  /* Reduced padding */
    font-size: 0.8em;             /* Slightly smaller font */
    white-space: nowrap;
    margin-left: 0 !important;
    min-width: 70px;              /* Prevent buttons from getting too skinny */
    }
}
/* ════════════════════════════════════════════════
 *  RESPONSIVE DESIGN FOR PHONE SCREENS
 *  ════════════════════════════════════════════════ */

/* Ensure all containers fit within viewport */
* {
    box-sizing: border-box;
}

/* Page container adjustments */
body {
    padding-left: 10px;
    padding-right: 10px;
}

@media (max-width: 768px) {
    body {
        max-width: 100%;
        padding: 0 10px 20px 10px;
    }

    h1 {
        font-size: 24px;
        padding: 15px;
        margin: 0 -10px 20px -10px;
    }

    .tabcontent {
        padding: 10px 12px 20px 12px !important;
    }

    /* Chart dropdown — full width on mobile */
    #chartSelect {
    width: 100% !important;
    max-width: 100% !important;
    }

    /* OLD: Removed — #chartTable no longer exists, tables are created dynamically */


    /* ══════ FIX 1: TABS - Keep in single row with horizontal scroll ══════ */
    .tab {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        display: flex;
    }

    .tab button {
        flex-shrink: 0;
        flex-grow: 0;
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
        min-width: 100px;
    }

    .franchise-header {
        padding: 10px 12px;
        font-size: 0.95em;
    }

    .franchise-body {
        padding: 5px;
    }

    /* FIX 2: HEADERS - Keep collapse icons on the same line, aligned right */
    /* Store card headers: nowrap keeps collapse icon on the right */
    .store-card-header {
        flex-wrap: nowrap !important;
        align-items: center;
        display: flex;
    }

    /* Tank headers: ALLOW wrapping so chart name and capacity info
     *  can flow to a second line cleanly */
    /* Row 1: arrows always on opposite ends */
    .tank-header > div:first-child {
        flex-wrap: wrap;
        margin-bottom: 8px;
    }
    .tank-header > div:first-child > span:first-child {
        flex-shrink: 0;
    }
    .tank-header > div:first-child > div:nth-child(2) {
        flex: 1;
        min-width: 0;
    }
    .tank-header > div:first-child > span:last-child {
        flex-shrink: 0;
        margin-left: auto;
    }
    .tank-header > div:last-child {
        margin-left: 0px;
        font-size: 0.95em;
        line-height: 1.4;
    }

    /* Collapse icon stays in header line */
    .collapse-icon {
        margin-left: 10px !important;
        margin-top: 0 !important;
        min-width: 24px;
        text-align: center;
        flex-shrink: 0;
    }

    /* Store card collapse icon specifically - force to far right */
    .store-card-header .collapse-icon {
        margin-left: auto !important;
    }

    /* Buttons in headers - smaller on mobile */
    .btn-small {
        padding: 4px 8px !important;
        font-size: 0.75em !important;
        margin-left: 2px !important;
        margin-top: 0 !important;
    }

    /* Inputs and selects - full width on mobile (Manage tab only) */
    #Stores input[type="text"],
    #Stores input[type="number"],
    #Stores select {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 8px;
    }

    #Stores div[style*="max-width:340px"],
    #Stores div[style*="max-width: 340px"] {
    max-width: 100% !important;
    }

    /* Remove max-width caps on Delivery tab containers for mobile */
    #Delivery div[style*="max-width:340px"],
    #Delivery div[style*="max-width: 340px"] {
    max-width: 100% !important;
    }
}

/* Override full-width for silo ft/in inputs — keep them on same row */
input[id^="arr_ft_"], input[id^="arr_in_"] {
    width: 65px !important;
    max-width: 65px !important;
    margin-bottom: 0 !important;
    margin-right: 6px !important;
    display: inline-block !important;
}

/* Tables - horizontal scroll if too wide */
table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
}

/* Tank/block content - tighter spacing */
.tank-block,
.manifold {
    padding: 12px;
    margin: 8px 0;
}

/* Input labels - prevent overflow */
label {
    word-break: break-word;
}

/* Toast notifications - wider on small screens */
.toast {
    max-width: 95vw;
    padding: 10px 16px;
    font-size: 0.85em;
}

/* Make move arrows easier to tap */
.tank-move-arrow {
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Checkbox and radio buttons - larger tap targets */
input[type="checkbox"],
input[type="radio"] {
    transform: scale(1.2);
    margin-right: 8px;
}



/* Close/delete buttons - bigger hit area */
span[onclick*="removeTank"],
span[onclick*="removeStore"] {
    min-width: 30px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    #Stores button:not(.tab-tutorial-btn) {
    padding: 4px 8px !important;
    font-size: 0.75em !important;
    }
}

@media (max-width: 480px) {
    #Stores button:not(.tab-tutorial-btn) {
    padding: 3px 6px !important;
    font-size: 0.7em !important;
    }
    #Stores label strong {
    font-size: 0.75em;
    }
}

/* Extra small screens (iPhone SE, older phones) */
@media (max-width: 480px) {
    h1 {
        font-size: 20px;
    }

    .tabcontent {
        padding: 10px 8px 20px 8px !important;
    }

    .tab button {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 90px;
    }

    .tank-block,
    .manifold {
        padding: 10px;
    }

    /* Make badges more compact */
    .badge-87,
    .badge-89,
    .badge-93,
    .badge-90,
    .badge-ulsd-clear,
    .badge-ulsd-dyed,
    .badge-e85 {
        width: 14px;
        height: 14px;
        font-size: 0.6em;
        margin-right: 3px;
    }

    /* Results section - smaller text */
    .result,
    .cap-safe,
    .cap-warn,
    .cap-danger {
        font-size: 0.9em;
        padding: 8px;
    }

    /* Delivery live gallons boxes - compact */
    .delivery-live-gal > div {
        font-size: 0.95em !important;
        padding: 3px 8px !important;
    }
}

.tabcontent h2 {
    margin-top: 8px !important;
    margin-bottom: 15px !important;
}

/* Terminal filter — keep inline on small screens */
/* Terminal filter — keep inline on small screens */
@media (max-width: 480px) {
    #terminalFilter {
    min-width: 75px;
    max-width: 100px;
    padding: 4px 8px !important;
    font-size: 0.8em !important;
    }
}

/* Store card header — badge + arrow anchored right */
.store-card-header {
    flex-wrap: wrap !important;
    align-items: center;
    justify-content: space-between;
}

/* === FIX: Store info text wrapping alignment === */
.name-container {
    display: block;
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.name-container .store-num {
    white-space: normal;
}

.store-card-header .header-left {
    display: flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
    gap: 4px;
}

.store-card-header .header-left .store-num {
    flex-shrink: 0;
    white-space: nowrap;
}

.store-card-header .header-left .store-info {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.store-card-header .header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 12px;
}

.store-card-header .terminal-badge {
    background: #9e9e9e;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: bold;
    white-space: nowrap;
}

body.dark-mode .store-card-header .terminal-badge {
    background: #666;
    color: #e0e0e0;
}

/* Terminal dropdowns inside store cards — fixed width */
#Stores select[id^="terminal_"] {
min-width: 180px !important;
width: 180px !important;
max-width: 180px !important;
box-sizing: border-box !important;
margin-bottom: 0;
}

/* Franchise dropdowns inside store cards — match terminal width */
#Stores select[id^="franchise_"] {
min-width: 180px !important;
width: 180px !important;
max-width: 180px !important;
box-sizing: border-box !important;
margin-bottom: 0;
}

/* Manage tab terminal filter — don't stretch full width */
#manageTerminalFilter {
width: auto !important;
max-width: 150px;
margin-bottom: 0;
}

/* Dark mode — Delivery tab terminal filter */
body.dark-mode #terminalFilter {
    background: #444 !important;
    color: #e0e0e0 !important;
    border: 1px solid #666 !important;
}

/* Dark mode — Manage tab terminal filter */
body.dark-mode #manageTerminalFilter {
    background: #444;
    color: #e0e0e0;
    border: 1px solid #666;
}

/* Dark mode — Terminal dropdowns inside store cards */
body.dark-mode select[id^="terminal_"] {
    background: #444;
    color: #e0e0e0;
    border: 1px solid #666;
}

/* Dark mode — Franchise dropdowns inside store cards */
body.dark-mode select[id^="franchise_"] {
    background: #444;
    color: #e0e0e0;
    border: 1px solid #666;
}

/* Landscape mode on phones */
@media (max-width: 768px) and (orientation: landscape) {
    .tabcontent {
        padding: 10px;
    }

    /* Shorten tall elements */
    textarea {
        max-height: 100px;
        font-size: 0.9em;
    }

    .store-card-body {
        max-height: 50vh;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    /* Store cards fill container on mobile */
    .store-card {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Reclaim horizontal space inside franchise bodies on mobile */
    .franchise-body {
        padding: 5px 4px;
    }

    .franchise-body .store-card {
        margin: 6px 0;
    }

    /* L-shape border — thicker/darker on mobile for visibility */
    .franchise-card {
        border-left: 3px solid #666;
        border-bottom: 3px solid #666;
        border-top: none !important;
        border-right: none !important;
        border-radius: 4px 4px 0 0;
        margin-top: 15px;
        margin-bottom: 15px;
    }

    /* Store cards keep normal borders inside */
    .store-card {
        border: 1px solid #eee;
        border-radius: 6px;
    }
}

/* Ensure modal/import dialogs work on small screens */
@media (max-width: 480px) {
    div[style*="fixed"] > div {
        max-width: 90vw !important;
        max-height: 90vh !important;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    #History button:not(.history-tool-btn):not(.tab-tutorial-btn) {
    padding: 4px 8px !important;
    font-size: 0.75em !important;
    }
}

@media (max-width: 480px) {
    #History button:not(.history-tool-btn):not(.tab-tutorial-btn) {
    padding: 3px 6px !important;
    font-size: 0.7em !important;
    }
    #History label strong {
    font-size: 0.75em;
    }

    /* Even tighter franchise padding on smallest phones */
    .franchise-body {
        padding: 4px 2px;
    }

    .franchise-body .store-card {
        margin: 5px 0;
    }
}

/* ═══════════════════════════════════════════╗
 *  DESKTOP DUAL-COLUMN LAYOUT (1024px+)       ║
 *  ═══════════════════════════════════════════╝ */
@media (min-width: 1024px) {
    .manage-layout {
        display: grid;
        grid-template-columns: 340px 1fr;
        gap: 25px;
        align-items: start;
    }

    .manage-tools {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        padding-right: 10px;
    }

    /* Override inline max-widths so forms fill the column */
    .manage-tools > div[style*="max-width:340px"],
    .manage-tools > div[style*="max-width: 340px"] {
        max-width: 100% !important;
    }

    .manage-tools input[type="text"],
    .manage-tools input[type="number"],
    .manage-tools select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Store list takes full right column width */
    .manage-store-list {
        min-width: 0;
    }

    /* Section headers in tools column get tighter spacing */
    .manage-tools h3 {
        margin-top: 20px;
    }

    /* Custom scrollbar for the tools column */
    .manage-tools::-webkit-scrollbar {
        width: 6px;
    }
    .manage-tools::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 3px;
    }
    .manage-tools::-webkit-scrollbar-track {
        background: transparent;
    }

    body.dark-mode .manage-tools::-webkit-scrollbar-thumb {
        background: #555;
    }
}

/* Mobile: revert to single column */
@media (max-width: 1023px) {
    .manage-layout {
        display: block;
    }
    .manage-tools {
        position: static;
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
}
/* ═══════════════════════════════════════╗
 *  DELIVERY TAB DUAL-COLUMN LAYOUT        ║
 *  ═══════════════════════════════════════╝ */

@media (min-width: 1024px) {
    .delivery-layout {
        display: grid;
        grid-template-columns: 380px 1fr;
        gap: 25px;
        align-items: start;
    }

    .delivery-tools {
        position: sticky;
        top: 20px;
        padding-right: 10px;
    }

    /* Override inline max-widths so forms fill the column */
    .delivery-tools > div[style*="max-width:340px"],
    .delivery-tools > div[style*="max-width: 340px"] {
        max-width: 100% !important;
    }

    .delivery-tools input[type="text"],
    .delivery-tools input[type="number"],
    .delivery-tools select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Results take full right column width */
    .delivery-results {
        min-width: 0;
    }

    /* Custom scrollbar for tools column */
    .delivery-tools::-webkit-scrollbar {
        width: 6px;
    }
    .delivery-tools::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 3px;
    }
    .delivery-tools::-webkit-scrollbar-track {
        background: transparent;
    }

    body.dark-mode .delivery-tools::-webkit-scrollbar-thumb {
        background: #555;
    }
}

/* Mobile: revert to single column */
@media (max-width: 1023px) {
    .delivery-layout {
        display: block;
    }
    .delivery-tools {
        position: static;
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
}

/* ── CHARTS TAB LAYOUT ── */

#chartsContainer {
display: flex;
flex-direction: column;
gap: 10px;
padding: 0;
box-sizing: border-box;
}

/* Mobile: one column (default) */

/* Tablet+: multi-column */
@media (min-width: 768px) {
    #chartsContainer {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    }

    .chart-column {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
        box-sizing: border-box;
    }

    body.dark-mode .chart-column {
        background: transparent;
        border: none;
        box-shadow: none;
    }
}

/* Override global table rules INSIDE charts container only */
#chartsContainer table {
display: table !important;
overflow: visible !important;
width: 100% !important;
margin: 0 !important;
}

#chartsContainer .chart-table {
width: auto;
border-collapse: collapse;
margin: 0;
}

#chartsContainer .chart-table th,
#chartsContainer .chart-table td {
border: 1px solid #ddd;
padding: 2px 10px;
text-align: center;  /* This keeps both columns centered */
white-space: nowrap;
}

#chartsContainer .chart-table td:first-child {
text-align: center;
}

#chartsContainer .chart-table td:last-child {
text-align: center;
}

body.dark-mode #chartsContainer .chart-table th,
body.dark-mode #chartsContainer .chart-table td {
    border-color: #555;
    background: transparent;
    color: #e0e0e0;
}

/* ═══════════════════════════════════════════╗
 *  CHART COLUMN DIVIDERS                     ║
 *  ═══════════════════════════════════════════╝ */

.charts-grid {
    border-left: 2px solid #ccc;
}

/* Light mode — subtle warm gradient on the right edge */
.chart-col-wrapper {
    border-right: 2px solid #ccc;
    background: linear-gradient(to right, #fff 92%, #f0f0f0 92%);
}

/* Dark mode — cooler tones, easy on the eyes */
body.dark-mode .charts-grid {
    border-left: 2px solid #555;
}

body.dark-mode .chart-col-wrapper {
    border-right: 2px solid #555;
    background: linear-gradient(to right, #2d2d2d 92%, #222 92%);
}
#manifoldSlider {
    transition: background 0.3s ease;
}
#manifoldKnob {
    transition: transform 0.3s ease;
}
/* Sync Charts button — black/blue theme */
.sync-charts-btn {
    background: #000 !important;
    color: #4a90d9 !important;
    border: 2px solid #4a90d9 !important;
}
.sync-charts-btn:hover {
    background: #000 !important;
    color: #74b1ff !important;
    border-color: #74b1ff !important;
}

/* Dark mode */
body.dark-mode .sync-charts-btn {
    background: #111 !important;
}
body.dark-mode .sync-charts-btn:hover {
    background: #1a1a2e !important;
}
/* Light mode — green headers */
.chart-col-header {
    padding: 8px 12px;
    border-bottom: 2px solid #388E3C;
    font-weight: bold;
    text-align: center;
    background: #4CAF50;
    color: white;
}

/* Dark mode — green headers (slightly brighter for contrast) */
body.dark-mode .chart-col-header {
    padding: 8px 12px;
    border-bottom: 2px solid #2E7D32;
    font-weight: bold;
    text-align: center;
    background: #4CAF50;
    color: white;
}

/* ═════════════════════════════════════════════
 *  TUTORIAL SYSTEM STYLES
 *  ═════════════════════════════════════════════ */
/* Tutorial info button */
.tab-tutorial-btn {
    background: none !important;
    border: none !important;
    font-size: 1.3em !important;
    padding: 0 !important;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    flex-shrink: 0;
}
.tab-tutorial-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}
body.dark-mode .tab-tutorial-btn {
    color: #aaa;
}
body.dark-mode .tab-tutorial-btn:hover {
    color: #fff;
}

/* Dark mode — welcome overlay */
body.dark-mode #tutorialWelcomeOverlay > div {
    background: #2d2d2d !important;
    color: #e0e0e0 !important;
}
body.dark-mode #tutorialWelcomeOverlay h3 {
    color: #4CAF50 !important;
}

/* Dark mode — progress pill */
body.dark-mode #tutorialProgress {
    background: rgba(0,0,0,0.8) !important;
}

/* Dark mode — close button */
body.dark-mode #tutorialCloseBtn {
    color: #aaa !important;
}
body.dark-mode #tutorialCloseBtn:hover {
    color: #f44336 !important;
}
/* Welcome overlay */
#tutorialWelcomeOverlay {
    backdrop-filter: blur(3px);
    animation: tutorialFadeIn 0.3s ease;
}
@keyframes tutorialFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Spotlight overlay */
#tutorialOverlay {
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#tutorialOverlay.hidden {
    opacity: 0;
}

/* Callout box */
#tutorialCallout {
    pointer-events: auto;
    animation: calloutSlideIn 0.3s ease;
    max-height: 60vh;
    overflow-y: auto;
}
@keyframes calloutSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Progress pill */
#tutorialProgress {
    font-family: Arial, sans-serif;
    font-weight: bold;
    animation: tutorialPulse 2s infinite;
}
@keyframes tutorialPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Dark mode callout */
body.dark-mode #tutorialCallout {
    background: #2d2d2d !important;
    color: #e0e0e0 !important;
    border-color: #4CAF50 !important;
}
body.dark-mode #tutorialArrow {
    background: #4CAF50 !important;
}

/* Close button styling */
#tutorialCloseBtn {
    background: transparent;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
}
#tutorialCloseBtn:hover {
    color: #f44336;
}

/* Prevent iOS auto-zoom on input focus */
input[type="text"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="email"],
textarea,
select {
    font-size: 16px;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="email"],
    textarea,
    select {
        font-size: 14px;
    }
}

/* Larger sun/moon emoji inside dark mode toggle */
#darkModeToggle {
font-size: 22px !important;
}
