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

:root {
    --primary: #111827;
    --accent:  #f59e0b;
    --bg:      #f9fafb;
    --card:    #ffffff;
    --border:  #e5e7eb;
    --text:    #111827;
    --muted:   #6b7280;
    --radius:  12px;
    --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

html { font-size: 16px; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Full-screen states ─────────────────────────────────── */
.fullscreen {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    z-index: 100;
}
.fullscreen.hidden { display: none; }
.center-content { text-align: center; padding: 24px; }
.center-content h2 { font-size: 20px; font-weight: 700; margin: 16px 0 8px; }
.center-content p  { color: var(--muted); font-size: 14px; max-width: 280px; margin: 0 auto 20px; }
.big-icon { font-size: 56px; line-height: 1; }

/* ── Splash screen ──────────────────────────────────────── */
.splash { background: var(--primary); }

.splash-inner {
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
    text-align: center; padding: 24px;
}

.splash-emoji {
    font-size: 64px; line-height: 1;
    animation: splashBounce .6s cubic-bezier(.36,.07,.19,.97) both;
}

.splash-outlet-name {
    color: #fff;
    font-size: 26px; font-weight: 800; letter-spacing: -.5px;
    opacity: 0; transform: translateY(16px);
    transition: opacity .5s ease, transform .5s ease;
    min-height: 36px;
}
.splash-outlet-name.show {
    opacity: 1; transform: translateY(0);
}

.splash-loader {
    display: flex; gap: 7px; margin-top: 8px;
}
.splash-loader span {
    width: 7px; height: 7px;
    background: rgba(255,255,255,.4);
    border-radius: 50%;
    animation: dotPulse 1.2s ease-in-out infinite;
}
.splash-loader span:nth-child(2) { animation-delay: .2s; }
.splash-loader span:nth-child(3) { animation-delay: .4s; }

.splash.fade-out { animation: splashFade .4s ease-out forwards; }

@keyframes splashBounce {
    0%   { transform: scale(.4); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes dotPulse {
    0%, 100% { opacity: .3; transform: scale(.8); }
    50%       { opacity: 1;  transform: scale(1.2); }
}
@keyframes splashFade {
    to { opacity: 0; transform: scale(1.04); }
}

/* ── App container ──────────────────────────────────────── */
#app {
    display: flex; flex-direction: column; min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,.12);
}
#app.hidden { display: none; }

/* ── Header ─────────────────────────────────────────────── */
.header {
    position: sticky; top: 0; z-index: 50;
    background: var(--primary);
    padding: env(safe-area-inset-top, 0) 0 0;
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
}
.outlet-name { color: #fff; font-size: 17px; font-weight: 700; line-height: 1.2; }
.table-badge {
    display: inline-block;
    color: var(--accent);
    font-size: 12px; font-weight: 500;
    margin-top: 2px;
}
.cart-icon-btn {
    position: relative;
    background: rgba(255,255,255,.12);
    border: none; border-radius: 10px;
    color: #fff; cursor: pointer;
    padding: 8px; line-height: 0;
    transition: background .15s;
}
.cart-icon-btn:hover { background: rgba(255,255,255,.2); }
.cart-count {
    position: absolute; top: -4px; right: -4px;
    background: var(--accent); color: #000;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
}
.cart-count.hidden { display: none; }

/* ── Search ─────────────────────────────────────────────── */
.search-wrap {
    position: relative;
    background: var(--primary);
    padding: 0 16px 12px;
}
.search-icon {
    position: absolute; left: 28px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted); pointer-events: none;
}
.search-input {
    width: 100%; padding: 10px 14px 10px 38px;
    border: none; border-radius: 10px;
    background: rgba(255,255,255,.12);
    color: #fff; font-size: 14px; font-family: inherit;
    outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,.45); }

/* ── Categories ─────────────────────────────────────────── */
.cats-scroll {
    background: var(--primary);
    overflow-x: auto; scrollbar-width: none;
    padding: 0 16px 14px;
}
.cats-scroll::-webkit-scrollbar { display: none; }
.cats { display: flex; gap: 8px; width: max-content; }
.cat-btn {
    background: rgba(255,255,255,.12);
    border: none; border-radius: 20px;
    color: rgba(255,255,255,.7);
    font-size: 13px; font-weight: 500; font-family: inherit;
    padding: 6px 14px; cursor: pointer; white-space: nowrap;
    transition: background .15s, color .15s;
}
.cat-btn.active {
    background: var(--accent);
    color: #000;
}

/* ── Menu grid ──────────────────────────────────────────── */
.menu-wrap { flex: 1; padding: 16px 16px 120px; }
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.empty-grid {
    grid-column: 1/-1; text-align: center;
    color: var(--muted); padding: 48px 0;
    font-size: 14px;
}

/* Menu card */
.menu-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: transform .15s;
}
.menu-card:active { transform: scale(.97); }
.menu-thumb {
    width: 100%; height: 110px;
    background: #f3f4f6;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; color: #d1d5db;
    overflow: hidden;
}
.menu-thumb img { width: 100%; height: 100%; object-fit: cover; }
.menu-info { padding: 10px 10px 12px; flex: 1; display: flex; flex-direction: column; }
.menu-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.menu-desc { font-size: 11px; color: var(--muted); line-height: 1.4; margin-bottom: 8px; flex: 1;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.menu-price { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.btn-add {
    width: 100%; padding: 7px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 8px;
    font-size: 12px; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: opacity .15s;
}
.btn-add:hover { opacity: .85; }
.qty-ctrl {
    display: flex; align-items: center; justify-content: space-between;
    background: #f3f4f6; border-radius: 8px; padding: 2px;
}
.btn-qty {
    width: 30px; height: 30px; border: none; background: none;
    font-size: 18px; font-weight: 700; cursor: pointer; color: var(--primary);
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    transition: background .1s;
}
.btn-qty:hover { background: #e5e7eb; }
.qty-num { font-size: 14px; font-weight: 700; min-width: 20px; text-align: center; }

/* ── Cart FAB ───────────────────────────────────────────── */
.cart-fab {
    position: fixed; bottom: 0; left: 0; right: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(249,250,251,1) 80%, transparent);
    z-index: 40;
}
.cart-fab.hidden { display: none; }
.cart-fab-btn {
    width: 100%; padding: 14px 20px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 14px;
    font-size: 14px; font-weight: 600; font-family: inherit;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.fab-mid { color: rgba(255,255,255,.4); }
.fab-arrow { margin-left: auto; font-size: 13px; color: var(--accent); }

/* ── Modals ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end;
    backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
    width: 100%; max-height: 90dvh;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    display: flex; flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.slide-up { animation: slideUp .25s ease-out; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
    width: 36px; height: 4px; background: var(--border);
    border-radius: 2px; margin: 12px auto 0;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.btn-close {
    background: #f3f4f6; border: none;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 12px; cursor: pointer; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
}
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer { padding: 12px 20px 16px; border-top: 1px solid var(--border); }

/* Cart items */
.cart-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-thumb {
    width: 52px; height: 52px; flex-shrink: 0;
    background: #f3f4f6; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: #d1d5db; overflow: hidden;
}
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-size: 14px; font-weight: 600; margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-price { font-size: 12px; color: var(--muted); }
.cart-ctrl { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cart-ctrl .btn-qty { width: 26px; height: 26px; font-size: 16px; }
.cart-ctrl .qty-num { font-size: 13px; }

.empty-msg { color: var(--muted); text-align: center; padding: 32px 0; font-size: 14px; }

/* Price rows */
.price-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px; padding: 4px 0;
    color: var(--muted);
}
.price-total { font-size: 16px; font-weight: 700; color: var(--text); padding: 8px 0 12px; }

/* Checkout summary */
.order-summary { background: var(--bg); border-radius: 10px; padding: 12px; margin-top: 12px; }
.summary-item {
    display: flex; justify-content: space-between;
    font-size: 13px; color: var(--muted); padding: 3px 0;
}

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 14px; font-family: inherit; background: var(--bg);
    outline: none; resize: none;
    transition: border-color .15s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.optional { color: var(--muted); font-weight: 400; font-size: 12px; }

/* Buttons */
.btn-primary {
    width: 100%; padding: 14px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 12px;
    font-size: 15px; font-weight: 700; font-family: inherit;
    cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-outline {
    padding: 10px 24px;
    background: none; border: 1.5px solid var(--primary);
    border-radius: 10px; font-size: 14px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    transition: background .15s;
}
.btn-outline:hover { background: #f3f4f6; }

/* Success */
.order-num-label { font-size: 12px; color: var(--muted); margin: 16px 0 4px; }
.order-num { font-size: 22px; font-weight: 800; letter-spacing: .5px; }

/* Toast */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: rgba(17,24,39,.9); color: #fff;
    padding: 10px 20px; border-radius: 20px;
    font-size: 13px; font-weight: 500;
    white-space: nowrap; z-index: 300;
    transition: opacity .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.show { opacity: 1; }

.hidden { display: none !important; }
