*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
}

.bg-background { background-color: hsl(var(--background)); }
.bg-card { background-color: hsl(var(--card)); }
.bg-primary { background-color: hsl(var(--primary)); }
.text-foreground { color: hsl(var(--foreground)); }
.text-card-foreground { color: hsl(var(--card-foreground)); }
.text-on-primary { color: hsl(var(--on-primary)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-destructive { color: hsl(var(--destructive)); }
.border-border { border: 1px solid hsl(var(--border)); }
.border-input { border: 1px solid hsl(var(--input)); }

.min-h-screen { min-height: 100vh; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.w-20 { width: 5rem; }
.h-20 { height: 5rem; }
.h-9 { height: 2.25rem; }
.p-6 { padding: 1.5rem; }
.pt-0 { padding-top: 0; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.gap-2 { gap: 0.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mb-4 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.leading-none { line-height: 1; }
.tracking-tight { letter-spacing: -0.025em; }
.rounded-md { border-radius: calc(var(--radius) - 2px); }
.rounded-xl { border-radius: 0.75rem; }
.shadow { box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); }

.ui-card {
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.ui-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.5rem;
}

.ui-card-content {
  padding: 1.5rem;
  padding-top: 0;
}

.ui-input {
  display: flex;
  width: 100%;
  height: 2.25rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.ui-input::placeholder {
  color: hsl(var(--muted-foreground));
}

.ui-input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.25rem;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background-color: hsl(var(--primary));
  color: hsl(var(--on-primary));
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.ui-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ui-label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
}

.ui-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ui-checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: hsl(var(--primary));
}

.ui-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid hsl(var(--primary));
  border-top-color: transparent;
  border-radius: 9999px;
  animation: ui-spin 0.8s linear infinite;
}

@keyframes ui-spin {
  to { transform: rotate(360deg); }
}

.auth-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hsl(var(--background));
}

.bg-sidebar { background-color: hsl(var(--sidebar-background)); }
.text-sidebar-foreground { color: hsl(var(--sidebar-foreground)); }
.border-sidebar { border-color: hsl(var(--sidebar-border)); }

.app-shell {
  display: flex;
  min-height: 100vh;
  background-color: hsl(var(--background));
}

.app-sidebar {
  width: 16rem;
  flex-shrink: 0;
  background-color: hsl(var(--sidebar-background));
  color: hsl(var(--sidebar-foreground));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease-linear;
}

.app-sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--sidebar-border));
}

.app-sidebar-nav {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  overflow-y: auto;
}

.app-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.app-nav-group:not(:has(.app-nav-link)) {
  display: none;
}

.app-nav-group-label {
  padding: 0.25rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--sidebar-foreground) / 0.55);
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  font-size: 0.875rem;
  transition: background-color 0.15s ease;
}

.app-nav-link:hover {
  background-color: hsl(var(--sidebar-accent) / 0.6);
}

.app-nav-link.active {
  background-color: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-foreground));
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.app-header {
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

@media (min-width: 768px) {
  .app-content {
    padding: 2rem;
  }
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.dashboard-filter-button {
  width: auto;
  padding: 0 1rem;
}

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

.dashboard-stat-card {
  height: 100%;
}

.dashboard-stat-label {
  margin: 0;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.dashboard-stat-value {
  margin: 0.35rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.dashboard-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .dashboard-charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.line-chart {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.line-chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.line-chart-empty {
  margin: 0;
  min-height: 8rem;
  display: flex;
  align-items: center;
}

.line-chart-svg {
  width: 100%;
  height: 10rem;
  display: block;
}

.line-chart-grid {
  stroke: hsl(var(--border));
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.line-chart-area {
  fill: hsl(var(--primary) / 0.12);
  stroke: none;
}

.line-chart-line {
  fill: none;
  stroke: hsl(var(--primary));
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.line-chart-dot {
  fill: hsl(var(--primary));
}

.line-chart-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 1rem 1.5rem;
}

.detail-grid dt {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.25rem;
}

.detail-grid dd {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.sidebar-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: 40;
}

.sidebar-overlay.open {
  display: block;
}

.ui-button-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.ui-button-outline:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ui-table th,
.ui-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid hsl(var(--border));
}

.ui-table th {
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.ui-table tbody tr:hover {
  background-color: hsl(var(--muted) / 0.3);
}

@media (max-width: 767px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 18rem;
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-trigger {
    display: inline-flex;
  }
}

@media (min-width: 768px) {
  .sidebar-trigger {
    display: none;
  }

  .sidebar-overlay {
    display: none !important;
  }
}
