:root {
  --background: 210 40% 98%;
  --foreground: 222 47% 11%;
  --primary: 221 83% 53%;
  --secondary: 262 83% 58%;
  --muted: 215 20% 92%;
  --destructive: 0 84% 60%;
  --border: 214 20% 84%;
  --card: 0 0% 100%;
  --shadow-sm: 0 1px 2px hsla(222, 47%, 11%, 0.08);
  --shadow-md: 0 10px 30px hsla(221, 39%, 11%, 0.10);
  --shadow-lg: 0 20px 50px hsla(221, 39%, 11%, 0.16);
  --transition-fast: 160ms ease;
  --transition-smooth: 280ms ease;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

.dark {
  --background: 222 47% 8%;
  --foreground: 210 40% 96%;
  --primary: 217 91% 60%;
  --secondary: 269 97% 75%;
  --muted: 217 25% 17%;
  --destructive: 0 70% 55%;
  --border: 217 19% 24%;
  --card: 222 39% 11%;
  --shadow-sm: 0 1px 2px hsla(0, 0%, 0%, 0.30);
  --shadow-md: 0 10px 30px hsla(0, 0%, 0%, 0.35);
  --shadow-lg: 0 20px 60px hsla(0, 0%, 0%, 0.45);
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* Safe-area helpers */
.appbar-safe { padding-top: calc(0.75rem + env(safe-area-inset-top)); }

.app-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, hsla(221, 83%, 53%, 0.12), transparent 25%),
    radial-gradient(circle at bottom left, hsla(262, 83%, 58%, 0.10), transparent 20%),
    hsl(var(--background));
}

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-hover {
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-fast);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: hsla(221, 83%, 53%, 0.35);
}

.glass {
  background: hsla(0, 0%, 100%, 0.70);
  backdrop-filter: blur(14px);
}

.dark .glass {
  background: hsla(222, 39%, 11%, 0.72);
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 4px hsla(221, 83%, 53%, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: hsl(var(--primary)); color: white; box-shadow: var(--shadow-sm); }
.btn-secondary { background: hsla(262, 83%, 58%, 0.12); color: hsl(var(--secondary)); border-color: hsla(262, 83%, 58%, 0.16); }
.btn-muted { background: hsla(215, 20%, 92%, 0.6); color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.btn-danger { background: hsla(0, 84%, 60%, 0.12); color: hsl(var(--destructive)); border-color: hsla(0, 84%, 60%, 0.16); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
}

.skeleton {
  background: linear-gradient(90deg, hsla(215,20%,92%,0.7), hsla(215,20%,92%,0.95), hsla(215,20%,92%,0.7));
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}

.dark .skeleton {
  background: linear-gradient(90deg, hsla(217,25%,17%,0.7), hsla(217,25%,17%,1), hsla(217,25%,17%,0.7));
  background-size: 200% 100%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.scrollbar-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: hsla(221, 20%, 50%, 0.25); border-radius: 999px; }

.chart-bar {
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, hsla(221, 83%, 53%, 0.95), hsla(262, 83%, 58%, 0.85));
}

.ring-chart {
  width: 140px;
  height: 140px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: conic-gradient(hsla(221, 83%, 53%, 1) 0 38%, hsla(262, 83%, 58%, 1) 38% 67%, hsla(160, 84%, 39%, 1) 67% 100%);
}

.ring-chart::after {
  content: '';
  width: 88px;
  height: 88px;
  border-radius: 999px;
  background: hsl(var(--card));
  box-shadow: inset 0 0 0 1px hsl(var(--border));
}

.grid-auto {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.fade-in {
  animation: fadeIn 280ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sidebar-link.active {
  background: hsla(221, 83%, 53%, 0.12);
  color: hsl(var(--primary));
  border-color: hsla(221, 83%, 53%, 0.18);
}

.table-wrap { overflow-x: auto; }

.install-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(6.9rem + env(safe-area-inset-bottom));
  z-index: 34;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: 18px;
  background: hsla(0, 0%, 100%, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.dark .install-banner {
  background: hsla(222, 39%, 11%, 0.92);
}

.mobile-tabbar {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: 22px;
  background: hsla(0, 0%, 100%, 0.88);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.dark .mobile-tabbar {
  background: hsla(222, 39%, 11%, 0.9);
}

.mobile-tab {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-radius: 16px;
  padding: 0.6rem 0.3rem;
  color: hsl(var(--foreground));
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.mobile-tab span {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-tab.active {
  background: hsla(221, 83%, 53%, 0.12);
  color: hsl(var(--primary));
}

@media (max-width: 767px) {
  .mobile-bottom-space { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
  /* reduce hover lift on touch */
  .card-hover:hover { transform: none; }
}

@media (min-width: 768px) {
  .mobile-tabbar { display: none; }
  .install-banner { display: none; }
}
