:root {
  --brand: #1f6feb;
  --brand-dark: #1552b3;
  --brand-text: #ffffff;
  --brand-wash: color-mix(in srgb, var(--brand) 12%, white);
  --bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e9eaee;
  --text: #16181d;
  --muted: #6b7280;
  --success: #16803c;
  --success-bg: #e9f8ee;
  --danger: #c0392b;
  --danger-bg: #fdeceb;
  --warning: #a8710a;
  --warning-bg: #fff4d6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 20px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

/* Navbar */

.navbar {
  background: var(--brand);
  color: var(--brand-text);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.75rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.navbar-left {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.navbar .brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--brand-text);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.02em;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navbar .brand:hover { text-decoration: none; opacity: 0.92; }

.navbar .sidebar-toggle { display: none; flex-shrink: 0; }

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.15);
}

.navbar nav { grid-column: 3; justify-self: end; display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.navbar nav a, .navbar nav button {
  color: var(--brand-text);
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  opacity: 0.92;
}
.navbar nav a:hover, .navbar nav button:hover { text-decoration: none; opacity: 1; }

.navbar .badge {
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-search {
  grid-column: 2;
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1rem;
}
.nav-search .search-icon { font-size: 0.85rem; opacity: 0.55; }
.nav-search input {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.88rem;
  color: var(--text);
}
.nav-search input:focus { outline: none; box-shadow: none; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.15rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.22); }

.icon-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--brand);
}

.avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: var(--brand-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.avatar-dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 170px;
  padding: 0.4rem;
  z-index: 20;
}
.dropdown-menu.open { display: block; }
.navbar .dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 1;
}
.navbar .dropdown-menu a:hover { background: #f5f6f8; text-decoration: none; }

.dropdown-logout-form { margin: 0; }
.dropdown-logout-form button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.dropdown-logout-form button:hover { background: #f5f6f8; }

/* Layout */

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3.5rem;
}

.container.narrow { max-width: 480px; }

.narrow-inner { max-width: 480px; margin: 0 auto; }

/* App shell (sidebar + main content) */

.app-shell {
  display: flex;
  align-items: flex-start;
  max-width: 1280px;
  margin: 0 auto;
}

.sidebar {
  width: 168px;
  flex-shrink: 0;
  padding: 1.5rem 0.5rem;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 65px;
  height: calc(100vh - 65px);
  overflow-y: auto;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.1rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  font-size: 0.84rem;
  transition: background 0.15s ease;
}
.sidebar-link:hover { background: #f5f6f8; text-decoration: none; }
.sidebar-link.active { background: var(--brand-wash); color: var(--brand-dark); }

.sidebar-icon { font-size: 1.05rem; width: 1.25rem; text-align: center; flex-shrink: 0; }

.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0.5rem; }

.sidebar-backdrop { display: none; }

.content { flex: 1; min-width: 0; padding: 2.25rem 2rem 3.5rem; }

/* Horizontal scroll rows */

.row-section { margin-bottom: 2.5rem; }
.row-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.9rem; }
.row-header h2 { margin: 0; }
.see-all { font-size: 0.85rem; font-weight: 650; color: var(--muted); flex-shrink: 0; }
.see-all:hover { color: var(--brand); }

.scroll-row {
  display: flex;
  gap: 1.1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.scroll-card {
  flex: 0 0 220px;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.scroll-card:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.scroll-card-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: #eef1f5; }
.scroll-card-body { padding: 0.8rem 0.9rem 1rem; }
.scroll-card-body h3 { margin: 0 0 0.4rem; font-size: 0.95rem; font-weight: 700; }

.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.3rem; }
h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 1.9rem; font-size: 0.98rem; }

