@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
    --bg: #0d0f14;
    --surface: #161921;
    --surface2: #1e222e;
    --surface3: #252b3b;
    --accent: #f0c040;
    --accent2: #4a90d9;
    --accent3: #5ed68a;
    --danger: #e05555;
    --text: #e8eaf0;
    --text2: #8a90a8;
    --text3: #5a6080;
    --border: #252b3b;
    --radius: 12px;
    --radius-sm: 8px;
    
    /* Touch-friendly sizing */
    --touch-target: 44px;
    --font-base: 16px;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ── Screens (for multi-page app, these are page containers) ── */
.screen { 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
}

/* ── Login Screen ── */
#login {
    background: var(--bg);
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 100vh;
    padding: 16px;
}

.login-bg {
    position: absolute; 
    inset: 0; 
    overflow: hidden; 
    pointer-events: none;
}

.login-bg::before {
    content: '';
    position: absolute;
    width: min(600px, 80vw); 
    height: min(600px, 80vw);
    background: radial-gradient(circle, rgba(240,192,64,0.08) 0%, transparent 70%);
    top: -100px; 
    left: -100px;
}

.login-bg::after {
    content: '';
    position: absolute;
    width: min(500px, 70vw); 
    height: min(500px, 70vw);
    background: radial-gradient(circle, rgba(74,144,217,0.07) 0%, transparent 70%);
    bottom: -80px; 
    right: -80px;
}

.login-box {
    position: relative; 
    z-index: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: clamp(24px, 6vw, 48px) clamp(20px, 5vw, 40px);
    width: 100%; 
    max-width: 420px;
    box-shadow: 0 40px 80px rgba(0,0,0,0.5);
    margin: 20px auto;
}

.brand {
    display: flex; 
    align-items: center; 
    gap: 10px;
    margin-bottom: 8px;
}

.brand-icon {
    width: clamp(36px, 8vw, 40px); 
    height: clamp(36px, 8vw, 40px);
    background: var(--accent);
    border-radius: 10px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: clamp(18px, 5vw, 20px);
}

.brand-name {
    font-family: 'Syne', sans-serif;
    font-size: clamp(20px, 6vw, 24px); 
    font-weight: 800;
    color: var(--text);
}

.login-subtitle {
    color: var(--text2);
    font-size: clamp(13px, 3.5vw, 14px);
    margin-bottom: clamp(24px, 6vw, 36px);
}

label { 
    display: block; 
    font-size: clamp(11px, 3vw, 12px); 
    font-weight: 600; 
    color: var(--text2); 
    text-transform: uppercase; 
    letter-spacing: 0.08em; 
    margin-bottom: 6px; 
}

input[type="text"], 
input[type="password"], 
input[type="number"], 
input[type="email"],
select, 
textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: var(--font-base);
    padding: clamp(12px, 3.5vw, 14px);
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 20px;
    -webkit-appearance: none;
    appearance: none;
}

input:focus, 
select:focus, 
textarea:focus { 
    border-color: var(--accent); 
}

select option { 
    background: var(--surface2); 
}

.btn {
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    padding: clamp(12px, 3.5vw, 13px) clamp(20px, 5vw, 24px);
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(14px, 4vw, 15px); 
    font-weight: 600;
    cursor: pointer; 
    border: none;
    transition: all 0.18s;
    text-decoration: none;
    min-height: var(--touch-target);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary { 
    background: var(--accent); 
    color: #111; 
    width: 100%; 
}

.btn-primary:hover, 
.btn-primary:active { 
    background: #f7d060; 
    transform: translateY(-1px); 
}

.btn-secondary { 
    background: var(--surface2); 
    color: var(--text); 
    border: 1px solid var(--border); 
}

.btn-secondary:hover, 
.btn-secondary:active { 
    background: var(--surface3); 
}

.btn-danger { 
    background: var(--danger); 
    color: white; 
}

.btn-ghost { 
    background: transparent; 
    color: var(--text2); 
    border: 1px solid var(--border); 
}

.btn-ghost:hover, 
.btn-ghost:active { 
    color: var(--text); 
    border-color: var(--text2); 
}

.btn-sm { 
    padding: clamp(6px, 2vw, 8px) clamp(12px, 3vw, 16px); 
    font-size: clamp(12px, 3.5vw, 13px); 
    min-height: 36px;
}

.btn-accent2 { 
    background: var(--accent2); 
    color: white; 
}

/* ── Top Nav ── */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    height: clamp(56px, 8vh, 60px);
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    position: sticky; 
    top: 0; 
    z-index: 100;
    gap: 8px;
}

