/* ══════════════════════════════════════════════
   style.css  —  SalesView Dashboard
   Mobile-first · iOS safe-area · Power BI vibes
   ══════════════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
  /* Brand */
  --navy:      #0d1b3e;
  --navy2:     #152347;
  --navy3:     #1c2e5c;
  --blue:      #2563eb;
  --blue2:     #3b82f6;
  --blue-lt:   #eff6ff;
  --blue-glow: rgba(59,130,246,.18);

  /* Accents */
  --gold:      #f59e0b;
  --gold-lt:   #fef3c7;
  --emerald:   #10b981;
  --em-lt:     #d1fae5;
  --rose:      #f43f5e;
  --rose-lt:   #ffe4e6;
  --violet:    #8b5cf6;

  /* Surface */
  --bg:        #f0f2f8;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --border2:   #f1f5f9;
  --text:      #0f172a;
  --text2:     #475569;
  --text3:     #94a3b8;

  /* Layout */
  --hdr-h:     56px;
  --r:         16px;
  --r-sm:      10px;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.15);

  /* Typography */
  --font:      'Sora', sans-serif;
  --mono:      'JetBrains Mono', monospace;

  /* Safe areas (iPhone notch / home bar) */
  --sat: env(safe-area-inset-top,    0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left,   0px);
  --sar: env(safe-area-inset-right,  0px);
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
input, select, button { font-family: var(--font); }
.hidden { display: none !important; }

/* ══════════════════════════════════════
   LOGIN
══════════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #060e1f 0%, #0d1b3e 45%, #1a3a7a 100%);
  padding: 24px max(16px, var(--sal));
  position: relative;
  overflow: hidden;
}

/* Background glow orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
}
.orb1 { width: 380px; height: 380px; background: rgba(37,99,235,.22);  top: -120px; right: -100px; }
.orb2 { width: 260px; height: 260px; background: rgba(245,158,11,.12); bottom: 20px; left: -80px; }
.orb3 { width: 200px; height: 200px; background: rgba(16,185,129,.1);  top: 45%; left: 28%; }

.login-card {
  background: rgba(255,255,255,.98);
  border-radius: 24px;
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 32px 80px rgba(0,0,0,.4);
  position: relative;
  z-index: 1;
  animation: fadeUp .4s cubic-bezier(.22,1,.36,1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.brand-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #0d1b3e, #1a3a7a);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.4px;
}

.login-h {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  margin-bottom: 5px;
}
.login-p {
  font-size: .82rem;
  color: var(--text3);
  margin-bottom: 26px;
}

/* Form fields */
.fld { margin-bottom: 16px; }
.fld-lbl {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 7px;
}
.fld-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.fld-ico {
  position: absolute;
  left: 13px;
  color: var(--text3);
  pointer-events: none;
  flex-shrink: 0;
}
.fld-wrap input {
  width: 100%;
  padding: 13px 42px 13px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .95rem;
  color: var(--text);
  background: #f8fafc;
  outline: none;
  -webkit-appearance: none;
  transition: border .2s, box-shadow .2s, background .2s;
}
.fld-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: #fff;
}
.eye-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  padding: 5px;
  display: flex;
  align-items: center;
  -webkit-appearance: none;
  transition: color .2s;
}
.eye-btn:active { color: var(--blue); }

.login-err {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff1f2;
  color: var(--rose);
  border: 1px solid #fecdd3;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .8rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.btn-login {
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  background: linear-gradient(135deg, var(--blue) 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .1px;
  -webkit-appearance: none;
  transition: transform .15s, box-shadow .15s;
}
.btn-login:hover  { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(37,99,235,.4); }
.btn-login:active { transform: scale(.98); }

.demo-hint {
  text-align: center;
  font-size: .74rem;
  color: var(--text3);
  margin-top: 16px;
}
.demo-hint b { color: var(--text2); }


/* ══════════════════════════════════════
   APP SHELL
══════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── HEADER ── */
.hdr {
  flex-shrink: 0;
  height: calc(var(--hdr-h) + var(--sat));
  padding: var(--sat) 16px 0;
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a7a 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 20px rgba(0,0,0,.3);
  position: relative;
  z-index: 50;
}
.hdr-l { display: flex; align-items: center; gap: 10px; }
.hdr-logo {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hdr-title {
  font-size: .95rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.3px;
}
.hdr-co {
  font-size: .62rem;
  color: rgba(255,255,255,.5);
  margin-top: 1px;
  letter-spacing: .3px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hdr-r { display: flex; align-items: center; gap: 8px; }

.hdr-filter-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.9);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  -webkit-appearance: none;
  transition: background .15s;
  white-space: nowrap;
}
.hdr-filter-btn:active { background: rgba(255,255,255,.22); }

.fbadge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--gold);
  color: #000;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: .58rem;
  font-weight: 800;
  min-width: 16px;
  text-align: center;
}

