:root {
    --bg-dark: #080b11;
    --card-bg: rgba(17, 24, 39, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-glow: rgba(99, 102, 241, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #6366f1; /* Indigo */
    --accent-primary-glow: rgba(99, 102, 241, 0.4);
    --accent-secondary: #06b6d4; /* Cyan */
    --accent-secondary-glow: rgba(6, 182, 212, 0.4);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
}

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

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport height: keeps footer reachable under mobile browser bars */
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-overflow-scrolling: touch;
}

/* Allow selection for scanned text and search inputs */
#resultText, #historySearch, .detail-value, .history-item-title {
    -webkit-user-select: text;
    user-select: text;
}

/* Touch targets optimization */
button, select, label, input, textarea, a, .history-item-main {
    touch-action: manipulation;
}

/* Background animated glow orbs */
.bg-blur {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
    animation: float 20s infinite alternate;
}

.bg-blur-1 {
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    top: -10%;
    left: -10%;
}

.bg-blur-2 {
    background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: calc(24px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    gap: 24px;
    z-index: 1;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(16px);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.logo-icon i {
    width: 24px;
    height: 24px;
    color: white;
}

.logo-area h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    box-shadow: 0 0 8px var(--text-muted);
    transition: var(--transition-smooth);
}

/* Status States */
.status-badge.scanning {
    color: var(--accent-secondary);
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.2);
}
.status-badge.scanning .status-dot {
    background-color: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-secondary);
    animation: pulse 1.5s infinite;
}

.status-badge.ready {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}
.status-badge.ready .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-badge.error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}
.status-badge.error .status-dot {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--danger);
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
}

/* Allow grid items to shrink below their content's intrinsic width.
   Without this, a long unbreakable value (e.g. in #resultText) forces the
   track wider than the viewport and the page overflows to the right. */
.dashboard-grid > * {
    min-width: 0;
}

.sidebar-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Card Common */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(16px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.card:hover {
    border-color: var(--card-border-glow);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h2 i {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

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

/* Custom Select Dropdown */
.camera-select-wrapper {
    position: relative;
    min-width: 180px;
}

#cameraSelect {
    width: 100%;
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    appearance: none;
    transition: var(--transition-smooth);
}

#cameraSelect:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary-glow);
}

.camera-select-wrapper::after {
    content: '▼';
    font-size: 9px;
    color: var(--text-secondary);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Scanner Viewport Container */
.scanner-viewport-container {
    width: 100%;
    aspect-ratio: 4/3;
    background: #04060a;
    border-radius: var(--border-radius-md);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* HTML5 QrCode Video Element overrides */
#reader {
    width: 100% !important;
    height: 100% !important;
}

#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: var(--border-radius-md);
}

/* Scanner Placeholder */
.scanner-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.8) 0%, #04060a 100%);
    z-index: 2;
    transition: opacity 0.4s ease;
}

.scanner-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 320px;
}

.glowing-orb {
    width: 72px;
    height: 72px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
    margin-bottom: 8px;
}

.glowing-orb i {
    width: 36px;
    height: 36px;
    color: var(--accent-primary);
}

.scanner-placeholder h3 {
    font-size: 16px;
    font-weight: 600;
}

.scanner-placeholder p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.pulsate-icon {
    animation: spin 8s linear infinite;
}

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