.topnav-brand {
    font-family: 'Syne', sans-serif;
    font-size: clamp(16px, 4.5vw, 18px); 
    font-weight: 800;
    color: var(--accent);
    flex-shrink: 0;
    text-decoration: none;
    white-space: nowrap;
}

.topnav-context {
    display: flex; 
    align-items: center; 
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: clamp(11px, 3vw, 12px); 
    font-weight: 600;
    color: var(--text2);
    white-space: nowrap;
}

.badge.accent { 
    background: rgba(240,192,64,0.15); 
    border-color: rgba(240,192,64,0.3); 
    color: var(--accent); 
}

.topnav-right { 
    display: flex; 
    gap: 8px; 
    flex-shrink: 0; 
}

/* ── Dashboard ── */
.dashboard .content, 
.content-page {
    flex: 1; 
    padding: clamp(16px, 4vw, 24px) clamp(12px, 3vw, 20px); 
    max-width: 900px; 
    margin: 0 auto; 
    width: 100%; 
}

.section-title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(12px, 3.5vw, 13px); 
    font-weight: 700;
    text-transform: uppercase; 
    letter-spacing: 0.1em;
    color: var(--text3);
    margin-bottom: 14px;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
    gap: clamp(8px, 2vw, 12px);
    margin-bottom: clamp(24px, 5vw, 32px);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
}

.stat-card .label { 
    font-size: clamp(11px, 3vw, 12px); 
    color: var(--text2); 
    margin-bottom: 6px; 
}

.stat-card .value { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(24px, 6vw, 28px); 
    font-weight: 800; 
    word-break: break-word;
}

.stat-card .value.yellow { 
    color: var(--accent); 
}

.stat-card .value.green { 
    color: var(--accent3); 
}

.stat-card .value.blue { 
    color: var(--accent2); 
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
    gap: clamp(8px, 2vw, 12px);
    margin-bottom: clamp(24px, 5vw, 32px);
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(20px, 5vw, 24px) clamp(16px, 4vw, 20px);
    cursor: pointer;
    transition: all 0.2s;
    display: flex; 
    flex-direction: column; 
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    min-height: 120px;
}

.action-card:hover, 
.action-card:active { 
    border-color: var(--accent); 
    transform: translateY(-2px); 
}

.action-card .icon { 
    font-size: clamp(24px, 6vw, 28px); 
}

.action-card .title { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(14px, 4vw, 15px); 
    font-weight: 700; 
}

.action-card .desc { 
    font-size: clamp(12px, 3.5vw, 13px); 
    color: var(--text2); 
    line-height: 1.4; 
}

/* ── Location/Category Select ── */
.location-select .content {
    flex: 1; 
    padding: clamp(24px, 6vw, 40px) 16px;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: clamp(24px, 6vw, 32px);
    max-width: 600px; 
    margin: 0 auto; 
    width: 100%;
}

.select-title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(24px, 6vw, 28px); 
    font-weight: 800;
    text-align: center;
}

.pill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
    gap: clamp(8px, 2vw, 12px);
    width: 100%;
}