.hdr-av {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue2), #1d4ed8);
  color: #fff;
  border: 2px solid rgba(255,255,255,.25);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  flex-shrink: 0;
  transition: transform .15s;
}
.hdr-av:active { transform: scale(.92); }


/* ── SCROLL BODY ── */
.body-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}


/* ── FILTER CHIPS ── */
.chips-row {
  display: flex;
  gap: 7px;
  padding: 10px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
.chips-row::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--blue-lt);
  border: 1px solid #bfdbfe;
  color: var(--blue);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  animation: popIn .2s cubic-bezier(.22,1,.36,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.75); }
  to   { opacity: 1; transform: scale(1); }
}
.chip-x {
  background: rgba(37,99,235,.15);
  border: none;
  color: var(--blue);
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: .58rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-appearance: none;
}
.chip-x:active { background: var(--rose); color: #fff; }


/* ── KPI BLOCK ── */
.kpi-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 14px 0;
}

.kpi-hero {
  background: linear-gradient(145deg, var(--navy) 0%, #1a3a7a 100%);
  border-radius: var(--r);
  padding: 20px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(13,27,62,.35);
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-hero::after {
  content: '';
  position: absolute;
  width: 130px; height: 130px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
  top: -35px; right: -35px;
  pointer-events: none;
}
.kpi-hero-lbl {
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  margin-bottom: 8px;
}
.kpi-hero-val {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  font-family: var(--mono);
  letter-spacing: -1px;
  line-height: 1;
}
.kpi-hero-sub {
  font-size: .65rem;
  color: rgba(255,255,255,.4);
  margin-top: 9px;
}

.kpi-trio {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kpi-mini {
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border2);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-mini-val {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
}
.kpi-mini-lbl {
  font-size: .65rem;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: .2px;
}


/* ── SEARCH BARS ── */
.search-block {
  padding: 12px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sbox {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: border .2s, box-shadow .2s;
}
.sbox:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.sbox.s-active {
  border-color: var(--blue);
  background: #f0f7ff;
}
.sbox-icon {
  padding: 0 4px 0 13px;
  font-size: .9rem;
  flex-shrink: 0;
  line-height: 1;
}
.sinp {
  flex: 1;
  padding: 13px 8px 13px 4px;
  border: none;
  background: transparent;
  outline: none;
  font-size: .9rem;
  color: var(--text);
  -webkit-appearance: none;
  min-width: 0;
}
.sinp::placeholder { color: var(--text3); }

.sclr {
  background: var(--text3);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: .6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 10px;
  -webkit-appearance: none;
  transition: background .15s;
}
.sclr:active { background: var(--rose); }

.sdrop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  max-height: 230px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 200;
  animation: dropIn .15s ease;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sdrop::-webkit-scrollbar { width: 4px; }
.sdrop::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.drop-item {
  padding: 12px 14px;
  font-size: .84rem;
  color: var(--text);
  border-bottom: 1px solid var(--border2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.drop-item:last-child { border-bottom: none; }
.drop-item:active { background: var(--blue-lt); }
.drop-item mark {
  background: #fef08a;
  color: #78350f;
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}
.drop-name { flex: 1; min-width: 0; }
.drop-amt {
  font-size: .72rem;
  color: var(--text3);
  font-family: var(--mono);
  flex-shrink: 0;
  white-space: nowrap;
}


/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--r);
  margin: 12px 14px 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--border2);
  overflow: hidden;
}

.card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border2);
}
.card-ttl {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}
.card-tag {
  font-size: .68rem;
  color: var(--text3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}


/* ── CHART ── */
.chart-wrap {
  padding: 14px 12px 12px;
  height: 200px;
  position: relative;
}


/* ── TABLES ── */
.tbl-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 310px;
  -webkit-overflow-scrolling: touch;
}
.tbl-wrap::-webkit-scrollbar { width: 3px; }
.tbl-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  table-layout: fixed;
}
.tbl thead { position: sticky; top: 0; z-index: 1; }
.tbl th {
  padding: 9px 12px;
  text-align: left;
  background: #f8fafc;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1.5px solid var(--border);
}
.tbl th:first-child  { width: 36px; }
.tbl th:last-child   { text-align: right; width: 72px; }
.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border2);
  color: var(--text);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tbl td:first-child  { color: var(--text3); font-size: .72rem; }
