/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: hsl(var(--sidebar-bg));
  color: hsl(var(--sidebar-fg));
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
}

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

.sidebar-brand h1 {
  font-size: 1.125rem;
  color: hsl(var(--sidebar-accent-fg));
}

.sidebar-brand p {
  font-size: 0.75rem;
  color: hsl(var(--sidebar-muted));
  margin-top: 0.125rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 1rem;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--sidebar-muted));
  padding: 0.5rem 0.75rem;
}

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

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

.nav-link.active {
  background: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-fg));
  font-weight: 500;
}

.nav-link svg {
  width: 1rem;
  height: 1rem;
  opacity: 0.7;
}

.nav-link.active svg,
.nav-link:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid hsl(var(--sidebar-accent));
  font-size: 0.75rem;
  color: hsl(var(--sidebar-muted));
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 3.5rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: hsl(var(--background));
  position: sticky;
  top: 0;
  z-index: 30;
}

.page {
  flex: 1;
  padding: 1.5rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header p {
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* Card */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card-header {
  padding: 1.25rem 1.5rem 0;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.card-content {
  padding: 1.25rem 1.5rem;
}

.card-footer {
  padding: 0 1.5rem 1.25rem;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
  background: hsl(var(--secondary) / 0.8);
}

.btn-outline {
  background: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background: hsl(var(--accent));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover {
  background: hsl(var(--accent));
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.badge-default {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-success {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
  border-color: hsl(var(--success) / 0.2);
}

.badge-warning {
  background: hsl(var(--warning) / 0.1);
  color: hsl(var(--warning));
  border-color: hsl(var(--warning) / 0.2);
}

.badge-destructive {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.2);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

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

thead tr {
  border-bottom: 1px solid hsl(var(--border));
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

tbody tr:hover {
  background: hsl(var(--muted) / 0.5);
}

/* Input */
.input,
.select {
  display: flex;
  height: 2.25rem;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  padding: 0 0.75rem;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.textarea {
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

.label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  display: block;
}

.form-group {
  margin-bottom: 1rem;
}

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Stat card */
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.stat-card .stat-change {
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

.stat-change.positive { color: hsl(var(--success)); }
.stat-change.negative { color: hsl(var(--destructive)); }

/* Progress */
.progress {
  height: 0.5rem;
  background: hsl(var(--secondary));
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: hsl(var(--primary));
  border-radius: 9999px;
  transition: width 0.3s;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: hsl(var(--foreground));
}

.tab.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--primary));
  font-weight: 500;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: hsl(var(--muted-foreground));
}

.empty-state svg {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  opacity: 0.4;
}

/* Avatar */
.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Separator */
.separator {
  height: 1px;
  background: hsl(var(--border));
  margin: 1rem 0;
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }

/* Alert */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid hsl(var(--border));
}

.alert-info {
  background: hsl(214 95% 93%);
  border-color: hsl(214 95% 85%);
  color: hsl(214 50% 30%);
}

.alert-warning {
  background: hsl(var(--warning) / 0.1);
  border-color: hsl(var(--warning) / 0.3);
  color: hsl(38 70% 30%);
}
