/* ═══════════════════════════════════════════════════════════════════════════
   SHWAPNO ZONE SALES DASHBOARD — "AURA" LIGHT PREMIUM THEME
   ---------------------------------------------------------------------------
   Every id/class used by index.html, admin.php and common.js is preserved
   exactly (only the look changes).
   ═══════════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --purple-dark: #4a1f6e;
  --purple-mid:  #7b3fbf;
  --purple-light:#b07ee0;
  --purple-pale: #ece5fb;
  --green:       #16a34a;
  --green-light: #dcfce7;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  --amber:       #d97706;
  --amber-light: #fef3c7;
  --blue-dark:   #1e3a5f;
  --card-bg:     #ffffff;
  --page-bg:     #f4f3fb;
  --text-dark:   #201c33;
  --text-mute:   #8a84a0;

  --accent-a: #7c5cff;   /* purple  */
  --accent-b: #ec4899;   /* pink    */
  --accent-c: #3b82f6;   /* blue    */
  --accent-d: #f5b800;   /* gold    */

  --glass:        rgba(255,255,255,.86);
  --glass-strong: rgba(255,255,255,.96);
  --glass-border: rgba(124,92,255,.12);
  --shadow:       0 6px 24px rgba(76,55,140,.08);
  --shadow-lg:    0 20px 44px rgba(76,55,140,.14);
  --shadow-glow:  0 10px 26px rgba(124,92,255,.35);
  --ease:         cubic-bezier(.2,.8,.2,1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
  color: var(--text-dark);
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f8f7fd 0%, #f1eefb 55%, #f6f4fc 100%);
}
* { -webkit-tap-highlight-color: transparent; }

/* ── SOFT DECORATIVE BLOBS (very light, sit behind everything) ── */
body::before, body::after {
  content: ""; position: fixed; border-radius: 50%;
  filter: blur(90px); z-index: 0; pointer-events: none; opacity: .5;
}
body::before {
  width: 460px; height: 460px; top: -140px; left: -120px;
  background: radial-gradient(circle, rgba(124,92,255,.35), transparent 70%);
  animation: floatBlobA 24s ease-in-out infinite;
}
body::after {
  width: 420px; height: 420px; bottom: -140px; right: -100px;
  background: radial-gradient(circle, rgba(245,184,0,.28), transparent 70%);
  animation: floatBlobB 28s ease-in-out infinite;
}
@keyframes floatBlobA { 0%,100%{ transform: translate(0,0) scale(1);} 50%{ transform: translate(40px,30px) scale(1.08);} }
@keyframes floatBlobB { 0%,100%{ transform: translate(0,0) scale(1);} 50%{ transform: translate(-30px,-30px) scale(1.1);} }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,92,255,.35); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,92,255,.55); }

/* ── HEADER (light glass, sticky) ── */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid rgba(124,92,255,.12);
  color: var(--text-dark);
  padding: 16px 24px 14px;
  padding-top: max(16px, env(safe-area-inset-top, 16px));
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  box-shadow: 0 4px 20px rgba(76,55,140,.06);
}
header h1 {
  font-size: 1.32rem; font-weight: 800; letter-spacing: .2px;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
header p  { font-size: .8rem; color: var(--text-mute); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── HEADER SEARCH (icon button + collapsible panel) ── */
.icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 50%; border: 1px solid rgba(124,92,255,.2);
  background: #faf9ff; color: var(--purple-dark); font-size: 1.05rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s var(--ease);
}
.icon-btn:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(76,55,140,.14); }
.icon-btn[aria-expanded="true"] {
  background: linear-gradient(135deg, var(--accent-a), var(--purple-mid)); color: #fff;
  border-color: transparent; box-shadow: var(--shadow-glow);
}
.header-search-panel {
  flex-basis: 100%; order: 3;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .3s var(--ease), opacity .22s var(--ease), margin-top .3s var(--ease);
}
header.search-open .header-search-panel { max-height: 76px; opacity: 1; margin-top: 12px; }
.header-search-panel .search-wrapper { width: 100%; }
.header-search-panel #storeSearch { width: 100%; min-width: 0; }

/* ── DASHBOARD / ADMIN WRAPPERS ── */
#dashboard, #adminWrap { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 16px 16px 40px; }