.flash {
  padding: 0.8rem 1.05rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.4rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.flash.error { background: var(--danger-bg); color: var(--danger); border-color: #f4c7c1; }
.flash.success { background: var(--success-bg); color: var(--success); border-color: #b8e6c8; }

/* Grid / cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.card .icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--brand-wash);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 0.2rem;
}
.card .icon { font-size: 1.8rem; }
.card h3 { margin: 0.1rem 0 0; font-size: 1.05rem; font-weight: 700; }
.card p { margin: 0; color: var(--muted); font-size: 0.87rem; }
.card .price { font-weight: 700; color: var(--brand-dark); }

.card-link { display: block; }
.card-link:hover { text-decoration: none; }
.card-link:hover .card { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--brand-wash);
  color: var(--brand-dark);
  border-radius: var(--radius-pill);
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 650;
  width: fit-content;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { background: #fbfbfc; color: var(--muted); font-weight: 650; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfbfc; }

/* Forms */

form.stacked { display: flex; flex-direction: column; gap: 1rem; max-width: 480px; }
label { font-size: 0.83rem; font-weight: 650; color: var(--muted); display: block; margin-bottom: 0.35rem; }
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
textarea { resize: vertical; }

/* Buttons */

.btn {
  display: inline-block;
  background: var(--brand);
  color: white;
  border: none;
  padding: 0.68rem 1.3rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-dark); text-decoration: none; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--card-bg); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.secondary:hover { background: #fafbfc; border-color: #d7dae0; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a5301f; }
.btn.small { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.row { display: flex; gap: 0.6rem; align-items: center; }
.row.between { justify-content: space-between; }

/* Status pills */

.status-pill {
  display: inline-block;
  padding: 0.22rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: capitalize;
}
.status-pending, .status-confirmed { background: var(--warning-bg); color: var(--warning); }
.status-ready, .status-assigned, .status-out_for_delivery { background: #e3edfd; color: var(--brand-dark); }
.status-delivered, .status-completed { background: var(--success-bg); color: var(--success); }
.status-cancelled { background: var(--danger-bg); color: var(--danger); }
.status-open { background: var(--success-bg); color: var(--success); }
.status-closed { background: var(--danger-bg); color: var(--danger); }

/* Cart / totals */

.cart-line { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--border); gap: 0.75rem; }
.cart-line:last-child { border-bottom: none; }
.qty-input { width: 62px; }

.totals {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  background: #fbfbfc;
}
.totals .line { display: flex; justify-content: space-between; margin-bottom: 0.35rem; font-size: 0.94rem; }
.totals .line.total { font-weight: 750; font-size: 1.15rem; }

.empty-state { color: var(--muted); padding: 2.5rem 0; text-align: center; font-size: 0.95rem; }

.section { margin-bottom: 2.25rem; }

.breadcrumb { font-size: 0.83rem; color: var(--muted); margin-bottom: 0.9rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }

/* Images */

.thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #eef1f5;
  display: block;
}
.thumb.small { width: 44px; height: 44px; aspect-ratio: unset; border-radius: 6px; }
.thumb.round { border-radius: 50%; }

.logo-header { display: flex; align-items: center; gap: 1.1rem; }
.logo-header .thumb { width: 68px; height: 68px; aspect-ratio: unset; border-radius: 16px; flex-shrink: 0; }
.logo-header .thumb.round { border-radius: 50%; }

/* Opening hours */

.hours-table { width: 100%; margin-top: 0.4rem; box-shadow: none; border: none; }
.hours-table th, .hours-table td { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.hours-table input[type="time"] { padding: 0.3rem 0.4rem; }
.hours-table input[type="checkbox"] { width: auto; }

.hours-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.hours-list li { display: flex; justify-content: space-between; padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.hours-list li:last-child { border-bottom: none; }
.hours-list .closed { color: var(--muted); }

.hours-details { max-width: 320px; margin-bottom: 1.75rem; }
.hours-details summary {
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.hours-details .hours-list { margin-top: 0.6rem; }

/* Store menu page */

.store-header { margin-bottom: 1.25rem; }
.store-meta { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.4rem; color: var(--muted); font-size: 0.88rem; }

.store-layout { display: flex; align-items: flex-start; gap: 2.5rem; }

.store-menu-sidebar { width: 190px; flex-shrink: 0; position: sticky; top: 85px; }
.menu-hours-today { color: var(--muted); font-size: 0.82rem; margin: 0 0 1rem; }

.menu-anchor-link.active { background: var(--brand-wash); color: var(--brand-dark); }

.store-menu { flex: 1; min-width: 0; }

.menu-section { margin-bottom: 2.5rem; scroll-margin-top: 85px; }
.menu-section h2 { margin-bottom: 0.75rem; }

.menu-item-row {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}
.menu-item-row:last-child { border-bottom: none; }

.menu-item-info { flex: 1; min-width: 0; }
.menu-item-info h3 { margin: 0 0 0.3rem; font-size: 1rem; font-weight: 700; }
.menu-item-info .price { margin: 0 0 0.3rem; font-weight: 650; color: var(--text); }
.menu-item-desc { margin: 0; }

.menu-item-media { position: relative; flex-shrink: 0; }
.menu-item-img {
  width: 130px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #eef1f5;
  display: block;
}
.menu-item-add-btn {
  position: absolute;
  bottom: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-item-add-btn:hover { background: var(--brand); color: white; border-color: var(--brand); }

/* ============ Mobile responsiveness ============ */

@media (max-width: 900px) {
  .app-shell { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    max-width: 80vw;
    height: 100vh;
    padding: 5rem 0.75rem 1.5rem;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 60;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 20, 28, 0.45);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .content { padding: 1.5rem 1.1rem 2.5rem; }

  .store-layout { flex-direction: column; gap: 0; }

  .store-menu-sidebar {
    width: 100%;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
    padding-bottom: 0.6rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .store-menu-sidebar .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 0.4rem;
    scrollbar-width: thin;
  }
  .store-menu-sidebar .sidebar-link { white-space: nowrap; flex: 0 0 auto; }
  .menu-hours-today { display: none; }

  .navbar .sidebar-toggle { display: inline-flex; }
}

@media (min-width: 901px) {
  .navbar .sidebar-toggle { display: none; }
}

@media (max-width: 700px) {
  .navbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
  }
  .navbar-left { width: 100%; min-width: 0; order: 1; }
  .navbar nav {
    width: 100%;
    justify-content: flex-end;
    gap: 1.1rem;
    order: 2;
  }
  .navbar nav.nav-scrollable {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .navbar nav.nav-scrollable::-webkit-scrollbar { display: none; }
  .nav-search {
    width: 100%;
    max-width: none;
    order: 3;
  }
  .navbar .brand { font-size: 1.05rem; }

  .nav-orders-btn, .nav-logout-btn { display: none; }

  .container { padding: 1.5rem 1.1rem 2.5rem; }
  h1 { font-size: 1.5rem; }

  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  form.stacked .row { flex-direction: column; align-items: stretch; }

  .cart-line { flex-wrap: wrap; row-gap: 0.6rem; }
  .cart-line > *:first-child { flex: 1 1 100%; }

  .menu-item-row { flex-direction: column-reverse; gap: 0.75rem; }
  .menu-item-img { width: 100%; height: 170px; }

  .logo-header { flex-wrap: wrap; }
  .logo-header .thumb { width: 56px; height: 56px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.9rem; }

  .scroll-card { flex-basis: 72vw; }

  form.stacked { max-width: 100%; }
}
