/* ============================================================
   SipUp Coffee Admin Panel — STYLESHEET
   Visual identity matches the SipUp Coffee mobile customer app
   (see Flutter Localsip/lib/theme/app_theme.dart):
   primary brown #8B4A1F, dark brown #6B3A16, cream #F2EDE6.
   ============================================================ */

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

:root {
  --brown: #8B4A1F;
  --brown-dark: #6B3A16;
  --brown-darker: #4a280f;
  --brown-tint: #f4e9de;
  --cream: #F2EDE6;
  --cream-soft: #F8F5F0;
  --white: #FFFFFF;
  --text-dark: #2B2B2B;
  --text-grey: #8A8A8A;
  --text-muted: #ADA79D;
  --border: rgba(43, 43, 43, 0.09);
  --border-soft: rgba(43, 43, 43, 0.06);

  --good: #0ca30c;
  --good-tint: #e4f6e2;
  --warning: #b8790f;
  --warning-tint: #fdf0d8;
  --info: #2a78d6;
  --info-tint: #e4eefb;
  --violet: #4a3aa7;
  --violet-tint: #eae7f8;
  --teal: #0d9488;
  --teal-tint: #d4f2ee;
  --critical: #d03b3b;
  --critical-tint: #fbe6e6;
  --gray: #6b7280;
  --gray-tint: #eaecef;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(43,43,43,0.06), 0 1px 1px rgba(43,43,43,0.04);
  --shadow-md: 0 6px 20px rgba(74,40,15,0.08);
  --shadow-lg: 0 16px 40px rgba(74,40,15,0.14);

  --sidebar-w: 264px;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--cream);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; }
p { margin: 0; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------------- App shell ---------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brown-darker);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* Desktop: the menu button collapses the sidebar off-screen to reclaim width. */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