/* ── ZONE SELECTOR ── */
.zone-bar {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 14px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  animation: fadeInUp .5s var(--ease);
}
.zone-bar label { font-weight: 700; color: var(--purple-dark); font-size: .92rem; white-space: nowrap; }
.area-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zone-btn {
  padding: 9px 20px; border-radius: 30px; border: 1px solid rgba(124,92,255,.2);
  background: #faf9ff; color: var(--purple-dark); font-weight: 600; font-size: .88rem;
  cursor: pointer; transition: all .25s var(--ease);
}
.zone-btn:hover    { background: #fff; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(76,55,140,.14); }
.zone-btn.active   {
  background: linear-gradient(135deg, var(--accent-a), var(--purple-mid)); color: #fff;
  border-color: transparent; box-shadow: var(--shadow-glow);
}
#storeSearch {
  padding: 9px 18px;
  border: 1px solid rgba(124,92,255,.2); border-radius: 30px;
  background: #faf9ff;
  font-size: .88rem; color: var(--text-dark); outline: none; min-width: 220px;
  transition: all .2s var(--ease);
}
#storeSearch:focus { border-color: var(--accent-a); background: #fff; box-shadow: 0 0 0 4px rgba(124,92,255,.12); }

/* ── STORE DROPDOWN ── */
#storeDropdown {
  position: absolute;
  background: var(--glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border); border-radius: 16px; box-shadow: var(--shadow-lg);
  max-height: 260px; overflow-y: auto; z-index: 999;
  min-width: 280px; display: none;
}
.store-opt { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid rgba(124,92,255,.08); font-size: .88rem; transition: background .15s; }
.store-opt:hover { background: var(--purple-pale); }
.store-opt .code { font-weight: 700; color: var(--purple-dark); margin-right: 6px; }
.store-opt .zone-tag { float: right; font-size: .72rem; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.zone-tag.Kurigram   { background: #dbeafe; color: #1d4ed8; }
.zone-tag.Lalmonirhat{ background: #fce7f3; color: #9d174d; }
.zone-tag.Rangpur    { background: #d1fae5; color: #065f46; }

/* ── BANNER ── */
#viewingBanner {
  background: linear-gradient(90deg, var(--accent-a), var(--purple-mid));
  color: #fff; border-radius: 16px; padding: 11px 20px;
  font-weight: 700; font-size: .95rem; margin-bottom: 22px;
  letter-spacing: .2px; box-shadow: var(--shadow-glow);
}

/* ── EXPORT BAR ── */
.export-bar {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 14px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  animation: fadeInUp .5s var(--ease) both;
}
.export-info { flex: 1 1 280px; min-width: 0; }
.export-title { font-weight: 800; color: var(--purple-dark); font-size: .92rem; }
.export-hint  { font-size: .78rem; color: var(--text-mute); margin-top: 3px; line-height: 1.45; overflow-wrap: anywhere; }
.export-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#exportPeriod {
  padding: 9px 16px; border-radius: 30px; border: 1px solid rgba(124,92,255,.2);
  background: #faf9ff; color: var(--purple-dark); font-family: inherit; font-size: .86rem; font-weight: 700;
  cursor: pointer; outline: none; transition: all .2s var(--ease);
}
#exportPeriod:focus { border-color: var(--accent-a); background: #fff; box-shadow: 0 0 0 4px rgba(124,92,255,.12); }
#exportBtn:disabled, #exportPdfBtn:disabled { opacity: .65; cursor: progress; transform: none; }

/* ── KPI CARDS (icon chip top-left, trend badge top-right) ── */
.kpi-section { margin-bottom: 22px; }
.kpi-section h3 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--purple-mid); font-weight: 800; margin-bottom: 10px;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px; padding: 66px 16px 16px;
  box-shadow: var(--shadow);
  text-align: left; position: relative; overflow: hidden;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
  animation: fadeInUp .5s var(--ease) both;
}
.kpi-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.kpi-card::before {
  content: ""; position: absolute; top: 16px; left: 16px; width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-a), var(--purple-mid));
  box-shadow: 0 8px 18px rgba(124,92,255,.35);
}
.kpi-card.green-top::before { background: linear-gradient(135deg, #34d399, var(--green)); box-shadow: 0 8px 18px rgba(22,163,74,.32); }
.kpi-card.green-top:hover   { box-shadow: 0 16px 40px rgba(22,163,74,.2); }
.kpi-card.red-top::before   { background: linear-gradient(135deg, #fb7185, var(--red)); box-shadow: 0 8px 18px rgba(220,38,38,.3); }
.kpi-card.red-top:hover     { box-shadow: 0 16px 40px rgba(220,38,38,.18); }
.kpi-card.amber-top::before { background: linear-gradient(135deg, #fbbf24, var(--amber)); box-shadow: 0 8px 18px rgba(217,119,6,.3); }
.kpi-card.amber-top:hover   { box-shadow: 0 16px 40px rgba(217,119,6,.18); }
/* ── KPI ICONS ──
   White glyph drawn over the coloured chip (.kpi-card::before).
   Default icon follows the card colour; add an .ic-* class to a card to override. */
.kpi-card {
  --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 20v-8M12 20V5M18 20v-11'/%3E%3C/svg%3E");
  --kpi-icon-size: 20px;
}
.kpi-card.green-top { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 7 13.5 15.5 8.5 10.5 2 17'/%3E%3Cpolyline points='16 7 22 7 22 13'/%3E%3C/svg%3E"); }
.kpi-card.red-top   { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 17 13.5 8.5 8.5 13.5 2 7'/%3E%3Cpolyline points='16 17 22 17 22 11'/%3E%3C/svg%3E"); }
.kpi-card.amber-top { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpolyline points='12 7 12 12 15.5 14'/%3E%3C/svg%3E"); }
.kpi-card.ic-target   { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3C/svg%3E"); }
.kpi-card.ic-store    { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9 5.5 4h13L20 9'/%3E%3Cpath d='M5 9v11h14V9'/%3E%3Cpath d='M4 9h16'/%3E%3Cpath d='M10 20v-6h4v6'/%3E%3C/svg%3E"); }
.kpi-card.ic-cart     { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.4'/%3E%3Ccircle cx='18' cy='20' r='1.4'/%3E%3Cpath d='M2 3h3l2.6 12.4a1 1 0 0 0 1 .8h9.1a1 1 0 0 0 1-.8L20.5 8H6'/%3E%3C/svg%3E"); }
.kpi-card.ic-money    { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='6' width='20' height='12' rx='2'/%3E%3Ccircle cx='12' cy='12' r='2.5'/%3E%3Cpath d='M6 12h.01M18 12h.01'/%3E%3C/svg%3E"); }
.kpi-card.ic-calendar { --kpi-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E"); }
.kpi-card::after {
  content: ""; position: absolute; top: 16px; left: 16px; width: 38px; height: 38px;
  background: #fff; pointer-events: none;
  -webkit-mask: var(--kpi-icon) center / var(--kpi-icon-size) var(--kpi-icon-size) no-repeat;
          mask: var(--kpi-icon) center / var(--kpi-icon-size) var(--kpi-icon-size) no-repeat;
}
.kpi-label { font-size: .73rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; font-weight: 700; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--text-dark); line-height: 1.15; }
.kpi-value.big { font-size: 1.22rem; }
.kpi-badge {
  position: absolute; top: 24px; right: 16px;      /* centred on the 38px chip */
  height: 22px; display: inline-flex; align-items: center;
  padding: 0 10px; border-radius: 20px; font-size: .72rem; font-weight: 800; line-height: 1;
}
.kpi-note { font-size: .67rem; color: var(--text-mute); margin-top: 6px; }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-amber  { background: var(--amber-light);  color: var(--amber); }
.badge-purple { background: var(--purple-pale);  color: var(--purple-dark); }

/* ── SECTION ROW ── */
.section-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
@media(max-width: 900px) { .section-row { grid-template-columns: 1fr; } }

/* ── PANEL ── */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 22px; padding: 20px; box-shadow: var(--shadow);
  transition: box-shadow .3s var(--ease);
  animation: fadeInUp .55s var(--ease) both;
  min-width: 0;   /* grid item fix — see note above; without this the outlet
                     table can never be swiped, it just gets clipped */
}
.panel:hover { box-shadow: var(--shadow-lg); }
.panel h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .8px;
  color: var(--purple-mid); font-weight: 800; margin-bottom: 14px;
  border-bottom: 2px solid var(--purple-pale); padding-bottom: 8px;
}

/* ── ZONE REPORT (COPYABLE) ── */
.report-panel {
  background: linear-gradient(135deg, var(--accent-a), var(--purple-dark));
  border-radius: 22px; padding: 22px; margin-bottom: 22px; box-shadow: var(--shadow-glow);
  color: #fff;
  animation: fadeInUp .55s var(--ease) both;
}
.report-panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.report-panel h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .8px; font-weight: 800; opacity: .92; }
.copyBtn {
  background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4);
  padding: 7px 16px; border-radius: 20px; font-size: .82rem; font-weight: 700;
  cursor: pointer; transition: all .2s var(--ease);
}
.copyBtn:hover { background: rgba(255,255,255,.32); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,.15); }
.copyBtn:active { transform: translateY(0) scale(.97); }
#reportText, #areaReportText {
  background: rgba(255,255,255,.14); border-radius: 16px; padding: 18px 20px;
  font-family: 'Consolas', 'Courier New', monospace; font-size: .92rem;
  line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  border: 1px solid rgba(255,255,255,.12);
}

/* ── STAT TABLE ── */
.stat-table { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 880px; }
.stat-table th {
  background: var(--purple-pale); color: var(--purple-dark);
  padding: 10px 12px; text-align: left; font-size: .74rem; letter-spacing: .4px;
  text-transform: uppercase; font-weight: 800; white-space: nowrap;
}
.stat-table th:first-child { border-radius: 12px 0 0 12px; }
.stat-table th:last-child  { border-radius: 0 12px 12px 0; }
.stat-table td { padding: 10px 12px; border-bottom: 1px solid #f1eefb; }
.stat-table tr { transition: background .2s; }
.stat-table tr:hover td { background: #faf8ff; }
.stat-table tr.outlet-row { cursor: pointer; }
.stat-table tr:last-child td { border-bottom: none; }
.ach-pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-weight: 700; font-size: .76rem; }
.ach-green  { background: var(--green-light); color: var(--green); }
.ach-amber  { background: var(--amber-light); color: var(--amber); }
.ach-red    { background: var(--red-light);   color: var(--red);   }

/* ── CHART WRAPPER ── */
.chart-wrap {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 22px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 22px;
  transition: box-shadow .3s var(--ease);
  animation: fadeInUp .55s var(--ease) both;
}
.chart-wrap:hover { box-shadow: var(--shadow-lg); }
.chart-wrap h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .8px;
  color: var(--purple-mid); font-weight: 800; margin-bottom: 14px;
  border-bottom: 2px solid var(--purple-pale); padding-bottom: 8px;
}
canvas { max-height: 320px; }

/* ── LEADERBOARD (activity-feed style rows) ── */
.leader-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 14px; margin-bottom: 8px;
  background: #faf9ff; border: 1px solid rgba(124,92,255,.08);
  transition: all .2s var(--ease);
  cursor: pointer;
}
.leader-item:hover { background: var(--purple-pale); transform: translateX(4px); }
.leader-rank { font-size: 1.2rem; width: 26px; text-align: center; }
.leader-info { flex: 1; }
.leader-code { font-weight: 700; color: var(--purple-dark); font-size: .88rem; }
.leader-name { font-size: .76rem; color: var(--text-mute); }
.leader-pct  { font-size: 1rem; font-weight: 800; min-width: 54px; text-align: right; }

/* ── DAILY TABLE ── */
.day-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.day-table { width: 100%; border-collapse: collapse; font-size: .83rem; min-width: 600px; }
.day-table th {
  background: var(--purple-pale); color: var(--purple-dark);
  padding: 9px 12px; text-align: center; font-size: .73rem; letter-spacing: .4px;
  text-transform: uppercase; font-weight: 800;
  position: sticky; top: 0; z-index: 1;
}
.day-table td { padding: 8px 12px; border-bottom: 1px solid #f1eefb; text-align: center; }
.day-table tr { transition: background .2s; }
.day-table tr:hover td { background: #faf8ff; }
.day-table .today-row td { background: var(--purple-pale) !important; font-weight: 700; border-left: 3px solid var(--accent-a); }
.day-table .future-row td { color: #c3bdd6; }

/* ── RRR BOX ── */
.rrr-box {
  background: linear-gradient(135deg, var(--accent-c), var(--blue-dark));
  color: #fff; border-radius: 22px; padding: 20px; margin-bottom: 22px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px;
  box-shadow: 0 14px 34px rgba(59,130,246,.28);
  animation: fadeInUp .55s var(--ease) both;
}
.rrr-item { text-align: center; }
.rrr-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; opacity: .85; }
.rrr-value { font-size: 1.6rem; font-weight: 800; margin-top: 4px; }
.rrr-sub   { font-size: .78rem; opacity: .8; margin-top: 2px; }

/* ── FOOTER ── */
footer {
  text-align: center; padding: 20px; padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  color: var(--text-mute); font-size: .78rem; position: relative; z-index: 1;
}

/* ── SPINNER ── */
#loadingMsg {
  display: none; text-align: center; padding: 40px;
  color: var(--purple-mid); font-size: 1.1rem; font-weight: 700;
  position: relative; z-index: 1;
}
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--purple-pale);
  border-top-color: var(--accent-a); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.search-wrapper { position: relative; }

/* ── TWO-FILE UPLOAD MODEL ── */
.upload-wrap { max-width: 1000px; margin: 28px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 0 16px; position: relative; z-index: 1; }
@media(max-width: 820px){ .upload-wrap { grid-template-columns: 1fr; } }
.drop-card {
  background: var(--card-bg);
  border: 2px dashed rgba(124,92,255,.3);
  border-radius: 22px; padding: 26px 20px; text-align: center; cursor: pointer;
  transition: all .3s var(--ease); box-shadow: var(--shadow);
}
.drop-card:hover { border-color: var(--accent-a); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.drop-card.ready { border-style: solid; border-color: var(--green); background: #f2fdf6; box-shadow: 0 14px 34px rgba(22,163,74,.16); }
.drop-card .ic { font-size: 2.6rem; filter: drop-shadow(0 4px 10px rgba(124,92,255,.25)); }
.drop-card h2 { color: var(--purple-dark); font-size: 1.05rem; margin: 6px 0 4px; }
.drop-card p { color: var(--text-mute); font-size: .82rem; margin-bottom: 14px; }
.drop-card .status { font-size: .8rem; font-weight: 700; margin-top: 10px; display: block; color: var(--purple-dark); }
.drop-card input[type=file] { display: none; }
.mini-btn {
  display: inline-block; padding: 9px 20px;
  background: linear-gradient(135deg, var(--accent-a), var(--purple-mid)); color: #fff;
  border-radius: 24px; font-size: .88rem; font-weight: 700; border: none; cursor: pointer;
  transition: all .25s var(--ease); box-shadow: 0 8px 18px rgba(124,92,255,.32);
}
.mini-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(124,92,255,.42); }
.mini-btn:active { transform: translateY(0) scale(.97); }
.mini-btn.pdf-btn {
  background: linear-gradient(135deg, #f87171, var(--red)); box-shadow: 0 8px 18px rgba(220,38,38,.28);
}
.mini-btn.pdf-btn:hover { box-shadow: 0 12px 26px rgba(220,38,38,.38); }
.status-bar { max-width: 1000px; margin: 14px auto 0; padding: 0 16px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; position: relative; z-index: 1; }
.chip {
  background: #fff; border: 1px solid var(--glass-border); border-radius: 20px;
  padding: 6px 14px; font-size: .8rem; font-weight: 700; color: var(--purple-dark);
  box-shadow: var(--shadow); transition: transform .2s var(--ease);
}
.chip:hover { transform: translateY(-2px); }
.chip.warn { background: var(--amber-light); border-color: var(--amber); color: var(--amber); }
.chip.ok   { background: var(--green-light); border-color: var(--green); color: var(--green); }
.day-picker { display: flex; align-items: center; gap: 8px; }
.day-picker select {
  padding: 8px 12px; border-radius: 20px; border: 1px solid rgba(124,92,255,.25);
  font-size: .86rem; font-family: inherit; background: #faf9ff; color: var(--purple-dark); font-weight: 700;
}
.saved-list { display: flex; flex-wrap: wrap; gap: 8px; }
.saved-pill {
  display: flex; align-items: center; gap: 7px; background: var(--purple-pale);
  border: 1px solid rgba(124,92,255,.14);
  border-radius: 18px; padding: 6px 8px 6px 13px; font-size: .8rem; font-weight: 700; color: var(--purple-dark);
  transition: all .2s var(--ease);
}
.saved-pill:hover { background: #e4d9fb; }
.saved-pill.active { background: linear-gradient(135deg, var(--accent-a), var(--purple-mid)); color: #fff; box-shadow: var(--shadow-glow); }
.saved-pill .del {
  background: rgba(220,38,38,.12); color: var(--red); border: none; border-radius: 50%;
  width: 20px; height: 20px; line-height: 1; cursor: pointer; font-size: .8rem; font-weight: 700;
  transition: transform .15s;
}
.saved-pill .del:hover { transform: scale(1.15); background: rgba(220,38,38,.22); }
.saved-pill .go { background: none; border: none; cursor: pointer; font: inherit; color: inherit; padding: 0; }
.report-opts { font-size: .78rem; color: #f1eefb; display: flex; align-items: center; gap: 6px; }
.danger-btn {
  background: var(--red-light); color: var(--red); border: 1px solid var(--red);
  border-radius: 18px; padding: 6px 14px; font-size: .78rem; font-weight: 700; cursor: pointer;
  transition: all .2s var(--ease);
}
.danger-btn:hover { background: var(--red); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 18px rgba(220,38,38,.28); }

/* ── PAGE NAVIGATION ── */
.nav-links { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-links a {
  text-decoration: none; color: var(--purple-dark); font-size: .84rem; font-weight: 700;
  background: var(--purple-pale); border: 1px solid rgba(124,92,255,.16);
  padding: 7px 16px; border-radius: 20px; transition: all .25s var(--ease); white-space: nowrap;
}
.nav-links a:hover  { background: #e4d9fb; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(124,92,255,.18); }
.nav-links a.active { background: linear-gradient(135deg, var(--accent-a), var(--purple-mid)); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }

.page { display: none; }
.page.show { display: block; }

/* ── ADMIN AREA ── */
.lock-card {
  max-width: 440px; margin: 48px auto; text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px; padding: 34px 28px; box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--accent-a); position: relative; z-index: 1;
  animation: fadeInUp .5s var(--ease) both;
}
.lock-card .ic { font-size: 3rem; filter: drop-shadow(0 6px 14px rgba(124,92,255,.28)); }
.lock-card h2 { color: var(--purple-dark); font-size: 1.15rem; margin: 10px 0 6px; }
.lock-card p  { color: var(--text-mute); font-size: .84rem; margin-bottom: 18px; }
.lock-card input {
  width: 100%; padding: 11px 16px; border: 1px solid rgba(124,92,255,.25);
  border-radius: 24px; font-size: .95rem; font-family: inherit; outline: none; text-align: center;
  background: #faf9ff; transition: all .2s var(--ease);
}
.lock-card input:focus { border-color: var(--accent-a); box-shadow: 0 0 0 4px rgba(124,92,255,.14); background: #fff; }
.lock-card .mini-btn { margin-top: 14px; width: 100%; padding: 11px 20px; }
#lockMsg { color: var(--red); font-size: .82rem; margin-top: 10px; min-height: 18px; }
.admin-head {
  background: linear-gradient(90deg, var(--accent-a), var(--purple-dark));
  color: #fff; border-radius: 16px; padding: 12px 20px; margin-bottom: 22px; font-weight: 800;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  box-shadow: var(--shadow-glow);
}
.admin-head .copyBtn { font-weight: 700; }

/* ── REPORT CONTROLS ── */
.report-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.report-controls label { font-size: .78rem; font-weight: 700; opacity: .9; }
.report-controls select {
  padding: 8px 12px; border-radius: 20px; border: 1px solid rgba(255,255,255,.4);
  font-size: .86rem; font-family: inherit; background: rgba(255,255,255,.95); color: var(--purple-dark); font-weight: 700;
  max-width: 100%;
}
.lock-card form { margin: 0; }
.lock-card .back-link { display: inline-block; margin-top: 16px; font-size: .82rem; color: var(--accent-a); text-decoration: none; font-weight: 700; }
.lock-card .back-link:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE-FRIENDLY LAYER (presentation only)
   ═══════════════════════════════════════════════════════════════════════════ */
.table-scroll, .day-table-wrap { position: relative; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.swipe-hint { display: none; }

@media (max-width: 820px) {
  #adminWrap, #dashboard { padding: 12px 12px 32px; }
}

@media (max-width: 640px) {
  /* scales every rem-based font size down together, so all text on the
     phone view reads as one consistent, standard size instead of the
     desktop-sized text that was showing before */
  html { font-size: 14.5px; }

  header { padding: 14px 12px 12px; padding-top: max(14px, env(safe-area-inset-top, 14px)); }
  header h1 { font-size: 1.1rem; line-height: 1.25; }
  header p  { font-size: .72rem; }
  .header-right { width: 100%; justify-content: flex-start; }
  .icon-btn { width: 36px; height: 36px; font-size: .95rem; }
  .nav-links { width: auto; flex: 1 1 auto; }
  .nav-links a { flex: 1 1 auto; text-align: center; padding: 8px 10px; font-size: .76rem; white-space: nowrap; }
  .header-search-panel #storeDropdown { left: 0; right: 0; width: auto !important; min-width: 0; }
  header.search-open .header-search-panel { max-height: 64px; }

  /* tighter vertical rhythm between blocks on phones */
  .zone-bar, #viewingBanner, .export-bar, .kpi-section, .section-row, .chart-wrap, .rrr-box, .report-panel, .admin-head { margin-bottom: 16px; }
  .section-row { gap: 16px; }

  .export-bar { padding: 12px 14px; gap: 10px; }
  .export-controls { width: 100%; }
  #exportPeriod { flex: 1 1 100%; min-width: 0; font-size: 16px; padding: 10px 14px; min-height: 44px; }
  #exportBtn, #exportPdfBtn {
    flex: 1 1 calc(50% - 5px); min-width: 0; font-size: .82rem; padding: 10px 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Area buttons swipe horizontally in one row (left→right), Report date
     sits on its own full-width row underneath, below all four area buttons.
     Outlet search now lives in the header, not here. */
  .zone-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px;
  }
  .zone-bar > label { width: auto; margin-bottom: 0; }
  .area-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 2px;
  }
  .area-group::-webkit-scrollbar { display: none; }
  .area-group { scrollbar-width: none; }
  .area-group .zone-btn {
    flex: 0 0 auto; scroll-snap-align: start;
    min-width: 128px;
    padding: 9px 14px; font-size: .76rem; min-height: 38px;
    text-align: center; white-space: nowrap;
  }

  /* Report date: full-width row below the area buttons; prev arrow / select
     / next arrow share the row. */
  .day-picker {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 6px; align-items: center;
    width: 100%;
  }
  .day-picker select { min-width: 0; font-size: .78rem; padding: 8px 4px; }
  .day-picker .zone-btn { min-height: 38px; min-width: 34px; padding: 7px 8px; font-size: .78rem; }

  .kpi-section h3 { font-size: .72rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 54px 12px 12px; border-radius: 16px; --kpi-icon-size: 17px; }
  .kpi-card::before { width: 32px; height: 32px; top: 12px; left: 12px; border-radius: 10px; }
  .kpi-card::after  { width: 32px; height: 32px; top: 12px; left: 12px; }
  .kpi-badge { top: 17px; right: 12px; }
  .kpi-label { font-size: .65rem; }
  .kpi-value.big { font-size: 1.05rem; }
  .kpi-badge { font-size: .68rem; }

  .rrr-box {
    grid-template-columns: repeat(2, 1fr);
    padding: 24px 18px;
    row-gap: 24px; column-gap: 14px;
    border-radius: 20px;
  }
  .rrr-item { padding: 0 4px; }
  /* a soft divider between the two rows of the 2x2 grid, so the second
     pair of figures doesn't sit crammed against the first */
  .rrr-item:nth-child(n+3) { border-top: 1px solid rgba(255,255,255,.18); padding-top: 20px; }
  .rrr-value { font-size: 1.3rem; margin-top: 6px; }
  .rrr-label { font-size: .66rem; }
  .rrr-sub { font-size: .68rem; margin-top: 4px; line-height: 1.45; }

  #viewingBanner { font-size: .82rem; padding: 10px 14px; line-height: 1.5; }

  .panel, .chart-wrap, .report-panel { padding: 14px; border-radius: 18px; }
  .panel h3, .chart-wrap h3 { font-size: .72rem; }
  canvas { max-height: 230px; }
  #reportText, #areaReportText { font-size: .84rem; padding: 14px 16px; }
  .report-panel-head { align-items: flex-start; }
  .copyBtn { padding: 9px 16px; }

  .stat-table, .day-table { font-size: .74rem; }
  .stat-table th, .stat-table td, .day-table th, .day-table td { padding: 7px 9px; }
  .stat-table th:nth-child(2), .stat-table td:nth-child(2) {
    position: sticky; left: 0; background: #fff; z-index: 1;
    box-shadow: 2px 0 4px rgba(76,55,140,.08);
  }
  .stat-table th:nth-child(2) { background: var(--purple-pale); z-index: 2; }

  /* swipe discoverability — a soft fade + a small "swipe" pill, both only
     shown while .table-scroll/.day-table-wrap actually has more to reveal */
  .table-scroll.can-scroll::after, .day-table-wrap.can-scroll::after {
    content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 28px;
    background: linear-gradient(to right, transparent, rgba(244,243,251,.95));
    pointer-events: none; border-radius: 0 16px 16px 0;
  }
  .swipe-hint {
    display: none; align-items: center; gap: 4px; font-size: .66rem; font-weight: 700;
    color: var(--purple-mid); background: var(--purple-pale); padding: 3px 9px;
    border-radius: 20px; letter-spacing: .2px; white-space: nowrap;
  }
  .swipe-hint.show { display: inline-flex; }
  .panel h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

  .leader-item { padding: 9px 12px; }
  .leader-code { font-size: .84rem; }
  .leader-name { font-size: .72rem; }

  .upload-wrap { padding: 0 12px; margin-top: 20px; }
  .drop-card { padding: 20px 14px; }
  .drop-card .ic { font-size: 2.2rem; }
  .drop-card h2 { font-size: .95rem; }
  .status-bar { padding: 0 12px; }
  .chip { font-size: .74rem; padding: 6px 12px; }
  .admin-head { padding: 12px 16px; font-size: .84rem; }
  .report-controls { gap: 8px; }
  .report-controls select { flex: 1 1 140px; font-size: 16px; }
  .saved-pill { font-size: .74rem; }

  .lock-card { margin: 24px 16px; padding: 26px 18px; }
  .lock-card input { font-size: 16px; padding: 12px 16px; }

  .mini-btn, .danger-btn, .copyBtn { min-height: 40px; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .rrr-box { grid-template-columns: 1fr; row-gap: 18px; }
  .rrr-item:nth-child(n+3) { border-top: none; padding-top: 0; }
  .rrr-item:nth-child(n+2) { border-top: 1px solid rgba(255,255,255,.18); padding-top: 16px; }
  .zone-btn { font-size: .74rem; padding: 9px 6px; }
  #exportBtn, #exportPdfBtn { flex: 1 1 100%; font-size: .84rem; padding: 10px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ── OUTLET DRILL-DOWN MODAL ── */
.drill-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(30, 16, 58, .55);
  backdrop-filter: blur(2px);
  padding: 20px;
  align-items: center; justify-content: center;
}
.drill-overlay.show { display: flex; }
.drill-panel {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 760px; max-height: 88vh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 20px 20px 24px;
  animation: fadeInUp .25s var(--ease);
}
.drill-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.drill-head h3 { font-size: 1.1rem; color: var(--purple-dark); margin: 0; }
.drill-head p { font-size: .82rem; color: var(--text-mute); margin: 2px 0 0; }
.drill-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.drill-chart-wrap { margin-bottom: 18px; background: var(--card-bg); border-radius: 16px; padding: 12px; border: 1px solid var(--glass-border); }
.drill-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  .drill-overlay { padding: 0; align-items: flex-end; }
  .drill-panel { max-width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; padding: 16px 14px 20px; }
  .drill-head h3 { font-size: 1rem; }
  .drill-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