/* Custom Scanning Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

/* Animated Scanner Laser */
.scan-laser {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--accent-secondary), transparent);
    box-shadow: 0 0 15px 3px var(--accent-secondary);
    animation: scanAnimation 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes scanAnimation {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* Corner brackets for scanner targeting */
.corner-border {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid var(--accent-secondary);
    border-radius: 4px;
}

.top-left {
    top: 20px;
    left: 20px;
    border-right: none;
    border-bottom: none;
}

.top-right {
    top: 20px;
    right: 20px;
    border-left: none;
    border-bottom: none;
}

.bottom-left {
    bottom: 20px;
    left: 20px;
    border-right: none;
    border-top: none;
}

.bottom-right {
    bottom: 20px;
    right: 20px;
    border-left: none;
    border-top: none;
}

/* Buttons and Action elements */
.scanner-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn {
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
    width: 100%;
    outline: none;
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:active:not(:disabled), 
.btn-action:active, 
.btn-icon:active, 
.btn-history-action:active {
    transform: scale(0.96) !important;
    opacity: 0.85;
    box-shadow: none !important;
}

/* Divider styling */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.divider::before {
    margin-right: 12px;
}

.divider::after {
    margin-left: 12px;
}

/* File Upload element */
.file-upload-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-upload-wrapper input[type="file"] {
    display: none;
}

.file-upload-wrapper label {
    cursor: pointer;
}

.file-info {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Result Card */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.result-placeholder i {
    width: 48px;
    height: 48px;
    stroke-width: 1.5px;
    color: var(--text-muted);
}

.result-placeholder p {
    font-size: 14px;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-text-container {
    position: relative;
    border-radius: var(--border-radius-md);
    background: rgba(4, 6, 10, 0.6);
    border: 1px solid var(--card-border);
    padding: 12px;
    max-width: 100%;
    overflow: hidden;
}

#resultText {
    width: 100%;
    max-width: 100%;
    min-height: 110px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    overflow-y: auto;
}

.result-meta {
    display: flex;
    justify-content: flex-end;
}

.meta-item {
    font-size: 12px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.meta-item i {
    width: 14px;
    height: 14px;
}

/* Action grid */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-action {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: var(--border-radius-md);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-link {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(6, 182, 212, 0.05));
    border-color: rgba(6, 182, 212, 0.3);
    color: #22d3ee;
    text-decoration: none;
}

.btn-link:hover {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(6, 182, 212, 0.1));
    border-color: rgba(6, 182, 212, 0.5);
    box-shadow: 0 0 10px var(--accent-secondary-glow);
}

/* History Card */
.history-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-icon i {
    width: 16px;
    height: 16px;
}

.history-search {
    position: relative;
    width: 100%;
}

.history-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: rgba(4, 6, 10, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: var(--transition-smooth);
}

.history-search input:focus {
    border-color: var(--accent-primary);
    background: rgba(4, 6, 10, 0.8);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.history-list-container {
    max-height: 280px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbar for history list */
.history-list-container::-webkit-scrollbar {
    width: 6px;
}

.history-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.history-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.history-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.history-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    color: var(--text-muted);
    gap: 8px;
    text-align: center;
}

.history-placeholder i {
    width: 32px;
    height: 32px;
}

.history-placeholder p {
    font-size: 13px;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: var(--transition-smooth);
    animation: slideIn 0.3s ease forwards;
    min-width: 0;
}

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

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.history-item-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.history-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    font-size: 11px;
    color: var(--text-secondary);
}

.history-item-badge {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    text-transform: uppercase;
}

.history-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-history-action {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-history-action:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.btn-history-action.delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.btn-history-action i {
    width: 14px;
    height: 14px;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-primary-glow);
    padding: 12px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 999;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

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

.toast-icon {
    width: 18px;
    height: 18px;
    color: var(--success);
}

.toast-message {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

}

/* Product Info Card Styles */
.badge-success {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
    color: #34d399 !important;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #f87171 !important;
}

.product-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 16px;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.product-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 12px;
    text-align: center;
    color: var(--text-muted);
}

.product-error i {
    width: 36px;
    height: 36px;
    color: var(--danger);
}

.product-info-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.product-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.5;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.product-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.detail-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value.font-mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

.price-tag {
    color: var(--accent-secondary) !important;
    font-size: 15px;
    font-weight: 700;
}

.rests-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.rests-section h4 {
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.rests-section h4 i {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

.rests-table-container {
    background: rgba(4, 6, 10, 0.4);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.rests-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.rests-table th, .rests-table td {
    padding: 10px 14px;
    text-align: left;
}

.rests-table th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
}

.rests-table td {
    color: var(--text-primary);
}

.rests-table tr:not(:last-child) td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.rests-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

.no-rests-message {
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

}

/* Modal Overlay Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(4, 6, 10, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
}

.modal-card {
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 480px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 30px rgba(99, 102, 241, 0.15);
    backdrop-filter: blur(20px);
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-close-btn:active {
    transform: scale(0.9);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.modal-footer .camera-controls-row {
    width: 100%;
    justify-content: space-between;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: auto;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: calc(6px + env(safe-area-inset-top)) calc(6px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left));
        gap: 6px;
    }
    
    .app-header {
        padding: 8px 10px;
    }
    
    .logo-icon {
        width: 28px;
        height: 28px;
    }
    
    .logo-icon i {
        width: 14px;
        height: 14px;
    }
    
    .logo-area h1 {
        font-size: 15px;
    }
    
    .subtitle {
        font-size: 9px;
        letter-spacing: 0.5px;
    }
    
    .status-badge {
        padding: 2px 5px;
        font-size: 9px;
    }
    
    .card {
        padding: 10px 8px;
        gap: 8px;
    }
    
    .card-header h2 {
        font-size: 14px;
    }
    
    #cameraSelect {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .camera-select-wrapper {
        min-width: 120px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 12px;
        border-radius: 8px;
    }

    /* Optimize camera aspect ratio to a shorter wider format (16:10) on mobile to save vertical space */
    .scanner-viewport-container {
        aspect-ratio: 16 / 10;
    }

    /* Place controls side-by-side on mobile, saving vertical space */
    .scanner-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .scanner-actions .divider {
        display: none;
    }
    
    .scanner-actions .file-info {
        display: none;
    }

    .file-upload-wrapper {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .file-upload-wrapper label {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0;
        box-sizing: border-box;
        padding: 10px 16px;
        font-size: 13px;
    }

    #startBtn {
        width: 100%;
        box-sizing: border-box;
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Compact Scanned Results */
    .result-placeholder {
        padding: 16px 8px;
        gap: 8px;
    }

    .result-placeholder i {
        width: 32px;
        height: 32px;
    }

    .result-content {
        gap: 8px;
    }

    .result-text-container {
        padding: 8px;
    }

    #resultText {
        min-height: 44px !important;
        font-size: 13px;
        line-height: 1.4;
    }

    .action-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .btn-action {
        font-size: 12px;
        padding: 8px 12px;
        border-radius: 8px;
    }

    /* Compact Product Info */
    .product-title {
        font-size: 14px;
    }

    .product-details-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .detail-item {
        padding: 8px;
    }

    .detail-label {
        font-size: 9px;
    }

    .detail-value {
        font-size: 12px;
        word-break: break-all;
        overflow-wrap: break-word;
    }

    .detail-value.font-mono {
        font-size: 11px;
        word-break: break-all;
        overflow-wrap: break-word;
    }

    .price-tag {
        font-size: 13px;
    }

    .rests-section {
        gap: 8px;
        margin-top: 4px;
    }

    .rests-table th, .rests-table td {
        padding: 6px 8px;
        font-size: 11px;
    }

    .no-rests-message {
        padding: 12px;
        font-size: 11px;
    }

    /* Compact History List */
    .history-placeholder {
        padding: 16px 8px;
    }

    .history-list-container {
        max-height: 110px;
    }

    .history-item {
        padding: 8px;
        gap: 8px;
    }

    .history-item-title {
        font-size: 12px;
    }

    .history-item-meta {
        font-size: 10px;
    }

    /* Mobile Modal Native Bottom Sheet */
    .modal-overlay {
        align-items: flex-end;
    }

    .modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        border-bottom: none;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        animation: modalSlideUpMobile 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    }

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