/**
 * EverShelf - UI Styles
 * Mobile-first PWA design with CSS custom properties.
 *
 * @author Stimpfl Daniel <evershelfproject@gmail.com>
 * @license MIT
 */

/* ===== CSS VARIABLES & RESET ===== */
:root {
    --primary: #2d5016;
    --primary-light: #4a7c28;
    --primary-dark: #1a3009;
    --success: #16a34a;
    --success-light: #22c55e;
    --danger: #dc2626;
    --danger-light: #ef4444;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --accent: #7c3aed;
    --accent-light: #8b5cf6;
    --bg: #f0f4e8;
    --bg-card: #ffffff;
    --bg-dark: #1a1a2e;
    --text: #1a1a1a;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --nav-height: 70px;
    --header-height: 56px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    padding-top: var(--header-height);
    padding-bottom: var(--nav-height);
    -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow);
}

/* ===== PRELOADER ===== */
#app-preloader {
    position: fixed;
    inset: 0;
    background: #0c1222;
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.45s ease;
}
#app-preloader.fade-out {
    opacity: 0;
    pointer-events: none;
}
.app-preloader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}
.app-preloader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
.app-preloader-label {
    color: rgba(255,255,255,0.75);
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.app-preloader-logo {
    height: 150px;
    width: auto;
    object-fit: contain;
    animation: logoPulse 3.2s ease-in-out infinite;
}
@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 4px 20px rgba(74,222,128,0.18)); }
    50%       { filter: drop-shadow(0 4px 36px rgba(74,222,128,0.48)); }
}
.app-preloader-version {
    color: rgba(255,255,255,0.22);
    font-size: 0.68rem;
    font-family: monospace;
    letter-spacing: 0.6px;
    margin-top: -16px;
}
/* ── Startup progress section ────────────────────────────────────────── */
.preloader-progress-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: min(92vw, 520px);
    animation: zwFadeIn 0.25s ease;
}
.preloader-bar-track {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 99px;
    overflow: visible;
}
.preloader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    border-radius: 99px;
    transition: width 0.22s cubic-bezier(0.4,0,0.2,1), background 0.3s ease;
    box-shadow: 0 0 8px rgba(74,222,128,0.55);
}
.preloader-bar.bar-error { background: linear-gradient(90deg,#f87171,#ef4444); box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.preloader-bar.bar-warn  { background: linear-gradient(90deg,#fbbf24,#f59e0b); box-shadow: 0 0 8px rgba(251,191,36,0.5); }
.preloader-check-label { display: none; }

/* ── Status line: single element, opacity crossfade via JS ─────────── */
.check-ticker {
    width: 100%;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preloader-status-text {
    font-size: clamp(0.78rem, 2vw, 0.9rem);
    font-weight: 500;
    letter-spacing: 0.03em;
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 12px;
}
.preloader-status-text.state-ok    { color: #86efac; }
.preloader-status-text.state-warn  { color: #fde68a; }
.preloader-status-text.state-error { color: #fca5a5; }
.preloader-warnings {
    max-width: min(92vw, 600px);
    width: 100%;
    animation: zwFadeIn 0.3s ease;
}

/* ── Warning popup (auto-close 5s) ─────────────────────────── */
.startup-popup {
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
}
.startup-popup-warn {
    background: rgba(30,20,0,0.85);
    border: 1px solid rgba(251,191,36,0.45);
}
.startup-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px 7px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #fcd34d;
    gap: 8px;
}
.startup-popup-countdown {
    background: rgba(251,191,36,0.2);
    color: #fcd34d;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.startup-popup-body {
    padding: 2px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.startup-warn-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.startup-warn-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.startup-warn-body {
    font-size: 0.78rem;
    color: #d4c08a;
    line-height: 1.4;
}
.startup-warn-body strong {
    display: block;
    color: #fcd34d;
    font-size: 0.82rem;
    margin-bottom: 2px;
}
.startup-warn-body p {
    margin: 0;
    color: #c8a954;
}
.startup-popup-bar-wrap {
    height: 3px;
    background: rgba(251,191,36,0.15);
}
.startup-popup-bar {
    height: 3px;
    background: #fbbf24;
    width: 100%;
    will-change: width;
}

/* ── Error popup (blocking) ─────────────────────────────────── */
/* Keep .preloader-warn-badge for backward compat */
.preloader-warn-badge {
    background: rgba(251,191,36,0.15);
    color: #fcd34d;
    border: 1px solid rgba(251,191,36,0.35);
    border-radius: 99px;
    padding: 3px 10px;
    font-size: 0.71rem;
    white-space: nowrap;
}
.preloader-error-msg {
    color: #fca5a5;
    background: rgba(239,68,68,0.18);
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.80rem;
    text-align: left;
    max-width: 300px;
    line-height: 1.6;
    white-space: pre-line;
    animation: zwFadeIn 0.3s ease;
}
.preloader-error-msg strong {
    display: block;
    font-size: 0.9rem;
    color: #f87171;
    margin-bottom: 8px;
    text-align: center;
}
.preloader-retry-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    animation: zwFadeIn 0.3s ease;
}
.preloader-retry-btn:active { opacity: 0.8; }
.header-logo-icon {
    height: 28px;
    width: auto;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    gap: 8px;
}

/* Kiosk-only buttons (exit, refresh) — empty/absent on normal browser */
.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 1;
}

/* Title wrap — left-aligned by default; centered in kiosk mode */
.header-title-wrap {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}
.header-title-wrap > * {
    pointer-events: auto;
}

/* Kiosk mode: center title absolutely across full header width */
.kiosk-mode .header-title-wrap {
    position: absolute;
    left: 0;
    right: 0;
    flex: unset;
    justify-content: center;
    pointer-events: none;
}

.header-title {
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
    flex-shrink: 1;
}

.header-version {
    font-size: 0.6rem;
    font-weight: 400;
    opacity: 0.7;
    letter-spacing: 0.03em;
}

/* Update badge — shown beside title, title stays intact */
.header-update-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(251,191,36,0.15);
    border: 1px solid rgba(251,191,36,0.45);
    border-radius: 20px;
    padding: 2px 6px 2px 5px;
    white-space: nowrap;
    flex-shrink: 0;
    animation: header-update-pulse 2s ease-in-out infinite;
}
.header-update-badge-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #fde68a;
}
.header-update-btn {
    background: #fbbf24;
    color: #1e293b;
    border: none;
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: background 0.15s, transform 0.1s;
}
.header-update-btn:active {
    background: #f59e0b;
    transform: scale(0.96);
}
.header-update-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
}
@keyframes header-update-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* Actions — fixed-width, no stretching */
.header-actions {
    flex: 0 0 auto;
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* ── Base header button — all action icons use this ─────────────────── */
.header-btn {
    background: rgba(255,255,255,0.18);
    border: 1.5px solid rgba(255,255,255,0.28);
    color: white;
    font-size: 1.25rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.header-btn:active {
    background: rgba(255,255,255,0.38);
}

/* Scan button — slightly larger + pulse to draw attention */
.header-scan-btn {
    background: rgba(255,255,255,0.28);
    border: 2px solid rgba(255,255,255,0.6);
    font-size: 1.35rem;
    width: 48px;
    height: 48px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    animation: pulse-scan 2s ease-in-out infinite;
    touch-action: manipulation; /* prevent 300ms delay and double-tap zoom on mobile */
}
.header-scan-btn:active {
    background: rgba(255,255,255,0.45);
    transform: scale(0.93);
}

/* ── Smart Scale status indicator ───────────────────────────────────── */
/* Scale emoji with a small colored status dot in the lower-right corner */
.scale-status-indicator {
    cursor: pointer;
}
.scale-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}
.scale-icon-emoji {
    font-size: 20px;
    line-height: 1;
    /* Force white icon regardless of connection status — only the dot changes color */
    filter: brightness(0) invert(1);
    opacity: 0.9;
}
.scale-status-dot {
    position: absolute;
    bottom: 1px;
    right: 0px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.35);
    background: #94a3b8;
    transition: background 0.4s, box-shadow 0.4s, border-color 0.4s;
    pointer-events: none;
}
/* Connected: white fill + bright-green border ring — clearly visible on any dark/green bg */
.scale-status-connected    .scale-status-dot { background: #ffffff; border-color: #4ade80; box-shadow: 0 0 0 1px rgba(0,0,0,0.25), 0 0 8px #4ade80cc, 0 0 2px #fff; }
.scale-status-searching    .scale-status-dot { background: #f59e0b; border-color: rgba(0,0,0,0.35); animation: scaleStatusPulse 1.4s infinite; }
.scale-status-disconnected .scale-status-dot { background: #64748b; border-color: rgba(0,0,0,0.35); }
.scale-status-disconnected .scale-icon-emoji  { opacity: 0.55; }
.scale-status-error        .scale-status-dot { background: #ef4444; border-color: rgba(0,0,0,0.35); box-shadow: 0 0 5px #ef4444aa; }
@keyframes scaleStatusPulse {
    0%, 100% { box-shadow: 0 0 3px #f59e0b88; }
    50%       { box-shadow: 0 0 9px #f59e0bcc; }
}

/* ── Scale read button (add/use forms) ──────────────────────────────── */
.scale-read-btn {
    width: 100%;
    margin-top: 8px !important;
    font-size: 0.88rem;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1.5px dashed rgba(124,58,237,0.5);
    background: rgba(124,58,237,0.06);
    color: #7c3aed;
    font-weight: 600;
}
.scale-read-btn:active { background: rgba(124,58,237,0.15); }

/* ── Scale reading modal live display ──────────────────────────────── */
.scale-reading-live {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--accent, #7c3aed);
    letter-spacing: 0.04em;
    line-height: 1;
    padding: 12px 0;
}

/* Gemini button — indigo tint */
.header-gemini-btn {
    background: rgba(99,102,241,0.32);
    border-color: rgba(199,210,254,0.55);
}
.header-gemini-btn:active {
    background: rgba(99,102,241,0.55);
}
.header-gemini-btn.header-btn-no-ai {
    opacity: 0.45;
    filter: grayscale(0.7);
    border-color: rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.1);
    position: relative;
}
.header-gemini-btn.header-btn-no-ai::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #f59e0b;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.3);
}

.gemini-icon {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* (scan active is defined above in .header-scan-btn:active) */

/* ── Offline / server-unreachable banner ──────────────────────────────── */
.offline-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #dc2626;
    color: #fff;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 950;
    box-shadow: 0 2px 8px rgba(220,38,38,0.35);
}
.offline-banner-icon { font-size: 1rem; line-height: 1; }
.offline-banner-text { flex: 1; text-align: center; }
.offline-banner-retry {
    background: rgba(255,255,255,0.22);
    border: 1px solid rgba(255,255,255,0.55);
    color: #fff;
    border-radius: 6px;
    padding: 3px 11px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.offline-banner-retry:hover { background: rgba(255,255,255,0.38); }

/* Pulsing dot shown in the banner while the offline cache is being read */
.offline-banner-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f87171;
    margin-right: 6px;
    vertical-align: middle;
    animation: offline-dot-pulse 1.1s ease-in-out infinite;
}
@keyframes offline-dot-pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50%       { opacity: 1;   transform: scale(1.15); }
}

/* When server is offline, block interactions with the main content */
body.server-offline:not(.offline-mode) .app-content {
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.3s;
}
/* In offline-mode the app is usable; just a subtle left-border indicator */
body.offline-mode .app-content {
    border-left: 3px solid rgba(239, 68, 68, 0.45);
}
/* Hide the "Retry" button in the banner when in offline mode — use the Continue button instead */
body.offline-mode .offline-banner-retry {
    display: none;
}
body.server-offline .bottom-nav {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* Spesa mode banner */
.spesa-mode-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--shadow);
}
.spesa-banner-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.spesa-stat {
    font-size: 0.78rem;
    font-weight: 400;
    opacity: 0.92;
}
.spesa-mode-banner .btn {
    background: rgba(255,255,255,0.25);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.5);
    font-weight: 600;
    padding: 6px 14px;
    flex-shrink: 0;
}

/* Family sibling hint (spesa mode) — compact card with thumbnail */
.family-sibling-prompt {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    background: linear-gradient(145deg, #1e3a5f 0%, #0f2744 100%);
    color: #fff;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    max-width: min(440px, calc(100vw - 20px));
    width: calc(100% - 20px);
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.12);
    animation: family-sibling-in 0.22s ease-out;
}
@keyframes family-sibling-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.family-sibling-prompt-body {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.family-sibling-prompt-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.family-sibling-prompt-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.family-sibling-prompt-icon {
    font-size: 1.6rem;
    line-height: 1;
}
.family-sibling-prompt-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.family-sibling-prompt-title {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.85);
}
.family-sibling-prompt-name {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.family-sibling-prompt-stock {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.3;
    margin: 4px 0 0;
    color: #bbf7d0;
}
.family-sibling-prompt-meta {
    font-size: 0.8rem;
    line-height: 1.3;
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
}
.family-sibling-prompt-question {
    font-size: 0.82rem;
    line-height: 1.25;
    margin: 2px 0 0;
    color: #f8fafc;
    font-weight: 600;
}
.family-sibling-prompt-actions {
    display: flex;
    gap: 8px;
}
.family-sibling-prompt-actions button {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 9px 10px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 38px;
}
.family-sibling-prompt-yes {
    background: #22c55e;
    color: #fff;
}
.family-sibling-prompt-no {
    background: #475569;
    color: #fff;
}

@keyframes pulse-scan {
    0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
    50% { box-shadow: 0 2px 16px rgba(255,255,255,0.4); }
}

/* ===== MAIN CONTENT ===== */
.app-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px;
    min-height: calc(100vh - var(--header-height) - var(--nav-height));
}

/* ===== PAGE MANAGEMENT ===== */
.page {
    display: none;
    animation: fadeIn 0.2s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes inputShake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
.input-shake { animation: inputShake 0.5s ease; border-color: var(--danger, #ef4444) !important; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.page-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.back-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.back-btn:active {
    background: var(--border);
}

/* ===== DASHBOARD ===== */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.stat-card:active {
    transform: scale(0.97);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

/* Skeleton shimmer while stat card data is loading */
@keyframes stat-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.stat-value.stat-loading {
    color: transparent !important;
    background: linear-gradient(90deg, var(--border) 25%, color-mix(in srgb, var(--border) 40%, white) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: stat-shimmer 1.2s ease-in-out infinite;
    border-radius: 8px;
    min-width: 40px;
    min-height: 2.4rem;
    display: inline-block;
    vertical-align: middle;
    user-select: none;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
}

/* ===== ALERTS ===== */
.alert-section {
    background: #fef3c7;
    border: 2px solid var(--warning);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

/* Quick recipe bar */
.quick-recipe-bar {
    margin-bottom: 12px;
}
.btn-quick-recipe {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 2px 8px rgba(249,115,22,0.3);
}
.btn-quick-recipe span:first-child { font-size: 1.3rem; }
.btn-quick-recipe .quick-recipe-text { flex: 1; }
.btn-quick-recipe span:last-child { font-size: 1.1rem; opacity: 0.8; }
.btn-quick-recipe:active { transform: scale(0.98); }

/* ── Anti-Waste Report Card — same structure as .alert-section ── */
#waste-chart-section {
    background: #f0fdf4;
    border: 2px solid #86efac;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

/* Header row — mirrors .alert-section h3 */
.aw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.aw-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.aw-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

/* Live indicator dot */
.aw-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.aw-live-on {
    background: var(--success);
    animation: aw-pulse 2s ease-in-out infinite;
}
.aw-live-off { background: #9ca3af; }
@keyframes aw-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
    60%  { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* Grade badge */
.aw-grade {
    display: inline-block;
    min-width: 30px;
    text-align: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 900;
    color: #fff;
    cursor: default;
}
.aw-grade-ap { background: #16a34a; }
.aw-grade-a  { background: #22c55e; }
.aw-grade-b  { background: #f59e0b; }
.aw-grade-c  { background: #fb923c; }
.aw-grade-d  { background: #dc2626; }

/* ── Stacked single comparison bar ──────────────────────── */
.aw-cmp-wrap { margin-bottom: 10px; }
/* Track = the outer gray rail */
.aw-cmp-bar-track {
    position: relative;
    height: 18px;
    background: rgba(0,0,0,.07);
    border-radius: 9px;
    overflow: hidden;   /* clip both fills */
    margin-bottom: 5px;
}
/* Avg (orange) fills from the left — always the wider/background layer */
.aw-cmp-bar-fill-avg {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 9px;
    width: 0;
    background: linear-gradient(90deg, #fdba74, #f97316);
    transition: width 1.1s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
/* Your bar (green) sits on top, same height */
.aw-cmp-bar-fill-you {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 9px;
    width: 0;
    background: linear-gradient(90deg, #4ade80, #16a34a);
    transition: width 1.1s cubic-bezier(.4,0,.2,1) 0.15s;
    z-index: 1;
    overflow: hidden;
}
/* Shimmer on both fills */
.aw-cmp-bar-fill-avg::after,
.aw-cmp-bar-fill-you::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.35) 50%, transparent 100%);
    animation: aw-shimmer 2.2s ease-in-out infinite;
    opacity: 0;
    transition: opacity 0.5s 1s;
}
.aw-cmp-bar-fill-avg.loaded::after,
.aw-cmp-bar-fill-you.loaded::after { opacity: 1; }
@keyframes aw-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}
/* Labels row below the bar */
.aw-cmp-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    font-weight: 600;
    margin-bottom: 3px;
}
.aw-cmp-legend-you { color: #16a34a; }
.aw-cmp-legend-avg { color: #f97316; }
/* Inline status below bars */
.aw-status-inline {
    font-size: 0.75rem;
    font-weight: 600;
    margin: 2px 0 8px;
    padding: 0;
}
.aw-status-good { color: #16a34a; }
.aw-status-bad  { color: #dc2626; }
.aw-status-ok   { color: #b45309; }

/* ── Savings badges ─────────────────────────────────────── */
.aw-savings-row {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    justify-content: center;
    gap: 6px;
    margin-bottom: 9px;
    transition: opacity 0.38s ease;
}
.aw-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.aw-badge-icon { font-size: 0.92rem; flex-shrink: 0; }
.aw-badge-body {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.aw-badge-body b { font-size: 0.86rem; }
.aw-badge-body small { font-size: 0.66rem; font-weight: 500; opacity: .75; }
.aw-badge-rate   { background: #f5f3ff; color: #5b21b6; border-color: #c4b5fd; }
.aw-badge-money  { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.aw-badge-meals  { background: #f0fdf4; color: #166534; border-color: #86efac; }
.aw-badge-co2    { background: #eff6ff; color: #1e40af; border-color: #93c5fd; }
.aw-badge-wasted { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
.aw-badge-better { background: #f0fdf4; color: #15803d; border-color: #4ade80; }

/* ── Trend mini-cards ───────────────────────────────────── */
.aw-trend-cards {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 7px;
}
.aw-tcard {
    flex: 1;
    padding: 5px 4px 4px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid transparent;
}
.aw-tcard-good  { background: #f0fdf4; border-color: #86efac; }
.aw-tcard-ok    { background: #fffbeb; border-color: #fde68a; }
.aw-tcard-bad   { background: #fef2f2; border-color: #fca5a5; }
.aw-tcard-empty { background: var(--bg-main); border-color: var(--border); opacity: 0.45; }
.aw-tc-label {
    display: block;
    font-size: 0.63rem;
    color: var(--text-light);
    margin-bottom: 1px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.aw-tc-rate {
    display: block;
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 4px;
}
.aw-tcard-good  .aw-tc-rate { color: #16a34a; }
.aw-tcard-ok    .aw-tc-rate { color: #b45309; }
.aw-tcard-bad   .aw-tc-rate { color: #dc2626; }
.aw-tcard-empty .aw-tc-rate { color: var(--text-light); }
.aw-tc-minibar { height: 3px; background: rgba(0,0,0,.08); border-radius: 2px; overflow: hidden; }
.aw-tc-minibar > div { height: 100%; border-radius: 2px; }
.aw-tcard-good  .aw-tc-minibar > div { background: var(--success); }
.aw-tcard-ok    .aw-tc-minibar > div { background: #f59e0b; }
.aw-tcard-bad   .aw-tc-minibar > div { background: var(--danger); }
.aw-tcard-empty .aw-tc-minibar > div { background: #d1d5db; }
.aw-tc-arrow { font-size: 0.9rem; flex-shrink: 0; padding: 0 1px; }
.aw-arrow-good { color: var(--success); }
.aw-arrow-bad  { color: var(--danger); }
.aw-arrow-ok   { color: var(--text-light); }

/* ── Rotating food-fact box ─────────────────────────────── */
.aw-fact-rotator {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    padding: 5px 8px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 7px;
    border-left: 2px solid #38bdf8;
    margin-bottom: 5px;
    min-height: 26px;
}
.aw-fact-icon { font-size: 0.76rem; flex-shrink: 0; padding-top: 1px; }
.aw-fact-text {
    font-size: 0.76rem;
    color: #0369a1;
    line-height: 1.4;
    flex: 1;
    transition: opacity 0.4s ease;
}
.aw-fact-fade { opacity: 0; }

/* Source footnote */
.aw-source {
    font-size: 0.58rem;
    color: #9ca3af;
    margin-top: 0;
    text-align: right;
}

.alert-section h3 {
    font-size: 1.05rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.alert-danger {
    background: #fee2e2;
    border-color: var(--danger);
}

.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.7);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    gap: 8px;
}

.alert-item:last-child {
    margin-bottom: 0;
}

.alert-item-clickable {
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.alert-item-clickable:active {
    background: rgba(255,255,255,0.95);
    transform: scale(0.98);
}

.alert-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.alert-item-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alert-item-brand {
    font-size: 0.8rem;
    color: var(--text-light);
}

.alert-item-badge {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.alert-item-badge.expiring {
    background: var(--warning);
    color: #fff;
}

.alert-item-badge.expiring-soon {
    background: #ffc107;
    color: #333;
}

.alert-item-badge.expiring-later {
    background: #e0e0e0;
    color: #555;
}

.alert-item-badge.expired {
    background: var(--danger);
    color: #fff;
}

.alert-item-badge.today {
    background: var(--danger-light);
    color: #fff;
}

/* Safety badges for expired items */
.alert-item-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.safety-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
    cursor: help;
}

.safety-badge.safety-danger {
    background: #dc3545;
    color: #fff;
}

.safety-badge.safety-warning {
    background: #ffc107;
    color: #333;
}

.safety-badge.safety-ok {
    background: #28a745;
    color: #fff;
}

/* ===== SECTION CARD ===== */
.section-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.section-card h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--primary);
}

/* ===== LOCATION TABS ===== */
.location-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.location-tabs::-webkit-scrollbar { display: none; }

.tab {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 25px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tab:active {
    transform: scale(0.95);
}

/* ===== SEARCH BAR ===== */
.search-bar {
    margin-bottom: 12px;
}

.search-bar input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--bg-card);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--primary);
}

/* ===== INVENTORY LIST ===== */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inventory-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.15s;
}

.inventory-item:active {
    transform: scale(0.98);
}

.inv-image {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.inv-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.inv-info {
    flex: 1;
    min-width: 0;
}

.inv-name {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-brand {
    font-size: 0.8rem;
    color: var(--text-light);
}

.inv-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.inv-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.badge-location {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-category {
    background: #f1f5f9;
    color: #475569;
}

.badge-qty {
    background: #d1fae5;
    color: #047857;
}

.badge-expiry {
    background: #fef3c7;
    color: #92400e;
}

.badge-expired {
    background: #fee2e2;
    color: #dc2626;
}

.inv-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inv-action-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.2s;
}

.inv-action-btn:active {
    background: var(--border);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-large {
    padding: 16px 24px;
    font-size: 1.1rem;
    border-radius: var(--radius);
}

.btn-huge {
    padding: 28px 20px;
    font-size: 1.2rem;
    border-radius: 20px;
    flex: 1;
    flex-direction: column;
    min-height: 120px;
}

.btn-icon {
    font-size: 2.5rem;
}

.btn-text {
    text-align: center;
    line-height: 1.3;
}

.btn-text small {
    font-weight: 400;
    font-size: 0.8rem;
    opacity: 0.85;
}

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

.btn-primary:active {
    background: var(--primary-dark);
}

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

.btn-success:active {
    background: #15803d;
}

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

.btn-danger:active {
    background: #b91c1c;
}

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

#btn-report-bug {
    background: #f97316;
    color: #fff;
    border-color: #ea580c;
}
#btn-report-bug:hover {
    background: #ea580c;
    border-color: #c2410c;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 2px solid var(--border);
}

.move-countdown-btn {
    position: relative;
    overflow: hidden;
    transition: none;
}

/* ===== SCALE LIVE BOX ===== */
.scale-live-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 10px;
}
.scale-live-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}
.scale-live-content {
    flex: 1;
    min-width: 0;
}
.scale-live-val {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.scale-live-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.scale-live-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}
.scale-live-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent, #7c3aed);
    border-radius: 2px;
    transition: none;
}
.scale-live-box.scale-low-weight {
    border-color: #dc2626;
}
.scale-low-weight .scale-live-val {
    color: #dc2626 !important;
    animation: scaleLowTextBlink 0.65s ease-in-out infinite alternate;
}
.scale-low-weight .scale-live-label {
    color: #dc2626 !important;
    font-weight: 600;
    animation: scaleLowTextBlink 0.65s ease-in-out infinite alternate;
}
@keyframes scaleLowTextBlink {
    from { opacity: 1; }
    to   { opacity: 0.2; }
}

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

.btn-accent:active {
    background: #6d28d9;
}

.full-width {
    width: 100%;
}

.mt-2 {
    margin-top: 12px;
}

/* ===== ACTION BUTTONS (Scan page) ===== */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* ===== FORMS ===== */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-card);
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-row {
    display: flex;
    gap: 12px;
}

.flex-1 {
    flex: 1;
}

/* ===== LOCATION SELECTOR ===== */
.location-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.loc-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.loc-btn:active {
    transform: scale(0.97);
}

.loc-btn-opened {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.loc-opened-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #7a4b00;
    background: #fde68a;
    border: 1px solid #f59e0b;
}

.loc-btn.active .loc-opened-badge {
    color: #7a4b00;
    background: #fde68a;
    border-color: #f59e0b;
}

/* ===== QUANTITY CONTROL ===== */
.qty-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qty-btn {
    width: 50px;
    height: 50px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.qty-input {
    width: 80px;
    height: 50px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.qty-input:focus {
    border-color: var(--primary);
}

.qty-control-with-unit {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.qty-control-with-unit .qty-control {
    flex: 0 0 auto;
}

.qty-unit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 50px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.qty-unit-badge.qty-unit-muted {
    background: var(--bg-card);
    color: var(--primary);
    border: 2px solid var(--primary);
}

/* ===== USE OPTIONS ===== */
.use-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.use-unit-switch {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--primary);
}
.use-unit-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.use-unit-btn.active {
    background: var(--primary);
    color: #fff;
}

.use-all-btn {
    min-height: 70px;
    font-size: 1.15rem;
}

.use-partial {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.use-partial p {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Fraction quick-select for pz unit */
.pz-fraction-btns {
    width: 100%;
}
.pz-fraction-btns .form-hint {
    font-size: 0.82rem;
    color: var(--text-light);
    text-align: center;
    margin: 0 0 6px;
}
.fraction-btn-row {
    display: flex;
    gap: 6px;
}
.frac-btn {
    flex: 1;
    padding: 8px 4px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.frac-btn.active {
    background: var(--primary);
    color: #fff;
}
.frac-btn:hover:not(.active) {
    background: var(--primary-light, rgba(74,158,255,0.12));
}

/* ===== SCANNER ===== */
.scan-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* — Spesa chip nel page-header — */
.scan-spesa-chip {
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--accent);
    background: rgba(124,58,237,0.08);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.scan-spesa-chip:active { background: rgba(124,58,237,0.18); }

/* — Viewport 16/9 — */
.scanner-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

/* Spesa mode: hide manual barcode field only — tabs and normal viewport stay */
#page-scan.spesa-scan-layout .barcode-input-row {
    display: none !important;
}
.spesa-scan-barcode-hint {
    margin: 0;
    padding: 6px 4px 2px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.35;
}

.scanner-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
    transition: transform 0.2s ease;
}

/* — Guide frame corners — */
.scan-guide-frame {
    position: absolute;
    inset: 0;
    z-index: 11;
    pointer-events: none;
}
.sgf-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    border-color: rgba(255,255,255,0.85);
    border-style: solid;
}
.sgf-tl { top: 12px; left: 12px; border-width: 3px 0 0 3px; border-radius: 3px 0 0 0; }
.sgf-tr { top: 12px; right: 12px; border-width: 3px 3px 0 0; border-radius: 0 3px 0 0; }
.sgf-bl { bottom: 36px; left: 12px; border-width: 0 0 3px 3px; border-radius: 0 0 0 3px; }
.sgf-br { bottom: 36px; right: 12px; border-width: 0 3px 3px 0; border-radius: 0 0 3px 0; }

/* — Scan line — */
.scanner-overlay {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 3px;
    transform: translateY(-50%);
    z-index: 10;
    pointer-events: none;
}
.scanner-line {
    width: 100%;
    height: 3px;
    background: var(--danger);
    box-shadow: 0 0 10px var(--danger);
    animation: scanLine 2s ease-in-out infinite;
    transition: background 0.2s, box-shadow 0.2s, height 0.2s;
}
.scanner-line.scanning {
    background: #00c853;
    box-shadow: 0 0 12px #00c853;
    animation: scanLineActive 0.8s ease-in-out infinite;
}
.scanner-line.detecting {
    background: #ffd600;
    box-shadow: 0 0 20px #ffd600, 0 0 40px rgba(255,214,0,0.4);
    height: 5px;
    animation: scanLineDetect 0.3s ease-in-out infinite;
}
@keyframes scanLine {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
@keyframes scanLineActive {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes scanLineDetect {
    0%, 100% { opacity: 1; transform: scaleY(1); }
    50% { opacity: 0.7; transform: scaleY(2); }
}

/* — Live partial code — */
.scan-live-code {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 14px));
    z-index: 12;
    background: rgba(0,0,0,0.65);
    color: #ffd600;
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 8px;
    pointer-events: none;
    white-space: nowrap;
}

/* — Success confirm overlay — */
.scan-confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(0,180,80,0.82);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: var(--radius);
    animation: scanConfirmFade 0.12s ease-in;
}
@keyframes scanConfirmFade {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}
.scan-confirm-check {
    font-size: 2.8rem;
    color: #fff;
    line-height: 1;
}
.scan-confirm-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    padding: 0 16px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* — Scan status bar — */
.scan-status-bar {
    position: absolute;
    bottom: 38px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    pointer-events: none;
    z-index: 12;
}
.scan-status-method {
    font-size: 0.58rem;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-family: monospace;
}
.scan-status-msg {
    font-size: 0.74rem;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.55);
    padding: 3px 10px;
    border-radius: 12px;
    text-align: center;
    max-width: 92%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s, background 0.2s;
    backdrop-filter: blur(3px);
}
.scan-status-msg:empty { visibility: hidden; }
.scan-status-msg.state-partial { color: #fbbf24; }
.scan-status-msg.state-invalid { color: #f87171; background: rgba(239,68,68,0.28); }
.scan-status-msg.state-confirmed { color: #4ade80; background: rgba(74,222,128,0.22); }
.scan-status-msg.state-retry { color: #fb923c; }

/* — AI processing overlay (full-viewport, shown during Gemini Vision call) — */
.scan-ai-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--radius);
}
.scan-ai-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 28px;
    background: rgba(255,255,255,0.07);
    border: 1.5px solid rgba(255,255,255,0.18);
    border-radius: 16px;
}
.scan-ai-overlay-label {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: monospace;
}
.scan-ai-overlay-msg {
    font-size: 0.88rem;
    color: #fff;
    text-align: center;
    max-width: 220px;
}

/* — Manual AI button (user-triggered only) — */
.scan-ai-manual-btn {
    width: 100%;
    margin-top: 10px;
    font-size: 1.05rem;
    padding: 14px 16px;
    border-radius: 14px;
    border: 2px solid var(--accent);
    background: rgba(124,58,237,0.12);
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}
.scan-ai-manual-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.scan-ai-manual-btn:active:not(:disabled) { background: rgba(124,58,237,0.22); }

/* — Viewport overlay controls (torch / zoom / flip) — */
.scan-viewport-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.55));
}
.scan-ctrl-btn {
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.45);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.scan-ctrl-btn:active { background: rgba(255,255,255,0.35); }
.scan-ctrl-btn.torch-on { background: rgba(255,220,0,0.35); border-color: #ffd600; }
.scan-zoom-badge {
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1.5px solid rgba(255,255,255,0.4);
    letter-spacing: 0.5px;
}

/* — Scan result errors — */
.scan-result {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.scan-ai-match-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.scan-ai-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(34,197,94,0.1));
    border-radius: 14px;
    border: 1px solid var(--border);
}
.scan-ai-hero-icon {
    font-size: 2.6rem;
    line-height: 1;
    flex-shrink: 0;
}
.scan-ai-hero-text {
    min-width: 0;
    flex: 1;
}
.scan-ai-match-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.scan-ai-hero-name {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    word-break: break-word;
}
.scan-ai-hero-brand {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.scan-ai-action-hint {
    margin: -6px 0 0;
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--text-muted);
    text-align: center;
}
.scan-ai-or-divider {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}
.scan-ai-match-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
}
.scan-ai-match-list-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.scan-ai-match-list-title {
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}
.scan-ai-match-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.scan-ai-candidate-item {
    border: 1px solid var(--border);
    background: var(--bg-main);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}
.scan-ai-candidate-item:active { transform: scale(0.99); }
.scan-ai-candidate-thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
}
.scan-ai-candidate-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.scan-ai-candidate-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}
.scan-ai-candidate-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.scan-ai-candidate-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scan-ai-candidate-meta {
    font-size: 0.84rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scan-ai-candidate-cta {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 6px 10px;
    flex-shrink: 0;
}
.scan-ai-match-empty {
    font-size: 0.86rem;
    color: var(--text-muted);
    background: var(--bg-main);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.scan-ai-add-btn {
    width: 100%;
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    padding: 16px 20px !important;
    min-height: 54px;
    border-radius: 14px !important;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}
.scan-ai-detected-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.scan-ai-detected-pill {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-main);
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: 6px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* — Recent scans — */
.scan-recents {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}
.scan-recents-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.scan-recents-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}
.scan-recents-chips::-webkit-scrollbar { display: none; }
.scan-recent-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: var(--shadow);
    transition: background 0.12s, transform 0.1s;
}
.scan-recent-chip:active { background: var(--bg-main); transform: scale(0.96); }
.scan-recent-chip-icon { font-size: 1rem; }

/* — Input panel (bottom card) — */
.scan-input-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.scan-input-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.scan-input-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 6px;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.scan-input-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(124,58,237,0.05);
}
.scan-tab-content {
    padding: 12px;
}

/* — Barcode input row — */
.barcode-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.barcode-input-row .form-input {
    flex: 1;
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: 1px;
}
.barcode-input-row .btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* — AI tab buttons — */
.scan-ai-tab-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.scan-ai-tab-btns .btn { width: 100%; }

/* — AI number OCR fallback button — */
.scan-num-ocr-btn {
    width: 100%;
    margin-top: 8px;
    background: rgba(124,58,237,0.08);
    border: 1.5px dashed var(--accent);
    color: var(--accent);
    font-size: 0.88rem;
    padding: 9px;
    border-radius: var(--radius);
}
.scan-num-ocr-btn:active { background: rgba(124,58,237,0.18); }

/* — Quick name results (dropdown inside name tab) — */
.quick-name-results {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}
.quick-name-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-main);
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.1s;
}
.quick-name-result-item:active { transform: scale(0.98); }
.quick-name-result-item .qnr-icon { font-size: 1.4rem; flex-shrink: 0; }
.quick-name-result-item .qnr-info { flex: 1; min-width: 0; }
.quick-name-result-item .qnr-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quick-name-result-item .qnr-detail { font-size: 0.78rem; color: var(--text-muted); }
.quick-name-result-item.qnr-new {
    border: 1px dashed var(--accent);
    background: rgba(124,58,237,0.05);
}

/* ===== SHOPPING LIST (BRING!) ===== */
.shopping-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== SHOPPING TABS ===== */
.shopping-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow);
}

.shopping-tab {
    flex: 1;
    padding: 9px 8px;
    border-radius: calc(var(--radius) - 2px);
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.shopping-tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 6px rgba(45, 80, 22, 0.25);
}

.shopping-tab-count {
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.shopping-tab:not(.active) .shopping-tab-count {
    background: var(--bg);
    color: var(--accent);
}

.tab-panel-shopping {
    display: none;
}

.tab-panel-shopping.active {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== SHOPPING ITEM ENHANCEMENTS ===== */
.shopping-item {
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.shopping-item:active {
    transform: scale(0.99);
    background: #f0fdf4;
}

.shopping-item-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shopping-item-scan-hint {
    font-size: 0.75rem;
    opacity: 0.4;
    flex-shrink: 0;
}

.shopping-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
}

/* Generic small item badge (sinv = shopping inventory) */
.sinv-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
    line-height: 1.6;
}

.badge-critical { background: #fee2e2; color: #dc2626; }
.badge-high     { background: #ffedd5; color: #c2410c; }
.badge-medium   { background: #fef9c3; color: #a16207; }
.badge-low      { background: #dcfce7; color: #15803d; }

.badge-freq-high { background: #fce7f3; color: #be185d; }
.badge-freq-med  { background: #ede9fe; color: #6d28d9; }
.badge-freq-low  { background: #f1f5f9; color: #64748b; }

.badge-local-tag { background: #e0f2fe; color: #0369a1; cursor: pointer; }
.badge-local-tag:hover { background: #bae6fd; }

/* ─── Shopping price badge ─── */
.shopping-item-price-badge {
    margin-top: 4px;
    min-height: 1.2rem;
}
.price-badge-value {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #15803d;
    background: #dcfce7;
    border-radius: 8px;
    padding: 1px 7px;
    white-space: nowrap;
}
.price-badge-loading {
    display: inline-block;
    font-size: 0.7rem;
    color: #94a3b8;
    font-style: italic;
}
.price-badge-error {
    display: inline-block;
    font-size: 0.65rem;
    color: #94a3b8;
}

/* ─── Price column — right-side per-item price display ─── */
.shopping-item-price-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
    min-width: 58px;
    text-align: right;
    padding: 0 4px;
}
.price-col-main {
    font-size: 1.05rem;
    font-weight: 700;
    color: #15803d;
    white-space: nowrap;
    line-height: 1.25;
}
.price-col-main.price-col-approx {
    color: #64748b;
    font-weight: 600;
}
.price-col-unit {
    font-size: 0.62rem;
    color: #94a3b8;
    white-space: nowrap;
    line-height: 1.2;
    margin-top: 1px;
}
.price-col-loading {
    font-size: 0.7rem;
    color: #cbd5e1;
    font-style: italic;
}
.price-col-error {
    font-size: 0.75rem;
    color: #cbd5e1;
}

/* ─── Price summary bar (top of shopping tab) ─── */
.shopping-price-total-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 4px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-radius: 10px;
    margin: 8px 0 4px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #166534;
    box-shadow: 0 1px 4px rgba(21,128,61,0.08);
}
.price-total-label {
    flex: 1;
}
.price-total-value {
    font-size: 1rem;
    font-weight: 700;
}
.btn-price-refresh {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}
.btn-price-refresh:hover { background: rgba(0,0,0,0.07); }
.btn-price-refresh:disabled { opacity: 0.5; cursor: default; }

/* Loading progress bar */
.price-loading-bar {
    height: 3px;
    background: #dcfce7;
    border-radius: 2px;
    overflow: hidden;
    margin: 0 12px 6px;
}
.price-loading-inner {
    height: 100%;
    width: 0%;
    background: #16a34a;
    border-radius: 2px;
    transition: width 0.3s ease;
}
@keyframes price-sweep {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Tag add button */
.shopping-item-tag-btn {
    background: none;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.shopping-item-tag-btn:hover { opacity: 1; }

/* Tag menu dropdown */
.shopping-tag-menu-container {
    margin-top: 6px;
    padding: 6px 8px;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.shopping-tag-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.badge-tag-add {
    background: #f1f5f9;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    padding: 2px 8px;
}

.badge-tag-add:hover, .badge-tag-add.active {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #7dd3fc;
}

/* ===== SHOPPING SCAN TARGET BANNER ===== */
.shopping-scan-target-banner {
    background: linear-gradient(135deg, #FFF9C4, #FFF3CD);
    border: 1.5px solid #F59E0B;
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0 0 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shopping-scan-target-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stb-label {
    font-size: 0.8rem;
    color: #92400e;
    font-weight: 600;
    white-space: nowrap;
}

.stb-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #78350f;
}

.shopping-scan-target-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stb-btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.82rem;
    min-width: 120px;
}


.bring-loading {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bring-error {
    text-align: center;
    padding: 20px;
    background: #fef2f2;
    color: #dc2626;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.shopping-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.shopping-section-header h3 {
    font-size: 1rem;
    margin: 0;
}

.shopping-count {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.shopping-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shopping-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    /* tap-to-scan handled by JS; cursor/active defined in ENHANCEMENTS block above */
}

.shopping-item-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.shopping-item-body {
    flex: 1;
    min-width: 0;
}

.shopping-item-top {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.shopping-item-info {
    flex: 1;
    min-width: 0;
}

.shopping-item-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.shopping-item-spec {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.shopping-pantry-hint {
    font-size: 0.72rem;
    color: #15803d;
    font-weight: 500;
    margin-top: 2px;
    opacity: 0.85;
}
[data-theme="dark"] .shopping-pantry-hint {
    color: #4ade80;
}

.shopping-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    flex-shrink: 0;
    min-width: 70px;
}

.shopping-item-price {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--accent);
    line-height: 1.1;
    white-space: nowrap;
    margin-top: auto;
}

.shopping-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
    line-height: 1;
}

.shopping-item-remove:hover,
.shopping-item-remove:active {
    background: #fee2e2;
    color: #dc2626;
}

.shopping-item-remove:hover,
.shopping-item-remove:active {
    background: #fee2e2;
    color: #ef4444;
}

.shopping-actions {
    margin-top: 8px;
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.shopping-actions .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 10px 8px;
}

.seasonal-tip {
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #065f46;
    margin-bottom: 8px;
    border-left: 3px solid #10b981;
}

.suggestion-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    border: 2px solid transparent;
}

.suggestion-item.selected {
    border-color: var(--accent);
    background: #faf5ff;
}

.suggestion-item:active {
    transform: scale(0.98);
}

.suggestion-check {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.suggestion-info {
    flex: 1;
    min-width: 0;
}

.suggestion-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.suggestion-name small {
    font-weight: 400;
    color: var(--text-muted);
}

.suggestion-reason {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.suggestion-ai-tip {
    font-size: 0.75rem;
    color: #6366f1;
    margin-top: 3px;
    opacity: 0.88;
}

.priority-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    vertical-align: middle;
    margin-left: 4px;
    text-transform: uppercase;
}

.priority-high {
    background: #fee2e2;
    color: #dc2626;
}

.priority-med {
    background: #fef9c3;
    color: #ca8a04;
}

.priority-low {
    background: #ecfdf5;
    color: #059669;
}
.priority-ai {
    background: #f0f4ff;
    color: #4338ca;
    font-style: italic;
}

.suggestion-actions {
    margin-top: 12px;
    text-align: center;
}

.suggestion-actions .btn-success {
    width: 100%;
}

/* ===== SMART SHOPPING ===== */
.smart-shopping {
    margin-top: 16px;
}

.smart-shopping h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.smart-shopping h3 .shopping-count {
    font-size: 0.75rem;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-weight: 600;
}

.smart-last-update-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}
.smart-last-update {
    font-size: 0.70rem;
    color: rgba(255,255,255,0.30);
    font-style: italic;
}

.smart-filter-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.smart-filter-row::-webkit-scrollbar {
    display: none;
}

.smart-filter {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.smart-filter.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.smart-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.smart-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.1s;
}

.smart-item:active {
    transform: scale(0.99);
}

.smart-item-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.smart-check {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    flex-shrink: 0;
    cursor: pointer;
}

.smart-item-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}

.smart-item-info {
    flex: 1;
    min-width: 0;
}

.smart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
}

.smart-item-specific {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1.3;
    font-style: italic;
}

.shopping-item-specific {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
    font-style: italic;
}

.smart-brand {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.smart-item-reasons {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.smart-item-reasons span + span::before {
    content: '';
}

.smart-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.smart-urgency-badge,
.smart-freq-badge,
.smart-pred-badge,
.smart-bring-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 8px;
    white-space: nowrap;
}

.smart-urgency-badge {
    background: #f3f4f6;
}

.smart-freq-badge {
    background: #ede9fe;
    color: #6d28d9;
}

.smart-freq-badge.freq-high {
    background: #fce7f3;
    color: #be185d;
}

.smart-freq-badge.freq-med {
    background: #ede9fe;
    color: #6d28d9;
}

.smart-freq-badge.freq-low {
    background: #f0fdf4;
    color: #15803d;
}

.smart-freq-badge.freq-suggest {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
}
.smart-freq-badge.freq-suggest-approx {
    background: #f0f9ff;
    color: #0284c7;
    font-weight: 500;
    font-style: italic;
}

.smart-pred-badge {
    background: #fefce8;
    color: #a16207;
}

.smart-pred-badge.pred-urgent {
    background: #fee2e2;
    color: #dc2626;
}

.smart-pred-badge.pred-soon {
    background: #fff7ed;
    color: #c2410c;
}

.smart-bring-badge {
    background: #dbeafe;
    color: #1d4ed8;
}

.smart-item-stock {
    text-align: right;
    flex-shrink: 0;
    min-width: 50px;
}

.smart-qty {
    font-size: 0.8rem;
    font-weight: 700;
    display: block;
}

.smart-stock-bar {
    width: 44px;
    height: 5px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
    margin-left: auto;
}

.smart-stock-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.smart-actions {
    margin-top: 12px;
    text-align: center;
}

.smart-actions .btn {
    width: 100%;
    font-size: 0.85rem;
    padding: 10px;
}

.stat-urgent {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.3;
}
.stat-price-total {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #dcfce7;
    color: #15803d;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.3;
    white-space: nowrap;
}

/* ===== PRODUCT PREVIEW ===== */
.product-preview, .product-preview-small {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Action and Use page hero card */
#page-action .product-preview-small,
#page-use .product-preview-small {
    padding: 14px 16px;
    gap: 14px;
    border-left: 4px solid var(--primary);
    align-items: flex-start;
    position: relative;
}

/* action page: slightly larger name */
#page-action .use-hero-name {
    font-size: 1.15rem;
}

/* barcode pill on action page */
.action-pill-barcode { background: #f1f5f9; color: #64748b; }

.use-hero-icon {
    font-size: 2.4rem;
    width: 52px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
    padding-top: 2px;
}

.use-hero-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.use-hero-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.use-hero-brand {
    font-size: 0.8rem;
    color: var(--text-light);
}

.use-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.use-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 99px;
    line-height: 1.3;
    white-space: nowrap;
}

/* Expiry pill colours */
.use-pill-ok       { background: #dcfce7; color: #166534; }
.use-pill-warn     { background: #fef9c3; color: #854d0e; }
.use-pill-soon     { background: #fed7aa; color: #7c2d12; }
.use-pill-expired  { background: #fee2e2; color: #991b1b; }
/* Quantity pill */
.use-pill-qty      { background: #e0f2fe; color: #0c4a6e; }

.product-preview img, .product-preview-small img {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg);
}

.product-preview-small img {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.product-preview-emoji {
    font-size: 2.5rem;
    width: 60px;
    text-align: center;
}

.product-preview-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.product-preview-info p {
    font-size: 0.85rem;
    color: var(--text-light);
}

.product-image-preview {
    text-align: center;
    margin: 8px 0;
}

.product-image-preview img {
    max-width: 120px;
    border-radius: var(--radius-sm);
}

/* ===== AI PAGE ===== */
.ai-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-capture {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.ai-capture video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-preview {
    text-align: center;
}

.ai-preview img {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.ai-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-result {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    min-width: 56px;
}

.nav-btn.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-logo-icon {
    height: 24px;
    width: auto;
    object-fit: contain;
    display: block;
}

.nav-label {
    font-size: 0.65rem;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-dark);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
    gap: 12px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0;
}

#modal-overlay {
    z-index: 250;
}

/* Raise modal above cooking overlay when in cooking mode */
.cooking-mode-active #modal-overlay {
    z-index: 99999;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 1.15rem;
}

.modal-close {
    background: var(--bg);
    border: none;
    font-size: 1.3rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Bug report form ── */
.bug-type-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.bug-type-pill {
    flex: 1;
    min-width: 80px;
    padding: 7px 10px;
    border: 1.5px solid #cbd5e1;
    border-radius: 20px;
    background: #fff;
    color: #475569;
    font-size: 0.88rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.bug-type-pill.active {
    border-color: var(--primary, #2d5016);
    background: var(--primary, #2d5016);
    color: #fff;
    font-weight: 600;
}
.bug-type-pill:not(.active):hover {
    border-color: var(--primary, #2d5016);
    color: var(--primary, #2d5016);
}

.modal-detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.modal-detail-label {
    color: var(--text-light);
    font-weight: 500;
}

.modal-detail-value {
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ===== TRANSACTIONS LIST ===== */
.transaction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.transaction-item:last-child {
    border-bottom: none;
}

.tx-icon {
    font-size: 1.3rem;
    width: 32px;
    text-align: center;
}

.tx-info {
    flex: 1;
}

.tx-name {
    font-weight: 600;
}

.tx-detail {
    font-size: 0.8rem;
    color: var(--text-light);
}

.tx-qty {
    font-weight: 700;
    font-size: 0.9rem;
}

.tx-qty.in {
    color: var(--success);
}

.tx-qty.out {
    color: var(--danger);
}

/* ===== PRODUCTS LIST ===== */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.product-item:active {
    transform: scale(0.98);
}

/* ===== USE INVENTORY INFO ===== */
.use-inventory-info {
    background: #dbeafe;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #1d4ed8;
    font-weight: 500;
}

#use-expiry-hint {
    background: #fef3c7;
    border: 1.5px solid #f59e0b;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #92400e;
    font-weight: 500;
    line-height: 1.45;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ===== CATEGORY GROUP HEADERS ===== */
.cat-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px 4px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    margin-top: 8px;
}

.cat-group-header:first-child {
    margin-top: 0;
}

.cat-group-count {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: auto;
}

/* ===== EDIT UNKNOWN PRODUCT ===== */
.edit-unknown-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 0;
    box-shadow: var(--shadow);
    border: 2px solid var(--border);
}

.edit-unknown-card.highlight {
    border-color: var(--warning);
    background: #fffbeb;
}

.edit-unknown-card h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.edit-unknown-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.edit-unknown-form .form-group {
    margin-bottom: 10px;
}

.edit-unknown-form .form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

/* ===== COMPACT INVENTORY ON DASHBOARD ===== */
.inventory-list.compact {
    gap: 4px;
}

.compact-item {
    padding: 10px 12px;
    border-radius: 12px;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.compact-item:last-child {
    border-bottom: none;
}

.compact-item .inv-image {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
}

.compact-item .inv-image img {
    width: 36px;
    height: 36px;
}

.compact-item .inv-info {
    flex: 1;
    min-width: 0;
}

.compact-item .inv-name {
    font-size: 0.92rem;
}

.compact-item .inv-brand {
    font-size: 0.75rem;
}

.inv-qty-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    flex-shrink: 0;
}

.inv-qty-value {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary);
    white-space: nowrap;
}

.inv-qty-value small {
    font-size: 0.7rem;
    font-weight: 600;
    color: #4b5563;
}

.inv-qty-pkg-detail {
    font-size: 0.65rem;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

.inv-expiry-small {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.inv-expiry-small.expiring {
    color: var(--warning);
    font-weight: 600;
}

.inv-expiry-small.expired {
    color: var(--danger);
    font-weight: 600;
}

.section-card h3 {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .dashboard-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .location-selector {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    }
    body {
        padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
    }
}

/* ===== PURCHASE TYPE SELECTOR ===== */
.purchase-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0 12px;
}

.purchase-type-btn {
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.purchase-type-btn.active {
    border-color: var(--primary);
    background: rgba(45, 80, 22, 0.08);
    color: var(--primary);
}

/* ===== EXPIRY DETAIL ===== */
.expiry-detail {
    margin-top: 8px;
    padding: 12px;
    background: #f8faf5;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(45, 80, 22, 0.1);
}

.expiry-estimate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 8px;
}

.expiry-estimate-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.expiry-estimate-date {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.history-badge {
    font-size: 0.75rem;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    vertical-align: middle;
    font-weight: 500;
    cursor: default;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 28px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary, #3b82f6);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}
.vacuum-badge {
    font-size: 0.7rem;
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

.opened-badge {
    font-size: 0.7rem;
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

/* ===== REMAINING QUANTITY OPTIONS ===== */
.remaining-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 6px;
}

.remaining-btn {
    padding: 10px 4px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.remaining-btn.active {
    border-color: var(--primary);
    background: rgba(45, 80, 22, 0.08);
    font-weight: 600;
}

/* ===== MULTI-BATCH EXPIRY (conf products with different expiry dates) ===== */
.multi-batch-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.04);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.multi-batch-qty {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.multi-batch-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.multi-batch-date {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem !important;
}

.btn-icon-sm {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
}

.btn-link-small {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── Preferred use-location (collapsed row) ── */
.pref-loc-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.pref-loc-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}
.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 2px 6px;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.pref-loc-full-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ===== PRODUCT DETAILS CARD (Action Page) ===== */
.product-details-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin: 0 16px 16px;
    box-shadow: var(--shadow);
}

.product-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.product-detail-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    background: #f3f4f6;
    font-size: 0.8rem;
    color: #374151;
    white-space: nowrap;
}

.product-allergens {
    padding: 8px 10px;
    background: #fef3cd;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #856404;
}

.product-ingredients {
    margin-top: 6px;
}

.product-ingredients summary {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    padding: 6px 0;
}

.product-ingredients p {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.5;
    padding: 6px 0;
}

.product-conservation {
    font-size: 0.8rem;
    color: var(--text-light);
    padding: 6px 0;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}

/* ===== QUANTITY + UNIT ROW ===== */
.qty-unit-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.unit-select {
    width: 70px;
    min-width: 70px;
    padding: 10px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}

/* ===== CONF PACKAGE SIZE ROW ===== */
.conf-size-row {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f0f9ff;
    border: 1.5px solid #bae6fd;
    border-radius: var(--radius-sm);
}

.conf-size-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #0369a1;
}

.conf-size-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.conf-size-input {
    flex: 1;
    max-width: 120px;
}

.conf-size-unit {
    width: 65px;
    min-width: 65px;
}

.conf-size-info {
    font-size: 0.75em;
    color: var(--text-light);
    font-weight: 500;
}

/* ===== EXPIRY INPUT + CAMERA ROW ===== */
.expiry-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.expiry-input-row .form-input {
    flex: 1;
}

.btn-scan-expiry {
    padding: 10px 14px !important;
    font-size: 1.2rem;
    min-width: 48px;
    border-radius: var(--radius-sm);
}

/* ===== EXPIRY SCANNER MODAL ===== */
.expiry-scanner {
    padding: 4px 0;
}

.expiry-scanner-actions {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== RECIPE DIALOG ===== */
.recipe-dialog {
    max-height: 85vh;
    overflow-y: auto;
    width: 94%;
    max-width: 500px;
}

.recipe-ask {
    text-align: center;
}

.recipe-ask h3 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.recipe-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.recipe-ask .form-group {
    margin-bottom: 20px;
}

.recipe-ask .qty-control {
    justify-content: center;
}

.recipe-loading {
    text-align: center;
    padding: 40px 16px;
}

.recipe-loading p {
    margin-top: 16px;
    color: var(--text-muted);
    font-weight: 600;
    transition: opacity 0.25s ease;
    min-height: 1.4em;
}

.recipe-result {
    text-align: left;
}

.recipe-result h2 {
    font-size: 1.3rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.recipe-result h3 {
    font-size: 1.1rem;
    margin-top: 16px;
    margin-bottom: 8px;
    color: var(--text);
}

.recipe-result ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

.recipe-result li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.recipe-result ol {
    padding-left: 20px;
    margin-bottom: 8px;
}

.recipe-result ol li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.recipe-result .recipe-tag {
    display: inline-block;
    background: var(--bg-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    margin: 2px 4px 2px 0;
}

.recipe-result .recipe-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.recipe-result .recipe-expiry-note {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 12px;
    line-height: 1.5;
}

/* ===== RECIPE NUTRITION BLOCK ===== */
.recipe-nutrition-block {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    padding: 12px 14px 8px;
    margin-top: 16px;
}
.recipe-section-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: #15803d;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.recipe-nutrition-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    text-align: center;
}
.recipe-nutrition-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.recipe-nutrition-icon { font-size: 1.2rem; }
.recipe-nutrition-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #15803d;
}
.recipe-nutrition-label {
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.recipe-nutrition-note {
    font-size: 0.7rem;
    color: #94a3b8;
    text-align: center;
    margin: 6px 0 0;
}
.recipe-nutrition-footnote {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* ===== RECIPE STORAGE CARD ===== */
.recipe-storage-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 12px 14px 8px;
    margin-top: 12px;
}
.recipe-storage-card .recipe-section-heading { color: #b45309; }
.recipe-storage-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.recipe-storage-badge {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 20px;
    padding: 2px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #92400e;
    white-space: nowrap;
    text-transform: capitalize;
}
.recipe-storage-days { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.recipe-storage-now  { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.recipe-storage-tips {
    font-size: 0.82rem;
    color: #78350f;
    margin: 2px 0 0;
    line-height: 1.4;
}

.recipe-tools-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #3730a3;
    margin-bottom: 12px;
    line-height: 1.5;
}
.recipe-tool-chip {
    background: #e0e7ff;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.8rem;
    color: #3730a3;
    white-space: nowrap;
}
/* Appliance/mode badge shown inline next to a step text */
.recipe-step-appliance {
    display: inline-block;
    margin-left: 6px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 1px 8px;
    font-size: 0.72rem;
    color: #15803d;
    vertical-align: middle;
    white-space: nowrap;
}

/* Regen choice panel */
.recipe-regen-choice {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    margin-top: 10px;
}
.recipe-regen-choice-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    margin: 0 0 10px 0;
    text-align: center;
}

/* Recipe ingredient use buttons */
.recipe-ingredients {
    list-style: none;
    padding: 0;
}

.recipe-ingredient {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--bg-light);
}

.recipe-ingredient:last-child {
    border-bottom: none;
}

.recipe-ing-text {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}
.recipe-ing-name {
    cursor: pointer;
    border-bottom: 1px dashed rgba(74,222,128,0.5);
    transition: color 0.15s, border-color 0.15s;
}
.recipe-ing-name:hover {
    color: #4ade80;
    border-bottom-color: #4ade80;
}

.btn-use-ingredient {
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, opacity 0.2s;
}

.btn-use-ingredient:active {
    opacity: 0.7;
}

.btn-use-ingredient:disabled {
    cursor: default;
    opacity: 0.6;
}

.btn-use-ingredient.btn-used {
    background: var(--success);
}

.recipe-ing-used .recipe-ing-text {
    text-decoration: line-through;
    opacity: 0.5;
}

.recipe-ing-detail {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.3;
}

.recipe-ing-stock {
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.35;
    opacity: 0.9;
}

/* ===== SHOPPING SECTION (REPARTO) HEADERS ===== */
.shopping-section-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 2px 4px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    margin-top: 4px;
}

.shopping-section-divider:first-child {
    margin-top: 0;
    padding-top: 2px;
    border-bottom: none;
}

.shopping-section-divider span.sec-icon {
    font-size: 1rem;
}

/* ===== WEEKLY MEAL PLAN ===== */
.mplan-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mplan-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 2px;
    padding-left: 44px;
}
.mplan-col-header {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.mplan-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.mplan-row-today {
    background: rgba(45,80,22,0.08);
    outline: 2px solid var(--primary-light);
    border-radius: var(--radius-sm);
}
.mplan-day-name {
    width: 36px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: center;
}
.mplan-badge {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    padding: 7px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s, transform 0.1s;
    text-align: center;
    line-height: 1.2;
}
.mplan-badge:active { transform: scale(0.93); }
.mplan-badge-pranzo { background: var(--primary-light); }
.mplan-badge-cena   { background: #1e3a6e; }

/* Meal plan picker popup */
.mplan-picker {
    position: fixed;
    z-index: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    left: 50% !important;
    transform: translateX(-50%);
    width: min(320px, 92vw);
}
.mplan-pick-btn {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.mplan-pick-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.mplan-pick-btn:active { opacity: 0.7; }

/* Legend in settings */
.mplan-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

/* Recipe dialog banner (top strip) */
.recipe-mealplan-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--primary);
    color: #fff;
    padding: 11px 20px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: -20px -20px 16px;
    letter-spacing: 0.2px;
}

/* Recipe dialog hint */
.recipe-mealplan-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(45,80,22,0.07);
    border: 1px solid rgba(45,80,22,0.18);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin: 4px 0 12px;
    font-size: 0.88rem;
}
.mplan-hint-badge {
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}
.mplan-hint-label {
    color: var(--text-muted);
    font-size: 0.80rem;
}

/* ===== COOKING MODE ===== */
.cooking-overlay {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    z-index: 99998; /* above every fixed UI: header, update banner, etc. */
    display: flex;
    flex-direction: column;
    color: #fff;
    overflow: hidden;
    touch-action: pan-y;
}

/* Hide update banner, app-header and any other fixed-top chrome while in cooking mode */
body.cooking-mode-active #_evershelf_update_banner,
body.cooking-mode-active .app-header {
    display: none !important;
}

.cooking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.10);
    flex-shrink: 0;
    min-height: 54px;
}

.cooking-title {
    flex: 1;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    margin: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cooking-close-btn,
.cooking-tts-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.cooking-close-btn:active,
.cooking-tts-btn:active {
    background: rgba(255,255,255,0.2);
}

.cooking-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    gap: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.cooking-step-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-shrink: 0;
    width: 100%;
}

.cooking-step-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.1em;
    text-align: center;
    flex-shrink: 0;
}

.cooking-restart-btn {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    color: rgba(255,255,255,0.45);
    border-radius: 14px;
    padding: 4px 11px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.cooking-restart-btn:active {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

/* Progress dots */
.cooking-progress-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    max-width: 320px;
    width: 100%;
}
.cprog-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 1.5px solid rgba(255,255,255,0.18);
    transition: background 0.25s, border-color 0.25s, transform 0.2s;
    flex-shrink: 0;
}
.cprog-dot.visited {
    background: rgba(255,255,255,0.50);
    border-color: rgba(255,255,255,0.50);
}
.cprog-dot.current {
    background: #f59e0b;
    border-color: #fbbf24;
    transform: scale(1.35);
}

.cooking-wheel {
    position: relative;
    --wheel-tilt-x: 0deg;
    --wheel-tilt-y: 0deg;
    --wheel-glow: 0.45;
    width: min(90vw, 680px);
    max-width: 680px;
    min-height: clamp(240px, 36vh, 340px);
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1100px;
    overflow: hidden;
    border-radius: 24px;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.07), rgba(255,255,255,0.02) 58%, transparent 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: inset 0 0 48px rgba(0,0,0,0.35);
    touch-action: pan-y;
}

.cooking-wheel::before,
.cooking-wheel::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.cooking-wheel::before {
    background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.18), rgba(251, 191, 36, 0.08) 36%, transparent 72%);
    opacity: var(--wheel-glow);
    transition: opacity 0.2s ease;
}

.cooking-wheel::after {
    background: linear-gradient(180deg, rgba(0,0,0,0.34) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.34) 100%);
}

.cooking-step-text,
.cooking-step-ghost {
    width: min(88vw, 620px);
    text-align: center;
    line-height: 1.5;
    padding: 18px 20px;
    border-radius: 20px;
    transform-style: preserve-3d;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.cooking-step-text {
    position: relative;
    z-index: 3;
    font-size: clamp(1.35rem, 4.6vw, 2.1rem);
    font-weight: 600;
    color: #fff;
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.20);
    box-shadow: 0 18px 35px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.24);
    transform: rotateX(var(--wheel-tilt-x)) rotateY(var(--wheel-tilt-y));
    animation: cookingCardFloat 4.2s ease-in-out infinite;
}

.cooking-step-ghost {
    position: absolute;
    left: 50%;
    top: 0;
    transform-origin: center center;
    font-size: clamp(1.08rem, 3.9vw, 1.52rem);
    font-weight: 560;
    color: rgba(255,255,255,0.95);
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow: 0 12px 28px rgba(0,0,0,0.38), inset 0 1px 0 rgba(255,255,255,0.22);
    text-shadow: 0 1px 2px rgba(0,0,0,0.34);
    opacity: 0.66;
    max-height: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cooking-step-prev {
    color: rgba(255, 243, 210, 0.97);
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.24), rgba(251, 191, 36, 0.10));
    border-color: rgba(251, 191, 36, 0.36);
    transform: translateX(-50%) rotateX(56deg) rotateY(calc(var(--wheel-tilt-y) * 0.28)) scale(0.9);
}

.cooking-step-next {
    color: rgba(220, 243, 255, 0.97);
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.24), rgba(56, 189, 248, 0.10));
    border-color: rgba(56, 189, 248, 0.36);
    transform: translateX(-50%) rotateX(-56deg) rotateY(calc(var(--wheel-tilt-y) * 0.28)) scale(0.9);
}

.cooking-step-ghost.is-empty {
    opacity: 0;
}

.cooking-wheel.turn-next .cooking-step-text {
    animation: cookingWheelCenterNext 0.34s ease;
}

.cooking-wheel.turn-prev .cooking-step-text {
    animation: cookingWheelCenterPrev 0.34s ease;
}

.cooking-wheel.turn-next .cooking-step-prev {
    animation: cookingWheelGhostNext 0.34s ease;
}

.cooking-wheel.turn-prev .cooking-step-next {
    animation: cookingWheelGhostPrev 0.34s ease;
}

.cooking-wheel.snap .cooking-step-text {
    animation: cookingWheelSnap 0.28s ease;
}

@keyframes cookingWheelCenterNext {
    from { transform: translateY(20px) rotateX(-10deg); opacity: 0.75; }
    to   { transform: translateY(0) rotateX(0); opacity: 1; }
}

@keyframes cookingWheelCenterPrev {
    from { transform: translateY(-20px) rotateX(10deg); opacity: 0.75; }
    to   { transform: translateY(0) rotateX(0); opacity: 1; }
}

@keyframes cookingWheelGhostNext {
    from { opacity: 0.1; transform: translateX(-50%) rotateX(68deg) scale(0.84); }
    to   { opacity: 0.66; transform: translateX(-50%) rotateX(56deg) scale(0.9); }
}

@keyframes cookingWheelGhostPrev {
    from { opacity: 0.1; transform: translateX(-50%) rotateX(-68deg) scale(0.84); }
    to   { opacity: 0.66; transform: translateX(-50%) rotateX(-56deg) scale(0.9); }
}

@keyframes cookingCardFloat {
    0%, 100% { transform: rotateX(var(--wheel-tilt-x)) rotateY(var(--wheel-tilt-y)) translateY(0); }
    50%      { transform: rotateX(var(--wheel-tilt-x)) rotateY(var(--wheel-tilt-y)) translateY(-3px); }
}

@keyframes cookingWheelSnap {
    0%   { transform: rotateX(var(--wheel-tilt-x)) rotateY(var(--wheel-tilt-y)) scale(0.97); }
    70%  { transform: rotateX(var(--wheel-tilt-x)) rotateY(var(--wheel-tilt-y)) scale(1.018); }
    100% { transform: rotateX(var(--wheel-tilt-x)) rotateY(var(--wheel-tilt-y)) scale(1); }
}

.cooking-replay-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.20);
    color: #fff;
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.cooking-replay-btn:active {
    background: rgba(255,255,255,0.22);
}

.cooking-timer-wrap {
    display: none; /* legacy - replaced by cooking-timers-bar */
}

/* ===== Persistent timers bar (fixed below header, survives step changes) ===== */
.cooking-timers-bar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.10);
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cooking-timers-bar::-webkit-scrollbar { display: none; }

.cooking-tools-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(99,102,241,0.15);
    border-bottom: 1px solid rgba(99,102,241,0.25);
    flex-shrink: 0;
    font-size: 0.78rem;
    color: #c7d2fe;
}
.cooking-tool-chip {
    background: rgba(99,102,241,0.25);
    border: 1px solid rgba(99,102,241,0.4);
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 0.76rem;
    color: #e0e7ff;
    white-space: nowrap;
}

.cooking-timer-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 14px;
    padding: 6px 10px 6px 14px;
    flex-shrink: 0;
    white-space: nowrap;
}

.ctimer-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.60);
    max-width: 85px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctimer-display {
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    letter-spacing: 0.03em;
    min-width: 48px;
    text-align: center;
}
.ctimer-display.ctimer-warning { color: #f97316; }
.ctimer-display.ctimer-done {
    color: #ef4444;
    animation: timerPulse 0.8s ease-in-out infinite alternate;
}

@keyframes timerPulse {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0.5; transform: scale(1.06); }
}

/* ===== COOKING SCREEN FLASH ===== */
.cooking-flash-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    background: transparent;
}
.cooking-flash-overlay.flash-warning {
    animation: cookFlashOrange 1.1s ease-in-out infinite;
}
.cooking-flash-overlay.flash-done {
    animation: cookFlashRed 0.65s ease-in-out infinite;
}
@keyframes cookFlashOrange {
    0%, 100% { background: transparent; }
    50%       { background: rgba(249, 115, 22, 0.28); }
}
@keyframes cookFlashRed {
    0%, 100% { background: transparent; }
    50%       { background: rgba(220, 38, 38, 0.42); }
}

.ctimer-btns {
    display: flex;
    gap: 4px;
    align-items: center;
}
.ctimer-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 8px;
    width: 28px;
    height: 28px;
    font-size: 0.80rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.ctimer-btn:active { background: rgba(255,255,255,0.25); }
.ctimer-toggle.running {
    background: rgba(239,68,68,0.28);
    border-color: rgba(239,68,68,0.55);
}
.ctimer-remove {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.45);
    font-size: 0.65rem;
}
.ctimer-remove:active { background: rgba(239,68,68,0.25); }

/* ===== Step timer suggestion button ===== */
.cooking-timer-suggest {
    display: flex;
    justify-content: center;
    width: 100%;
}
.cooking-timer-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(251,191,36,0.12);
    border: 1.5px dashed rgba(251,191,36,0.45);
    color: #fbbf24;
    border-radius: 22px;
    padding: 10px 22px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.cooking-timer-add-btn:active { background: rgba(251,191,36,0.26); }

.cooking-step-ings {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cooking-ing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 10px 14px;
}

.cooking-ing-name {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
    flex: 1;
    min-width: 0;
}

.cooking-ing-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.cooking-ing-chip {
    font-size: 0.72rem;
    background: rgba(255,255,255,0.12);
    border-radius: 5px;
    padding: 2px 7px;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
}

.cooking-ing-chip.exp-soon {
    background: rgba(239,68,68,0.3);
    color: #fca5a5;
}

.cooking-ing-chip.exp-close {
    background: rgba(234,179,8,0.3);
    color: #fde047;
}

.cooking-use-btn {
    flex-shrink: 0;
    background: #16a34a;
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.cooking-use-btn:active {
    background: #15803d;
}

.cooking-use-btn.btn-used {
    background: #374151;
    cursor: default;
}

.cooking-nav {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.04);
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.cooking-nav-btn {
    flex: 1;
    padding: 14px 10px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    border: 1.5px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
}

.cooking-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.cooking-next-btn {
    background: rgba(22, 163, 74, 0.35);
    border-color: rgba(22, 163, 74, 0.6);
}

.cooking-next-btn.is-finish {
    background: rgba(22, 163, 74, 0.6);
}

.cooking-nav-btn:not(:disabled):active {
    background: rgba(255,255,255,0.2);
}

@media (max-width: 640px) {
    .cooking-wheel {
        min-height: clamp(210px, 34vh, 300px);
        border-radius: 18px;
    }

    .cooking-step-text,
    .cooking-step-ghost {
        padding: 14px 14px;
    }

}

@media (prefers-reduced-motion: reduce) {
    .cooking-step-text,
    .cooking-step-ghost,
    .cooking-wheel.turn-next .cooking-step-text,
    .cooking-wheel.turn-prev .cooking-step-text,
    .cooking-wheel.turn-next .cooking-step-prev,
    .cooking-wheel.turn-prev .cooking-step-next,
    .cooking-wheel.snap .cooking-step-text {
        animation: none !important;
        transition: none !important;
    }
}

/* Cooking button in recipe dialog */
.btn-cooking {
    background: linear-gradient(135deg, #1e3a5f, #2d5016);
    color: #fff;
}

.btn-cooking:hover, .btn-cooking:active {
    opacity: 0.9;
}

/* ===== LOG PAGE ===== */
.log-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--space-sm);
}

.log-date-header {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: capitalize;
    padding: 12px 0 4px;
    border-bottom: 1px solid var(--bg-light);
    margin-bottom: 2px;
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.log-entry.log-in {
    border-left: 3px solid var(--success);
    background: rgba(40, 167, 69, 0.06);
}

.log-entry.log-out {
    border-left: 3px solid var(--danger);
    background: rgba(220, 53, 69, 0.06);
}

.log-entry.log-bring {
    border-left: 3px solid var(--primary);
    background: rgba(52, 120, 246, 0.06);
}

.log-entry.log-undone {
    opacity: 0.45;
    filter: grayscale(60%);
    text-decoration: line-through;
}

.log-undone-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    color: #fff;
    background: var(--text-muted);
    border-radius: 4px;
    padding: 1px 5px;
    text-decoration: none;
    vertical-align: middle;
    margin-left: 4px;
}

.log-recipe-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-style: italic;
}

.btn-log-undo {
    flex-shrink: 0;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #f87171;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}
.btn-log-undo:hover {
    background: rgba(248, 113, 113, 0.25);
    color: #fca5a5;
}


.log-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.log-info {
    flex: 1;
    min-width: 0;
}

.log-product {
    font-size: 0.9rem;
    line-height: 1.3;
}

.log-product em {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.log-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 1px;
}

/* ===== AI IDENTIFICATION RESULTS ===== */
.ai-identified-card {
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
}

.ai-matches-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.ai-match-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-card);
    border: 2px solid var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.ai-match-item:active {
    border-color: var(--primary);
    background: var(--bg-light);
}

.ai-match-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: #fff;
}

.ai-match-info {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.ai-match-info strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-match-barcode {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
    flex-shrink: 0;
}

/* ===== SETTINGS PAGE ===== */
.settings-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 25px;
    padding: 7px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.settings-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.settings-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.settings-card h4 {
    font-size: 1.05rem;
    margin-bottom: 4px;
    color: var(--primary);
}

.settings-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
}

.settings-status {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.settings-status.success {
    background: #d1fae5;
    color: #047857;
}

.settings-status.error {
    background: #fee2e2;
    color: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-label:active {
    background: var(--border);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.recipe-pref-checks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Appliances */
.appliances-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.appliance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
}

.appliance-item .appliance-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    transition: background 0.2s;
}

.appliance-item .appliance-remove:active {
    background: #fee2e2;
}

.appliance-quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.common-appliances .btn-small {
    font-size: 0.78rem;
    padding: 5px 10px;
}

/* ===== RECIPE OPTIONS GRID ===== */
.recipe-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
}

.recipe-option-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    border: 2px solid transparent;
}

.recipe-option-chip:has(input:checked) {
    background: rgba(45, 80, 22, 0.08);
    border-color: var(--primary);
}

/* Meal-plan chip: visually highlighted to stand out as the planned food type */
.recipe-opt-mealplan-chip {
    grid-column: 1 / -1;
    background: rgba(100, 60, 20, 0.07);
    border-color: #b07830;
    font-weight: 600;
}
.recipe-opt-mealplan-chip:has(input:checked) {
    background: rgba(120, 70, 10, 0.13);
    border-color: #c08020;
}
.recipe-opt-mealplan-chip:has(input:not(:checked)) {
    opacity: 0.6;
    text-decoration: line-through;
    text-decoration-color: #c08020;
}

.recipe-option-chip input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Meal type selector */
.recipe-meal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
}
.recipe-meal-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    border: 2px solid transparent;
    text-align: center;
    white-space: nowrap;
}
.recipe-meal-chip:has(input:checked) {
    background: rgba(45, 80, 22, 0.1);
    border-color: var(--primary);
    font-weight: 600;
}
.recipe-meal-chip input[type="radio"] {
    display: none;
}

/* Sub-type grid for dolce/succo */
.recipe-subtype-grid {
    margin-top: 8px;
    grid-template-columns: 1fr 1fr;
    animation: bannerSlideIn 0.25s ease-out;
}
.recipe-subtype-chip {
    font-size: 0.75rem;
    padding: 8px 6px;
    background: #fef9ef;
    border-color: #f0e4cc;
}
.recipe-subtype-chip:has(input:checked) {
    background: #fff3d4;
    border-color: #e6a817;
}

/* ===== LARGER PRODUCT PREVIEW (Action page) ===== */
.product-preview-large {
    flex-direction: column;
    text-align: center;
    padding: 20px;
}

.product-preview-large img {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    object-fit: cover;
    margin-bottom: 8px;
}

.product-preview-large .product-preview-emoji {
    font-size: 4rem;
    width: auto;
    margin-bottom: 8px;
}

.product-preview-large .product-preview-info {
    text-align: center;
}

.product-preview-large .product-preview-info h3 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.product-preview-large .product-preview-info p {
    font-size: 0.95rem;
}

.btn-edit-inline {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.product-preview-large {
    position: relative;
}

/* ===== INVENTORY STATUS BAR ===== */
.inventory-status-bar {
    background: linear-gradient(135deg, #dbeafe 0%, #c7d2fe 100%);
    border: 2px solid #93b4f8;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inventory-status-bar .inv-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inventory-status-bar .inv-status-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e40af;
}

.inventory-status-bar .inv-status-total {
    font-size: 2.2rem;
    font-weight: 900;
    color: #1e3a8a;
    background: rgba(255,255,255,0.8);
    padding: 8px 22px;
    border-radius: 24px;
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.inventory-status-bar .inv-status-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inventory-status-bar .inv-status-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #1d4ed8;
    padding: 5px 10px;
    background: rgba(255,255,255,0.55);
    border-radius: var(--radius-sm);
}

.inventory-status-bar .inv-status-item .inv-status-qty {
    font-weight: 700;
}

.inventory-status-bar .inv-status-item-clickable {
    cursor: pointer;
    transition: background 0.15s;
}
.inventory-status-bar .inv-status-item-clickable:active {
    background: rgba(59, 130, 246, 0.15);
}

/* Related stock hint (same generic family, different brand/product) */
.action-related-stock-card {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #166534;
    margin-bottom: 12px;
    line-height: 1.5;
}
.action-related-stock-card strong { color: #15803d; }
.related-stock-item { display: inline-block; margin-right: 8px; }
[data-theme="dark"] .action-related-stock-card {
    background: rgba(21, 128, 61, 0.12);
    border-color: #166534;
    color: #86efac;
}
[data-theme="dark"] .action-related-stock-card strong { color: #4ade80; }

/* ===== ACTION BUTTONS GRID ===== */
.action-buttons-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.action-buttons-4col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.action-buttons-3col .btn-huge,
.action-buttons-4col .btn-huge {
    min-height: 100px;
    padding: 18px 8px;
    font-size: 1rem;
}

.action-buttons-3col .btn-icon,
.action-buttons-4col .btn-icon {
    font-size: 2rem;
}

.btn-throw {
    background: #f97316;
    color: white;
}

.btn-throw:active {
    background: #ea580c;
}

.btn-edit {
    background: #6366f1;
    color: white;
}

.btn-edit:active {
    background: #4f46e5;
}

.btn-recipe-from-ingredient {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-recipe-from-ingredient:active {
    opacity: 0.85;
}

/* ===== STRUCTURED QUANTITY IN INVENTORY ===== */
.inv-qty-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 56px;
    background: #ecfdf5;
    border-radius: 14px;
    padding: 6px 12px;
}

.inv-qty-number {
    font-size: 1.55rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.inv-qty-unit {
    font-size: 0.7rem;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
    line-height: 1.2;
    text-align: center;
}

.inv-qty-pkg {
    font-weight: 500;
    color: #6b7280;
}

.inv-qty-frac {
    font-size: 0.75rem;
    font-weight: 700;
    color: #9ca3af;
    line-height: 1;
    margin-top: 1px;
}

/* Package fraction indicators (used elsewhere) */
.pkg-fraction {
    font-size: 1rem;
    font-weight: 700;
    color: #6b7280;
    white-space: nowrap;
}

.inv-pkg-frac {
    display: block;
    text-align: center;
}

.inv-status-total-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.inv-status-total-frac {
    font-size: 0.8rem;
}

/* ===== REVIEW SECTION ===== */
/* ===== ALERT TOP BANNER ===== */
.alert-banner {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1.5px solid #f59e0b;
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
    animation: bannerSlideIn 0.35s ease-out;
}
@keyframes bannerSlideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.alert-banner.banner-prediction {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    border-color: #8b5cf6;
}
.alert-banner.banner-anomaly {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-color: #ea580c;
}
.banner-anomaly .alert-banner-title { color: #9a3412; }
.banner-anomaly .alert-banner-counter .banner-dot.active { background: #ea580c; }
.alert-banner.banner-dup-loss {
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
    border-color: #dc2626;
}
.banner-dup-loss .alert-banner-title { color: #991b1b; }
.banner-dup-loss .alert-banner-counter .banner-dot.active { background: #dc2626; }
.alert-banner.banner-no-expiry {
    background: linear-gradient(135deg, #f0fdf4 0%, #bbf7d0 100%);
    border-color: #16a34a;
}
.banner-no-expiry .alert-banner-title { color: #14532d; }
.banner-no-expiry .alert-banner-counter .banner-dot.active { background: #16a34a; }
.alert-banner-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 44px 8px 12px; /* right pad reserves space for abs-positioned close btn */
    position: relative;
}
.alert-banner-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
}
.alert-banner-body {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}
.alert-banner-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #92400e;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
}
.banner-prediction .alert-banner-title {
    color: #5b21b6;
}
.alert-banner-detail {
    font-size: 0.82rem;
    color: #78716c;
    margin-top: 2px;
    line-height: 1.4;
}
.alert-banner-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.08);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #78716c;
    z-index: 1;
}
.alert-banner-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 10px;
    flex-wrap: wrap;
}
.alert-banner-actions .btn-banner {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.btn-banner-ok {
    background: #d1fae5;
    color: #059669;
}
.btn-banner-edit {
    background: #e0e7ff;
    color: #4338ca;
}
.btn-banner-ai {
    background: #ede9fe;
    color: #7c3aed;
}
.btn-banner-weigh {
    background: #f3e8ff;
    color: #7c3aed;
}
.btn-banner-confirm {
    background: #d1fae5;
    color: #059669;
}
.alert-banner-counter {
    font-size: 0.72rem;
    color: #a1977a;
    text-align: center;
    padding: 0 12px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.banner-prediction .alert-banner-counter {
    color: #7c6cb0;
}

/* Dot indicators */
.banner-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(0,0,0,0.18);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.banner-dot.active {
    background: rgba(0,0,0,0.55);
    transform: scale(1.3);
}
.banner-expired .banner-dot.active { background: #dc2626; }
.banner-expiring .banner-dot.active { background: #ea580c; }
.banner-prediction .banner-dot.active { background: #7c3aed; }

/* Nav arrows */
.banner-nav-arrow {
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    color: rgba(0,0,0,0.35);
    user-select: none;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}
.banner-nav-arrow:active { color: rgba(0,0,0,0.7); }

/* Swipe slide animations */
@keyframes bannerSlideInLeft {
    from { opacity: 0; transform: translateX(60px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes bannerSlideInRight {
    from { opacity: 0; transform: translateX(-60px); }
    to   { opacity: 1; transform: translateX(0); }
}
.banner-slide-left .alert-banner-inner,
.banner-slide-left .alert-banner-actions {
    animation: bannerSlideInLeft 0.25s ease-out;
}
.banner-slide-right .alert-banner-inner,
.banner-slide-right .alert-banner-actions {
    animation: bannerSlideInRight 0.25s ease-out;
}

.alert-review {
    background: #fffbeb;
    border-color: #f59e0b;
}

.alert-review h3 {
    color: #92400e;
}

/* ===== OPENED PRODUCTS SECTION ===== */
.alert-opened {
    background: #eff6ff;
    border-color: #3b82f6;
}

.alert-opened h3 {
    color: #1e40af;
}

.alert-item-badge.opened {
    background: #3b82f6;
    color: #fff;
    font-size: 0.7rem;
}

/* Opened expiry badges */
.alert-item-badge.opened-expiry {
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 20px;
    padding: 2px 7px;
}
.opened-expiry-ok      { background: #dcfce7; color: #166534; }
.opened-expiry-soon    { background: #fef9c3; color: #854d0e; }
.opened-expiry-urgent  { background: #fee2e2; color: #991b1b; }
.opened-expiry-today   { background: #f97316; color: #fff; }
.opened-expiry-spoiled { background: #1f2937; color: #f9fafb; }

.alert-item-spoiled {
    opacity: 0.75;
}
.alert-item-spoiled .alert-item-name {
    color: var(--text-light);
}

.alert-more-note {
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: center;
    padding: 6px 0 2px;
}

.review-hint {
    font-size: 0.8rem;
    color: #92400e;
    margin: -4px 0 10px;
    opacity: 0.8;
}

.review-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.7);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.review-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.review-item-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.review-item-icon img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

.review-item-text {
    min-width: 0;
}

.review-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.review-item-meta {
    font-size: 0.75rem;
    color: #78716c;
}

.review-warn {
    color: #dc2626;
    font-weight: 600;
}

.review-item-qty {
    flex-shrink: 0;
}

.review-qty-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #dc2626;
    background: #fee2e2;
    padding: 3px 10px;
    border-radius: 16px;
    white-space: nowrap;
}

.review-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-review {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-review-ok {
    background: #d1fae5;
    color: #059669;
}

.btn-review-ok:active {
    background: #a7f3d0;
}

.btn-review-edit {
    background: #e0e7ff;
    color: #4338ca;
}

.btn-review-edit:active {
    background: #c7d2fe;
}

/* ===== ALERT QUANTITY BADGES ===== */
.alert-item-qty {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-light);
    padding: 2px 8px;
    background: rgba(255,255,255,0.6);
    border-radius: 12px;
    white-space: nowrap;
}

/* ===== GEMINI CHAT ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - var(--nav-height) - 24px);
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: white;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-title {
    font-weight: 700;
    font-size: 1rem;
    color: #4338ca;
}

.btn-chat-clear {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    opacity: 0.6;
}

.btn-chat-clear:active {
    background: var(--bg);
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}

.chat-welcome {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-light);
}

.chat-welcome h3 {
    margin: 12px 0 6px;
    color: var(--text);
    font-size: 1.1rem;
}

.chat-welcome p {
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 300px;
    margin: 0 auto 20px;
}

.gemini-icon-lg {
    opacity: 0.3;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chat-suggestion {
    background: white;
    border: 1.5px solid #e0e7ff;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    color: #4338ca;
    font-weight: 500;
    transition: all 0.15s;
}

.chat-suggestion:active {
    background: #e0e7ff;
    transform: scale(0.97);
}

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    animation: chatFadeIn 0.2s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-user {
    align-self: flex-end;
    background: #4338ca;
    color: white;
    border-bottom-right-radius: 6px;
}

.chat-gemini {
    align-self: flex-start;
    background: white;
    color: var(--text);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-gemini strong {
    color: #4338ca;
}

.chat-gemini ul, .chat-gemini ol {
    margin: 4px 0;
    padding-left: 20px;
}

.chat-gemini li {
    margin-bottom: 2px;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #6366f1;
}

.btn-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #4338ca;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-chat-send:active {
    transform: scale(0.92);
    background: #3730a3;
}

.btn-chat-send:disabled {
    background: #a5b4fc;
    cursor: default;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #a5b4fc;
    border-radius: 50%;
    animation: chatTyping 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ====== Chat Transfer to Recipes button ====== */
.btn-chat-use-recipe {
    display: inline-block;
    margin-top: 10px;
    padding: 7px 14px;
    background: var(--card-bg, #1e293b);
    border: 1px solid #6366f1;
    color: #a5b4fc;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-chat-use-recipe:hover {
    background: #312e81;
    color: white;
}
.btn-chat-use-recipe:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ====== Recipe Archive ====== */
.recipe-archive {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

.recipe-archive-day {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recipe-archive-date {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    padding: 2px 0;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 2px;
}

.recipe-archive-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.recipe-archive-card:hover,
.recipe-archive-card:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}

.recipe-archive-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recipe-archive-meal {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.recipe-archive-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recipe-archive-card-meta {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* ===== RECIPE FAVORITES (#124) ===== */
.recipe-fav-badge {
    margin-left: auto;
    font-size: 1.1rem;
    color: #f59e0b;
    flex-shrink: 0;
}

.recipe-archive-card-fav {
    border-left: 3px solid #f59e0b;
}

.btn-recipe-fav {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
    line-height: 1;
    vertical-align: middle;
    transition: color 0.2s, transform 0.15s;
    margin-left: auto;
}

.btn-recipe-fav:hover { color: #f59e0b; transform: scale(1.2); }
.btn-recipe-fav.active { color: #f59e0b; }

/* ===== PORTION RESCALER (#123) ===== */
.recipe-persons-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0 6px;
    vertical-align: middle;
    line-height: 1;
}

.btn-persons-adj {
    background: none;
    border: none;
    color: var(--text-primary);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-persons-adj:hover { background: var(--accent, #6366f1); color: #fff; }

#recipe-persons-display {
    white-space: nowrap;
    font-size: 0.82rem;
}

/* ===== MACRONUTRIENT PANEL (#118) ===== */
.macro-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 8px;
}

.macro-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.macro-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 70px;
    flex-shrink: 0;
}

.macro-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--bg-secondary, #1e2a3a);
    border-radius: 4px;
    overflow: hidden;
}

.macro-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.macro-val {
    font-size: 0.72rem;
    color: var(--text-primary);
    text-align: right;
    min-width: 80px;
    flex-shrink: 0;
}

.macro-val small {
    color: var(--text-muted);
}

/* ===== SCREENSAVER ===== */
.screensaver-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.8s ease;
}
.screensaver-overlay.visible {
    opacity: 1;
}
.screensaver-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 20px;
    max-width: 90vw;
}
.screensaver-clock {
    color: rgba(255,255,255,0.85);
    font-size: 7rem;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    letter-spacing: 4px;
    text-align: center;
    line-height: 1.2;
    user-select: none;
}
.screensaver-clock .screensaver-date {
    font-size: 1.4rem;
    font-weight: 300;
    opacity: 0.45;
    letter-spacing: 1px;
    margin-top: 4px;
}
.screensaver-fact {
    color: rgba(255,255,255,0.55);
    font-size: 1.6rem;
    font-weight: 300;
    text-align: center;
    line-height: 1.5;
    max-width: 500px;
    min-height: 2.5em;
    opacity: 0;
    transition: opacity 1.5s ease;
    user-select: none;
}
.screensaver-fact.visible {
    opacity: 1;
}
.screensaver-mealplan {
    text-align: center;
    user-select: none;
    margin: -8px 0 4px;
}
.screensaver-mealplan-badge {
    display: inline-block;
    background: rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.70);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 28px;
    padding: 8px 24px;
    font-size: 1.35rem;
    font-weight: 400;
    letter-spacing: 0.4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.screensaver-shopping {
    text-align: center;
    user-select: none;
    margin: -8px 0 0;
}
.screensaver-shopping-card {
    display: inline-flex;
    align-items: center;
    gap: 18px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 20px;
    padding: 14px 32px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.ss-shop-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.ss-shop-sep {
    width: 1px;
    height: 36px;
    background: rgba(255,255,255,0.18);
}
.ss-shop-value {
    color: rgba(255,255,255,0.92);
    font-size: 1.9rem;
    font-weight: 300;
    letter-spacing: 1px;
    line-height: 1;
}
.ss-shop-label {
    color: rgba(255,255,255,0.38);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}
.screensaver-shortcuts {
    position: absolute;
    bottom: max(32px, env(safe-area-inset-bottom, 32px));
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10001;
}
.screensaver-shortcut-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.2s, transform 0.15s;
    user-select: none;
    -webkit-user-select: none;
}
.screensaver-shortcut-btn:active {
    background: rgba(255,255,255,0.25);
    transform: scale(0.92);
}

/* ── Screensaver nutrition panel ── */
.screensaver-nutrition {
    display: none;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    pointer-events: none;
    user-select: none;
}
.ss-nutr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.ss-nutr-title {
    color: rgba(255,255,255,0.75);
    font-size: 1.3rem;
    font-weight: 300;
    letter-spacing: 1px;
    text-align: center;
}
.ss-nutr-charts {
    display: flex;
    align-items: flex-start;
    gap: 36px;
    flex-wrap: wrap;
    justify-content: center;
}
.ss-nutr-chart-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.ss-nutr-chart-label {
    color: rgba(255,255,255,0.5);
    font-size: .85rem;
    text-align: center;
}
/* 3D animated pie */
.ss-pie3d {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--pie-bg, conic-gradient(#4ade80 0deg 90deg, #60a5fa 90deg 180deg, #fbbf24 180deg 270deg, #334155 270deg 360deg));
    transform: perspective(250px) rotateX(40deg) scale(0.82);
    box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 4px 0 rgba(255,255,255,0.06);
    transition: transform 0.8s cubic-bezier(.34,1.56,.64,1), box-shadow 0.8s;
    will-change: transform;
}
.ss-pie3d.ss-pie3d-ready {
    transform: perspective(250px) rotateX(30deg) scale(1);
    animation: ss-pie-spin 18s linear infinite;
}
@keyframes ss-pie-spin {
    from { transform: perspective(250px) rotateX(30deg) rotate(0deg) scale(1); }
    to   { transform: perspective(250px) rotateX(30deg) rotate(360deg) scale(1); }
}
.ss-nutr-legend {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 130px;
}
.ss-leg-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.65);
    font-size: .8rem;
}
.ss-leg-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ss-leg-pct {
    margin-left: auto;
    color: rgba(255,255,255,0.45);
}
/* Score donut column */
.ss-nutr-scores-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}
.ss-donut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ss-donut-label {
    color: rgba(255,255,255,0.45);
    font-size: .75rem;
}
/* CSS-only ring donut using conic-gradient */
.ss-donut-ring {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: conic-gradient(var(--color, #4ade80) calc(var(--val, 0) * 1%), rgba(255,255,255,0.08) calc(var(--val, 0) * 1%));
    transform: perspective(120px) rotateX(30deg) scale(0.7);
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    transition: transform 0.7s cubic-bezier(.34,1.56,.64,1), background 0.9s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ss-donut-ring.ss-donut-ready {
    transform: perspective(120px) rotateX(25deg) scale(1);
    animation: ss-donut-bob 4s ease-in-out infinite;
}
@keyframes ss-donut-bob {
    0%,100% { transform: perspective(120px) rotateX(25deg) scale(1) translateY(0); }
    50%      { transform: perspective(120px) rotateX(25deg) scale(1) translateY(-4px); }
}
.ss-donut-ring::after {
    content: '';
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #0a0a0a;
}
.ss-donut-text {
    position: relative;
    z-index: 1;
    color: rgba(255,255,255,0.8);
    font-size: .8rem;
    font-weight: 600;
}

/* ── Dashboard nutrition card ── */
.nutr-card {
    background: var(--bg-card, #fff);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.nutr-body {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin: 12px 0;
}
.nutr-pie-wrap {
    position: relative;
    flex-shrink: 0;
}
.nutr-pie-3d {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    transform: perspective(180px) rotateX(38deg) scale(0.82);
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    transition: transform 0.7s cubic-bezier(.34,1.56,.64,1);
    will-change: transform;
}
.nutr-pie-3d.nutr-pie-ready {
    transform: perspective(180px) rotateX(28deg) scale(1);
    animation: nutr-pie-spin 22s linear infinite;
}
@keyframes nutr-pie-spin {
    from { transform: perspective(180px) rotateX(28deg) rotate(0deg) scale(1); }
    to   { transform: perspective(180px) rotateX(28deg) rotate(360deg) scale(1); }
}
.nutr-pie-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.nutr-pie-total {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}
.nutr-pie-label {
    font-size: .6rem;
    color: var(--text-secondary);
}
.nutr-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nutr-leg-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
}
.nutr-leg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.nutr-leg-pct {
    margin-left: auto;
    color: var(--text-secondary);
    font-weight: 600;
}
/* Score bars */
.nutr-scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.nutr-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
}
.nutr-score-label { flex: 0 0 80px; white-space: nowrap; }
.nutr-score-track {
    flex: 1;
    height: 7px;
    border-radius: 4px;
    background: rgba(0,0,0,0.07);
    overflow: hidden;
}
.nutr-score-fill {
    height: 100%;
    border-radius: 4px;
    width: 0%;
    transition: width 1s ease;
}
.nutr-score-val { flex: 0 0 32px; text-align: right; font-weight: 600; }

/* ===== MONTHLY STATS PANEL ===== */
.ms-main-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 12px 0 8px;
}
.ms-main-num {
    font-size: 2.8rem;
    font-weight: 700;
    color: #6366f1;
    line-height: 1;
    letter-spacing: -0.02em;
}
.ms-main-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ms-main-label {
    font-size: .85rem;
    color: #94a3b8;
}
.ms-trend {
    font-size: .8rem;
    font-weight: 500;
}
.ms-cats-section {
    margin: 6px 0 4px;
}
.ms-cats-title {
    font-size: .68rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 7px;
}
.ms-cat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}
.ms-cat-name {
    font-size: .74rem;
    color: #cbd5e1;
    min-width: 78px;
    max-width: 78px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ms-cat-bar-wrap {
    flex: 1;
    height: 8px;
    background: #1e293b;
    border-radius: 4px;
    overflow: hidden;
}
.ms-cat-bar {
    height: 100%;
    border-radius: 4px;
    width: 0;
}
.ms-cat-cnt {
    font-size: .7rem;
    color: #64748b;
    min-width: 22px;
    text-align: right;
}
.ms-badges-row {
    margin-top: 6px;
}

/* ===== SETUP WIZARD ===== */
.setup-wizard-content {
    max-width: 480px;
    width: 95%;
    margin: auto;
    border-radius: 20px;
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.setup-header {
    background: var(--primary);
    color: #fff;
    padding: 24px 20px 16px;
    text-align: center;
}
.setup-header h2 {
    margin: 0 0 12px;
    font-size: 1.5rem;
}
.setup-progress {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.setup-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: background 0.3s, transform 0.3s;
}
.setup-dot.active {
    background: #fff;
    transform: scale(1.3);
}
.setup-dot.done {
    background: var(--success-light);
}
.setup-body {
    padding: 24px 20px;
    overflow-y: auto;
    flex: 1;
}
.setup-body h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}
.setup-body p {
    color: #666;
    margin: 0 0 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.setup-body .form-group {
    margin-bottom: 16px;
}
.setup-body .form-input {
    width: 100%;
    box-sizing: border-box;
}
.setup-lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.setup-lang-btn {
    padding: 14px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    font-size: 1rem;
    transition: border-color 0.2s, background 0.2s;
}
.setup-lang-btn.selected {
    border-color: var(--primary);
    background: rgba(45,80,22,0.08);
}
.setup-lang-btn:hover {
    border-color: var(--primary-light);
}
.setup-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
}
.setup-footer .btn {
    flex: 1;
    padding: 12px;
    font-size: 1rem;
}
.setup-skip-link {
    display: block;
    text-align: center;
    color: #999;
    font-size: 0.8rem;
    margin-top: 12px;
    cursor: pointer;
    text-decoration: underline;
}
.setup-skip-link:hover {
    color: #666;
}

/* ===== QUICK ACCESS BUTTONS ===== */
#quick-access-section {
    margin-bottom: 12px;
}
.quick-access-group {
    margin-bottom: 10px;
}
.quick-access-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 8px;
    padding-left: 2px;
}
.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.quick-access-grid-8 {
    grid-template-columns: repeat(4, 1fr);
}
.quick-access-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px 8px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
    min-width: 0;
}
.quick-access-btn:active {
    transform: scale(0.95);
}
.quick-access-btn:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}
.qa-img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: var(--bg);
    flex-shrink: 0;
}
.qa-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.qa-name {
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    color: var(--text);
}
.qa-brand {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ===== BANNER VARIANTS: EXPIRED & EXPIRING ===== */
.alert-banner.banner-expired {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #dc2626;
}
.banner-expired .alert-banner-title {
    color: #991b1b;
}
.banner-expired .alert-banner-counter {
    color: #b91c1c;
}
.alert-banner.banner-expiring {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-color: #f97316;
}
.banner-expiring .alert-banner-title {
    color: #9a3412;
}
.banner-expiring .alert-banner-counter {
    color: #c2410c;
}
.btn-banner-use {
    background: #dbeafe;
    color: #1d4ed8;
}
.btn-banner-throw {
    background: #fee2e2;
    color: #dc2626;
}
.alert-banner.banner-expired-ok {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #16a34a;
}
.banner-expired-ok .alert-banner-title {
    color: #14532d;
}
.banner-expired-ok .alert-banner-counter {
    color: #15803d;
}
.banner-expired-ok .banner-dot.active { background: #16a34a; }
.alert-banner.banner-expired-warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #d97706;
}
.banner-expired-warning .alert-banner-title {
    color: #78350f;
}
.banner-expired-warning .alert-banner-counter {
    color: #92400e;
}
.banner-expired-warning .banner-dot.active { background: #d97706; }
.alert-banner.banner-expired-danger {
    background: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
    border-color: #b91c1c;
    border-width: 2px;
}
.banner-expired-danger .alert-banner-title {
    color: #7f1d1d;
}
.banner-safety-tip {
    display: inline-block;
    font-size: 0.82em;
    margin-top: 1px;
}
.banner-safety-danger {
    color: #b91c1c;
    font-weight: 600;
}
.banner-safety-warning {
    color: #92400e;
}
.banner-safety-ok {
    color: #166534;
}
.btn-banner-throw-primary {
    background: #dc2626;
    color: #fff;
    font-weight: 600;
}
.btn-banner-use-danger {
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 0.8em;
}
.btn-banner-vacuum {
    background: #ede9fe;
    color: #6d28d9;
}
.btn-banner-edit2 {
    background: #e0f2fe;
    color: #0369a1;
}

/* ===== PAGE HEADER ACTION BUTTON (export etc.) ===== */
.page-header-action-btn {
    margin-left: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--primary);
}
.page-header-action-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* ===== ZERO-WASTE TIP CARD (cooking mode) ===== */
.cooking-zerowaste-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(16, 185, 129, 0.10);
    border: 1.5px solid rgba(16, 185, 129, 0.35);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 10px 16px 0;
    position: relative;
    animation: zwFadeIn 0.3s ease;
    flex-direction: column;
}
@keyframes zwFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cooking-zerowaste-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #059669;
}
.cooking-zerowaste-scrap {
    font-size: 0.85rem;
    font-weight: 700;
    color: #065f46;
    margin-left: 4px;
}
.cooking-zerowaste-text {
    font-size: 0.85rem;
    color: var(--text);
    margin: 4px 0 0;
    line-height: 1.45;
}
.cooking-zerowaste-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    color: #6b7280;
    padding: 2px 4px;
    line-height: 1;
}
.cooking-zerowaste-close:hover { color: #374151; }
[data-theme="dark"] .cooking-zerowaste-tip {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
}
[data-theme="dark"] .cooking-zerowaste-scrap { color: #6ee7b7; }
[data-theme="dark"] .cooking-zerowaste-label { color: #34d399; }
[data-theme="dark"] .cooking-zerowaste-close { color: #9ca3af; }

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-dark: #020617;
    --bg-secondary: #263448;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --text-muted: #64748b;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 2px 8px rgba(0,0,0,0.45);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.6);
    color-scheme: dark;
}
[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text);
}
/* Bottom nav */
[data-theme="dark"] .bottom-nav {
    box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
}
/* Location tabs */
[data-theme="dark"] .tab {
    background: var(--bg-card);
    color: var(--text-light);
}
[data-theme="dark"] .tab.active {
    background: var(--primary);
    color: #fff;
}
/* Location selector (add/use modal) */
[data-theme="dark"] .location-option {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
}
[data-theme="dark"] .location-option.selected {
    border-color: var(--primary);
    background: rgba(45,80,22,0.3);
}
/* Inputs & selects */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-muted);
}
/* Buttons */
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-outline,
[data-theme="dark"] .back-btn,
[data-theme="dark"] .page-header-action-btn {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .btn-outline {
    color: var(--primary-light);
    border-color: var(--primary-light);
}
/* Inventory items */
[data-theme="dark"] .inventory-item {
    background: var(--bg-card);
}
[data-theme="dark"] .inv-location-badge {
    background: rgba(45,80,22,0.35);
    color: #86efac;
}
/* Shopping items */
[data-theme="dark"] .shopping-item {
    background: var(--bg-card) !important;
}
[data-theme="dark"] .shopping-item-tag-menu-container {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .shopping-item-tag-btn {
    background: #1e293b;
    color: var(--text-light);
    border-color: var(--border);
}
[data-theme="dark"] .badge-local-tag {
    background: #0c2a4e;
    color: #7dd3fc;
}
[data-theme="dark"] .badge-freq-med {
    background: #2e1a4a;
    color: #c4b5fd;
}
[data-theme="dark"] .badge-freq-low {
    background: #1e293b;
    color: #94a3b8;
}
/* Settings rows */
[data-theme="dark"] .settings-row {
    border-color: var(--border);
}
[data-theme="dark"] .settings-label {
    color: var(--text);
}
[data-theme="dark"] .settings-hint {
    color: var(--text-muted);
}
/* Toggle switch */
[data-theme="dark"] .toggle-slider {
    background: #334155;
}
/* Search bar */
[data-theme="dark"] .search-bar input {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
/* Action modal location selector */
[data-theme="dark"] .action-location-btn {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
}
/* Scan page */
[data-theme="dark"] .scan-input-row {
    background: var(--bg-card);
}
[data-theme="dark"] .scan-result-item {
    background: var(--bg-card);
    border-color: var(--border);
}
/* Quick access chips */
[data-theme="dark"] .quick-access-chip {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
}
/* Scan recents */
[data-theme="dark"] .scan-recent-chip {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-light);
}
/* Alert banners */
[data-theme="dark"] .alert-banner {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .alert-banner.banner-expiring {
    background: #1c1300;
    border-color: #78350f;
}
[data-theme="dark"] .alert-banner.banner-expired {
    background: #1f0808;
    border-color: #7f1d1d;
}
[data-theme="dark"] .alert-banner.banner-finished {
    background: #0f1f0f;
    border-color: #166534;
}
[data-theme="dark"] .alert-banner.banner-anomaly {
    background: #1a1a2e;
    border-color: #4c1d95;
}
/* Recipe dialog */
[data-theme="dark"] .recipe-dialog-content {
    background: var(--bg-card);
}
[data-theme="dark"] .recipe-option-btn {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
}
[data-theme="dark"] .recipe-option-btn.active {
    background: rgba(45,80,22,0.4);
    border-color: var(--primary-light);
    color: var(--primary-light);
}
/* Log rows */
[data-theme="dark"] .log-item {
    background: var(--bg-card);
    border-color: var(--border);
}
/* Dashboard stat cards */
[data-theme="dark"] .stat-card {
    background: var(--bg-card);
}
/* Screensaver */
[data-theme="dark"] .screensaver-overlay {
    background: #020617;
}
/* Charts / nutrition */
[data-theme="dark"] .nutrition-chart-bg {
    background: var(--bg-card);
}
/* AW badges */
[data-theme="dark"] .aw-badge-rate  { background: #2e1a4a; color: #c4b5fd; border-color: #6d28d9; }
[data-theme="dark"] .aw-badge-money { background: #1c1300; color: #fde047; border-color: #78350f; }
[data-theme="dark"] .aw-badge-meals { background: #0f1f0f; color: #4ade80; border-color: #166534; }
[data-theme="dark"] .aw-badge-co2   { background: #0c1f3a; color: #7dd3fc; border-color: #1e3a5f; }
[data-theme="dark"] .aw-badge-wasted{ background: #1f0808; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .aw-badge-better{ background: #0f1f0f; color: #4ade80; border-color: #166534; }
/* Chat */
[data-theme="dark"] .chat-input {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .chat-message.user {
    background: var(--primary-dark);
}
[data-theme="dark"] .chat-message.bot {
    background: var(--bg-card);
}
/* Smart shopping forecast */
[data-theme="dark"] .smart-item {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .smart-filter-btn {
    background: var(--bg-card);
    color: var(--text-light);
    border-color: var(--border);
}
[data-theme="dark"] .smart-filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
/* Offline banner */
[data-theme="dark"] #offline-banner {
    background: #450a0a;
    border-color: #7f1d1d;
}
/* Setup wizard */
[data-theme="dark"] .setup-content {
    background: var(--bg-card);
}
[data-theme="dark"] .setup-lang-btn {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .setup-lang-btn.selected {
    background: rgba(45,80,22,0.4);
    border-color: var(--primary-light);
    color: var(--primary-light);
}
/* @media prefers-color-scheme: auto handled in JS */

/* ===== DARK MODE — EXTENDED COMPONENT OVERRIDES ===== */

/* ── Inventory badges ── */
[data-theme="dark"] .badge-location { background: #0c2a4e; color: #7dd3fc; }
[data-theme="dark"] .badge-category { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] .badge-qty      { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .badge-expiry   { background: #2a1a00; color: #fcd34d; }
[data-theme="dark"] .badge-expired  { background: #2a0808; color: #fca5a5; }

/* ── Urgency / priority badges ── */
[data-theme="dark"] .badge-critical  { background: #2a0808; color: #fca5a5; }
[data-theme="dark"] .badge-high      { background: #2a1200; color: #fdba74; }
[data-theme="dark"] .badge-medium    { background: #2a1e00; color: #fde68a; }
[data-theme="dark"] .badge-low       { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .badge-freq-high { background: #2e0d1a; color: #f9a8d4; }
[data-theme="dark"] .badge-tag-add   { background: #1e293b; color: #94a3b8; }

/* ── Smart shopping badges ── */
[data-theme="dark"] .smart-freq-badge.freq-suggest        { background: #0c2a4e; color: #7dd3fc; }
[data-theme="dark"] .smart-freq-badge.freq-suggest-approx { background: #0c1f3a; color: #93c5fd; font-style: italic; }
[data-theme="dark"] .smart-pred-badge                     { background: #2a1e00; color: #fde68a; }
[data-theme="dark"] .smart-pred-badge.pred-urgent         { background: #2a0808; color: #fca5a5; }
[data-theme="dark"] .smart-pred-badge.pred-soon           { background: #2a1200; color: #fdba74; }
[data-theme="dark"] .smart-bring-badge                    { background: #0c2a4e; color: #7dd3fc; }

/* ── AW trend mini-cards ── */
[data-theme="dark"] .aw-tcard-good { background: #0f2a1a; border-color: #166534; }
[data-theme="dark"] .aw-tcard-ok   { background: #1c1300; border-color: #78350f; }
[data-theme="dark"] .aw-tcard-bad  { background: #2a0808; border-color: #7f1d1d; }

/* ── Alert sections ── */
[data-theme="dark"] .alert-danger                { background: #2a0808; border-color: var(--danger); }
[data-theme="dark"] .alert-item                  { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .alert-item-qty              { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .alert-review                { background: #1c1300; border-color: #78350f; }
[data-theme="dark"] .alert-review h3             { color: #fcd34d; }
[data-theme="dark"] .alert-opened               { background: #0c1f3a; border-color: #1e3a8a; }
[data-theme="dark"] .alert-opened h3             { color: #7dd3fc; }
[data-theme="dark"] .alert-item-badge.opened     { background: #1e40af; }

/* ── Opened expiry badges ── */
[data-theme="dark"] .opened-expiry-ok     { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .opened-expiry-soon   { background: #2a1e00; color: #fde68a; }
[data-theme="dark"] .opened-expiry-urgent { background: #2a0808; color: #fca5a5; }

/* ── Alert banner: gradient overrides ── */
[data-theme="dark"] .alert-banner.banner-expired            { background: #2a0808; border-color: #7f1d1d; }
[data-theme="dark"] .banner-expired .alert-banner-title     { color: #fca5a5; }
[data-theme="dark"] .banner-expired .alert-banner-counter   { color: #f87171; }
[data-theme="dark"] .alert-banner.banner-expiring           { background: #1c1300; border-color: #78350f; }
[data-theme="dark"] .banner-expiring .alert-banner-title    { color: #fdba74; }
[data-theme="dark"] .banner-expiring .alert-banner-counter  { color: #fb923c; }
[data-theme="dark"] .alert-banner.banner-expired-ok              { background: #0f2a1a; border-color: #166534; }
[data-theme="dark"] .banner-expired-ok .alert-banner-title       { color: #86efac; }
[data-theme="dark"] .banner-expired-ok .alert-banner-counter     { color: #4ade80; }
[data-theme="dark"] .alert-banner.banner-expired-warning         { background: #1c1300; border-color: #78350f; }
[data-theme="dark"] .banner-expired-warning .alert-banner-title  { color: #fde68a; }
[data-theme="dark"] .banner-expired-warning .alert-banner-counter { color: #fcd34d; }
[data-theme="dark"] .alert-banner.banner-expired-danger          { background: #2a0808; border-color: #7f1d1d; border-width: 2px; }
[data-theme="dark"] .banner-expired-danger .alert-banner-title   { color: #fca5a5; }
[data-theme="dark"] .alert-banner.banner-prediction              { background: #1a1040; border-color: #6d28d9; }
[data-theme="dark"] .banner-prediction .alert-banner-title       { color: #c4b5fd; }
[data-theme="dark"] .banner-prediction .alert-banner-counter     { color: #a78bfa; }
[data-theme="dark"] .alert-banner.banner-anomaly                 { background: #1a1200; border-color: #c2410c; }
[data-theme="dark"] .banner-anomaly .alert-banner-title          { color: #fdba74; }
[data-theme="dark"] .alert-banner.banner-dup-loss                { background: #2a0808; border-color: #dc2626; }
[data-theme="dark"] .banner-dup-loss .alert-banner-title         { color: #fca5a5; }
[data-theme="dark"] .alert-banner.banner-no-expiry               { background: #0f2a1a; border-color: #166534; }
[data-theme="dark"] .banner-no-expiry .alert-banner-title        { color: #86efac; }

/* ── Alert banner: default text & close ── */
[data-theme="dark"] .alert-banner-title  { color: #e2e8f0; }
[data-theme="dark"] .alert-banner-detail { color: #94a3b8; }
[data-theme="dark"] .alert-banner-close  { color: #94a3b8; background: rgba(255,255,255,0.06); }
[data-theme="dark"] .banner-safety-warning { color: #fdba74; }
[data-theme="dark"] .banner-safety-ok      { color: #86efac; }
[data-theme="dark"] .banner-safety-danger  { color: #fca5a5; }

/* ── Banner action buttons ── */
[data-theme="dark"] .btn-banner-ok           { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .btn-banner-edit         { background: #1a1040; color: #c4b5fd; }
[data-theme="dark"] .btn-banner-ai           { background: #2e1a4a; color: #c4b5fd; }
[data-theme="dark"] .btn-banner-weigh        { background: #2e1a4a; color: #c4b5fd; }
[data-theme="dark"] .btn-banner-confirm      { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .btn-banner-use          { background: #0c2a4e; color: #7dd3fc; }
[data-theme="dark"] .btn-banner-throw        { background: #2a0808; color: #fca5a5; }
[data-theme="dark"] .btn-banner-throw-primary { background: #dc2626; color: #fff; }
[data-theme="dark"] .btn-banner-use-danger   { background: #1e293b; color: #64748b; }
[data-theme="dark"] .btn-banner-vacuum       { background: #2e1a4a; color: #c4b5fd; }
[data-theme="dark"] .btn-banner-edit2        { background: #0c2a4e; color: #7dd3fc; }

/* ── Review items ── */
[data-theme="dark"] .review-item          { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .review-item-meta     { color: #94a3b8; }
[data-theme="dark"] .review-warn          { color: #fca5a5; }
[data-theme="dark"] .review-qty-value     { background: #2a0808; color: #fca5a5; }
[data-theme="dark"] .btn-review-ok        { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .btn-review-ok:active { background: #0d2416; }
[data-theme="dark"] .btn-review-edit        { background: #1a1040; color: #c4b5fd; }
[data-theme="dark"] .btn-review-edit:active { background: #140d36; }

/* ── Chat UI ── */
[data-theme="dark"] .chat-header-bar    { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .chat-title         { color: #818cf8; }
[data-theme="dark"] .chat-suggestion    { background: #1a1040; border-color: #3730a3; color: #a5b4fc; }
[data-theme="dark"] .chat-suggestion:active { background: #2e1a4a; }
[data-theme="dark"] .chat-gemini        { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
[data-theme="dark"] .chat-gemini strong { color: #818cf8; }
[data-theme="dark"] .chat-input-bar     { background: var(--bg-card); border-color: var(--border); }

/* ── Settings status ── */
[data-theme="dark"] .settings-status.success { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .settings-status.error   { background: #2a0808; color: #fca5a5; }

/* ── Inventory status bar ── */
[data-theme="dark"] .inventory-status-bar {
    background: linear-gradient(135deg, #0c2a4e 0%, #1a1040 100%);
    border-color: #1e3a8a;
}
[data-theme="dark"] .inventory-status-bar .inv-status-title { color: #7dd3fc; }
[data-theme="dark"] .inventory-status-bar .inv-status-total { color: #e2e8f0; background: rgba(0,0,0,0.3); }
[data-theme="dark"] .inventory-status-bar .inv-status-item  { color: #93c5fd; background: rgba(0,0,0,0.2); }

/* ── Use inventory info ── */
[data-theme="dark"] .use-inventory-info { background: #0c2a4e; color: #7dd3fc; }
[data-theme="dark"] #use-expiry-hint    { background: #2a1e00; border-color: #78350f; color: #fde68a; }
[data-theme="dark"] #page-use .product-preview-small  { border-left-color: var(--primary); }
[data-theme="dark"] #page-action .product-preview-small { border-left-color: var(--primary); }
[data-theme="dark"] .action-pill-barcode { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] .use-pill-ok       { background: #14532d; color: #86efac; }
[data-theme="dark"] .use-pill-warn     { background: #422006; color: #fde68a; }
[data-theme="dark"] .use-pill-soon     { background: #431407; color: #fdba74; }
[data-theme="dark"] .use-pill-expired  { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .use-pill-qty      { background: #0c2a4e; color: #7dd3fc; }

/* ── Recipe components ── */
[data-theme="dark"] .recipe-expiry-note  { background: #2a1e00; color: #fde68a; }
[data-theme="dark"] .recipe-nutrition-block { background: #052e16; border-color: #166534; }
[data-theme="dark"] .recipe-section-heading { color: #4ade80; }
[data-theme="dark"] .recipe-storage-card .recipe-section-heading { color: #fbbf24; }
[data-theme="dark"] .recipe-nutrition-value { color: #4ade80; }
[data-theme="dark"] .recipe-nutrition-label { color: #94a3b8; }
[data-theme="dark"] .recipe-nutrition-note  { color: #64748b; }
[data-theme="dark"] .recipe-nutrition-footnote { color: var(--text-muted); }
[data-theme="dark"] .recipe-storage-card { background: #1c1400; border-color: #78350f; }
[data-theme="dark"] .recipe-storage-badge { background: #2a1e00; border-color: #92400e; color: #fde68a; }
[data-theme="dark"] .recipe-storage-days { background: #0c1a2e; border-color: #1d4ed8; color: #93c5fd; }
[data-theme="dark"] .recipe-storage-now  { background: #2a0a0a; border-color: #b91c1c; color: #fca5a5; }
[data-theme="dark"] .recipe-storage-tips { color: #fde68a; }
[data-theme="dark"] .recipe-tools-banner { background: #1a1040; border-color: #3730a3; color: #c4b5fd; }
[data-theme="dark"] .recipe-tool-chip    { background: #2e1a4a; color: #c4b5fd; }
[data-theme="dark"] .recipe-step-appliance { background: #052e16; border-color: #166534; color: #4ade80; }
[data-theme="dark"] .recipe-regen-choice { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .recipe-regen-choice-title { color: #94a3b8; }
[data-theme="dark"] .recipe-subtype-chip { background: #1c1300; border-color: #78350f; color: var(--text); }
[data-theme="dark"] .recipe-subtype-chip:has(input:checked) { background: #2a1e00; border-color: #d97706; }

/* ── Bug report pills ── */
[data-theme="dark"] .bug-type-pill { background: var(--bg-card); border-color: var(--border); color: var(--text-light); }

/* ── Shopping tag menu ── */
[data-theme="dark"] .shopping-tag-menu-container { background: #1a2336; }

/* ── Edit unknown card ── */
[data-theme="dark"] .edit-unknown-card.highlight { background: #1c1300; border-color: var(--warning); }

/* ── AI match image ── */
[data-theme="dark"] .ai-match-img { background: var(--bg-card); }

/* ── Inline edit button ── */
[data-theme="dark"] .btn-edit-inline { background: rgba(30,41,59,0.92); border-color: var(--border); color: var(--text); }

/* ── Setup wizard ── */
[data-theme="dark"] .setup-body p    { color: var(--text-muted); }
[data-theme="dark"] .setup-footer    { border-color: var(--border); }
[data-theme="dark"] .setup-skip-link       { color: var(--text-muted); }
[data-theme="dark"] .setup-skip-link:hover { color: var(--text-light); }

/* ── Appliance remove active ── */
[data-theme="dark"] .appliance-item .appliance-remove:active { background: #2a0808; }

/* ===== NETWORK ERROR OVERLAY ===== */
#network-error-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 20, 0.97);
    z-index: 300000; /* highest: above screensaver(10000), cooking(99999), preloader(200000) */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
#network-error-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.net-error-body {
    text-align: center;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.net-error-icon {
    font-size: 5.5rem;
    line-height: 1;
    margin-bottom: 1.75rem;
    animation: net-pulse 2.2s ease-in-out infinite;
    display: block;
    filter: drop-shadow(0 0 32px rgba(248, 113, 113, 0.35));
}
#network-error-overlay.restored .net-error-icon {
    animation: none;
    filter: drop-shadow(0 0 32px rgba(74, 222, 128, 0.45));
}
#network-error-overlay.checking .net-error-icon {
    animation: net-spin 1.2s linear infinite;
}
@keyframes net-pulse {
    0%, 100% { opacity: 0.45; transform: scale(0.92); }
    50%       { opacity: 1;    transform: scale(1.06); }
}
@keyframes net-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.net-error-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #f87171;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    transition: color 0.4s;
}
#network-error-overlay.restored .net-error-title {
    color: #4ade80;
}
.net-error-subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    max-width: 420px;
    line-height: 1.6;
    margin: 0 auto;
}
.net-error-status {
    margin-top: 1.5rem;
    font-size: 0.88rem;
    color: #475569;
    min-height: 1.3em;
    letter-spacing: 0.01em;
}
/* "Continue in offline mode" button — appears after 3 s */
.net-error-continue-btn {
    margin-top: 2.2rem;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.22);
    color: #94a3b8;
    border-radius: 10px;
    padding: 0.7rem 1.6rem;
    font-size: 0.92rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.3s, opacity 0.3s;
    opacity: 0;
    transform: translateY(8px);
}
.net-error-continue-btn.visible {
    opacity: 1;
    transform: translateY(0);
}
.net-error-continue-btn:hover {
    background: rgba(255,255,255,0.16);
    color: #e2e8f0;
}

/* ─── Offline mode: hide AI and network-dependent UI ────────────────────────
   Sections that require a live server response or AI are hidden so the user
   isn't confronted with empty/broken widgets while offline.               */
body.offline-mode #waste-chart-section,
body.offline-mode #nutrition-section,
body.offline-mode #quick-recipe-bar,
body.offline-mode .header-gemini-btn,
body.offline-mode #btn-suggest,
body.offline-mode #btn-fetch-prices,
body.offline-mode .recipe-generate-btn {
    display: none !important;
}
/* Smart-shopping AI section: show as disabled rather than disappearing entirely */
body.offline-mode #smart-shopping {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(0.6);
}