.pill-btn {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: 'Syne', sans-serif;
    font-size: clamp(14px, 4vw, 16px); 
    font-weight: 700;
    color: var(--text);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pill-btn:hover, 
.pill-btn.selected { 
    border-color: var(--accent); 
    color: var(--accent); 
    background: rgba(240,192,64,0.08); 
}

.pill-btn .pill-icon { 
    font-size: clamp(24px, 6vw, 28px); 
    margin-bottom: 8px; 
    display: block; 
}

/* ── Inventory Screen ── */
.inventory-layout { 
    display: flex; 
    flex: 1; 
    overflow: hidden; 
    flex-direction: row;
}

/* Location sidebar with mobile optimizations */
.location-tabs {
    width: min(200px, 30%);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; 
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.loc-tab {
    padding: clamp(12px, 3vh, 16px) clamp(12px, 2vw, 18px);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: clamp(13px, 3.5vw, 14px); 
    font-weight: 500;
    color: var(--text2);
    transition: all 0.15s;
    display: flex; 
    align-items: center; 
    gap: 10px;
    min-height: var(--touch-target);
}

.loc-tab:hover, 
.loc-tab:active { 
    background: var(--surface2); 
    color: var(--text); 
}

.loc-tab.active { 
    background: rgba(240,192,64,0.08); 
    color: var(--accent); 
    border-right: 3px solid var(--accent); 
}

.loc-tab .tab-icon { 
    font-size: clamp(16px, 4vw, 18px); 
}

/* Product grid */
.product-area {
    flex: 1; 
    overflow-y: auto;
    padding: clamp(12px, 3vw, 20px);
    -webkit-overflow-scrolling: touch;
}

.shelf-header {
    font-family: 'Syne', sans-serif;
    font-size: clamp(16px, 4.5vw, 18px); 
    font-weight: 800;
    margin-bottom: 16px;
    display: flex; 
    align-items: center; 
    gap: 10px;
    flex-wrap: wrap;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
    gap: clamp(8px, 2vw, 10px);
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(12px, 3vw, 14px);
    cursor: pointer;
    transition: all 0.2s;
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    position: relative;
    min-height: 140px;
}

.product-card:hover, 
.product-card:active { 
    border-color: var(--accent2); 
}

.product-card.low-stock { 
    border-color: rgba(224,85,85,0.5); 
}

.product-card .prod-emoji { 
    font-size: clamp(24px, 6vw, 28px); 
    text-align: center; 
}

.product-card .prod-name { 
    font-size: clamp(12px, 3.5vw, 13px); 
    font-weight: 600; 
    line-height: 1.3; 
}

.product-card .prod-count {
    display: flex; 
    align-items: center; 
    gap: 6px;
    background: var(--surface2);
    border-radius: 6px;
    padding: 6px 8px;
}

.prod-count button {
    background: none; 
    border: none; 
    color: var(--text2); 
    cursor: pointer;
    font-size: clamp(18px, 5vw, 20px); 
    line-height: 1; 
    width: clamp(24px, 6vw, 28px); 
    height: clamp(24px, 6vw, 28px);
    display: flex; 
    align-items: center; 
    justify-content: center;
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: 0;
}

.prod-count button:hover, 
.prod-count button:active { 
    color: var(--accent); 
}

.prod-count .qty {
    flex: 1; 
    text-align: center;
    font-family: 'DM Mono', monospace;
    font-size: clamp(14px, 4vw, 15px); 
    font-weight: 500;
}

.par-label {
    font-size: clamp(10px, 3vw, 11px); 
    color: var(--text3);
    font-family: 'DM Mono', monospace;
}

.par-ok { 
    color: var(--accent3); 
}

.par-low { 
    color: var(--danger); 
}

.low-badge {
    position: absolute; 
    top: 8px; 
    right: 8px;
    background: var(--danger); 
    color: white;
    border-radius: 4px; 
    padding: 2px 6px;
    font-size: clamp(9px, 2.5vw, 10px); 
    font-weight: 700;
    text-transform: uppercase;
}

/* ── Product Detail Modal ── */
.modal-overlay {
    position: fixed; 
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none; 
    align-items: center; 
    justify-content: center;
    z-index: 200; 
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.open { 
    display: flex; 
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: clamp(16px, 4vw, 20px);
    width: 100%; 
    max-width: 560px;
    max-height: min(90vh, 600px);
    overflow-y: auto;
    padding: clamp(20px, 5vw, 28px);
    -webkit-overflow-scrolling: touch;
}

.modal-header {
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}

.modal-title { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(18px, 5vw, 20px); 
    font-weight: 800; 
    word-break: break-word;
}

.close-btn {
    background: var(--surface2); 
    border: none; 
    color: var(--text2);
    width: clamp(36px, 8vw, 40px); 
    height: clamp(36px, 8vw, 40px); 
    border-radius: 8px;
    cursor: pointer; 
    font-size: clamp(18px, 5vw, 20px); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    flex-shrink: 0;
}

.close-btn:hover, 
.close-btn:active { 
    color: var(--text); 
}

.modal-product-img {
    width: 100%; 
    height: clamp(120px, 30vw, 160px);
    background: var(--surface2);
    border-radius: var(--radius);
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: clamp(48px, 15vw, 64px);
    margin-bottom: 20px;
}

.detail-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
    gap: clamp(8px, 2vw, 12px); 
    margin-bottom: 20px;
}

.detail-item { 
    background: var(--surface2); 
    border-radius: var(--radius-sm); 
    padding: clamp(10px, 3vw, 12px) clamp(12px, 3.5vw, 14px); 
}

.detail-item .d-label { 
    font-size: clamp(10px, 3vw, 11px); 
    color: var(--text3); 
    text-transform: uppercase; 
    letter-spacing: 0.06em; 
    margin-bottom: 4px; 
}

.detail-item .d-value { 
    font-size: clamp(14px, 4vw, 15px); 
    font-weight: 600; 
    word-break: break-word;
}

.detail-item.full { 
    grid-column: 1 / -1; 
}

.price-history { 
    margin-bottom: 20px; 
}

.price-row {
    display: flex; 
    justify-content: space-between;
    padding: clamp(8px, 2.5vw, 10px) 0;
    border-bottom: 1px solid var(--border);
    font-size: clamp(13px, 3.5vw, 14px);
    flex-wrap: wrap;
    gap: 8px;
}

.price-row:last-child { 
    border-bottom: none; 
}

.price-row .price-date { 
    color: var(--text2); 
}

.price-row .price-val { 
    font-family: 'DM Mono', monospace; 
    font-weight: 600; 
}

/* ── Shopping List Screen ── */
.shopping-screen .content { 
    flex: 1; 
    padding: clamp(16px, 4vw, 20px); 
    max-width: 800px; 
    margin: 0 auto; 
    width: 100%; 
}

.vendor-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.vendor-header {
    background: var(--surface2);
    padding: clamp(14px, 4vw, 16px) clamp(16px, 4vw, 20px);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.vendor-name { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(15px, 4.5vw, 16px); 
    font-weight: 700; 
}

.vendor-count { 
    font-size: clamp(12px, 3.5vw, 13px); 
    color: var(--text2); 
}

.shopping-item {
    display: flex; 
    align-items: center; 
    gap: clamp(10px, 3vw, 14px);
    padding: clamp(12px, 3.5vw, 14px) clamp(16px, 4vw, 20px);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    cursor: pointer;
    min-height: var(--touch-target);
}

.shopping-item:last-child { 
    border-bottom: none; 
}

.shopping-item:hover, 
.shopping-item:active { 
    background: var(--surface2); 
}

.shopping-item.checked { 
    opacity: 0.4; 
}

.shopping-item.checked .shop-name { 
    text-decoration: line-through; 
}

.shop-check {
    width: clamp(22px, 6vw, 24px); 
    height: clamp(22px, 6vw, 24px);
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    color: transparent;
}

.shopping-item.checked .shop-check { 
    background: var(--accent3); 
    border-color: var(--accent3); 
    color: white;
}

.shop-emoji { 
    font-size: clamp(20px, 5vw, 22px); 
    flex-shrink: 0;
}

.shop-info { 
    flex: 1; 
    min-width: 0;
}

.shop-name { 
    font-size: clamp(13px, 4vw, 14px); 
    font-weight: 600; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-detail { 
    font-size: clamp(11px, 3.5vw, 12px); 
    color: var(--text2); 
    font-family: 'DM Mono', monospace; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-aisle { 
    font-size: clamp(11px, 3.5vw, 12px); 
    color: var(--accent2); 
    background: rgba(74,144,217,0.1); 
    border-radius: 4px; 
    padding: 2px 8px; 
    white-space: nowrap;
}

.shop-qty { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(15px, 4.5vw, 16px); 
    font-weight: 700; 
    color: var(--accent); 
    flex-shrink: 0;
}

/* ── AI Suggestions Screen ── */
.ai-screen .content { 
    flex: 1; 
    padding: clamp(16px, 4vw, 24px) clamp(16px, 4vw, 20px); 
    max-width: 800px; 
    margin: 0 auto; 
    width: 100%; 
}

.ai-header-box {
    background: linear-gradient(135deg, rgba(74,144,217,0.15), rgba(94,214,138,0.10));
    border: 1px solid rgba(74,144,217,0.3);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
    margin-bottom: 24px;
    display: flex; 
    align-items: center; 
    gap: clamp(12px, 3.5vw, 14px);
    flex-wrap: wrap;
}

.ai-icon-big { 
    font-size: clamp(32px, 8vw, 36px); 
}

.ai-header-text .title { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(15px, 4.5vw, 16px); 
    font-weight: 700; 
    margin-bottom: 4px; 
}

.ai-header-text .sub { 
    font-size: clamp(12px, 3.5vw, 13px); 
    color: var(--text2); 
}

.suggestion-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
    margin-bottom: 12px;
    display: flex; 
    gap: clamp(12px, 3.5vw, 16px);
    flex-wrap: wrap;
}

.sug-icon { 
    font-size: clamp(24px, 6vw, 28px); 
    flex-shrink: 0; 
}

.sug-content { 
    flex: 1; 
    min-width: 200px;
}

.sug-title { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(14px, 4vw, 15px); 
    font-weight: 700; 
    margin-bottom: 6px; 
}

.sug-text { 
    font-size: clamp(13px, 3.5vw, 14px); 
    color: var(--text2); 
    line-height: 1.5; 
    margin-bottom: 12px; 
}

.sug-savings { 
    font-size: clamp(12px, 3.5vw, 13px); 
    color: var(--accent3); 
    font-weight: 600; 
    margin-bottom: 12px; 
}

.sug-actions { 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
}

/* ── Reports Screen ── */
.reports-screen .content { 
    flex: 1; 
    padding: clamp(16px, 4vw, 24px) clamp(16px, 4vw, 20px); 
    max-width: 800px; 
    margin: 0 auto; 
    width: 100%; 
}

.report-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); 
    gap: clamp(8px, 2vw, 12px); 
    margin-bottom: 24px; 
}

.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
}

.report-card .r-label { 
    font-size: clamp(11px, 3vw, 12px); 
    color: var(--text2); 
    margin-bottom: 4px; 
}

.report-card .r-val { 
    font-family: 'Syne', sans-serif; 
    font-size: clamp(22px, 6vw, 26px); 
    font-weight: 800; 
    word-break: break-word;
}

.report-card .r-sub { 
    font-size: clamp(11px, 3vw, 12px); 
    color: var(--text3); 
    margin-top: 2px; 
}

.spend-bar-wrap { 
    margin-bottom: 24px; 
}

.spend-bar { 
    margin-bottom: 10px; 
}

.spend-bar .sb-label { 
    display: flex; 
    justify-content: space-between; 
    font-size: clamp(12px, 3.5vw, 13px); 
    margin-bottom: 4px; 
    flex-wrap: wrap;
    gap: 8px;
}

.spend-bar .sb-label .sb-name { 
    color: var(--text); 
}

.spend-bar .sb-label .sb-val { 
    color: var(--accent); 
    font-family: 'DM Mono', monospace; 
}

.bar-track { 
    background: var(--surface2); 
    border-radius: 4px; 
    height: 8px; 
    overflow: hidden; 
}

.bar-fill { 
    height: 100%; 
    border-radius: 4px; 
    background: var(--accent); 
    transition: width 1s ease; 
}

.bar-fill.blue { 
    background: var(--accent2); 
}

.bar-fill.green { 
    background: var(--accent3); 
}

/* ── Store Layout ── */
.store-layout-screen .content { 
    flex: 1; 
    padding: clamp(16px, 4vw, 24px) clamp(16px, 4vw, 20px); 
    max-width: 900px; 
    margin: 0 auto; 
    width: 100%; 
}

.store-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
    margin-bottom: 20px;
}

