/* Tajawal — self-hosted so the panel matches the mobile app and needs no CDN */
@font-face {
  font-family: 'Tajawal';
  src: url('/assets/fonts/Tajawal-Regular.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('/assets/fonts/Tajawal-Medium.ttf') format('truetype');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('/assets/fonts/Tajawal-Bold.ttf') format('truetype');
  font-weight: 700; font-display: swap;
}

:root {
  --brand: #166534;
  --brand-dark: #14532d;
  --bg: #f4f7f4;
  --card: #fff;
  --line: #e6ebe6;
  --muted: #6b7280;
  --danger: #dc2626;
  --amber: #b45309;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: #1f2937;
  line-height: 1.65;
  font-size: 15px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  background: linear-gradient(135deg, var(--brand-dark), #15803d);
  color: #fff; padding: 0 24px; height: 62px;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand {
  font-weight: 700; font-size: 17px; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.topbar nav {
  display: flex; gap: 4px; flex: 1;
  overflow-x: auto; scrollbar-width: none;
}
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  color: #d1fae5; text-decoration: none; padding: 7px 14px;
  border-radius: 10px; font-size: 15px; white-space: nowrap;
  transition: background .15s;
}
.topbar nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar nav a.on { background: rgba(255,255,255,.22); color: #fff; font-weight: 500; }

/* the account block must never be clipped off the edge */
.topbar .who {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; white-space: nowrap; flex-shrink: 0;
}
.topbar .who .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.topbar .logout {
  color: #fff; text-decoration: none;
  background: rgba(255,255,255,.16); padding: 5px 12px; border-radius: 9px;
  font-size: 13px;
}
.topbar .logout:hover { background: rgba(255,255,255,.28); }

main { max-width: 1200px; margin: 26px auto 60px; padding: 0 20px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; color: var(--brand-dark); font-weight: 700; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.card h2 {
  font-size: 16px; margin-bottom: 14px; color: var(--brand-dark); font-weight: 700;
}
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.stat .n {
  font-size: 25px; font-weight: 700; color: var(--brand-dark);
  line-height: 1.3; direction: ltr; text-align: right;
}
.stat .l { font-size: 13px; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 12px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  background: #fafbfa; white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: #fafcfa; }
td.num, th.num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.mono { direction: ltr; text-align: left; font-size: 12.5px; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 15px; font-family: inherit; background: #fbfdfb;
  color: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,101,52,.12);
  background: #fff;
}
input[dir=ltr], .mono input { direction: ltr; text-align: left; }

.search { display: flex; gap: 10px; align-items: center; }
.search input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; font-family: inherit;
  background: var(--brand); color: #fff; padding: 11px 20px;
  border-radius: 12px; font-size: 15px; font-weight: 500; text-decoration: none;
  transition: background .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn.sec { background: #fff; color: var(--brand-dark); border: 1px solid var(--line); }
.btn.sec:hover { background: #f3f6f3; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 6px 13px; font-size: 13px; border-radius: 9px; }

/* ---------- bits ---------- */
.pill {
  font-size: 12px; padding: 3px 11px; border-radius: 20px;
  display: inline-block; font-weight: 500; white-space: nowrap;
}
.pill.ok { background: #dcfce7; color: #166534; }
.pill.off { background: #fee2e2; color: #991b1b; }
.pill.warn { background: #fef3c7; color: var(--amber); }
.pill.info { background: #dbeafe; color: #1d4ed8; }

.flash { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.flash.err { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.muted { color: var(--muted); font-size: 13px; }
.right { text-align: left; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-dark), #15803d);
  padding: 20px;
}
.login-box {
  background: #fff; padding: 36px; border-radius: 26px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.login-box h1 { font-size: 24px; text-align: center; color: var(--brand-dark); margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-box .btn { width: 100%; margin-top: 20px; padding: 13px; }
.err { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }

@media (max-width: 820px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .brand span { display: none; }
  .topbar .who .name { display: none; }
  main { padding: 0 12px; }
}

/* ---------- store logo & map ---------- */
.store-cell { display: flex; align-items: center; gap: 10px; }
.logo-sm {
  width: 38px; height: 38px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line); background: #fff; flex-shrink: 0;
}
.logo-sm.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; background: #f3f6f3; color: var(--muted);
}
.logo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.logo-preview {
  width: 82px; height: 82px; border-radius: 14px; object-fit: cover;
  border: 1px solid var(--line); background: #fff;
}
.logo-preview.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; background: #f3f6f3; color: var(--muted);
}
input[type=file] {
  width: 100%; padding: 9px; border: 1px dashed var(--line);
  border-radius: 12px; background: #fbfdfb; font-family: inherit; font-size: 14px;
}
.map-box {
  height: 320px; border-radius: 14px; border: 1px solid var(--line);
  overflow: hidden; margin-top: 4px;
}
.map-search { display: flex; gap: 8px; margin-bottom: 8px; }
.map-search input { flex: 1; }
