/* ─────────────────────────────────────────────────────────────────────────
   Zendesk Ticket Tracker — Web Dashboard Styles
   Mirrors the extension popup's "moody" theme so the two feel like one app.
   ───────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* "classic" is the dashboard's original look — kept as the default/fallback
   (the bare :root rule doubles as its values, same convention as the
   extension's popup.css) so existing visitors see no change unless they
   pick a new theme via the Appearance picker (🎨 button in the header). */
:root,
:root[data-theme="classic"] {
  --bg-0: #0e0e10;
  --bg-1: #171717;
  --bg-2: #202123;
  --bg-card: #202123;
  --bg-card-h: #2a2b2e;
  --border: rgba(255, 255, 255, 0.08);
  --border-h: rgba(255, 255, 255, 0.14);
  --text-1: #ececec;
  --text-2: rgba(236, 236, 236, 0.6);
  --text-3: rgba(236, 236, 236, 0.32);
  --accent: #10a37f;
  --accent-dim: rgba(16, 163, 127, 0.18);
  --red: #ff6b6b;
  --red-glow: rgba(255, 107, 107, 0.2);
  --yellow: #ffd93d;
  --yellow-glow: rgba(255, 217, 61, 0.2);
  --blue: #59a8ff;
  --blue-glow: rgba(89, 168, 255, 0.2);
  --green: #22c58b;
  --green-glow: rgba(34, 197, 139, 0.2);
  --brown: #b5723e;
  --brown-glow: rgba(181, 114, 62, 0.2);
  --gray: #9a9a9a;
  --gray-glow: rgba(154, 154, 154, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --header-grad: linear-gradient(135deg, #171717 0%, #202123 100%);
  --chart-tooltip-bg: rgba(14, 14, 16, 0.95);
  --chart-grid: rgba(255, 255, 255, 0.05);
  --chart-grid-y: rgba(255, 255, 255, 0.07);
  --chart-ticks: rgba(255, 255, 255, 0.4);
  --btn-active-bg: linear-gradient(135deg, rgba(16, 163, 127, 0.25), rgba(16, 163, 127, 0.1));
  --btn-active-border: rgba(16, 163, 127, 0.5);
}

/* ── Additional themes (from a user-supplied Real Time Colors palette set) ──
   Same 7 themes added to the extension's popup/widget, minus the couple of
   popup-only variables (--cal-*, --week-hover) this dashboard never uses. */
:root[data-theme="blue-light"] {
  --bg-0: #f2f2f5;
  --bg-1: #fbfbfe;
  --bg-2: #f2f2f9;
  --bg-card: #f5f5fe;
  --bg-card-h: #e6e6ef;
  --border: rgba(5, 3, 21, 0.09);
  --border-h: rgba(5, 3, 21, 0.15);
  --text-1: #050315;
  --text-2: #3b3a48;
  --text-3: #74737e;
  --accent: #2f27ce;
  --accent-dim: rgba(47, 39, 206, 0.12);
  --red: #b63539;
  --red-glow: rgba(182, 53, 57, 0.15);
  --yellow: #b69835;
  --yellow-glow: rgba(182, 152, 53, 0.15);
  --blue: #357ab6;
  --blue-glow: rgba(53, 122, 182, 0.15);
  --green: #35b675;
  --green-glow: rgba(53, 182, 117, 0.15);
  --brown: #91633b;
  --brown-glow: rgba(145, 99, 59, 0.15);
  --gray: #6a6a81;
  --gray-glow: rgba(106, 106, 129, 0.15);
  --header-grad: linear-gradient(135deg, #fbfbfe 0%, #f2f2f5 100%);
  --chart-tooltip-bg: rgba(5, 3, 21, 0.92);
  --chart-grid: rgba(5, 3, 21, 0.05);
  --chart-grid-y: rgba(5, 3, 21, 0.07);
  --chart-ticks: rgba(5, 3, 21, 0.4);
  --btn-active-bg: linear-gradient(135deg, rgba(47, 39, 206, 0.14), rgba(67, 59, 255, 0.06));
  --btn-active-border: rgba(47, 39, 206, 0.4);
}

:root[data-theme="blue-dark"] {
  --bg-0: #010103;
  --bg-1: #010104;
  --bg-2: #09090f;
  --bg-card: #06060f;
  --bg-card-h: #15151d;
  --border: rgba(235, 233, 252, 0.1);
  --border-h: rgba(235, 233, 252, 0.17);
  --text-1: #ebe9fc;
  --text-2: rgba(235, 233, 252, 0.62);
  --text-3: rgba(235, 233, 252, 0.34);
  --accent: #3a31d8;
  --accent-dim: rgba(58, 49, 216, 0.2);
  --red: #f06a6f;
  --red-glow: rgba(240, 106, 111, 0.22);
  --yellow: #f0d16a;
  --yellow-glow: rgba(240, 209, 106, 0.22);
  --blue: #6ab2f0;
  --blue-glow: rgba(106, 178, 240, 0.22);
  --green: #6af0ad;
  --green-glow: rgba(106, 240, 173, 0.22);
  --brown: #c49164;
  --brown-glow: rgba(196, 145, 100, 0.22);
  --gray: #9696a6;
  --gray-glow: rgba(150, 150, 166, 0.22);
  --header-grad: linear-gradient(135deg, #010104 0%, #010103 100%);
  --chart-tooltip-bg: rgba(1, 1, 3, 0.95);
  --chart-grid: rgba(235, 233, 252, 0.06);
  --chart-grid-y: rgba(235, 233, 252, 0.08);
  --chart-ticks: rgba(235, 233, 252, 0.42);
  --btn-active-bg: linear-gradient(135deg, rgba(58, 49, 216, 0.28), rgba(6, 0, 194, 0.14));
  --btn-active-border: rgba(58, 49, 216, 0.5);
}

:root[data-theme="emerald-forest"] {
  --bg-0: #040806;
  --bg-1: #050c08;
  --bg-2: #0d1b15;
  --bg-card: #0a1e17;
  --bg-card-h: #192c25;
  --border: rgba(236, 247, 242, 0.1);
  --border-h: rgba(236, 247, 242, 0.17);
  --text-1: #ecf7f2;
  --text-2: rgba(236, 247, 242, 0.62);
  --text-3: rgba(236, 247, 242, 0.34);
  --accent: #10b981;
  --accent-dim: rgba(16, 185, 129, 0.2);
  --red: #f06a6f;
  --red-glow: rgba(240, 106, 111, 0.22);
  --yellow: #f0d16a;
  --yellow-glow: rgba(240, 209, 106, 0.22);
  --blue: #6ab2f0;
  --blue-glow: rgba(106, 178, 240, 0.22);
  --green: #6af0ad;
  --green-glow: rgba(106, 240, 173, 0.22);
  --brown: #c49164;
  --brown-glow: rgba(196, 145, 100, 0.22);
  --gray: #9696a6;
  --gray-glow: rgba(150, 150, 166, 0.22);
  --header-grad: linear-gradient(135deg, #050c08 0%, #040806 100%);
  --chart-tooltip-bg: rgba(4, 8, 6, 0.95);
  --chart-grid: rgba(236, 247, 242, 0.06);
  --chart-grid-y: rgba(236, 247, 242, 0.08);
  --chart-ticks: rgba(236, 247, 242, 0.42);
  --btn-active-bg: linear-gradient(135deg, rgba(16, 185, 129, 0.28), rgba(245, 158, 11, 0.14));
  --btn-active-border: rgba(16, 185, 129, 0.5);
}

:root[data-theme="crisp-light"] {
  --bg-0: #eff1f3;
  --bg-1: #f8fafc;
  --bg-2: #edf0f3;
  --bg-card: #eff3f7;
  --bg-card-h: #e1e4e8;
  --border: rgba(15, 23, 42, 0.09);
  --border-h: rgba(15, 23, 42, 0.15);
  --text-1: #0f172a;
  --text-2: #424958;
  --text-3: #787d89;
  --accent: #6366f1;
  --accent-dim: rgba(99, 102, 241, 0.12);
  --red: #b63539;
  --red-glow: rgba(182, 53, 57, 0.15);
  --yellow: #b69835;
  --yellow-glow: rgba(182, 152, 53, 0.15);
  --blue: #357ab6;
  --blue-glow: rgba(53, 122, 182, 0.15);
  --green: #35b675;
  --green-glow: rgba(53, 182, 117, 0.15);
  --brown: #91633b;
  --brown-glow: rgba(145, 99, 59, 0.15);
  --gray: #6a6a81;
  --gray-glow: rgba(106, 106, 129, 0.15);
  --header-grad: linear-gradient(135deg, #f8fafc 0%, #eff1f3 100%);
  --chart-tooltip-bg: rgba(15, 23, 42, 0.92);
  --chart-grid: rgba(15, 23, 42, 0.05);
  --chart-grid-y: rgba(15, 23, 42, 0.07);
  --chart-ticks: rgba(15, 23, 42, 0.4);
  --btn-active-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(244, 63, 94, 0.06));
  --btn-active-border: rgba(99, 102, 241, 0.4);
}

:root[data-theme="crisp-dark"] {
  --bg-0: #020405;
  --bg-1: #030507;
  --bg-2: #0e1114;
  --bg-card: #0d1115;
  --bg-card-h: #1c1f23;
  --border: rgba(214, 222, 240, 0.1);
  --border-h: rgba(214, 222, 240, 0.17);
  --text-1: #d6def0;
  --text-2: rgba(214, 222, 240, 0.62);
  --text-3: rgba(214, 222, 240, 0.34);
  --accent: #0d109b;
  --accent-dim: rgba(13, 16, 155, 0.2);
  --red: #f06a6f;
  --red-glow: rgba(240, 106, 111, 0.22);
  --yellow: #f0d16a;
  --yellow-glow: rgba(240, 209, 106, 0.22);
  --blue: #6ab2f0;
  --blue-glow: rgba(106, 178, 240, 0.22);
  --green: #6af0ad;
  --green-glow: rgba(106, 240, 173, 0.22);
  --brown: #c49164;
  --brown-glow: rgba(196, 145, 100, 0.22);
  --gray: #9696a6;
  --gray-glow: rgba(150, 150, 166, 0.22);
  --header-grad: linear-gradient(135deg, #030507 0%, #020405 100%);
  --chart-tooltip-bg: rgba(2, 4, 5, 0.95);
  --chart-grid: rgba(214, 222, 240, 0.06);
  --chart-grid-y: rgba(214, 222, 240, 0.08);
  --chart-ticks: rgba(214, 222, 240, 0.42);
  --btn-active-bg: linear-gradient(135deg, rgba(13, 16, 155, 0.28), rgba(193, 11, 41, 0.14));
  --btn-active-border: rgba(13, 16, 155, 0.5);
}

:root[data-theme="crimson-light"] {
  --bg-0: #e4e4e6;
  --bg-1: #ececee;
  --bg-2: #e3e3e6;
  --bg-card: #e6e6e9;
  --bg-card-h: #d8d8db;
  --border: rgba(9, 9, 11, 0.09);
  --border-h: rgba(9, 9, 11, 0.15);
  --text-1: #09090b;
  --text-2: #3b3b3d;
  --text-3: #6f6f71;
  --accent: #d72323;
  --accent-dim: rgba(215, 35, 35, 0.12);
  --red: #b63539;
  --red-glow: rgba(182, 53, 57, 0.15);
  --yellow: #b69835;
  --yellow-glow: rgba(182, 152, 53, 0.15);
  --blue: #357ab6;
  --blue-glow: rgba(53, 122, 182, 0.15);
  --green: #35b675;
  --green-glow: rgba(53, 182, 117, 0.15);
  --brown: #91633b;
  --brown-glow: rgba(145, 99, 59, 0.15);
  --gray: #6a6a81;
  --gray-glow: rgba(106, 106, 129, 0.15);
  --header-grad: linear-gradient(135deg, #ececee 0%, #e4e4e6 100%);
  --chart-tooltip-bg: rgba(9, 9, 11, 0.92);
  --chart-grid: rgba(9, 9, 11, 0.05);
  --chart-grid-y: rgba(9, 9, 11, 0.07);
  --chart-ticks: rgba(9, 9, 11, 0.4);
  --btn-active-bg: linear-gradient(135deg, rgba(215, 35, 35, 0.14), rgba(220, 159, 4, 0.06));
  --btn-active-border: rgba(215, 35, 35, 0.4);
}

:root[data-theme="crimson-dark"] {
  --bg-0: #0d0d0e;
  --bg-1: #121214;
  --bg-2: #1c1c1e;
  --bg-card: #1b1b1e;
  --bg-card-h: #29292c;
  --border: rgba(245, 245, 247, 0.1);
  --border-h: rgba(245, 245, 247, 0.17);
  --text-1: #f5f5f7;
  --text-2: rgba(245, 245, 247, 0.62);
  --text-3: rgba(245, 245, 247, 0.34);
  --accent: #dc2626;
  --accent-dim: rgba(220, 38, 38, 0.2);
  --red: #f06a6f;
  --red-glow: rgba(240, 106, 111, 0.22);
  --yellow: #f0d16a;
  --yellow-glow: rgba(240, 209, 106, 0.22);
  --blue: #6ab2f0;
  --blue-glow: rgba(106, 178, 240, 0.22);
  --green: #6af0ad;
  --green-glow: rgba(106, 240, 173, 0.22);
  --brown: #c49164;
  --brown-glow: rgba(196, 145, 100, 0.22);
  --gray: #9696a6;
  --gray-glow: rgba(150, 150, 166, 0.22);
  --header-grad: linear-gradient(135deg, #121214 0%, #0d0d0e 100%);
  --chart-tooltip-bg: rgba(13, 13, 14, 0.95);
  --chart-grid: rgba(245, 245, 247, 0.06);
  --chart-grid-y: rgba(245, 245, 247, 0.08);
  --chart-ticks: rgba(245, 245, 247, 0.42);
  --btn-active-bg: linear-gradient(135deg, rgba(220, 38, 38, 0.28), rgba(251, 191, 36, 0.14));
  --btn-active-border: rgba(220, 38, 38, 0.5);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg-0);
}

body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] { display: none !important; }

h1, h2 { font-weight: 700; }

/* ── Splash / session-restore screen ─────────────────────────────────────
   Covers the brief window while Firebase resolves a persisted sign-in, and
   the visible feedback while that session's data loads — an animated
   version of the app logo "checking in" three times, then a checkmark once
   loadUserData() actually resolves, instead of a static spinner. */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bg-0);
  transition: opacity 0.35s ease;
}

.splash-screen.fade-out { opacity: 0; pointer-events: none; }

.splash-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 52px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.splash-bar {
  width: 11px;
  height: 44px;
  border-radius: 4px;
  transform: scaleY(0.15);
  transform-origin: bottom;
  animation: splash-bar-rise 1.1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.splash-bar-blue   { background: var(--blue);   animation-delay: 0s; }
.splash-bar-yellow { background: var(--yellow); animation-delay: 0.15s; }
.splash-bar-red    { background: var(--red);    animation-delay: 0.3s; }

@keyframes splash-bar-rise {
  0%   { transform: scaleY(0.15); }
  55%  { transform: scaleY(1.15); }
  75%  { transform: scaleY(0.88); }
  100% { transform: scaleY(1); }
}

.splash-check {
  position: absolute;
  width: 60px;
  height: 60px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.splash-check svg { width: 100%; height: 100%; }

.splash-check-circle {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
}

.splash-check-mark {
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
}

.splash-screen.tick .splash-bars {
  opacity: 0;
  transform: scale(0.85);
}

.splash-screen.tick .splash-check {
  opacity: 1;
  transform: scale(1);
}

.splash-screen.tick .splash-check-circle {
  animation: splash-circle 0.5s ease forwards;
}

.splash-screen.tick .splash-check-mark {
  animation: splash-check-draw 0.35s ease 0.35s forwards;
}

.splash-screen.tick .splash-text { opacity: 0; }

@keyframes splash-circle { to { stroke-dashoffset: 0; } }
@keyframes splash-check-draw { to { stroke-dashoffset: 0; } }

.splash-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: opacity 0.2s ease;
}

/* ── Sign-in screen ───────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 20px;
  margin-bottom: 10px;
}

.auth-card p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 20px;
}

.btn-google-signin {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 22px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn-google-signin:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.auth-error {
  margin-top: 14px;
  font-size: 12px;
  color: var(--red);
}

/* ── Header ───────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 18px 16px;
  background: var(--header-grad);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(16, 163, 127, 0.4);
}

.app-title {
  font-size: 16px;
  line-height: 1.2;
}

.user-name {
  font-size: 12px;
  color: var(--text-2);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55vw;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-theme {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-refresh { display: block; }

.btn-theme:hover {
  border-color: var(--border-h);
  background: var(--bg-card-h);
}

/* Spins #refresh-btn's icon while a manual/auto refresh is in flight —
   the only feedback the button gives since the fetch itself is quick. */
@keyframes btn-refresh-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.btn-theme.is-refreshing .icon-refresh {
  animation: btn-refresh-spin 0.7s linear infinite;
}

.btn-signout {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-signout:hover {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.35);
  color: var(--red);
}

/* ── Appearance / Theme Picker Modal ─────────────────────────────────────── */
.theme-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.theme-picker-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.theme-picker-card {
  width: min(380px, 92vw);
  max-height: 80vh;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s ease;
}

.theme-picker-overlay.open .theme-picker-card {
  transform: scale(1) translateY(0);
}

.theme-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.theme-picker-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}

.theme-picker-close {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-picker-close:hover {
  color: var(--text-1);
  border-color: var(--border-h);
}

.theme-picker-list {
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}

.theme-row:hover {
  background: var(--bg-2);
}

.theme-row.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.theme-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border-h);
}

.theme-row-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.theme-row-check {
  color: var(--accent);
  font-weight: 700;
  width: 16px;
  text-align: center;
}

/* ── Range Nav ────────────────────────────────────────────────────────── */
.range-nav {
  display: flex;
  gap: 8px;
  padding: 16px 18px 8px;
  max-width: 820px;
  margin: 0 auto;
}

.range-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.range-btn:hover {
  border-color: var(--border-h);
  color: var(--text-1);
}

.range-btn.active {
  background: var(--btn-active-bg);
  border-color: var(--btn-active-border);
  color: var(--text-1);
}

/* ── Date Picker + XLSX Export (below the range nav) ─────────────────── */
.range-tools {
  display: flex;
  gap: 8px;
  padding: 0 18px 8px;
  max-width: 820px;
  margin: 0 auto;
}

.stats-date-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-2);
  color: var(--text-1);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.stats-date-input:hover {
  border-color: var(--border-h);
}

.btn-export-xlsx {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-export-xlsx:hover {
  border-color: var(--border-h);
  color: var(--text-1);
  background: var(--accent-dim, var(--bg-2));
}

/* ── Stat Cards ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  padding: 8px 18px 4px;
  max-width: 820px;
  margin: 0 auto;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s, transform 0.15s;
}

.stat-card:hover {
  border-color: var(--border-h);
  transform: translateY(-2px);
}

.stat-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.red-dot { background: var(--red); box-shadow: 0 0 10px var(--red-glow); }
.yellow-dot { background: var(--yellow); box-shadow: 0 0 10px var(--yellow-glow); }
.blue-dot { background: var(--blue); box-shadow: 0 0 10px var(--blue-glow); }
.green-dot { background: var(--green); box-shadow: 0 0 10px var(--green-glow); }
.brown-dot { background: var(--brown); box-shadow: 0 0 10px var(--brown-glow); }
.gray-dot { background: var(--gray); box-shadow: 0 0 10px var(--gray-glow); }

.total-dot {
  background: linear-gradient(135deg, var(--accent), #3ecfcf);
  width: auto;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-open .stat-value { color: var(--red); }
.stat-new .stat-value { color: var(--yellow); }
.stat-team .stat-value { color: var(--blue); }
.stat-compliance .stat-value { color: var(--green); }
.stat-escalation .stat-value { color: var(--brown); }
.stat-closed .stat-value { color: var(--gray); }
.stat-total .stat-value { color: var(--text-1); }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── Chart ────────────────────────────────────────────────────────────── */
.chart-section {
  padding: 10px 18px;
  max-width: 820px;
  margin: 0 auto;
}

.chart-view-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.chart-view-btn {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-view-btn:hover {
  border-color: var(--border-h);
  color: var(--text-1);
}

.chart-view-btn.active {
  background: var(--btn-active-bg);
  border-color: var(--btn-active-border);
  color: var(--text-1);
}

/* ── Team Leaderboard "Rank by" sub-toggle ──────────────────────────────────
   Deliberately not styled like the primary Week/Month toggle above it —
   smaller pills + a label + a left rule, so it reads as a secondary
   refinement of the selected period, not a second, visually-identical
   toggle that gets confused with the first. */
.lb-category-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -6px 0 14px 6px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

.lb-category-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.lb-cat-btn {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.lb-cat-btn:hover {
  color: var(--text-1);
  border-color: var(--border-h);
}

.lb-cat-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Bigger, standalone legend — the web dashboard has the room the popup
   doesn't, so these chips are sized for easy reading, not squeezed in. */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.payee-legend-row {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.payee-legend-row .legend-chip {
  padding: 6px 12px;
  font-size: 12px;
  cursor: default;
}

.payee-legend-row .legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.chart-wrap {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  height: 260px;
  position: relative;
}

/* ── Panels (Leaderboard / Tickets) ───────────────────────────────────── */
.panel-section {
  padding: 10px 18px;
  max-width: 820px;
  margin: 0 auto;
}

.panel-title {
  font-size: 14px;
  margin-bottom: 10px;
}

.leaderboard-period-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.leaderboard-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.leaderboard-row:last-child { border-bottom: none; }

.leaderboard-rank {
  width: 22px;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  flex-shrink: 0;
}

.leaderboard-row.rank-1 .leaderboard-rank { color: #f1c40f; }
.leaderboard-row.rank-2 .leaderboard-rank { color: #d0d0d8; }
.leaderboard-row.rank-3 .leaderboard-rank { color: #d98e3e; }

.leaderboard-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-2);
  object-fit: cover;
}

.leaderboard-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-total {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.leaderboard-empty, .tickets-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.tickets-scroll {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
}

.tickets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.tickets-table th {
  position: sticky;
  top: 0;
  background: var(--bg-card-h);
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-3);
  z-index: 1;
}

.tickets-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-1);
}

.tickets-table td.ticket-issue {
  color: var(--text-2);
  white-space: normal;
  min-width: 160px;
}

.footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 18px;
}

/* ── Chart Expand Button ─────────────────────────────────────────────────── */
.chart-expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.chart-expand-btn:hover {
  background: var(--bg-card-h);
  color: var(--text-1);
  border-color: var(--border-h);
}

/* ── Detailed Chart Modal ─────────────────────────────────────────────────── */
.detail-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.detail-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-modal {
  width: min(760px, 92vw);
  max-height: 88vh;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s ease;
}

.detail-modal-overlay.open .detail-modal {
  transform: scale(1) translateY(0);
}

.detail-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

.detail-modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.detail-range-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.detail-range-btn {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.detail-range-btn.active {
  background: var(--accent);
  color: #fff;
}

.detail-date-btn,
.detail-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-date-btn:hover,
.detail-close-btn:hover {
  color: var(--text-1);
  border-color: var(--border-h);
}

.detail-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 10px;
}

.detail-chart-wrap {
  flex: 1;
  min-height: 320px;
  padding: 10px 20px 22px;
  position: relative;
}

@media (max-width: 640px) {
  .detail-modal { width: 96vw; }
  .detail-modal-header { padding: 14px; }
  .detail-legend, .payee-legend-row { padding-left: 14px; padding-right: 14px; }
  .detail-chart-wrap { padding: 8px 14px 16px; min-height: 240px; }
}

/* ── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 14px 6px 12px; gap: 6px; }
  .stat-dot { width: 12px; height: 12px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 10px; }
  .legend-chip { padding: 6px 11px; font-size: 12px; }
  .chart-wrap { height: 220px; padding: 12px; }
}
