/* ==========================================================================
   Admin panel
   ========================================================================== */
:root {
  --espresso: #2b1d16;
  --espresso-2: #3a2a21;
  --brand: #b5562f;
  --brand-dark: #964524;
  --bg: #f5f3f0;
  --panel: #ffffff;
  --line: #e9e4de;
  --muted: #7d726a;
  --sidebar-w: 248px;
}
body { background: var(--bg); font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; color: #2b231e; font-size: .95rem; }
a { color: var(--brand); }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-light { background: #f3f0ec; border-color: #f3f0ec; }
.btn-light:hover { background: #e9e4de; border-color: #e9e4de; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #d39a80; box-shadow: 0 0 0 .2rem rgba(181,86,47,.18); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.page-link { color: var(--brand); }
.active > .page-link { background: var(--brand); border-color: var(--brand); }

.admin-shell { display: flex; min-height: 100vh; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: 17px; flex: 0 0 auto; }
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 26px; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--espresso); color: #e9ded3; display: flex; flex-direction: column; }
@media (min-width: 768px) { .sidebar { position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); } }
@media (max-width: 767.98px) { .sidebar.offcanvas-md { --bs-offcanvas-width: 270px; background: var(--espresso); } }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; color: #fff; font-size: 1.05rem; }
.sidebar-nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav-section { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(233,222,211,.45); margin: 16px 10px 6px; }
.sidebar .nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #e9ded3; text-decoration: none; font-weight: 500; }
.sidebar .nav-link i { font-size: 1.05rem; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; }
.sidebar-foot { padding: 14px 18px; font-size: .78rem; color: rgba(233,222,211,.55); border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot a { color: #f0c8b4; text-decoration: none; font-weight: 700; }

/* Main */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: rgba(245,243,240,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-title { font-size: 1.25rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { font-size: 1.5rem; padding: 2px 6px; }
.btn-user { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #efe2d6; color: var(--brand-dark); display: inline-grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.admin-content { padding: 24px; }
@media (max-width: 575px) { .admin-content { padding: 16px 12px; } .topbar { padding: 10px 12px; } }

.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filter-bar .input-group { max-width: 320px; min-width: 200px; flex: 1; }
.filter-bar .form-select { width: auto; }

.panel { border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03); overflow: hidden; }
.panel > .card-header { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 18px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel .card-footer { background: #fbfaf8; border-top: 1px solid var(--line); }
.table > thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: #fbfaf8; border-bottom-color: var(--line); white-space: nowrap; }
.table td { border-color: #f1ede8; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; }
.thumb-empty { display: inline-grid; place-items: center; background: #f3eee8; color: #b9a797; font-size: 1.1rem; }
.min-w-0 { min-width: 0; }

.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; gap: 14px; align-items: center; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: 0 0 auto; }
.tone-green { background: #e6f2e4; color: #3f7a36; }
.tone-brand { background: #f8e6dd; color: var(--brand); }
.tone-amber { background: #fdf0d5; color: #a26a00; }
.tone-blue { background: #e3edf8; color: #2f63a3; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state > i { font-size: 2.6rem; color: #cdbcad; display: block; margin-bottom: 10px; }

.drag-handle { cursor: grab; }
tr.dragging { opacity: .4; }
tr.drag-over td { border-top: 2px solid var(--brand); }

.diet-tag { display: inline-block; font-size: .62rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; vertical-align: middle; }
.diet-tag.veg { background: #e6efdf; color: #5f7a52; }
.diet-tag.vegan { background: #5f7a52; color: #fff; }
.btn-star { border: 0; background: none; color: #c9b8a8; font-size: 1.1rem; padding: 2px 6px; }
.btn-star.on { color: #e0a100; }

.role-super_admin { background: #2b1d16; color: #fff; }
.role-manager { background: #f8e6dd; color: var(--brand-dark); }
.role-cashier { background: #e3edf8; color: #2f63a3; }
.role-kitchen { background: #e6f2e4; color: #3f7a36; }

/* Product form */
.option-rows { display: flex; flex-direction: column; gap: 8px; }
.option-row { display: grid; grid-template-columns: 1fr 1.3fr 110px 70px 38px; gap: 8px; align-items: center; }
.option-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
@media (max-width: 767.98px) {
  .option-row { grid-template-columns: 1fr 1fr; padding: 10px; background: #faf8f5; border-radius: 10px; }
}
.allergen-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.allergen-chip input { position: absolute; opacity: 0; pointer-events: none; }
.allergen-chip span { display: inline-block; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); cursor: pointer; font-size: .85rem; user-select: none; }
.allergen-chip input:checked + span { background: #fbeee5; border-color: #e8b79f; color: var(--brand-dark); font-weight: 500; }
.allergen-chip input:focus-visible + span { outline: 2px solid var(--brand); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.image-tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: #f3eee8; }
.image-tile.primary { border-color: var(--brand); }
.image-tile img { width: 100%; height: 100%; object-fit: cover; }
.image-actions { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px; }
.primary-badge { position: absolute; left: 6px; top: 6px; background: var(--brand); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 99px; }
.sticky-save { position: sticky; bottom: 16px; }

/* Auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #4a3327 0, var(--espresso) 55%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 36px 32px; box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.auth-title { font-family: 'Fraunces', Georgia, serif; font-size: 1.7rem; margin: 0; }
.auth-card .footer-credit a { font-weight: 700; }