/* ---------------- Sidebar ---------------- */

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brown);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.brand-icon { width: 20px; height: 20px; color: #fff; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.2px; color: #fff; }
.sidebar-close { display: none; background: none; border: none; color: var(--cream); padding: 6px; border-radius: 8px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(242,237,230,0.72);
  font-size: 0.92rem; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-icon { width: 18px; height: 18px; }
.nav-link:hover { background: rgba(242,237,230,0.08); color: #fff; }
.nav-link.active { background: var(--brown); color: #fff; font-weight: 600; box-shadow: var(--shadow-sm); }

.sidebar-foot { margin-top: auto; padding: 14px 12px 18px; border-top: 1px solid rgba(242,237,230,0.1); }
.logout-link { color: rgba(242,237,230,0.6); }
.logout-link:hover { background: rgba(208,59,59,0.18); color: #f3caca; }
.sidebar-tag { margin-top: 10px; padding: 8px 14px; font-size: 0.7rem; color: rgba(242,237,230,0.4); letter-spacing: 0.03em; }

.sidebar-scrim {
  display: none;
  position: fixed; inset: 0; background: rgba(20,10,3,0.45);
  z-index: 55;
}

/* ---------------- Topbar ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  min-width: 0;
  padding: 16px 28px;
  background: rgba(248,245,240,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.menu-toggle { display: flex; }
.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 1.28rem; font-weight: 700; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 0.83rem; color: var(--text-grey); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dark);
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--cream); }
.icon-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--critical); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--cream-soft);
}

.profile-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 999px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brown); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem;
  flex-shrink: 0;
}
.profile-name { font-size: 0.85rem; font-weight: 600; }
.chev { width: 15px; height: 15px; color: var(--text-grey); }

.notif-wrap, .profile-wrap { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 320px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-soft);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all 0.16s ease;
  z-index: 50;
}
.dropdown-panel.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); font-weight: 700; font-size: 0.9rem; }
.dropdown-header a { font-size: 0.78rem; color: var(--brown); font-weight: 600; }

.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--brown-tint); }
.notif-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon .icon { width: 16px; height: 16px; }
.notif-stock { background: var(--warning-tint); color: var(--warning); }
.notif-order-new { background: var(--info-tint); color: var(--info); }
.notif-order-update { background: var(--good-tint); color: var(--good); }
.notif-system { background: var(--brown-tint); color: var(--brown); }
.notif-stock-critical { background: var(--critical-tint); color: var(--critical); }
.notif-stock-low { background: var(--warning-tint); color: var(--warning); }
.notif-stock-out { background: var(--gray-tint); color: var(--gray); }
.notif-restock { background: var(--good-tint); color: var(--good); }
.notif-delivery-update { background: var(--teal-tint); color: var(--teal); }
.notif-delivery-assigned { background: var(--teal-tint); color: var(--teal); }
.notif-delivery-complete { background: var(--good-tint); color: var(--good); }
.notif-title { font-size: 0.82rem; font-weight: 700; }
.notif-message { font-size: 0.78rem; color: var(--text-grey); margin-top: 2px; line-height: 1.4; }
.notif-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.dropdown-user { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.dropdown-user-name { font-weight: 700; font-size: 0.88rem; }
.dropdown-user-role { font-size: 0.75rem; color: var(--text-grey); }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-size: 0.85rem; font-weight: 500; }
.dropdown-item .icon { width: 17px; height: 17px; }
.dropdown-item:hover { background: var(--cream); }
.dropdown-item.danger { color: var(--critical); }
.dropdown-item.danger:hover { background: var(--critical-tint); }

/* ---------------- Content ---------------- */

.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; min-width: 0; margin: 0 auto; }
.section-gap { margin-top: 22px; }

/* ---------------- Cards ---------------- */

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  padding: 20px 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head > div:first-child { min-width: 0; }
.card-title { font-size: 1.02rem; font-weight: 700; }
.card-subtitle { font-size: 0.8rem; color: var(--text-grey); margin-top: 2px; }
.card-link { font-size: 0.82rem; font-weight: 600; color: var(--brown); }
.card-link:hover { text-decoration: underline; }

.grid-2 { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

/* ---------------- Stat cards ---------------- */

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.stat-icon .icon { width: 19px; height: 19px; }
.stat-icon.brown { background: var(--brown-tint); color: var(--brown); }
.stat-icon.good { background: var(--good-tint); color: var(--good); }
.stat-icon.info { background: var(--info-tint); color: var(--info); }
.stat-icon.warning { background: var(--warning-tint); color: var(--warning); }
.stat-icon.critical { background: var(--critical-tint); color: var(--critical); }
.stat-icon.gray { background: var(--gray-tint); color: var(--gray); }
.stat-delta { font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 3px; }
.stat-delta.up { background: var(--good-tint); color: var(--good); }
.stat-delta.down { background: var(--critical-tint); color: var(--critical); }
.stat-delta .icon { width: 12px; height: 12px; }
.stat-label { font-size: 0.8rem; color: var(--text-grey); font-weight: 500; }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---------------- Segmented control (period toggle) ---------------- */

.seg-group { display: inline-flex; max-width: 100%; background: var(--cream-soft); border: 1px solid var(--border-soft); border-radius: 999px; padding: 3px; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.seg-group::-webkit-scrollbar { display: none; }
.seg-btn { border: none; background: none; padding: 7px 15px; border-radius: 999px; font-size: 0.79rem; font-weight: 600; color: var(--text-grey); white-space: nowrap; flex-shrink: 0; transition: all 0.15s ease; }
.seg-btn.active { background: var(--brown); color: #fff; box-shadow: var(--shadow-sm); }
.seg-btn:not(.active):hover { color: var(--text-dark); }

/* ---------------- Buttons ---------------- */

.btn { display: inline-flex; align-items: center; gap: 7px; border-radius: 10px; padding: 10px 16px; font-size: 0.85rem; font-weight: 600; border: 1px solid transparent; transition: all 0.15s ease; white-space: nowrap; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brown); color: #fff; }
.btn-primary:hover { background: var(--brown-dark); }
.btn-secondary { background: var(--white); border-color: var(--border); color: var(--text-dark); }
.btn-secondary:hover { background: var(--cream); }
.btn-ghost { background: transparent; color: var(--brown); }
.btn-ghost:hover { background: var(--brown-tint); }
.btn-sm { padding: 7px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger-ghost { background: var(--critical-tint); color: var(--critical); }
.btn-danger-ghost:hover { background: #f5cccc; }

/* ---------------- Filters row ---------------- */

.filters-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-input { position: relative; flex: 1; min-width: 200px; }
.search-input .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 17px; height: 17px; }
.search-input input { width: 100%; padding: 10px 14px 10px 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--white); font-size: 0.85rem; font-family: inherit; }
.search-input input:focus { outline: 2px solid var(--brown); outline-offset: -1px; }
.select-input, .date-input {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--white); font-size: 0.83rem; font-family: inherit; color: var(--text-dark);
}

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-soft); }
table.table { width: 100%; border-collapse: collapse; min-width: 640px; }
table.table thead th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-grey); background: var(--cream-soft); padding: 12px 16px; font-weight: 700;
  border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
table.table tbody td { padding: 13px 16px; font-size: 0.86rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: var(--cream-soft); }
.cell-strong { font-weight: 700; }
.cell-muted { color: var(--text-grey); font-size: 0.8rem; }
.cell-amount { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------------- Badges ---------------- */

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-pending { background: var(--warning-tint); color: var(--warning); }
.badge-pending .badge-dot { background: var(--warning); }
.badge-preparing { background: var(--info-tint); color: var(--info); }
.badge-preparing .badge-dot { background: var(--info); }
.badge-ready { background: var(--violet-tint); color: var(--violet); }
.badge-ready .badge-dot { background: var(--violet); }
.badge-completed { background: var(--good-tint); color: var(--good); }
.badge-completed .badge-dot { background: var(--good); }
.badge-cancelled { background: var(--critical-tint); color: var(--critical); }
.badge-cancelled .badge-dot { background: var(--critical); }
.badge-delivery { background: var(--teal-tint); color: var(--teal); }
.badge-delivery .badge-dot { background: var(--teal); }
.badge-delivered { background: var(--good-tint); color: var(--good); }
.badge-delivered .badge-dot { background: var(--good); }

/* Inventory stock-status badges (Objective 2) */
.badge-instock { background: var(--good-tint); color: var(--good); }
.badge-instock .badge-dot { background: var(--good); }
.badge-lowstock { background: var(--warning-tint); color: var(--warning); }
.badge-lowstock .badge-dot { background: var(--warning); }
.badge-criticalstock { background: var(--critical-tint); color: var(--critical); }
.badge-criticalstock .badge-dot { background: var(--critical); }
.badge-outstock { background: var(--gray-tint); color: var(--gray); }
.badge-outstock .badge-dot { background: var(--gray); }

/* ---------------- Rank list (top products / sales by product) ---------------- */

.rank-list { display: flex; flex-direction: column; gap: 16px; }
.rank-item { display: flex; align-items: center; gap: 12px; }
.rank-lead { width: 26px; text-align: center; flex-shrink: 0; }
.rank-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--cream-soft); color: var(--text-grey); font-size: 0.75rem; font-weight: 700; }
.rank-num.top { background: var(--brown); color: var(--white); }
.rank-main { flex: 1; min-width: 0; }
.rank-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 0.85rem; }
.rank-name { font-weight: 600; }
.rank-value { color: var(--text-grey); font-variant-numeric: tabular-nums; font-weight: 600; }
.rank-track { height: 8px; background: var(--cream-soft); border-radius: 999px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }

/* ---------------- Charts ---------------- */

.chart-box { position: relative; width: 100%; }
.chart-box.h-260 { height: 260px; }
.chart-box.h-320 { height: 320px; }
.chart-box.h-180 { height: 180px; }

/* ---------------- KPI rows ---------------- */

.kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kpi-tile { padding: 16px 18px; border-radius: var(--radius-md); background: var(--cream-soft); border: 1px solid var(--border-soft); }
.kpi-label { font-size: 0.78rem; color: var(--text-grey); font-weight: 600; }
.kpi-value { font-size: 1.35rem; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------------- Report cards ---------------- */

.report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.report-card { display: flex; flex-direction: column; gap: 16px; }
.report-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--brown-tint); color: var(--brown); display: flex; align-items: center; justify-content: center; }
.report-rows { display: flex; flex-direction: column; gap: 10px; }
.report-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 0.85rem; }
.report-row:last-child { border-bottom: none; }
.report-row span:first-child { color: var(--text-grey); }
.report-row span:last-child { font-weight: 700; }
.report-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

