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

[hidden] { display: none !important; }

:root {
  --accent: #ff5f1f;
  --accent-2: #ff9f1c;
  --dark: #1c1917;
  --muted: #75716b;
  --bg: #faf6f2;
  --card: #ffffff;
  --line: #eee6de;
  --green: #22a06b;
  --red: #e5484d;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(60, 30, 10, .08);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.45;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; }

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 800; }
.brand-badge { font-size: 26px; }
.brand-name { letter-spacing: -.5px; }
.brand-accent { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-btn {
  padding: 8px 14px; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: #f5efe9; color: var(--dark); }
.nav-btn.active { background: var(--dark); color: #fff; }
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.cart-btn {
  position: relative; display: flex; align-items: center; gap: 4px;
  background: var(--dark); color: #fff; padding: 9px 14px; border-radius: 999px; font-weight: 700;
}
.cart-btn .cart-icon { font-size: 18px; }
.cart-count {
  background: var(--accent); border-radius: 999px; min-width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; padding: 0 6px;
}
.cart-count.hidden { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 8px; background: #f5efe9;
  padding: 7px 12px; border-radius: 999px; font-weight: 600; font-size: 14px;
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800;
}
.user-chip .logout { color: var(--muted); font-size: 15px; padding: 2px 4px; }
.user-chip .logout:hover { color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; padding: 10px 18px; font-size: 15px; font-weight: 700;
  transition: transform .1s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 16px rgba(255, 95, 31, .28); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-ghost { background: #f1ebe5; color: var(--dark); }
.btn-small { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

.icon-btn { font-size: 18px; color: var(--muted); padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: #f1ebe5; color: var(--dark); }

/* Hero */
.hero {
  background: linear-gradient(120deg, #4a2c14, #7a3b12 45%, #d04a14 90%, #ff7a1c);
  color: #fff; border-radius: 22px; margin: 22px 20px 0; padding: 44px 40px;
  position: relative; overflow: hidden;
}
.hero-title { font-size: clamp(28px, 4vw, 42px); font-weight: 900; letter-spacing: -.5px; max-width: 460px; }
.hero-sub { margin-top: 10px; font-size: 17px; opacity: .92; max-width: 460px; }
.hero-emoji { position: absolute; right: 26px; bottom: -10px; font-size: 130px; opacity: .35; transform: rotate(-8deg); }
.hero-free { display: inline-block; margin-top: 18px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.35); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; }

/* View / page */
.view { max-width: 1120px; margin: 0 auto; padding: 24px 20px 60px; width: 100%; flex: 1; }
.page-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 20px; }

/* Category chips */
.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 20px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat-chip {
  white-space: nowrap; padding: 9px 16px; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); font-weight: 600; font-size: 14px; transition: all .15s;
}
.cat-chip:hover { border-color: var(--accent-2); }
.cat-chip.active { background: var(--dark); color: #fff; border-color: var(--dark); }

/* Menu grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.dish {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.dish:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(60,30,10,.14); }
.dish-cover {
  height: 150px; display: flex; align-items: center; justify-content: center;
  font-size: 68px; position: relative;
}
.dish-cat {
  position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.35); color: #fff;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(4px);
}
.dish-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.dish-name { font-weight: 800; font-size: 16px; }
.dish-desc { color: var(--muted); font-size: 13px; margin-top: 4px; flex: 1; }
.dish-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.dish-price { font-weight: 800; font-size: 17px; }
.dish-price small { font-size: 13px; font-weight: 600; color: var(--muted); }
.add-btn { background: var(--accent); color: #fff; border-radius: 10px; padding: 7px 16px; font-weight: 700; font-size: 15px; box-shadow: 0 4px 12px rgba(255,95,31,.3); }

/* Overlay + drawer */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 12, 6, .45); z-index: 50;
  opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px);
}
.overlay.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 94vw); z-index: 60;
  background: #fff; box-shadow: -10px 0 40px rgba(0,0,0,.2);
  transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head, .layer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h2, .layer-head h2 { font-size: 19px; font-weight: 800; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 20px; }
.drawer-foot { padding: 14px 20px 20px; border-top: 1px solid var(--line); }

/* Cart items */
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-item:last-child { border-bottom: none; }
.cart-emoji {
  width: 52px; height: 52px; border-radius: 14px; font-size: 26px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-weight: 700; font-size: 15px; }
.cart-price { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cart-line { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.qty { display: inline-flex; align-items: center; gap: 2px; background: #f4eee7; border-radius: 10px; padding: 2px; }
.qty button { width: 26px; height: 26px; border-radius: 8px; font-size: 16px; font-weight: 800; }
.qty button:hover { background: #fff; }
.qty span { min-width: 26px; text-align: center; font-weight: 700; }
.cart-item-total { font-weight: 800; font-size: 15px; }
.cart-del { color: var(--muted); padding: 4px; font-size: 15px; }
.cart-del:hover { color: var(--red); }

.totals { background: #faf5f0; border-radius: 14px; padding: 14px 16px; margin-top: 6px; }
.totals-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); padding: 4px 0; }
.totals-row.total { font-size: 17px; font-weight: 800; color: var(--dark); border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; }
.totals-row.free { color: var(--green); font-weight: 700; }

/* Layer (modal) */
.layer {
  position: fixed; inset: 0; z-index: 70; background: rgba(20, 12, 6, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px);
}
.layer-card {
  background: #fff; border-radius: 18px; width: min(540px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 70px rgba(0,0,0,.3);
}
.auth-card { width: min(420px, 96vw); }
.layer-body { padding: 20px; overflow-y: auto; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--dark); }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; outline: none; transition: border-color .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field small { color: var(--muted); }

.tabs { display: flex; background: #f4eee7; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--dark); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Addresses */
.addr-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.addr-card {
  border: 1.5px solid var(--line); border-radius: 13px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all .15s; background: #fff;
}
.addr-card:hover { border-color: var(--accent-2); }
.addr-card.selected { border-color: var(--accent); background: #fff7f1; }
.addr-card .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #d8d0c8; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.addr-card.selected .radio { border-color: var(--accent); }
.addr-card.selected .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.addr-main { flex: 1; font-weight: 700; font-size: 14px; }
.addr-sub { color: var(--muted); font-size: 13px; font-weight: 400; }

/* Orders */
.order-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.order-id { font-weight: 800; font-size: 16px; }
.order-date { color: var(--muted); font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.status.pending_payment { background: #fff3e0; color: #b26a00; }
.status.paid { background: #e2f5ec; color: var(--green); }
.status.cancelled { background: #fdeaea; color: var(--red); }
.status.delivered { background: #e5edff; color: #3457d5; }
.order-items { margin-top: 12px; font-size: 14px; color: var(--dark); }
.order-items .li { display: flex; justify-content: space-between; padding: 3px 0; }
.order-meta { margin-top: 10px; font-size: 13px; color: var(--muted); }
.order-total { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; font-weight: 800; font-size: 16px; }
.order-actions { margin-top: 14px; display: flex; gap: 10px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 56px; margin-bottom: 12px; }

/* Profile */
.profile-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; font-size: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 900;
}
.profile-name { font-size: 19px; font-weight: 800; }
.profile-mail { color: var(--muted); font-size: 14px; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  animation: rise .2s ease; max-width: 90vw;
}
.toast.err { background: var(--red); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.footer { border-top: 1px solid var(--line); padding: 22px 20px; background: #fff; }
.footer-inner { max-width: 1120px; margin: 0 auto; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .nav-btn { padding: 8px 10px; font-size: 14px; }
  .hero { padding: 32px 24px; }
  .hero-emoji { font-size: 90px; }
}