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

:root {
    --primary: #0066ff;
    --primary-dark: #0052cc;
    --primary-light: #e6f0ff;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --success: #28a745;
    --success-light: #d4edda;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6c757d;
    --border: #e1e5e9;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 16px;
    --radius-sm: 10px;
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    backdrop-filter: blur(10px);
    padding: 16px 0 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary) 0%, #00c6ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0,102,255,0.3);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 10px 14px;
    font-size: 13px;
}

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

.btn-outline {
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--text-secondary);
    width: 100%;
    padding: 14px;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-camera {
    background: var(--primary);
    color: white;
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,102,255,0.3);
}

.btn-capture {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: white;
    border: 4px solid var(--primary);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shutter-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    transition: transform 0.1s;
}

.btn-capture:active .shutter-button {
    transform: scale(0.85);
}

.btn-icon {
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.btn-submit {
    width: 100%;
    padding: 16px;
    background: var(--success);
    color: white;
    font-size: 16px;
    border-radius: var(--radius);
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(40,167,69,0.3);
}

.btn-submit:disabled {
    background: var(--border);
    color: var(--text-secondary);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-quantity {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 20px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 700;
}

/* Camera Section */
.camera-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}

.camera-container video,
.camera-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.focus-frame {
    width: 70%;
    height: 60%;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 12px;
    position: relative;
}

.focus-frame::before,
.focus-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary);
    border-style: solid;
}

.focus-frame::before {
    top: -2px;
    left: -2px;
    border-width: 3px 0 0 3px;
}

.focus-frame::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 3px 3px 0;
}

.camera-hint {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    margin-top: 12px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: 20px;
}

.camera-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.file-input-wrapper {
    text-align: center;
}

.or-divider {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 10px;
}

/* Form */
.product-form {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.id-field {
    display: flex;
    gap: 8px;
}

.id-input {
    font-family: 'SF Mono', monospace;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    letter-spacing: 1px;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quantity-input {
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    flex: 1;
}

/* Items List */
.items-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

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

.badge {
    background: var(--primary);
    color: white;
    font-size: 13px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 700;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state .sub {
    font-size: 14px;
    margin-top: 4px;
    opacity: 0.7;
}

.item-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

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

.item-image {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: #ddd;
}

.item-image-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

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

.item-id {
    font-family: monospace;
    font-size: 12px;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 2px;
}

.item-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.item-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    align-self: center;
}

.item-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.btn-delete {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--danger-light);
    color: var(--danger);
    border-radius: 10px;
}

.btn-edit {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    z-index: 1001;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    white-space: nowrap;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