/* ---------------- Prep banner (Objective 2 placeholder) ---------------- */

.prep-banner { display: flex; align-items: center; gap: 14px; background: var(--warning-tint); border: 1px solid #f0d9a6; border-radius: var(--radius-md); padding: 16px 18px; }
.prep-banner .icon { color: var(--warning); width: 22px; height: 22px; }
.prep-banner-title { font-weight: 700; font-size: 0.9rem; }
.prep-banner-text { font-size: 0.82rem; color: var(--text-grey); margin-top: 2px; }
.prep-pill { margin-left: auto; background: var(--white); border: 1px solid var(--border); padding: 6px 13px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; color: var(--brown); flex-shrink: 0; }

/* ---------------- Product grid ---------------- */

.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.product-card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--border-soft); box-shadow: var(--shadow-sm); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.product-thumb { width: 52px; height: 52px; border-radius: 14px; background: var(--cream-soft); color: var(--brown); display: flex; align-items: center; justify-content: center; }
.product-thumb .icon { width: 24px; height: 24px; }
.product-thumb-lg { width: 76px; height: 76px; border-radius: 20px; background: var(--cream-soft); color: var(--brown); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.product-thumb-lg .icon { width: 34px; height: 34px; }
.product-name { font-weight: 700; font-size: 0.92rem; }
.product-cat { font-size: 0.76rem; color: var(--text-grey); }
.product-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.product-price { font-weight: 800; font-size: 1rem; }

/* ---------------- Promotions ---------------- */

.app-banner-preview {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #1c3c2b, #12281c);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  color: #fff;
}
.app-banner-icon { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,0.14); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-banner-icon .icon { width: 22px; height: 22px; }
.app-banner-body { min-width: 0; }
.app-banner-tag { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #e8b84b; }
.app-banner-tag .icon { width: 13px; height: 13px; }
.app-banner-title { font-size: 1.05rem; font-weight: 800; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-banner-sub { font-size: 0.8rem; color: rgba(255,255,255,0.65); margin-top: 2px; }
.app-banner-cta { margin-left: auto; background: #e8b84b; color: #2b1a02; font-weight: 700; padding: 10px 18px; border-radius: 10px; font-size: 0.82rem; white-space: nowrap; flex-shrink: 0; }
.app-banner-empty { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-radius: var(--radius-lg); background: var(--cream-soft); border: 1px dashed var(--border); color: var(--text-grey); font-size: 0.86rem; }

.promo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.promo-card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--border-soft); box-shadow: var(--shadow-sm); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.promo-card.is-featured { border-color: var(--brown); box-shadow: 0 0 0 2px var(--brown-tint); }
.promo-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.promo-discount-pill { display: inline-flex; align-items: baseline; gap: 2px; background: var(--brown-tint); color: var(--brown); font-weight: 800; font-size: 1.15rem; padding: 8px 13px; border-radius: 12px; flex-shrink: 0; }
.promo-discount-pill span { font-size: 0.68rem; font-weight: 700; }
.promo-name { font-weight: 700; font-size: 0.95rem; }
.promo-product { font-size: 0.8rem; color: var(--text-grey); margin-top: 2px; }
.promo-meta-row { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-grey); }
.promo-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-featured { background: var(--brown-tint); color: var(--brown); }
.badge-featured .badge-dot { background: var(--brown); }
.badge-inactive { background: var(--gray-tint); color: var(--gray); }
.badge-inactive .badge-dot { background: var(--gray); }
.promo-foot { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.promo-foot .btn { flex: 1; justify-content: center; }

/* ---------------- Inventory: stock progress bar ---------------- */

.stock-bar-track { position: relative; height: 10px; background: var(--cream-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--border-soft); }
.stock-bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.stock-bar-fill.good { background: var(--good); }
.stock-bar-fill.low { background: var(--warning); }
.stock-bar-fill.critical { background: var(--critical); }
.stock-bar-fill.out { background: var(--gray); }
.stock-bar-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--brown-darker); opacity: 0.55; }
.stock-bar-legend { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--text-grey); margin-top: 6px; }

