/**
 * Main Stylesheet for BizSuite
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --secondary-color: #7b68ee;
    --secondary-hover: #5a4fc9;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --dark-color: #333;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --menu-bg: #ffffff;
    --menu-text: #212529;
    --menu-active-bg: #4a90e2;
    --menu-active-text: #ffffff;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f5f5f5;
}

/* Simple tooltips for guidance */
.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: help;
    position: relative;
}

.help-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    transform: translateX(calc(-50% + var(--tooltip-dx, 0px)));
    bottom: calc(100% + 8px);
    width: max-content;
    min-width: 0;
    max-width: min(320px, calc(100vw - 24px));
    padding: 8px 10px;
    background: #222;
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 2000;
    text-align: left;
    white-space: normal;
}

.help-tip:hover::after,
.help-tip:focus::after {
    opacity: 1;
    visibility: visible;
}

.help-text {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
    color: #666;
}

/* Form hints - subtle guidance text below inputs */
.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.form-hint a {
    color: var(--primary-color);
}

/* Help panels - collapsible guidance boxes */
.help-panel {
    background: linear-gradient(135deg, #e8f4fd 0%, #f0f7ff 100%);
    border: 1px solid #b8daff;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.help-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.5);
    border-bottom: 1px solid #b8daff;
}

.help-panel-icon {
    font-size: 1.25rem;
}

.help-panel-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #666;
    padding: 0 0.25rem;
}

.help-panel-close:hover {
    color: #333;
}

.help-panel-content {
    padding: 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.help-panel-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.help-panel-content li {
    margin-bottom: 0.25rem;
}

/* Quick tip - inline highlighted guidance */
.quick-tip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fff3cd;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #856404;
    margin-bottom: 1rem;
}

.quick-tip-icon {
    font-size: 1rem;
}

/* Page intro tip - dismissible banner */
.page-intro-tip {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #d4edda 0%, #e8f5e9 100%);
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.page-intro-tip-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.page-intro-tip-content {
    flex: 1;
}

.page-intro-tip-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-intro-tip-text {
    font-size: 0.95rem;
    color: #155724;
}

.page-intro-tip-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #155724;
    padding: 0;
    opacity: 0.7;
}

.page-intro-tip-close:hover {
    opacity: 1;
}