.aisle-row {
    display: flex; 
    align-items: center; 
    gap: clamp(8px, 2vw, 12px);
    padding: clamp(10px, 3vw, 12px) 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.aisle-row:last-child { 
    border-bottom: none; 
}

.aisle-num {
    font-family: 'DM Mono', monospace;
    font-size: clamp(12px, 3.5vw, 13px); 
    color: var(--text2);
    width: clamp(50px, 15vw, 60px); 
    flex-shrink: 0;
}

.aisle-name { 
    flex: 1; 
    font-size: clamp(13px, 4vw, 14px); 
    font-weight: 500; 
    min-width: 120px;
}

.aisle-items { 
    font-size: clamp(11px, 3.5vw, 12px); 
    color: var(--text2); 
}

/* ── Bottom Nav (mobile optimized) ── */
.bottom-nav {
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    height: clamp(60px, 8vh, 64px);
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 99;
    padding: 4px 0;
}

.bnav-item {
    flex: 1;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    color: var(--text3);
    font-size: clamp(9px, 2.5vw, 10px); 
    font-weight: 600; 
    text-transform: uppercase; 
    letter-spacing: 0.04em;
    transition: color 0.15s;
    border: none; 
    background: none;
    text-decoration: none;
    min-height: var(--touch-target);
    padding: 4px;
}

.bnav-item:hover, 
.bnav-item:active,
.bnav-item.active { 
    color: var(--accent); 
}

.bnav-icon { 
    font-size: clamp(18px, 5vw, 20px); 
}

/* ── Print ── */
@media print {
    body { 
        background: white; 
        color: black; 
    }
    .topnav, 
    .bottom-nav, 
    .location-tabs, 
    .modal-overlay { 
        display: none !important; 
    }
    .product-card { 
        border: 1px solid #ccc; 
    }
}

/* ── Enhanced Responsive Breakpoints ── */

/* Small phones */
@media (max-width: 380px) {
    :root {
        --touch-target: 40px;
    }
    
    .dash-grid {
        grid-template-columns: 1fr;
    }
    
    .action-grid {
        grid-template-columns: 1fr;
    }
    
    .product-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .pill-grid {
        grid-template-columns: 1fr;
    }
    
    .login-box {
        padding: 24px 16px;
    }
    
    .vendor-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .shop-detail {
        white-space: normal;
    }
}

/* Phones */
@media (min-width: 381px) and (max-width: 480px) {
    .dash-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .report-grid {
        grid-template-columns: 1fr;
    }
}

/* Small tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .dash-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .report-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablets and small laptops */
@media (min-width: 769px) and (max-width: 1024px) {
    .dash-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Landscape orientation on phones */
@media (max-height: 480px) and (orientation: landscape) {
    .login-box {
        padding: 16px 24px;
    }
    
    .modal {
        max-height: 85vh;
    }
    
    .bottom-nav {
        height: 50px;
    }
    
    .bnav-item {
        flex-direction: row;
        gap: 6px;
    }
    
    .bnav-icon {
        font-size: 16px;
    }
}

/* High-resolution tablets and desktops */
@media (min-width: 1025px) {
    .bottom-nav {
        display: none; /* Hide bottom nav on desktop */
    }
    
    .topnav {
        padding: 0 32px;
    }
    
    .dashboard .content, 
    .content-page {
        padding: 32px 24px;
    }
}

/* iPad Pro and large screens */
@media (min-width: 1366px) {
    .dashboard .content, 
    .content-page {
        max-width: 1100px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .action-card:hover,
    .product-card:hover,
    .shopping-item:hover {
        transform: none;
    }
    
    .btn:active,
    .action-card:active,
    .product-card:active,
    .shopping-item:active {
        opacity: 0.8;
    }
    
    input, 
    select, 
    textarea,
    button {
        font-size: 16px !important; /* Prevents zoom on focus in iOS */
    }
}

/* Dark mode support for system preference */
@media (prefers-color-scheme: dark) {
    :root {
        /* Your existing dark theme is already set */
    }
}

/* Scrollbar styling (optional) */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px;
}

::-webkit-scrollbar-track { 
    background: transparent; 
}

::-webkit-scrollbar-thumb { 
    background: var(--border); 
    border-radius: 3px; 
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text3);
}

/* Utility classes */
.text-center { 
    text-align: center; 
}

.mt-20 { 
    margin-top: clamp(16px, 5vw, 20px); 
}

.mb-20 { 
    margin-bottom: clamp(16px, 5vw, 20px); 
}

.hidden { 
    display: none !important; 
}

.error-message {
    color: var(--danger);
    font-size: clamp(13px, 3.5vw, 14px);
    margin-bottom: 10px;
}

.success-message {
    color: var(--accent3);
    font-size: clamp(13px, 3.5vw, 14px);
    margin-bottom: 10px;
}

/* Accessibility improvements */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Loading states */
.loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}