/* ═══════════════════════════════════════════════════
   SHARED — Design Tokens, Reset, Layout, Utilities
   Premium Responsive Dashboard v3
   ═══════════════════════════════════════════════════ */

:root {
  /* ─── Color Palette ─── */
  --bg: #f0f2fa;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --border: #e2e5f0;

  --p: #534AB7;    --pm: #7F77DD;   --pl: #AFA9EC;  --pp: #EEEDFE;
  --b: #185FA5;    --bm: #378ADD;   --bl: #B5D4F4;  --bp: #E6F1FB;
  --txt: #1a1d2e;  --txt2: #5b6280; --txt3: #9ca3af;

  --green: #22c55e; --red: #ef4444; --amber: #f59e0b; --teal: #14b8a6;

  /* ─── Radii ─── */
  --r: 14px;  --rs: 8px;

  /* ─── Premium Shadows (multi-layered) ─── */
  --sh:
    0 1px 2px rgba(83,74,183,.04),
    0 4px 12px rgba(83,74,183,.06),
    0 0 0 1px rgba(83,74,183,.03);
  --sh-hover:
    0 4px 8px rgba(83,74,183,.06),
    0 12px 40px rgba(83,74,183,.14),
    0 0 0 1px rgba(83,74,183,.05);

  /* ─── Premium Gradients ─── */
  --primary-gradient: linear-gradient(135deg, #534AB7, #7F77DD);
  --secondary-gradient: linear-gradient(135deg, #185FA5, #378ADD);
  --success-gradient: linear-gradient(135deg, #15803d, #22c55e);

  /* ─── Sidebar Width (used by sidebar + main) ─── */
  --sb-w: 240px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: 'Inter', 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  min-height: 100dvh;            /* modern mobile viewport */
  display: block;   /* Changed from flex to block to fix overflow */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Animations ─── */
@keyframes fadeInUp   { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeInLeft { from{opacity:0;transform:translateX(-20px)} to{opacity:1;transform:translateX(0)} }
@keyframes scaleIn   { from{opacity:0;transform:scale(.92)} to{opacity:1;transform:scale(1)} }
@keyframes shimmer   { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
@keyframes pulse     { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.6;transform:scale(1.3)} }
@keyframes slideDown { from{opacity:0;max-height:0} to{opacity:1;max-height:800px} }

.animate-fade-in {
  animation: fadeInUp .5s ease-out both;
  animation-delay: calc(var(--animation-order, 0) * .1s);
}

/* ═══════════════════ MAIN AREA ═══════════════════ */
.main {
  margin-left: var(--sb-w);
  min-width: 0;
  padding: clamp(14px, 3vw, 28px) clamp(12px, 3vw, 28px);
  min-height: 100vh;
  min-height: 100dvh;
  transition: margin .35s cubic-bezier(.4,0,.2,1);
  animation: fadeInUp .4s ease-out;
}

/* ═══════════════════ HEADER ═══════════════════ */
.hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: clamp(16px, 2.5vw, 24px);
  gap: 12px;
  flex-wrap: wrap;
  animation: fadeInLeft .5s ease-out;
}
.hdr-left { min-width: 0; flex: 1; }
.hdr-title {
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 800;
  color: var(--txt);
  letter-spacing: -.3px;
  line-height: 1.25;
}
.hdr-sub {
  font-size: clamp(12px, 1.4vw, 14px);
  color: var(--txt2);
  margin-top: 3px;
}
.hdr-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.hdr-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--txt3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px;
}
.live-badge {
  display: flex; align-items: center; gap: 5px;
  background: #dcfce7; border-radius: 20px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; color: #16a34a;
}
.live-dot {
  width: 6px; height: 6px;
  background: #22c55e; border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.sync-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 14px;
  font-size: 13px; font-weight: 700; color: var(--p);
  cursor: pointer; transition: all .24s ease;
  box-shadow: var(--sh);
}
.sync-btn:hover {
  background: var(--pp); border-color: var(--pl);
  transform: translateY(-1px); box-shadow: var(--sh-hover);
}
.sync-btn svg { transition: transform .5s cubic-bezier(.4,0,.2,1); }
.sync-btn:active { transform: translateY(0); }
.sync-btn.syncing svg { animation: rotate 1s linear infinite; }

@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ─── Month Selector ─── */
.month-selector-container {
  position: relative;
  animation: popIn 0.4s ease-out;
}
.month-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 30px 5px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
  cursor: pointer;
  transition: all 0.24s ease;
  box-shadow: var(--sh);
  font-family: 'Inter', sans-serif;
  outline: none;
}
.month-select:hover {
  background: var(--surface);
  border-color: var(--pm);
  box-shadow: var(--sh-hover);
  transform: translateY(-1px);
}
.month-selector-container::after {
  content: '▼';
  font-size: 8px;
  color: var(--p);
  position: absolute;
  right: 12px;
  top: 52%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.7;
}

/* ─── Hamburger (mobile only) ─── */
.hamburger {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--surface);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  transition: background .2s;
  z-index: 250;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--txt); border-radius: 2px;
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ─── Sidebar backdrop (mobile) ─── */
.sb-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 15, 30, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 190;
  opacity: 0;
  transition: opacity .35s ease;
}
.sb-backdrop.visible { display: block; opacity: 1; }

