body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    color: #333;
}

.main-nav {
    background-color: #0066CC;
    padding: 0 20px;
    display: flex;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-link {
    color: white;
    padding: 15px 20px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.nav-link:hover {
    background-color: #0052a3;
}

.nav-link.active {
    background-color: #004499;
    border-bottom: 3px solid #66b3ff;
}

main#app-content {
    padding: 30px;
    max-width: 900px;
    margin: 20px auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page h2 {
    color: #0066CC;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 10px;
}

.hidden {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    border: 1px solid #dee2e6;
    padding: 12px;
    text-align: center;
    min-width: 80px;
}

th {
    background-color: #f8f9fa;
}

input[type="number"] {
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100px;
    box-sizing: border-box;
}

.controls, .controls-grid {
    margin-bottom: 20px;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
}

.checkbox-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

.action-buttons {
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
}

.action-buttons.full-width {
    grid-column: 1 / -1;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.copy-btn { background-color: #6c757d; }
.copy-btn:hover { background-color: #5a6268; }

.export-btn { background-color: #28a745; }
.export-btn:hover { background-color: #218838; }

.reset-btn { background-color: #dc3545; }
.reset-btn:hover { background-color: #c82333; }

.status-box {
    font-weight: bold;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid transparent;
}
.status-box.invalid {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}
.status-box.valid {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.input-error {
    border: 2px solid #dc3545 !important;
}

/* Barcode Plate Styles */
.plate-container {
    overflow-x: auto;
}
.plate-table {
    border: 2px solid #333;
}
.plate-table td {
    width: 70px;
    height: 50px;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
}
.plate-table td:hover {
    background-color: #e3f2fd;
}

/* Settings Page Styles */
.settings-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 15px;
    align-items: center;
    max-width: 500px;
}

.global-controls {
    background-color: #f8f9fa;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 10px;
}

.global-controls label {
    font-weight: bold;
}

#barcodes-page {
    max-width: 1200px;
}

main.wide-mode {
    max-width: 95vw; 
}

.plate-table {
    table-layout: fixed;
    border: 2px solid #333;
}

.plate-table td {
    height: 45px;
    font-size: 11px;
    padding: 2px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.plate-table td.selected {
    background-color: #007bff;
    color: white;
    box-shadow: inset 0 0 0 2px #0056b3;
}

.context-menu {
    position: absolute;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-radius: 4px;
    padding: 5px 0;
    z-index: 1000;
}

.context-menu-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
}

.context-menu-item:hover {
    background-color: #007bff;
    color: white;
}
.hidden {
    display: none;
}

@media (max-width: 768px) {

    /* 1. NAV BAR FIX
      Forces the flex items (your nav links) to wrap to new lines 
      when they run out of space.
    */
    .main-nav {
        flex-wrap: wrap;
    }

    /* Gives the nav links a bit less padding on mobile to help them fit better */
    .nav-link {
        padding: 12px 10px;
    }

    /* 2. CALCULATOR CONTROLS FIX
      This is the key fix. We change the two-column grid 
      into a single-column grid so the control boxes stack vertically.
    */
    .controls-grid {
        grid-template-columns: 1fr; /* Stacks to 1 column */
    }

    /* 3. SETTINGS PAGE FIX
      Stacks the settings grid to 1 column as well.
    */
    .settings-grid {
        grid-template-columns: 1fr;
    }

    /* 4. TABLE SCROLLING FIX (Kept from before)
      Ensures any wide tables (like Barcodes or calculators)
      don't stretch the page, but scroll horizontally instead.
    */
    #conversion-page table,
    #circ-dig-page table,
    #dnb-standard-page table,
    #dnb-onestep-page table,
    #pooling-page table,
    .plate-container {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}/* Added: Number of Samples +/- controls + auto-save hint */
.num-samples-wrap{display:flex;align-items:center;gap:8px;}
.num-btn{width:32px;height:32px;border-radius:8px;border:1px solid rgba(0,0,0,0.15);background:#fff;cursor:pointer;font-size:18px;line-height:1;}
.num-btn:active{transform:translateY(1px);}
.save-indicator{margin-left:12px;font-size:12px;opacity:0;transition:opacity .2s ease;}
.save-indicator.show{opacity:0.85;}
.mgi-error{margin-top:10px;padding:10px;border:1px solid #f5c6cb;background:#f8d7da;color:#721c24;border-radius:6px;font-size:13px;}
.setting-help{display:block;font-size:12px;opacity:.85;margin-top:6px;}