/* shadcn-inspired design system with warm school accent */
:root {
  --background: 0 0% 100%;
  --foreground: 30 15% 12%;
  --card: 0 0% 100%;
  --card-foreground: 30 15% 12%;
  --popover: 0 0% 100%;
  --popover-foreground: 30 15% 12%;
  --primary: 30 60% 50%;
  --primary-foreground: 30 30% 98%;
  --secondary: 30 20% 96%;
  --secondary-foreground: 30 15% 18%;
  --muted: 30 12% 95%;
  --muted-foreground: 30 8% 45%;
  --accent: 30 25% 94%;
  --accent-foreground: 30 15% 18%;
  --destructive: 0 72% 50%;
  --destructive-foreground: 0 0% 98%;
  --success: 150 55% 38%;
  --success-foreground: 0 0% 98%;
  --warning: 38 92% 50%;
  --warning-foreground: 30 15% 12%;
  --border: 30 15% 90%;
  --input: 30 15% 90%;
  --ring: 30 60% 50%;
  --radius: 0.5rem;

  --row-height: 44px;
  --card-padding: 20px;

  /* Accent (overridable via tweaks) */
  --accent-h: 30;
  --accent-s: 60%;
  --accent-l: 50%;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(30 20% 98%);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.tabular { font-variant-numeric: tabular-nums; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: hsl(30 25% 99%);
  border-right: 1px solid hsl(var(--border));
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 16px;
}
.sidebar-brand-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.sidebar-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
  color: white;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 13px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.sidebar-section {
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: hsl(var(--foreground));
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: hsl(var(--accent)); }
.nav-item.active {
  background: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.1);
  color: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 10%));
}
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .icon { opacity: 1; }
.nav-item-tail {
  margin-left: auto;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}

/* Main content */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(0 0% 100% / 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title {
  font-weight: 600;
  font-size: 15px;
}
.topbar-crumb {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}
.topbar-spacer { flex: 1; }

.content {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
}
.content h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.content .lede {
  color: hsl(var(--muted-foreground));
  margin: 0 0 24px;
  font-size: 14px;
}

/* Card */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}
.card-desc {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  margin: 2px 0 0;
}
.card-body { padding: 0 20px 20px; }
.card-body.flush { padding: 0; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
  color: white;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 6%)); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.btn.secondary:hover { background: hsl(var(--accent)); }
.btn.outline {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.btn.outline:hover { background: hsl(var(--accent)); }
.btn.ghost {
  background: transparent;
  color: hsl(var(--foreground));
}
.btn.ghost:hover { background: hsl(var(--accent)); }
.btn.destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn.destructive:hover { background: hsl(0 72% 44%); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn .icon { width: 14px; height: 14px; }

/* Input */
.input, .select, .textarea {
  display: inline-flex;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid hsl(var(--input));
  border-radius: 6px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 13.5px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.textarea { padding: 8px 12px; height: auto; min-height: 70px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
  box-shadow: 0 0 0 3px hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.15);
}
.input::placeholder { color: hsl(var(--muted-foreground)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: hsl(var(--foreground));
}
.field-help {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.neutral { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border-color: hsl(var(--border)); }
.badge.success { background: hsl(150 50% 94%); color: hsl(150 60% 26%); border-color: hsl(150 35% 80%); }
.badge.warning { background: hsl(38 95% 94%); color: hsl(28 80% 32%); border-color: hsl(38 80% 80%); }
.badge.destructive { background: hsl(0 80% 96%); color: hsl(0 72% 38%); border-color: hsl(0 60% 86%); }
.badge.accent { background: hsl(var(--accent-h) var(--accent-s) 95%); color: hsl(var(--accent-h) var(--accent-s) 30%); border-color: hsl(var(--accent-h) var(--accent-s) 85%); }
.badge.dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Table */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: hsl(var(--muted-foreground));
  padding: 10px 16px;
  background: hsl(30 20% 98%);
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
  height: var(--row-height);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 80ms; }
.table tbody tr:hover { background: hsl(var(--accent) / 0.5); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; }

/* Tabs */
.tabs {
  display: inline-flex;
  padding: 3px;
  background: hsl(var(--muted));
  border-radius: 7px;
  gap: 2px;
}
.tab {
  padding: 6px 14px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 500;
  transition: background 120ms, color 120ms;
}
.tab.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.tab:hover:not(.active) { color: hsl(var(--foreground)); }

/* Stat card */
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat {
  padding: 18px 20px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
.stat-label {
  font-size: 12.5px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-delta {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  margin-top: 4px;
}
.stat-delta.up { color: hsl(var(--success)); }
.stat-delta.down { color: hsl(var(--destructive)); }

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* Dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 8, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 150ms ease;
}
.dialog {
  background: hsl(var(--card));
  border-radius: 12px;
  border: 1px solid hsl(var(--border));
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,0.18);
  animation: pop-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dialog-header {
  padding: 22px 24px 14px;
}
.dialog-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.dialog-desc {
  font-size: 13.5px;
  color: hsl(var(--muted-foreground));
  margin: 0;
}
.dialog-body { padding: 6px 24px 18px; }
.dialog-footer {
  padding: 16px 24px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: hsl(30 20% 98%);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: hsl(30 15% 12%);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.success { background: hsl(150 60% 26%); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Layout helpers */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.muted { color: hsl(var(--muted-foreground)); }
.tnum { font-variant-numeric: tabular-nums; }
.text-sm { font-size: 12.5px; } .text-lg { font-size: 16px; }

/* Progress bar */
.progress {
  width: 100%;
  height: 6px;
  background: hsl(var(--muted));
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
  transition: width 240ms ease;
}
.progress-bar.success { background: hsl(var(--success)); }

/* Density variants */
.density-compact { --row-height: 36px; --card-padding: 16px; }
.density-compact .table td { padding: 7px 14px; }
.density-compact .table th { padding: 7px 14px; }
.density-compact .card-header { padding: 14px 16px 10px; }
.density-compact .card-body { padding: 0 16px 16px; }
.density-compact .stat { padding: 14px 16px; }

.density-spacious { --row-height: 56px; --card-padding: 24px; }
.density-spacious .table td { padding: 16px 20px; }
.density-spacious .table th { padding: 12px 20px; }
.density-spacious .card-header { padding: 22px 24px 16px; }
.density-spacious .card-body { padding: 0 24px 24px; }
.density-spacious .stat { padding: 22px 24px; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(30 10% 80%); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: hsl(30 10% 65%); border: 2px solid transparent; background-clip: content-box; }

/* Receipt-style box */
.receipt {
  background: hsl(30 25% 99%);
  border: 1px dashed hsl(var(--border));
  border-radius: 8px;
  padding: 18px 20px;
}
.receipt-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13.5px;
}
.receipt-line.total {
  border-top: 1px solid hsl(var(--border));
  margin-top: 6px;
  padding-top: 12px;
  font-weight: 600;
  font-size: 15px;
}