/* ═══════════════════ SECTION LABELS ═══════════════════ */
.sec-lbl {
  font-size: clamp(11px, 1.2vw, 12px);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--txt3);
  margin-bottom: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sec-lbl::after {
  content: '';
  flex: 1; height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

/* ═══════════════════ CHART CARDS ═══════════════════ */
.chart-row { display: grid; gap: clamp(10px, 1.5vw, 14px); margin-bottom: 16px; }
.cr2 { grid-template-columns: 1fr 1fr; }
.cr3 { grid-template-columns: 2fr 1fr; }
.cr-full { grid-template-columns: 1fr; }

.cc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: clamp(14px, 2vw, 22px);
  box-shadow: var(--sh);
  transition: all .35s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
}
.cc::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 3px;
  background: var(--primary-gradient);
  opacity: 0; transition: opacity .3s ease;
}
.cc:hover { box-shadow: var(--sh-hover); transform: translateY(-4px); }
.cc:hover::before { opacity: 1; }

.cc-hdr {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px; flex-wrap: wrap;
}
.cc-title { font-size: clamp(14px, 1.6vw, 16px); font-weight: 700; color: var(--txt); }
.cc-sub   { font-size: clamp(12px, 1.2vw, 13px); color: var(--txt3); margin-top: 2px; }
.cc-badge {
  font-size: 13px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  background: var(--pp); color: var(--p); flex-shrink: 0;
}
.chart-wrap { position: relative; }

/* ═══════════════════ PILLS ═══════════════════ */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 20px;
  font-size: 13px; font-weight: 700;
  transition: transform .2s ease;
}
.pill:hover { transform: scale(1.05); }
.pg { background: #dcfce7; color: #166534; }
.pa { background: #fef3c7; color: #92400e; }
.pr { background: #fee2e2; color: #991b1b; }
.pp { background: var(--pp); color: var(--p); }
.pb { background: var(--bp); color: var(--b); }

/* ═══════════════════ PROGRESS BAR ═══════════════════ */
.pbar {
  height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
  width: 70px; display: inline-block;
  vertical-align: middle; margin-left: 5px;
}
.pbar-fill {
  height: 100%; border-radius: 2px;
  transition: width .6s ease;
  background: linear-gradient(90deg, var(--p), var(--pm));
}

/* ═══════════════════ TOOLTIP ═══════════════════ */
.custom-tip {
  position: fixed;
  background: rgba(26,29,46,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff; padding: 8px 12px;
  border-radius: 8px; font-size: 12px;
  pointer-events: none; z-index: 999;
  opacity: 0; transition: opacity .15s, transform .15s;
  transform: translateY(4px);
  max-width: 220px; line-height: 1.5;
}
.custom-tip.show { opacity: 1; transform: translateY(0); }

/* ═══════════════════ SCROLLBAR ═══════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--pl);
  border-radius: 4px;
  transition: background .2s;
}
::-webkit-scrollbar-thumb:hover { background: var(--pm); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--pl) transparent; }

/* ═══════════════════ RESPONSIVE BREAKPOINTS ═══════════════════ */

/* ── Large Tablets / Small Laptops ── */
@media (max-width: 1200px) {
  :root { --sb-w: 220px; }
  .cr3 { grid-template-columns: 1fr 1fr; }
}

/* ── Tablets ── */
@media (max-width: 1024px) {
  .cr2, .cr3 { grid-template-columns: 1fr; }
}

/* ── Mobile / Small Tablets ── */
@media (max-width: 768px) {
  .main {
    margin-left: 0;
    padding: 14px 12px;
    padding-top: 10px;
  }
  .hamburger { display: flex; }

  .hdr { flex-wrap: wrap; gap: 8px; }
  .hdr-right { order: -1; width: 100%; justify-content: space-between; }
  .hdr-title { font-size: 17px; }

  .cr2, .cr3 { grid-template-columns: 1fr; }

  .cc:hover { transform: none; }  /* prevent annoying lift on touch */

  /* Footer */
  footer { font-size: 11px !important; padding: 12px 8px !important; }
}

/* ── Extra-Small Phones ── */
@media (max-width: 420px) {
  .main { padding: 10px 8px; }
  .hdr-title { font-size: 15px; }
  .hdr-sub { font-size: 12px; }
  .hdr-date { font-size: 11px; padding: 5px 10px; }
  .live-badge { font-size: 11px; padding: 5px 10px; }
  .cc { padding: 12px; border-radius: 10px; }
  .sec-lbl { font-size: 12px; }
}