/* ---------------- Inventory: alert cards ---------------- */

.alert-card { display: flex; flex-direction: column; gap: 10px; border-radius: var(--radius-md); padding: 16px 18px; border: 1px solid; }
.alert-card.critical { background: var(--critical-tint); border-color: #f0c3c3; }
.alert-card.low { background: var(--warning-tint); border-color: #f0d9a6; }
.alert-card-head { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.alert-card.critical .alert-card-head { color: var(--critical); }
.alert-card.low .alert-card-head { color: var(--warning); }
.alert-card-head .icon { width: 15px; height: 15px; }
.alert-card-name { font-size: 1rem; font-weight: 700; }
.alert-card-sub { font-size: 0.82rem; color: var(--text-grey); }
.alert-card-sub strong { color: var(--text-dark); }

/* ---------------- Inventory: quantity stepper ---------------- */

.qty-stepper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qty-stepper input { width: 72px; flex-shrink: 0; text-align: center; padding: 8px 6px; border-radius: 9px; border: 1px solid var(--border); font-family: inherit; font-weight: 700; font-size: 0.9rem; }

/* ---------------- Toggle switch (product availability) ---------------- */

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: #b9bdc4; border: 1px solid #a3a8b0; border-radius: 999px; transition: background 0.15s ease; cursor: pointer; }
.switch-track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 50%; transform: translateY(-50%); background: var(--white); border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.15s ease; }
.switch input:checked + .switch-track { background: var(--good); border-color: var(--good); }
.switch input:checked + .switch-track::before { transform: translateY(-50%) translateX(18px); }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brown); outline-offset: 2px; }
.switch-labeled { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex-shrink: 0; }
.switch-state { font-size: 0.8rem; font-weight: 700; color: var(--text-grey); min-width: 22px; text-align: right; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.status-dot.on { background: var(--good); }
.status-dot.off { background: var(--critical); }
.icon-inline { width: 12px; height: 12px; vertical-align: -1px; }

/* ---------------- Modal ---------------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,13,4,0.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity 0.2s ease; z-index: 100;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-panel {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  transform: translateY(14px); transition: transform 0.2s ease;
}
.modal-overlay.show .modal-panel { transform: translateY(0); }
.modal-wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--white); z-index: 2; }
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: var(--cream-soft); border: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 22px 24px; }
body.modal-open { overflow: hidden; }

.od-section { margin-bottom: 20px; }
.od-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-grey); font-weight: 700; margin-bottom: 10px; }
.od-customer { display: flex; align-items: center; gap: 12px; }
.od-customer-name { font-weight: 700; }
.od-customer-meta { font-size: 0.8rem; color: var(--text-grey); }
.od-items { display: flex; flex-direction: column; gap: 10px; }
.od-item { display: flex; justify-content: space-between; font-size: 0.86rem; }
.od-item-name { font-weight: 600; }
.od-item-qty { color: var(--text-grey); font-size: 0.78rem; }
.od-totals { border-top: 1px dashed var(--border); margin-top: 14px; padding-top: 12px; display: flex; flex-direction: column; gap: 7px; font-size: 0.86rem; }
.od-totals .grand { font-size: 1rem; font-weight: 800; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.od-badges { display: flex; gap: 8px; flex-wrap: wrap; }

.timeline { display: flex; flex-direction: column; }
.timeline-step { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before {
  content: ""; position: absolute; left: 8px; top: 20px; bottom: 0; width: 2px; background: var(--border);
}
.timeline-step:last-child::before { display: none; }
.timeline-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); background: var(--white); flex-shrink: 0; z-index: 1; }
.timeline-step.done .timeline-dot { background: var(--brown); border-color: var(--brown); }
.timeline-step.cancelled .timeline-dot { background: var(--critical); border-color: var(--critical); }
.timeline-step.cancelled .timeline-label { color: var(--critical); }
.timeline-label { font-weight: 600; font-size: 0.85rem; }
.timeline-step:not(.done) .timeline-label { color: var(--text-grey); }
.timeline-time { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }

/* ---------------- Toast ---------------- */

.toast-host { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--brown-darker); color: var(--cream);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 0.83rem; font-weight: 600;
  opacity: 0; transform: translateY(8px); transition: all 0.22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { width: 17px; height: 17px; color: #b7e6b0; }

/* ---------------- Login page ---------------- */

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #a8623a 0%, var(--brown-darker) 55%, #2a1608 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--white); border-radius: 22px;
  box-shadow: var(--shadow-lg); padding: 36px 32px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; text-align: center; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 15px; }
.login-brand .brand-icon { width: 26px; height: 26px; }
.login-brand h1 { font-family: var(--font-display); font-size: 1.5rem; color: var(--brown-darker); }
.login-brand p { font-size: 0.82rem; color: var(--text-grey); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; color: var(--text-dark); }
.field input, .field select { width: 100%; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--border); font-size: 0.88rem; font-family: inherit; background: var(--cream-soft); }
.field input:focus { outline: 2px solid var(--brown); outline-offset: -1px; background: #fff; }
.login-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; margin-bottom: 20px; }
.login-row label { display: flex; align-items: center; gap: 6px; color: var(--text-grey); }
.login-row a { color: var(--brown); font-weight: 600; }
.login-demo { margin-top: 18px; padding: 12px 14px; background: var(--cream-soft); border-radius: 11px; font-size: 0.76rem; color: var(--text-grey); text-align: center; line-height: 1.5; }
.login-foot { text-align: center; margin-top: 18px; font-size: 0.76rem; color: var(--text-muted); }

