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

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

/* Navigation */
nav {
    background: #2c3e50;
    color: white;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 600;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: #ccc;
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-links a:hover {
    color: white;
}

/* Main content */
main {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

h1 {
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
    color: #2c3e50;
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Buttons */
.btn {
    display: inline-block;
    background: #2980b9;
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}

.btn:hover {
    background: #2471a3;
}

.btn-secondary {
    background: #7f8c8d;
}

.btn-secondary:hover {
    background: #6c7a7b;
}

.btn-danger {
    background: #c0392b;
}

.btn-danger:hover {
    background: #a93226;
}

.btn-preset {
    background: white;
    color: #2980b9;
    border: 1px solid #2980b9;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.btn-preset:hover {
    background: #eaf4fb;
}

.preset-group {
    display: flex;
    gap: 0.3rem;
    align-items: flex-end;
}

/* Stats row */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    min-width: 120px;
}

a.stat-box-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
}

a.stat-box-link:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.stat-num   { font-size: 2rem; font-weight: 700; color: #2980b9; }
.stat-label { font-size: 0.8rem; color: #888; margin-top: 2px; }

/* Upload / drop zone */
.upload-card { max-width: 560px; }

.drop-zone {
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone.drag-over {
    border-color: #2980b9;
    background: #eaf4fb;
}

.drop-icon  { font-size: 2.5rem; margin-bottom: 0.5rem; }
.drop-label { font-size: 1rem; font-weight: 500; margin-bottom: 0.25rem; }
.drop-sub   { color: #aaa; margin-bottom: 0.75rem; }
.drop-hint  { font-size: 0.78rem; color: #aaa; margin-top: 0.75rem; }

.preview-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f0f3f4;
    border-radius: 5px;
    font-size: 0.9rem;
}

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
    padding: 0.45rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2980b9;
}

.file-tag {
    font-size: 0.8rem;
    background: #eef;
    border-radius: 4px;
    padding: 2px 6px;
    color: #555;
    font-family: monospace;
}

/* Line items table */
.table-wrap { overflow-x: auto; }

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.items-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    padding: 0.4rem 0.5rem;
    border-bottom: 2px solid #eee;
}

.items-table td {
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid #f2f2f2;
}

.items-table input,
.items-table select {
    width: 100%;
    padding: 0.3rem 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.btn-remove {
    background: none;
    border: none;
    color: #c0392b;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 5px;
}

.btn-remove:hover { color: #922b21; }

/* Data table (receipts list) */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid #eee;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f5f5f5;
}

.data-table tr:hover td { background: #fafafa; }

.badge {
    font-size: 0.75rem;
    background: #eaf4fb;
    color: #2471a3;
    padding: 2px 7px;
    border-radius: 10px;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
}

/* Reports */
.filters-bar {
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
}

.filters-inner {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
}

.filter-group input,
.filter-group select {
    padding: 0.45rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
    .charts-row { grid-template-columns: 1fr; }
}

.chart-card { margin-bottom: 1.5rem; }

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container.tall {
    height: 340px;
}

.chart-empty {
    text-align: center;
    padding: 2rem;
    color: #aaa;
    font-size: 0.9rem;
}

/* Price tracker search */
.search-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}

.search-row input {
    flex: 1;
    padding: 0.45rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.suggestions-list li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.88rem;
}

.suggestions-list li:hover {
    background: #f0f3f4;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #d5f5e3; color: #1e8449; }
.alert-error   { background: #fadbd8; color: #922b21; }
.alert-info    { background: #d6eaf8; color: #1a5276; }

/* Receipt groups (grouped by company) */
.receipt-group { padding: 1rem 1.5rem; }

.receipt-group-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.receipt-group-summary::-webkit-details-marker { display: none; }

.receipt-group-name {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
}

.receipt-group-meta {
    font-size: 0.85rem;
    color: #888;
}

.receipt-group-chevron {
    font-size: 0.75rem;
    color: #aaa;
    transition: transform 0.2s;
}

details[open] .receipt-group-chevron { transform: rotate(180deg); }

/* Hamburger — hidden on desktop */
.nav-hamburger { display: none; }

/* =========================================================
   Mobile — 768px and below
   ========================================================= */
@media (max-width: 768px) {

    /* --- Navigation --- */
    nav { padding: 0 1rem; position: relative; flex-wrap: wrap; }

    .nav-hamburger {
        display: flex;
        flex-direction: column;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px;
    }

    .nav-hamburger span {
        display: block;
        width: 24px;
        height: 2px;
        background: white;
        border-radius: 2px;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #2c3e50;
        padding: 0.25rem 0 0.75rem;
        z-index: 1000;
        gap: 0;
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }

    .nav-links.open { display: flex; }

    .nav-links li { border-top: 1px solid rgba(255,255,255,0.07); }

    .nav-links a {
        display: block;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    /* --- Layout --- */
    main { margin: 1rem auto; padding: 0 0.75rem; }

    h1 { font-size: 1.25rem; margin-bottom: 1rem; }
    h2 { font-size: 1rem; }

    .card { padding: 1rem; }

    /* --- Stats row — 2 per row grid --- */
    .stats-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .stat-box { min-width: 0; }
    .stat-num  { font-size: 1.4rem; }

    /* --- Upload --- */
    .upload-card { max-width: 100%; }

    /* --- Filters bar --- */
    .filters-inner { flex-direction: column; align-items: stretch; }
    .filter-group input,
    .filter-group select { width: 100%; }
    .filters-inner .btn { width: 100%; text-align: center; }

    /* --- Charts --- */
    .charts-row { grid-template-columns: 1fr; }
    .chart-container      { height: 220px; }
    .chart-container.tall { height: 260px; }

    /* --- Price tracker search --- */
    .search-row { flex-direction: column; align-items: stretch; }
    .search-row .btn { width: 100%; text-align: center; }

    /* --- Page header rows (title + action button) --- */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* --- Data tables: scroll horizontally --- */
    .table-wrap { -webkit-overflow-scrolling: touch; }

    /* --- Form grid: single column --- */
    .form-grid { grid-template-columns: 1fr; }
}

/* Price Tracker full-page layout */
.pt-page { display: flex; flex-direction: column; height: calc(100vh - 56px - 4rem); }
.pt-desc  { color: #666; font-size: 0.9rem; margin-bottom: 1rem; }
.pt-search { margin-bottom: 1rem; }
.pt-chart-wrap {
    flex: 1;
    position: relative;
    min-height: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 1rem;
}


/* Sortable table headers */
th.sortable:hover { color: #2980b9; }
th.sortable .sort-icon { font-size: 0.7rem; color: #2980b9; }

/* =========================================================
   Multi-shopper additions
   ========================================================= */

/* Login page */
body.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f4f6f9;
    padding: 1rem;
}
.login-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 380px;
}
.login-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c6fad;
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-form .form-group {
    margin-bottom: 1rem;
}
.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}
.login-form input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
}
.btn-full { width: 100%; margin-top: 0.5rem; }

/* View-as bar */
.view-as-bar {
    background: #2c6fad;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 1.2rem;
    font-size: 0.85rem;
}
.view-as-label { font-weight: 600; }
.view-as-bar select {
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

/* Nav user info */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-nickname {
    font-weight: 600;
    color: #fff;
    opacity: 0.9;
}
.nav-logout {
    font-size: 0.82rem;
    color: #fff !important;
    opacity: 0.75;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
}
.nav-logout:hover { opacity: 1; }

/* Inactive shopper row */
.row-inactive td { opacity: 0.5; }

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.checkbox-label input { width: auto; margin: 0; }

/* ── Password show/hide toggle ─────────────────────────────────── */
.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrap input {
    padding-right: 2.8rem;
    flex: 1;
}
.pw-toggle {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 0.2rem;
    display: flex;
    align-items: center;
}
.pw-toggle:hover { color: #333; }
