body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

h1 {
    margin-top: 0;
    text-align: center;
    color: #333;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: #666;
}

input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    width: 100%;
    padding: 0.75rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

button:hover {
    background-color: #0056b3;
}

.message {
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    display: none;
}

.message.success {
    display: block;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

p {
    text-align: center;
    margin-top: 1rem;
    color: #666;
}

/* Dashboard Styles */
.dashboard-container {
    width: 95%;
    max-width: 1400px;
    height: 95vh;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.developer-config {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.developer-config label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

nav button {
    width: auto;
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    background-color: #6c757d;
}

nav button:last-child {
    background-color: #dc3545;
}

/* Global Filters */
.global-filters {
    flex-shrink: 0;
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 2rem;
    align-items: center;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.global-filters .form-group {
    margin-bottom: 0;
}

.global-filters select, .global-filters input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.checkbox-label {
    font-size: 0.85rem;
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: normal;
    color: #666;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
}

.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.account-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    max-width: 640px;
}

.account-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.account-section h2 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
}

.account-section-header h2 { margin: 0; }

.account-table {
    width: 100%;
    border-collapse: collapse;
}

.account-table td {
    padding: 0.35rem 0.5rem 0.35rem 0;
    vertical-align: top;
}

.account-table td:first-child {
    color: #666;
    white-space: nowrap;
    width: 45%;
}

.account-table td:last-child {
    font-weight: 600;
}

.account-form .form-group { max-width: 320px; }

.table-container {
    flex: 1;
    overflow-y: auto;
    background: white;
    border: 1px solid #eee;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f8f9fa;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.stub-container {
    text-align: center;
    padding: 3rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ccc;
}

.filters {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
}

.form-group.inline {
    margin-bottom: 0;
}

.form-group.inline input, .form-group.inline select {
    width: 100px;
}

.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.filters button {
    width: auto;
    padding: 0.6rem 1.5rem;
}

/* Fuel Surcharge Styles */
.fuel-params {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.price-summary {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.price-box {
    flex: 1;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
}

.price-box strong {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.price-box span {
    font-size: 1.2rem;
    font-weight: bold;
}

.price-box small {
    color: #888;
}

.price-box.highlighted {
    background: #e9ecef;
    border-color: #adb5bd;
}

.fuel-tables {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    min-height: 0;
    padding-right: 0.5rem;
}

.table-section {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.table-section h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: #444;
    border-left: 4px solid #007bff;
    padding-left: 0.5rem;
}

.table-container.small {
    border: 1px solid #eee;
    background: white;
}

.toggle-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    line-height: 24px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.route-details {
    background-color: #fcfcfc;
}

.line-details {
    padding: 1rem 2rem;
}

.line-details table {
    font-size: 0.9rem;
    border: 1px solid #eee;
}

.line-details th {
    background-color: #f1f1f1;
}

.text-calculated {
    color: #0056b3;
    font-weight: bold;
    text-decoration: underline dotted;
}

.text-no-url {
    color: #dc3545;
    font-weight: bold;
}

.fuel-totals {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    margin-top: 1rem;
}

.total-item {
    font-size: 1rem;
    color: #666;
}

.total-item span {
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
    margin-left: 0.5rem;
}

.total-item.highlighted span {
    color: #28a745;
}

#routeTable select {
    padding: 0.25rem;
    width: auto;
}

/* =============================================
   Mobile Styles (max-width: 768px)
   ============================================= */
@media (max-width: 768px) {

    /* --- Layout foundation --- */
    body {
        align-items: flex-start;
        height: auto;
        min-height: 100vh;
        padding: 0;
    }

    .dashboard-container {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        padding: 0.75rem;
        overflow: visible;
        box-shadow: none;
    }

    main {
        overflow: visible;
        flex: none;
    }

    .tab-content {
        flex: none;
    }

    /* --- Header / nav stacking --- */
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    nav button {
        margin-left: 0;
        flex: 1 1 auto;
        min-width: 80px;
        padding: 0.6rem 0.5rem;
        font-size: 0.9rem;
    }

    /* --- Global filters wrapping --- */
    .global-filters {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .global-filters .form-group {
        flex: 1 1 120px;
    }

    .global-filters select,
    .global-filters input {
        width: 100%;
        padding: 0.6rem;
        font-size: 1rem;
    }

    /* --- Tab-local filters wrapping --- */
    .filters {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .form-group.inline {
        flex: 1 1 100px;
    }

    .form-group.inline input,
    .form-group.inline select {
        width: 100%;
    }

    .filters button {
        width: 100%;
    }

    /* --- Tables: horizontal scroll with touch-friendly rows --- */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overflow-y: visible;
    }

    th, td {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Expand toggle buttons for touch */
    .toggle-btn {
        width: 36px;
        height: 36px;
        line-height: 36px;
        font-size: 1.1rem;
    }

    /* --- Fuel: price boxes stack vertically --- */
    .price-summary {
        flex-direction: column;
    }

    .price-box {
        flex: none;
    }

    /* --- Fuel: totals stack vertically --- */
    .fuel-totals {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* --- Login page --- */
    .login-container {
        border-radius: 0;
        box-shadow: none;
        padding: 1.5rem 1rem;
        max-width: 100%;
    }
}