/* ---------------- Empty / misc ---------------- */

.mock-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.68rem; font-weight: 700; color: var(--text-muted); background: var(--cream-soft); border: 1px dashed var(--border); padding: 4px 10px; border-radius: 999px; }
.divider { height: 1px; background: var(--border-soft); margin: 20px 0; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .promo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .sidebar-close { display: flex; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .kpi-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}

@media (max-width: 760px) {
  .content { padding: 18px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .topbar-title p { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .promo-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .app-banner-preview { flex-wrap: wrap; }
  .app-banner-cta { margin-left: 0; width: 100%; text-align: center; }
  .dropdown-panel { width: 92vw; right: -8px; }
  .kpi-row { grid-template-columns: 1fr; }

  table.table thead { display: none; }
  table.table, table.table tbody, table.table tr, table.table td { display: block; width: 100%; }
  table.table { min-width: 0; }
  table.table tr { border: 1px solid var(--border-soft); border-radius: var(--radius-md); margin-bottom: 12px; padding: 6px 4px; background: var(--white); }
  table.table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px dashed var(--border-soft); padding: 10px 12px; text-align: right; }
  table.table td:last-child { border-bottom: none; }
  table.table td::before { content: attr(data-label); font-size: 0.72rem; font-weight: 700; color: var(--text-grey); text-transform: uppercase; letter-spacing: 0.03em; text-align: left; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .product-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .seg-group { flex-wrap: wrap; }
  .login-card { padding: 28px 22px; }
}

/* ============================================================
   Deliveries page — 4-up metric row + rider roster
   ============================================================ */

.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }

.rider-row { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.rider-row:first-child { padding-top: 4px; }
.rider-row:last-child { border-bottom: none; padding-bottom: 0; }
.rider-avatar { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: var(--brown-tint); color: var(--brown); font-weight: 700; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; }
.rider-info { min-width: 0; }
.rider-name { font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; gap: 7px; }
.rider-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.rider-dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-tint); }
.rider-dot.off { background: var(--gray); }
.rider-meta { font-size: 0.78rem; color: var(--text-grey); margin-top: 3px; }
.rider-job { font-size: 0.78rem; color: var(--brown); font-weight: 600; margin-top: 5px; }

/* Three form fields side by side (password change), stacked on phones */
.grid-3-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 720px) { .grid-3-fields { grid-template-columns: 1fr; } }

