/* CSS Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --success-color: #2E7D32;
    --error-color: #D32F2F;
    --warning-color: #F57C00;
    --text-primary: #212121;
    --text-secondary: #757575;
    --background: #FAFAFA;
    --surface: #FFFFFF;
    --border: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 8px 12px;
    padding-bottom: 24px;
}

/* Header */
.app-header {
    text-align: center;
    padding: 4px 0;
    margin-bottom: 8px;
}

.header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.btn-logout {
    position: absolute;
    right: 0;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background-color: var(--border);
    color: var(--text-primary);
}

/* Logo Styling */
.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 1.6rem;
    font-weight: 500;
    font-style: italic;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.logo-nutr {
    color: #000000;
}

.logo-ai {
    color: var(--primary-color);
}

.build-info {
    color: var(--text-secondary);
    font-size: 0.65rem;
    text-align: center;
    padding: 16px 0;
    margin-top: auto;
    font-family: monospace;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

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

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

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

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

.btn-secondary {
    background-color: var(--border);
    color: var(--text-primary);
}

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

.btn-icon-svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Action Button Row (Scan, Search, AI) */
.action-btn-row {
    display: flex;
    gap: 10px;
}

.btn-action {
    flex: 1;
    flex-direction: column;
    padding: 14px 10px;
    gap: 6px;
}

.btn-action .btn-icon-svg {
    width: 28px;
    height: 28px;
}

.btn-action span {
    font-size: 0.85rem;
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scanner Section */
.scanner-section {
    margin-bottom: 16px;
}

.scanner-container {
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
    aspect-ratio: 4/3;
    display: none;
}

.scanner-container.active {
    display: block;
}

.scanner-viewport {
    width: 100%;
    height: 100%;
}

.scanner-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 8px 0;
}

/* Product Card */
.product-card {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Product Header V2 - Redesigned */
.product-header-v2 {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.product-image-v2 {
    width: 35%;
    max-width: 120px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    background-color: var(--border);
}

.product-info-v2 {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.product-info-v2 h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-info-v2 .product-brand {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 6px;
}

/* Compact Scores (next to image) */
.scores-compact {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.score-compact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 4px 6px;
    background-color: var(--background);
    border-radius: 6px;
}

.score-label-compact {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.score-label-compact .info-icon {
    font-size: 0.6rem;
}

.score-grades-compact {
    display: flex;
    gap: 2px;
}

.score-grades-compact .grade {
    width: 18px;
    height: 18px;
    font-size: 0.55rem;
    border-radius: 3px;
}

.score-grades-compact .grade.active {
    transform: scale(1.2);
    font-size: 0.65rem;
}

/* Nutrition Basis V2 */
.nutrition-basis-v2 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    padding: 4px 8px;
    background-color: var(--background);
    border-radius: 4px;
    display: inline-block;
}

/* Nutrition Rows V2 (with progress bars) */
.nutrition-rows-v2 {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 10px;
    padding: 4px 8px;
    background-color: var(--background);
    border-radius: 8px;
}

.nutrition-row-v2 {
    display: flex;
    align-items: center;
    padding: 1px 0;
    gap: 4px;
}

.nutrition-row-label-v2 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    width: 48px;
    flex-shrink: 0;
}

.nutrition-row-value-v2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 38px;
    flex-shrink: 0;
    text-align: right;
}

.nutrition-row-percent {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    width: 32px;
    flex-shrink: 0;
    text-align: right;
}

/* Nutrition Bar Container */
.nutrition-bar-container {
    flex: 1;
    height: 16px;
    background-color: var(--surface);
    border-radius: 3px;
    position: relative;
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border);
}

/* 100% limit marker line */
.nutrition-bar-limit {
    position: absolute;
    right: 0;
    top: -1px;
    bottom: -1px;
    width: 0;
    border-right: 2px dashed rgba(0,0,0,0.3);
    z-index: 2;
    pointer-events: none;
}

/* Already logged (grey) */
.nutrition-bar-logged {
    height: 100%;
    background-color: #BDBDBD;
    border-radius: 2px 0 0 2px;
    transition: width 0.2s ease;
    flex-shrink: 0;
}

/* Current item portion (colored) */
.nutrition-bar-current {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.2s ease;
    flex-shrink: 0;
}

/* Color variants for different nutrients */
.nutrition-row-v2[data-nutrient="calories"] .nutrition-bar-current { background-color: #FF9800; }
.nutrition-row-v2[data-nutrient="fat"] .nutrition-bar-current { background-color: #F44336; }
.nutrition-row-v2[data-nutrient="satfat"] .nutrition-bar-current { background-color: #E91E63; }
.nutrition-row-v2[data-nutrient="protein"] .nutrition-bar-current { background-color: #2196F3; }
.nutrition-row-v2[data-nutrient="fiber"] .nutrition-bar-current { background-color: #8BC34A; }
.nutrition-row-v2[data-nutrient="carbs"] .nutrition-bar-current { background-color: #9C27B0; }
.nutrition-row-v2[data-nutrient="sugar"] .nutrition-bar-current { background-color: #FF5722; }
.nutrition-row-v2[data-nutrient="salt"] .nutrition-bar-current { background-color: #607D8B; }

/* Over 100% state - bars are scaled, limit line moves left */
.nutrition-bar-container.over-limit .nutrition-bar-limit {
    border-right-color: #D32F2F;
    border-right-style: solid;
}

/* Serving Info V2 */
.serving-info-v2 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 6px 10px;
    background-color: var(--background);
    border-radius: 6px;
}

.serving-info-v2 p {
    margin: 0;
}

/* Portion Section V2 */
.portion-section-v2 {
    margin-bottom: 12px;
}

.portion-section-v2 label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.portion-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.btn-portion-adjust {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-portion-adjust:hover {
    background-color: var(--background);
    border-color: var(--primary-color);
}

.btn-portion-adjust:active {
    transform: scale(0.95);
}

.btn-portion-adjust.btn-reset {
    font-size: 1.1rem;
}

.portion-input-group-v2 {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.portion-input-group-v2 input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    -webkit-appearance: none;
}

.portion-input-group-v2 input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.portion-input-group-v2 .portion-unit {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Portion Slider */
.portion-slider-container {
    margin-bottom: 10px;
    padding: 0 4px;
}

.portion-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.portion-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.portion-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Calculated Calories V2 */
.calculated-calories-v2 {
    text-align: center;
    font-size: 1rem;
    padding: 10px;
    background-color: var(--background);
    border-radius: 8px;
}

.calculated-calories-v2 strong {
    color: var(--primary-color);
    font-size: 1.3rem;
}

/* Legacy styles - keep for compatibility */
.product-header {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.product-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    background-color: var(--border);
}

.product-info {
    flex: 1;
}

.product-info h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

.product-brand {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.product-barcode {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    margin-top: 4px;
}

/* Nutrition Grid */
.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.nutrition-item {
    text-align: center;
    padding: 10px 4px;
    background-color: var(--background);
    border-radius: 10px;
}

.nutrition-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nutrition-label {
    display: block;
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 2px;
}

/* Nutrition Basis Label */
.nutrition-basis {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 8px;
    font-weight: 500;
}

/* Color-coded nutrition boxes */
.nutrition-grid-colored {
    margin-bottom: 6px;
}

.nutrition-grid-colored .nutrition-item {
    transition: background-color 0.2s ease;
}

/* Nutrient level colors */
.nutrition-item.level-low {
    background-color: #E8F5E9;
}
.nutrition-item.level-low .nutrition-value {
    color: #2E7D32;
}

.nutrition-item.level-moderate {
    background-color: #FFF3E0;
}
.nutrition-item.level-moderate .nutrition-value {
    color: #F57C00;
}

.nutrition-item.level-high {
    background-color: #FFEBEE;
}
.nutrition-item.level-high .nutrition-value {
    color: #D32F2F;
}

/* Plain nutrition grid (no colors) */
.nutrition-grid-plain {
    margin-bottom: 14px;
}

/* Scores Section */
.scores-section {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.score-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background-color: var(--background);
    border-radius: 10px;
}

.score-box-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.score-box-clickable:hover {
    background-color: var(--border);
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.info-icon {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Score grades display */
.score-grades {
    display: flex;
    gap: 4px;
}

.grade {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    opacity: 0.3;
    transition: all 0.2s ease;
}

.grade.active {
    opacity: 1;
    transform: scale(1.3);
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* NutriScore grade colors */
.grade-a { background-color: #038141; color: white; }
.grade-b { background-color: #85BB2F; color: white; }
.grade-c { background-color: #FECB02; color: #333; }
.grade-d { background-color: #EE8100; color: white; }
.grade-e { background-color: #E63E11; color: white; }

/* NOVA grade colors */
.grade-nova-1 { background-color: #038141; color: white; }
.grade-nova-2 { background-color: #85BB2F; color: white; }
.grade-nova-3 { background-color: #FECB02; color: #333; }
.grade-nova-4 { background-color: #E63E11; color: white; }

/* Score not available */
.score-na {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 20px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    animation: modalSlideIn 0.2s ease;
}

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

.modal-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    text-align: left;
    white-space: pre-line;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 10px;
}

.action-buttons .btn {
    flex: 1;
}

/* Expandable Sections */
.expandable-sections {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.detail-section {
    margin-bottom: 8px;
}

.detail-section summary {
    cursor: pointer;
    padding: 10px 12px;
    background-color: var(--background);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.detail-section summary::-webkit-details-marker {
    display: none;
}

.detail-section summary::after {
    content: '+';
    font-size: 1.25rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.detail-section[open] summary::after {
    content: '-';
}

.detail-content {
    padding: 12px;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Raw Data Section */
.raw-data-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--background);
}

.raw-data-search {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.raw-data-search input {
    flex: 1;
    min-width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
}

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

.match-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 50px;
}

.btn-nav {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
}

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

.btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-copy {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}

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

.btn-copy.copied {
    background: #E8F5E9;
    border-color: var(--success-color);
}

.raw-data-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.7rem;
    max-height: 300px;
    overflow-y: auto;
    background-color: #f5f5f5;
    border-radius: 4px;
    margin: 0;
}

.raw-data-content .highlight {
    background-color: #FFEB3B;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

.raw-data-content .highlight-current {
    background-color: #FF9800;
    color: #000;
}

/* Serving Hint */
.serving-hint {
    font-weight: normal;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.serving-hint .hint-text {
    color: var(--text-secondary);
}

/* Mode Toggle Button (dry/cooked, drained/liquid) */
.mode-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mode-toggle-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.mode-toggle-btn:active {
    transform: scale(0.95);
}

/* Serving Info */
.serving-info {
    background-color: #E8F5E9;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.serving-info p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.serving-info strong {
    color: var(--primary-dark);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
    width: auto;
}

/* Portion Section */
.portion-section {
    margin-bottom: 16px;
}

.portion-section label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.portion-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.portion-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    -webkit-appearance: none;
}

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

.portion-unit {
    font-size: 1rem;
    color: var(--text-secondary);
}

.calculated-calories {
    text-align: center;
    font-size: 1.125rem;
    padding: 12px;
    background-color: var(--background);
    border-radius: 10px;
}

.calculated-calories strong {
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
}

/* Error Message */
.error-message {
    text-align: center;
    padding: 16px;
    background-color: #FFEBEE;
    border-radius: 12px;
    margin-bottom: 16px;
}

.error-message p {
    color: var(--error-color);
    margin-bottom: 12px;
}

/* Logs Section */
.logs-section {
    margin-bottom: 16px;
}

.logs-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.logs-list {
    background-color: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px var(--shadow);
}

.empty-state {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.log-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

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

.log-item-info {
    flex: 1;
}

.log-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.log-item-portion {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.log-item-calories {
    font-weight: 700;
    color: var(--primary-color);
}

.daily-total {
    margin-top: 8px;
    text-align: right;
    font-size: 0.95rem;
    padding: 10px 12px;
    background-color: var(--surface);
    border-radius: 10px;
}

.daily-total strong {
    color: var(--primary-color);
    font-size: 1.25rem;
}

/* Manual Entry */
.manual-entry {
    margin-top: 24px;
}

.manual-entry summary {
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 8px 0;
}

.manual-input-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.manual-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
}

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

.manual-input-group .btn {
    width: auto;
    padding: 12px 20px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Scanning active state button */
.btn-scanning {
    background-color: var(--error-color);
}

/* Toast notification for success */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--success-color);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 500;
    box-shadow: 0 4px 12px var(--shadow);
    animation: slideUp 0.3s ease;
    z-index: 1000;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Safe area insets for notched iPhones */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-container {
        padding-top: calc(8px + env(safe-area-inset-top));
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* Auth Section */
.auth-section {
    margin-bottom: 16px;
    background-color: var(--surface);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 8px var(--shadow);
}

.auth-forms {
    margin-bottom: 12px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}

.auth-form input {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

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

.auth-switch {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-error {
    color: var(--error-color);
    font-size: 0.875rem;
    text-align: center;
    margin-bottom: 12px;
    padding: 8px;
    background-color: #FFEBEE;
    border-radius: 8px;
}

.auth-success {
    color: var(--success-color);
    font-size: 0.875rem;
    text-align: center;
    margin-bottom: 12px;
    padding: 8px;
    background-color: #E8F5E9;
    border-radius: 8px;
}

.auth-logged-out {
    text-align: center;
}

.auth-logged-in {
    display: flex;
    justify-content: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Pending Approval State */
.auth-pending {
    text-align: center;
    padding: 12px 0;
}

.pending-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.auth-pending h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.auth-pending p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.pending-email {
    background-color: var(--background);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 12px !important;
}

.pending-email strong {
    color: var(--text-primary);
}

/* Search Section */
.search-section {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.search-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.btn-back {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 4px 0;
    font-weight: 500;
}

.search-input-container {
    position: relative;
    margin-bottom: 16px;
}

.search-input-container input {
    width: 100%;
    padding: 14px 48px 14px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    min-height: 48px;
}

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

.btn-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--border);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

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

/* Search Loading */
.search-loading {
    text-align: center;
    padding: 32px 16px;
}

.search-loading .spinner {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
}

.search-loading p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Search Results */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--background);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

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

.search-result-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    background-color: var(--border);
    flex-shrink: 0;
}

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

.search-result-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-brand {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.search-result-arrow {
    color: var(--text-secondary);
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Search Empty/Error States */
.search-empty,
.search-error {
    text-align: center;
    padding: 32px 16px;
}

.search-empty p,
.search-error p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-error p {
    color: var(--error-color);
}

/* ================================================
   Classification Badge & Clarification Modal
   ================================================ */

/* Classification Badge */
.classification-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: #E8F5E9;
    color: #2E7D32;
    margin-bottom: 4px;
}

.classification-badge.hidden {
    display: none;
}

/* Clarification Modal */
.clarify-modal-content {
    max-width: 340px;
}

.clarify-modal-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    line-height: 1.4;
}

.clarify-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.clarify-option-btn {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--background);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.clarify-option-btn:hover {
    border-color: var(--primary-color);
    background-color: #E8F5E9;
}

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

/* ================================================
   Bad Data Button & Modal
   ================================================ */

/* Danger/Red Button */
.btn-danger {
    background-color: var(--error-color);
    color: white;
}

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

/* Bad Data Modal */
.bad-data-modal-content {
    max-width: 340px;
    text-align: left;
}

.bad-data-modal-content h3 {
    text-align: center;
    color: var(--error-color);
}

.bad-data-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
}

.bad-data-modal-content textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    margin-bottom: 16px;
}

.bad-data-modal-content textarea:focus {
    outline: none;
    border-color: var(--error-color);
}

.bad-data-actions {
    display: flex;
    gap: 10px;
}

.bad-data-actions .btn {
    flex: 1;
}