/* Label with tooltip - common pattern */
.label-with-tip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.label-with-tip .help-tip {
    margin-left: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header - responsive, no horizontal overflow (uses theme --menu-*) */
.site-header {
    background-color: var(--menu-bg);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    position: relative;
    z-index: 100;
}

/* ===== Two-row header: Top bar + Nav bar ===== */
.header-top-bar {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.header-top-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.header-top-right .user-name {
    font-size: 0.88rem;
    color: var(--menu-text);
    font-weight: 500;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
}

.header-btn-storefront {
    background: #dcfce7;
    color: #166534;
}
.header-btn-storefront:hover {
    background: #16a34a;
    color: #fff;
}

.header-btn-outline {
    background: #fff3cd;
    color: #856404;
}
.header-btn-outline:hover {
    background: #ffc107;
    color: #333;
}

.header-btn-logout {
    background: #fee2e2;
    color: #991b1b;
}
.header-btn-logout:hover {
    background: #dc2626;
    color: #fff;
}

.header-nav-bar {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    /* Mobile: collapsed by default */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-out;
}

.site-header.nav-open .header-nav-bar {
    max-height: 85vh;
    overflow-y: auto;
}

.header-nav-bar nav {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.35rem 1rem;
}

/* Legacy .header-content for any pages still using old markup */
.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: bold;
    flex-shrink: 0;
}

.logo-img {
    max-height: 44px;
    width: auto;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.logo-text {
    white-space: nowrap;
}

/* Site search bar */
.header-search {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 280px;
}

.site-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.site-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.site-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 2px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.site-search-results.site-search-results--open {
    display: block;
}

.site-search-result-item {
    display: block;
    padding: 0.6rem 0.75rem;
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
}

.site-search-result-item:last-child {
    border-bottom: none;
}

.site-search-result-item:hover {
    background: var(--light-color);
}

.site-search-result-title {
    font-weight: 600;
}

.site-search-result-meta {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

.site-search-empty {
    padding: 0.6rem 0.75rem;
    color: #666;
}

/* Hamburger - visible on tablet/phone only */
.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    margin-left: auto;
    margin-right: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
}

.nav-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    margin: 0 auto;
    background-color: var(--menu-text);
    border-radius: 1px;
    transition: transform 0.25s, opacity 0.25s;
}

.site-header.nav-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.site-header.nav-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.site-header.nav-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Legacy nav-wrap for any pages still using old markup */
.nav-wrap {
    width: 100%;
    order: 3;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-out;
}

.site-header.nav-open .nav-wrap {
    max-height: 85vh;
    overflow-y: auto;
}

.nav-wrap nav {
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
}

nav ul.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

nav ul.nav-list li {
    border-bottom: 1px solid var(--border-color);
}

nav ul.nav-list li:last-child {
    border-bottom: none;
}

/* Category heading (mobile) */
nav .nav-group-label {
    display: block;
    padding: 0.6rem 1rem;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

nav .nav-group-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

nav .nav-group-menu li {
    border-bottom: none;
}

nav .nav-group-menu a {
    padding-left: 1.5rem;
}

nav a {
    display: block;
    text-decoration: none;
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

nav a:hover {
    background-color: var(--light-color);
}

nav a.active {
    background-color: var(--primary-color);
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.75rem;
    flex-shrink: 0;
}

.user-info .user-name {
    font-size: 0.9rem;
    color: var(--menu-text);
}

/* Desktop: horizontal nav, no hamburger */
@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }

    /* Two-row header: nav bar always visible on desktop */
    .header-nav-bar {
        max-height: none;
        overflow: visible;
    }

    .header-nav-bar nav {
        padding: 0.25rem 1rem;
    }

    nav ul.nav-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 2px 0;
        justify-content: flex-start;
        align-items: center;
    }

    nav ul.nav-list li {
        border-bottom: none;
        flex-shrink: 0;
    }

    nav a {
        display: inline-block;
        padding: 0.35rem 0.6rem;
        font-size: 0.82rem;
        white-space: nowrap;
        border-radius: 6px;
    }

    nav a.active {
        background-color: var(--primary-color);
        color: white;
        border-radius: 6px;
    }

    nav a:hover:not(.active) {
        background-color: #f1f5f9;
    }

    /* Legacy .nav-wrap support */
    .nav-wrap {
        width: auto;
        max-height: none;
        overflow: visible;
        order: 0;
        flex: 1 1 auto;
        min-width: 0;
    }

    .nav-wrap nav {
        padding: 0;
        border-top: none;
    }

    .header-content {
        max-width: 1600px;
        flex-wrap: wrap;
        padding: 0.6rem 1.25rem;
        gap: 0.25rem 0.5rem;
        align-items: center;
    }

    .logo {
        flex-shrink: 0;
        margin-right: 0.25rem;
    }

    .header-search {
        order: 0;
        max-width: 220px;
    }

    /* Desktop: category = dropdown trigger */
    nav .nav-group {
        position: relative;
    }

    nav .nav-group-label {
        display: inline-block;
        padding: 0.35rem 0.5rem;
        font-size: 0.82rem;
        cursor: pointer;
        border-radius: 4px;
        color: var(--text-color);
        text-transform: none;
        letter-spacing: 0;
    }

    nav .nav-group-label:hover {
        background-color: var(--light-color);
    }

    nav .nav-group-menu {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 160px;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        box-shadow: var(--shadow-lg);
        padding: 0.25rem 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-4px);
        transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
        z-index: 100;
    }

    nav .nav-group:hover .nav-group-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    nav .nav-group-menu a {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        padding-left: 1rem;
    }

    .user-info {
        flex-shrink: 1;
        min-width: 0;
        margin-left: auto;
    }

    .user-info .user-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 140px;
    }
}

