*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #FF6B35;
    --primary-dark: #E55A2B;
    --primary-light: #FFF3EE;
    --success: #22C55E;
    --danger: #EF4444;
    --warning: #F59E0B;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
}

.hidden { display: none !important; }
.screen { min-height: 100dvh; }
.screen:not(.active) { display: none; }
.view:not(.active) { display: none; }

/* Login */
.login-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100dvh; padding: 24px; background: linear-gradient(135deg, #FF6B35 0%, #FF8F65 100%);
}
.login-logo { font-size: 64px; margin-bottom: 8px; }
.login-container h1 { color: #fff; font-size: 32px; font-weight: 700; }
.login-subtitle { color: rgba(255,255,255,0.85); margin-bottom: 32px; }
.login-form {
    background: #fff; border-radius: var(--radius); padding: 24px;
    width: 100%; max-width: 380px; box-shadow: var(--shadow-lg);
}
.input-group {
    display: flex; align-items: center; border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: 0 12px; margin-bottom: 16px; transition: border-color .2s;
}
.input-group:focus-within { border-color: var(--primary); }
.input-prefix { color: var(--gray-500); font-weight: 500; margin-right: 4px; }
.input-group input {
    flex: 1; border: none; outline: none; padding: 14px 0;
    font-size: 16px; font-family: inherit;
}
.otp-sent-msg { text-align: center; color: var(--gray-500); margin-bottom: 16px; font-size: 14px; }
.otp-inputs { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; }
.otp-box {
    width: 48px; height: 56px; text-align: center; font-size: 24px; font-weight: 600;
    border: 2px solid var(--gray-200); border-radius: var(--radius-sm); outline: none;
    font-family: inherit; transition: border-color .2s;
}
.otp-box:focus { border-color: var(--primary); }
.error-msg { background: #FEE2E2; color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); margin-top: 12px; font-size: 14px; text-align: center; max-width: 380px; width: 100%; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: none; border-radius: var(--radius-sm); font-family: inherit;
    font-size: 15px; font-weight: 600; cursor: pointer; padding: 12px 20px; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-full { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-link { background: none; color: var(--primary); text-decoration: underline; }
.btn-danger { background: var(--danger); color: #fff; }

/* Header */
.app-header {
    position: sticky; top: 0; z-index: 100; background: #fff;
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--gray-200); box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header-logo { font-size: 24px; }
.header-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.header-right { display: flex; gap: 4px; }
.header-btn {
    background: none; border: none; font-size: 22px; cursor: pointer;
    padding: 8px; border-radius: 50%; position: relative; transition: background .2s;
}
.header-btn:hover { background: var(--gray-100); }
.badge {
    position: absolute; top: 2px; right: 2px; background: var(--primary);
    color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px;
    border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* View Header */
.view-header {
    display: flex; align-items: center; gap: 12px; padding: 16px;
    background: #fff; border-bottom: 1px solid var(--gray-100);
}
.view-header h2 { font-size: 20px; font-weight: 700; }
.back-btn {
    background: none; border: none; font-size: 24px; cursor: pointer;
    padding: 4px 8px; border-radius: var(--radius-sm); transition: background .2s;
}
.back-btn:hover { background: var(--gray-100); }

/* Categories */
.categories-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 16px;
}
.category-card {
    background: #fff; border-radius: var(--radius); padding: 20px 16px;
    text-align: center; cursor: pointer; box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s; border: 2px solid transparent;
}
.category-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.category-card:active { transform: scale(0.97); }
.category-emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.category-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin-bottom: 8px; }
.category-name { font-size: 15px; font-weight: 600; color: var(--gray-700); }

/* Category Banner */
.category-banner { width: 100%; max-height: 180px; overflow: hidden; }
.category-banner img { width: 100%; height: 180px; object-fit: cover; }

/* Items */
.items-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; padding-bottom: 90px; }
.item-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    display: flex; overflow: hidden; transition: transform .15s;
}
.item-card:active { transform: scale(0.98); }
.item-img {
    width: 120px; min-height: 120px; background: var(--gray-100);
    display: flex; align-items: center; justify-content: center; font-size: 40px; flex-shrink: 0;
}
.item-img img { width: 100%; height: 100%; object-fit: cover; }
.item-info { flex: 1; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; }
.item-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.item-desc { font-size: 13px; color: var(--gray-500); line-height: 1.4; margin-bottom: 8px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-vendor { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.item-bottom { display: flex; align-items: center; justify-content: space-between; }
.item-price { font-size: 16px; font-weight: 700; color: var(--primary); }
.add-btn {
    background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm);
    padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: background .2s;
}
.add-btn:hover { background: var(--primary-dark); }

/* Cart */
.cart-items { padding: 16px; display: flex; flex-direction: column; gap: 16px; padding-bottom: 220px; }
.cart-vendor { display: flex; flex-direction: column; gap: 8px; }
.cart-vendor-header {
    display: flex; justify-content: space-between; align-items: baseline;
    font-weight: 700; font-size: 15px; padding: 0 4px;
}
.cart-vendor-delivery { font-weight: 500; font-size: 13px; color: var(--gray-500); }
.cart-breakdown .summary-row { padding: 2px 0; }
.cart-item {
    background: #fff; border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 600; margin-bottom: 4px; }
.cart-item-price { color: var(--gray-500); font-size: 14px; }
.qty-controls { display: flex; align-items: center; gap: 12px; }
.qty-btn {
    width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--primary);
    background: #fff; color: var(--primary); font-size: 18px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-family: inherit; transition: all .2s;
}
.qty-btn:hover { background: var(--primary); color: #fff; }
.qty-value { font-size: 16px; font-weight: 700; min-width: 24px; text-align: center; }
.cart-item-subtotal { font-weight: 700; color: var(--primary); min-width: 70px; text-align: right; }
.cart-footer {
    position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    padding: 16px; border-top: 1px solid var(--gray-200); box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}
.cart-total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; margin-bottom: 12px; }

/* Checkout */
.checkout-section { background: #fff; margin: 12px 16px; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.checkout-section h3 { font-size: 16px; margin-bottom: 12px; }
.checkout-section textarea, .checkout-section input[type="text"] {
    width: 100%; border: 2px solid var(--gray-200); border-radius: var(--radius-sm);
    padding: 12px; font-family: inherit; font-size: 14px; resize: vertical; outline: none; transition: border-color .2s;
}
.checkout-section textarea:focus, .checkout-section input:focus { border-color: var(--primary); }
.divider-text { text-align: center; color: var(--gray-500); font-size: 13px; margin: 12px 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox-label input { accent-color: var(--primary); width: 18px; height: 18px; }
.checkout-summary { margin: 12px 16px; background: #fff; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; color: var(--gray-500); }
.summary-row.total { font-size: 18px; font-weight: 700; color: var(--gray-900); border-top: 1px solid var(--gray-200); padding-top: 12px; margin-top: 4px; }
.summary-vendor { font-weight: 600; color: var(--gray-900); font-size: 14px; padding-top: 8px; }
.summary-row.sub { padding: 4px 0 4px 12px; font-size: 13px; }
.summary-row.sub small { color: var(--gray-500); }
.summary-row.subtotal { color: var(--gray-900); border-top: 1px dashed var(--gray-200); margin-top: 8px; }
#checkout-view .btn-lg { margin: 16px; width: calc(100% - 32px); }

.saved-addr {
    padding: 12px; border: 2px solid var(--gray-200); border-radius: var(--radius-sm);
    margin-bottom: 8px; cursor: pointer; transition: all .2s;
}
.saved-addr:hover { border-color: var(--primary); background: var(--primary-light); }
.saved-addr-label { font-weight: 600; font-size: 13px; color: var(--primary); }
.saved-addr-text { font-size: 14px; color: var(--gray-700); }

/* Order Placed */
.success-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 70vh; padding: 24px; text-align: center; }
.success-icon { font-size: 72px; margin-bottom: 16px; }
.success-state h2 { font-size: 28px; margin-bottom: 8px; }
.success-subtitle { color: var(--gray-500); margin-bottom: 24px; max-width: 300px; }
.success-actions { display: flex; gap: 12px; }

/* Orders */
.orders-list { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.order-card {
    background: #fff; border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); cursor: pointer; transition: transform .15s;
}
.order-card:active { transform: scale(0.98); }
.order-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-number { font-weight: 700; }
.order-status {
    font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
}
.status-pending { background: #FEF3C7; color: #92400E; }
.status-confirmed { background: #DBEAFE; color: #1E40AF; }
.status-preparing { background: #E0E7FF; color: #3730A3; }
.status-outfordelivery { background: #D1FAE5; color: #065F46; }
.status-delivered { background: #D1FAE5; color: #065F46; }
.status-completed { background: #D1FAE5; color: #065F46; }
.status-cancelled { background: #FEE2E2; color: #991B1B; }
.order-meta { font-size: 13px; color: var(--gray-500); display: flex; justify-content: space-between; }
.order-amount { font-weight: 600; color: var(--gray-900); }

/* Order Detail */
#order-detail-content { padding: 16px; }
.detail-section { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.detail-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--gray-700); }
.detail-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.detail-item:last-child { border-bottom: none; }

/* Floating Cart */
.floating-cart {
    position: fixed; bottom: 16px; left: 16px; right: 16px;
    background: var(--primary); color: #fff; border-radius: var(--radius);
    padding: 14px 20px; display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: var(--shadow-lg);
    z-index: 50; transition: transform .2s;
}
.floating-cart:active { transform: scale(0.97); }

/* Empty State */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; text-align: center; }
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state p { color: var(--gray-500); margin-bottom: 20px; }

/* Toast */
.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--gray-900); color: #fff; padding: 12px 24px; border-radius: 24px;
    font-size: 14px; font-weight: 500; z-index: 200; box-shadow: var(--shadow-lg);
    animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }

/* Loading */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center; z-index: 300;
}
.spinner {
    width: 40px; height: 40px; border: 4px solid var(--gray-200);
    border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (min-width: 600px) {
    .categories-grid { grid-template-columns: repeat(3, 1fr); }
    .login-form { padding: 32px; }
}
@media (min-width: 900px) {
    .categories-grid { grid-template-columns: repeat(4, 1fr); }
    .items-list { max-width: 700px; margin: 0 auto; }
    .cart-items { max-width: 700px; margin: 0 auto; }
    .cart-footer { max-width: 700px; margin: 0 auto; left: auto; right: auto; }
}