/* Rider roster actions (Deliveries page) */
.rider-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rider-row .rider-info { flex: 1; }

/* Countdown under a Pending order (it auto-cancels if not accepted in time) */
.accept-timer { margin-top: 5px; font-size: 0.74rem; font-weight: 700; color: var(--warning); white-space: nowrap; }
.accept-timer.late { color: var(--critical); }

/* Live delivery map (Google Maps, deliveries.html) */
.live-map { height: 380px; border-radius: var(--radius-md); overflow: hidden; background: var(--cream-soft); }
.live-map-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; color: var(--text-grey); font-size: 0.86rem; line-height: 1.5; }
.live-map-empty strong { color: var(--text-dark); }
.live-map-empty code { background: var(--brown-tint); color: var(--brown-dark); padding: 1px 6px; border-radius: 6px; font-size: 0.8rem; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--text-grey); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-pin { display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,0.3); border: 2px solid #fff; }
.map-pin.shop { width: 30px; height: 30px; background: var(--brown); }
.map-pin.shop .icon { width: 16px; height: 16px; }
.map-pin.rider { width: 30px; height: 30px; background: var(--teal); font-size: 0.68rem; }
.map-pin.rider.stale { background: var(--gray); }
.map-pin.dropoff { width: 14px; height: 14px; background: var(--critical); }
@media (max-width: 720px) { .live-map { height: 300px; } }

@media (max-width: 1100px) { .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .metric-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }

/* ============================================================
   Print — reports should come out clean, no chrome
   ============================================================ */

@media print {
  .sidebar, .topbar, .sidebar-scrim, .toast-host, .modal-overlay,
  .report-actions, .filters-row, .seg-group, .btn, .icon-btn,
  .menu-toggle, .card-link { display: none !important; }
  body { background: #fff; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd; break-inside: avoid; }
  .stat-grid, .metric-row { display: grid !important; }
  a[href]::after { content: ""; }
}