/* Very small screens: compact header */
@media (max-width: 768px) {
    .header-search {
        order: 3;
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 380px) {
    .user-info .user-name {
        display: none;
    }

    .logo-text {
        font-size: 1rem;
    }

    .header-search {
        max-width: none;
    }
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-small, .btn-danger {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #357abd;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

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

/* Forms */
.form-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.readonly-field {
    background-color: var(--light-color);
    cursor: not-allowed;
}

small {
    display: block;
    margin-top: 0.25rem;
    color: #6c757d;
    font-size: 0.85rem;
}

.price-hint {
    color: var(--warning-color) !important;
    font-weight: 500;
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

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

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

.message.flash {
    animation: flashPulse 1.6s ease-in-out infinite;
}

@keyframes flashPulse {
    0% { opacity: 1; }
    50% { opacity: 0.45; }
    100% { opacity: 1; }
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: var(--shadow);
    border-radius: 8px;
    overflow: hidden;
}

.data-table thead {
    background-color: var(--primary-color);
    color: white;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background-color: var(--light-color);
}

.data-table tbody tr.assigned {
    background-color: #e8f5e9;
}

.data-table tbody tr.unassigned {
    background-color: #fff3cd;
}

/* Receipt Items */
.receipt-header {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.receipt-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.items-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

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

.summary {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
}

/* Bulk Actions */
.bulk-actions {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 2px dashed var(--border-color);
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.selected-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #e7f3ff;
    border-radius: 4px;
    display: none;
}

/* Theme selector (Settings > Dashboard theme) */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.theme-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.theme-card:hover {
    border-color: var(--primary-color);
}

.theme-card--selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.theme-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-card__swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0.5rem;
    justify-content: center;
}

.theme-card__swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.theme-card__name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
}

/* Status badges (used in Settings, admin, etc.) */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-sent {
    background-color: #17a2b8;
    color: white;
}

.status-paid {
    background-color: #28a745;
    color: white;
}

.status-cancelled,
.status-draft {
    background-color: #6c757d;
    color: white;
}

/* Autocomplete */
.autocomplete-suggestions {
    position: absolute;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    display: none;
    width: 100%;
    margin-top: -1px;
}

.suggestion-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-item:hover {
    background-color: var(--light-color);
}

.suggestion-item small {
    display: block;
    color: #6c757d;
    font-size: 0.8rem;
}

/* Address map helpers – ensure map container has size so Leaflet can render */
.address-map-section .address-map {
    min-height: 280px;
    position: relative;
}
.address-map-section .address-map.leaflet-container {
    height: 280px;
}

.address-map-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.address-result-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
}

.close:hover {
    color: var(--dark-color);
}

/* Badges */
.unassigned-badge {
    background-color: #ffc107;
    color: #856404;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.linked-product {
    display: block;
    color: #6c757d;
    font-size: 0.85rem;
    font-style: italic;
}

.price-warning {
    display: block;
    color: var(--danger-color);
    font-weight: 500;
}

.currency-note {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.currency-note-box {
    background: #e7f3ff;
    border: 1px solid #b3d7ff;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    color: #004085;
}

.currency-note-box a {
    color: var(--primary-color);
    font-weight: 500;
}

.currency-converted {
    font-size: 0.9em;
    color: #6c757d;
}

/* Table scroll wrapper: use on small screens so tables scroll horizontally instead of squashing */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive .data-table {
    margin-bottom: 0;
}

/* Responsive - page content (header has its own breakpoints above) */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .form-section {
        padding: 1.25rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Small screens: tighter padding and comfortable tap targets */
@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .container {
        padding: 0.75rem;
    }

    .form-section {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .dashboard-card {
        padding: 1rem;
    }

    .dashboard-card .stat {
        font-size: 1.5rem;
    }

    nav a {
        padding: 0.85rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Login/Register Pages */
.auth-container {
    max-width: 400px;
    margin: 5% auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dashboard-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.dashboard-card .stat {
    font-size: 2rem;
    font-weight: bold;
    color: var(--dark-color);
}

/* Mileage tracking widget */
.mileage-tracking-widget-container {
    min-height: 2rem;
}
.mileage-tracking-widget .mt-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.mileage-tracking-widget .mt-label {
    font-weight: 500;
    color: var(--dark-color);
}
.mileage-tracking-widget .mt-msg {
    margin: 0 0 0.5rem 0;
    font-size: 0.95em;
}
.mileage-tracking-widget .mt-success { color: var(--success-color); }
.mileage-tracking-widget .mt-error { color: var(--danger-color); }
.mileage-tracking-widget .mt-hint { color: #666; }
.mileage-tracking-widget .mt-hint a { color: var(--primary-color); }