.tbl td:last-child   {
  text-align: right;
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 600;
  color: var(--blue);
}
.tbl tbody tr:nth-child(even) { background: #fafbfc; }
.tbl tbody tr { transition: background .1s; -webkit-tap-highlight-color: transparent; }
.tbl tbody tr:active { background: var(--blue-lt); }
.tbl tbody tr.row-sel {
  background: var(--blue-lt);
  border-left: 3px solid var(--blue);
}
.tbl tbody tr.row-sel td:first-child { padding-left: 9px; }


/* ── BOTTOM SHEET ── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  backdrop-filter: blur(3px);
  animation: fadeBG .2s ease;
}
@keyframes fadeBG { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  z-index: 301;
  padding-bottom: max(var(--sab), 12px);
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
  animation: sheetUp .28s cubic-bezier(.22,1,.36,1);
  max-height: 85vh;
  overflow-y: auto;
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.sheet-pip {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}
.sheet-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
}
.sheet-title { font-size: 1rem; font-weight: 800; color: var(--text); }
.sheet-reset {
  background: none;
  border: none;
  font-size: .82rem;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  -webkit-appearance: none;
  border-radius: 6px;
  transition: background .15s;
}
.sheet-reset:active { background: var(--blue-lt); }

.sheet-body { padding: 4px 20px 8px; }
.sh-lbl {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}

/* Period grid — 3 cols on mobile */
.pgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pb {
  padding: 11px 8px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: transparent;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  text-align: center;
  -webkit-appearance: none;
  transition: all .15s;
}
.pb:active { background: var(--blue-lt); }
.pb.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(37,99,235,.3);
}

.area-sel {
  width: 100%;
  padding: 13px 36px 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .875rem;
  color: var(--text);
  background: #f8fafc;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border .2s;
}
.area-sel:focus { border-color: var(--blue); }

.sheet-foot { padding: 16px 20px 4px; }
.btn-apply {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-appearance: none;
  transition: transform .15s, box-shadow .15s;
}
.btn-apply:active { transform: scale(.98); }


/* ── LOADER VEIL ── */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(13,27,62,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(6px);
}
.veil-pill {
  background: #fff;
  border-radius: 16px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  font-weight: 600;
  color: var(--text2);
}
.ring {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ══════════════════════════════════════
   TABLET  (≥ 600px)
══════════════════════════════════════ */
@media (min-width: 600px) {
  .kpi-block, .search-block { max-width: 700px; margin-left: auto; margin-right: auto; }
  .kpi-block  { padding: 18px 20px 0; }
  .search-block { padding: 14px 20px 0; }
  .card       { max-width: 700px; margin: 14px auto 0; }
  .chips-row  { max-width: 700px; margin: 0 auto; padding: 12px 20px; }
  .kpi-hero-val { font-size: 2rem; }
  .chart-wrap { height: 230px; }
}

/* ══════════════════════════════════════
   DESKTOP  (≥ 1024px)
══════════════════════════════════════ */
@media (min-width: 1024px) {
  .hdr { padding-left: 28px; padding-right: 28px; }
  .kpi-block, .search-block, .card, .chips-row { max-width: 960px; }
  .kpi-block { grid-template-columns: 5fr 4fr; gap: 14px; padding-top: 22px; }
  .kpi-trio  { flex-direction: row; }
  .kpi-mini  { flex-direction: column; align-items: flex-start; padding: 14px 16px; }
  .chart-wrap { height: 260px; }
  .tbl td { white-space: nowrap; }
}
