* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.nav-active { background: rgba(99,102,241,0.15); color: #818cf8; }
.nav-active svg { color: #818cf8; }
input:focus { outline: none; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { transition: opacity 0.3s; }
.table-row:hover td { background: #f8fafc; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* ── Mobile responsive helpers ────────────────────────────── */
@media (max-width: 767px) {
  /* Keep toast away from the bottom on mobile */
  #toast { bottom: 1rem; right: 1rem; left: 1rem; max-width: none; }

  /* Sidebar z-index above overlay */
  #sidebar { z-index: 40; }
}

/* ── Tooltip system ───────────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
  max-width: 220px;
  white-space: normal;
  text-align: center;
}
[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
[data-tip]:hover::after,
[data-tip]:hover::before { opacity: 1; }

/* ── Modern dashboard ─────────────────────────────────── */
.dashboard-hero {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 8%, rgba(96, 165, 250, 0.45), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(217, 119, 6, 0.30), transparent 28%),
    linear-gradient(135deg, #0f172a 0%, #1e3a8a 52%, #1e40af 100%);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}
.dashboard-hero::after {
  content: '';
  position: absolute;
  inset: auto -10% -45% 30%;
  height: 240px;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(48px);
  transform: rotate(-8deg);
}
.dash-hero-btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  color: #e0e7ff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.dash-hero-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.32);
}
.dash-hero-btn-primary {
  color: #0f172a;
  background: #ffffff;
  border-color: #ffffff;
}
.dash-hero-stat,
.dash-hero-skeleton {
  min-height: 92px;
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
}
.dash-hero-skeleton { animation: pulse 1.5s ease-in-out infinite; }
.dashboard-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.07);
}
.dashboard-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid #f1f5f9;
}
.dashboard-eyebrow {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.dashboard-title {
  color: #0f172a;
  font-size: 18px;
  font-weight: 800;
}
.dashboard-link-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 12px;
  font-weight: 800;
  transition: background 0.18s ease, color 0.18s ease;
}
.dashboard-link-btn:hover { background: #dbeafe; color: #1e40af; }
.dashboard-kpi {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-height: 132px;
  padding: 18px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.07);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.dashboard-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--kpi-border, #bfdbfe);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.11);
}
.dashboard-kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 15px;
  color: var(--kpi-fg, #2563eb);
  background: var(--kpi-bg, #eff6ff);
}
.dashboard-kpi-label {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.dashboard-kpi-value {
  display: block;
  color: #0f172a;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 8px;
}
.dashboard-kpi-sub {
  display: block;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 7px;
}
.dashboard-kpi-indigo { --kpi-bg: #eef2ff; --kpi-fg: #4f46e5; --kpi-border: #c7d2fe; }
.dashboard-kpi-emerald { --kpi-bg: #ecfdf5; --kpi-fg: #059669; --kpi-border: #a7f3d0; }
.dashboard-kpi-blue { --kpi-bg: #eff6ff; --kpi-fg: #2563eb; --kpi-border: #bfdbfe; }
.dashboard-kpi-violet { --kpi-bg: #f5f3ff; --kpi-fg: #7c3aed; --kpi-border: #ddd6fe; }
.dashboard-kpi-amber { --kpi-bg: #fffbeb; --kpi-fg: #d97706; --kpi-border: #fde68a; }
.dashboard-kpi-red { --kpi-bg: #fef2f2; --kpi-fg: #dc2626; --kpi-border: #fecaca; }
.dashboard-kpi-slate { --kpi-bg: #f8fafc; --kpi-fg: #475569; --kpi-border: #cbd5e1; }
.dashboard-kpi-sky { --kpi-bg: #f0f9ff; --kpi-fg: #0284c7; --kpi-border: #bae6fd; }
.dash-priority-card {
  text-align: left;
  min-height: 150px;
  border-radius: 20px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.dash-priority-card:hover { transform: translateY(-1px); background: #ffffff; }
.dash-status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  margin-top: 4px;
  background: var(--dot, #10b981);
  box-shadow: 0 0 0 5px var(--dot-ring, rgba(16, 185, 129, 0.14));
}
.dash-priority-good { --dot: #10b981; --dot-ring: rgba(16, 185, 129, 0.14); }
.dash-priority-warn { --dot: #d97706; --dot-ring: rgba(217, 119, 6, 0.16); border-color: #fde68a; background: #fffbeb; }
.dash-priority-info { --dot: #2563eb; --dot-ring: rgba(37, 99, 235, 0.14); border-color: #bfdbfe; background: #eff6ff; }
.dash-bar-wrap {
  flex: 1;
  min-width: 24px;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  flex-direction: column;
  gap: 8px;
}
.dash-bar {
  width: 100%;
  min-height: 8px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
}
.dash-bar-wrap span {
  color: #94a3b8;
  font-size: 10px;
  text-align: center;
}
.dash-mini-stat,
.dash-live-cell {
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  padding: 12px;
}
.dash-mini-stat span,
.dash-live-cell span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}
.dash-mini-stat strong,
.dash-live-cell strong {
  display: block;
  color: #0f172a;
  font-size: 18px;
  font-weight: 900;
  margin-top: 3px;
}
.dash-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  color: #3730a3;
  background: linear-gradient(135deg, #eef2ff, #dbeafe);
  font-size: 13px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.dashboard-skeleton-line {
  height: 120px;
  border-radius: 20px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 220% 100%;
  animation: dash-shimmer 1.2s ease-in-out infinite;
}
@keyframes dash-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard-kpi,
  .dash-priority-card,
  .dash-hero-btn,
  .dashboard-link-btn {
    transition: none;
  }
  .dashboard-kpi:hover,
  .dash-priority-card:hover,
  .dash-hero-btn:hover {
    transform: none;
  }
  .dashboard-skeleton-line,
  .dash-hero-skeleton {
    animation: none;
  }
}
@media (max-width: 640px) {
  .dashboard-hero { padding: 22px; border-radius: 22px; }
  .dashboard-section-head { align-items: flex-start; flex-direction: column; }
}
