@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-light: #dbeafe;
    --green: #16a34a;
    --green-light: #dcfce7;
    --red: #dc2626;
    --red-light: #fee2e2;
    --orange: #ea580c;
    --orange-light: #fff7ed;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--slate-50);
    color: var(--slate-900);
    line-height: 1.5;
    padding-bottom: 80px;
    min-height: 100vh;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px;
}

.page-header {
    padding: 16px 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--slate-900);
}

.page-header .back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--slate-100);
    color: var(--slate-600);
    text-decoration: none;
}

.page-header .back-btn svg {
    width: 20px;
    height: 20px;
}

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

.card-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

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

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    text-align: center;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--slate-900);
}

.stat-card .label {
    font-size: 0.75rem;
    color: var(--slate-500);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.938rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
    line-height: 1;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
}

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

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-outline {
    background: #fff;
    color: var(--slate-700);
    border: 1.5px solid var(--slate-200);
}

.btn-outline:hover {
    background: var(--slate-50);
    border-color: var(--slate-300);
}

.btn-block {
    width: 100%;
}

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

.btn-sm {
    padding: 8px 14px;
    font-size: 0.813rem;
    min-height: 36px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--slate-700);
    transition: all 0.15s;
}

.quick-action:active {
    transform: scale(0.97);
}

.quick-action .icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-action .icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

.quick-action .icon.blue { background: var(--blue-light); color: var(--blue); }
.quick-action .icon.green { background: var(--green-light); color: var(--green); }
.quick-action .icon.orange { background: var(--orange-light); color: var(--orange); }

.quick-action span:last-child {
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

.search-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--slate-50);
    padding: 12px 0;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1.5px solid var(--slate-200);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
    color: var(--slate-900);
    outline: none;
    transition: border-color 0.15s;
}

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

.search-wrap {
    position: relative;
}

.search-wrap .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-400);
    pointer-events: none;
    display: flex;
}

.search-wrap .search-icon svg {
    width: 18px;
    height: 18px;
}

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

.form-label {
    display: block;
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--slate-600);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--slate-900);
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--blue);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.item-list {
    list-style: none;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--slate-100);
    text-decoration: none;
    color: inherit;
}

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

.item-row:active {
    background: var(--slate-50);
}

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

.item-title {
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--slate-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-subtitle {
    font-size: 0.8rem;
    color: var(--slate-500);
    margin-top: 2px;
}

.item-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-yellow { background: #fef9c3; color: #a16207; }

.item-price {
    font-size: 0.938rem;
    font-weight: 700;
    color: var(--slate-900);
    white-space: nowrap;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--slate-200);
    display: flex;
    justify-content: space-around;
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--slate-400);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 12px;
    transition: color 0.15s;
    min-width: 56px;
}

.nav-item i,
.nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

.nav-item.active {
    color: var(--blue);
}

.nav-item.scan-btn {
    position: relative;
    bottom: 12px;
}

.nav-item.scan-btn .scan-btn-inner {
    width: 52px;
    height: 52px;
    background: var(--blue);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-item.scan-btn .scan-btn-inner svg {
    width: 26px;
    height: 26px;
    color: #fff;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-success { background: var(--green-light); color: var(--green); }
.alert-error { background: var(--red-light); color: var(--red); }
.alert-info { background: var(--blue-light); color: var(--blue); }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.813rem;
}

.table th {
    text-align: left;
    padding: 10px 8px;
    font-weight: 600;
    color: var(--slate-500);
    border-bottom: 2px solid var(--slate-200);
    white-space: nowrap;
}

.table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--slate-400);
}

.empty-state .icon {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.empty-state .icon svg {
    width: 48px;
    height: 48px;
    stroke-width: 1;
    color: var(--slate-300);
}

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

.receipt-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 24px 20px;
    max-width: 400px;
    margin: 0 auto;
}

.receipt-header {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--slate-300);
    margin-bottom: 16px;
}

.receipt-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.receipt-header p {
    font-size: 0.75rem;
    color: var(--slate-500);
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.875rem;
}

.receipt-divider {
    border-top: 1px dashed var(--slate-300);
    margin: 12px 0;
}

.receipt-total {
    font-size: 1.25rem;
    font-weight: 700;
}

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filter-bar .form-input,
.filter-bar .form-select {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    font-size: 0.875rem;
}

.scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    color: #fff;
    background: rgba(0,0,0,0.5);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 201;
}

.scanner-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.scanner-close {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-close svg {
    width: 20px;
    height: 20px;
}

#scanner-video {
    flex: 1;
    width: 100%;
    object-fit: cover;
}

.scanner-target {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 260px;
    height: 260px;
    border: 3px solid rgba(255,255,255,0.6);
    border-radius: 24px;
    z-index: 201;
}

.scanner-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 16px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    background: rgba(0,0,0,0.5);
    z-index: 201;
}

.scanner-footer input {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    border: none;
    font-size: 1rem;
    text-align: center;
    background: rgba(255,255,255,0.9);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-item {
    padding: 8px 0;
}

.detail-item .label {
    font-size: 0.7rem;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-item .value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--slate-900);
    word-break: break-all;
}

.detail-item.full {
    grid-column: span 2;
}

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

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.813rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--slate-500); }
.text-bold { font-weight: 700; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.hidden { display: none; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--slate-900);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.login-logo .logo-circle {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.login-logo .logo-circle svg {
    width: 32px;
    height: 32px;
}

.menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
}

.menu-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
}

.menu-icon.blue { background: var(--blue-light); color: var(--blue); }
.menu-icon.green { background: var(--green-light); color: var(--green); }
.menu-icon.orange { background: var(--orange-light); color: var(--orange); }
.menu-icon.red { background: var(--red-light); color: var(--red); }
.menu-icon.slate { background: var(--slate-100); color: var(--slate-600); }

.login-card .subtitle {
    text-align: center;
    color: var(--slate-500);
    font-size: 0.875rem;
    margin-bottom: 32px;
}

.chip-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1.5px solid var(--slate-200);
    background: #fff;
    color: var(--slate-600);
    text-decoration: none;
    transition: all 0.15s;
}

.chip.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--slate-200);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--slate-300);
    border-radius: 14px;
    cursor: pointer;
    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(--blue);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}
