/* =============================================================
   shadcn/ui — new-york v4 style · dashboard-01 layout
   ============================================================= */

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142.1 70.6% 45.3%;
  --warning: 38 92% 50%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --sidebar: 0 0% 98%;
  --sidebar-foreground: 240 5.3% 26.1%;
  --sidebar-border: 220 13% 91%;
  --sidebar-accent: 240 4.8% 95.9%;
  --sidebar-accent-foreground: 240 5.9% 10%;
  --radius: 0.625rem;
}

.dark {
  --background: 240 5% 6%;
  --foreground: 0 0% 98%;
  --card: 240 5% 8.5%;
  --card-foreground: 0 0% 98%;
  --popover: 240 5% 8.5%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 50%;
  --destructive-foreground: 0 0% 98%;
  --success: 142.1 70.6% 45.3%;
  --warning: 38 92% 50%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
  --sidebar: 240 5.2% 7.5%;
  --sidebar-foreground: 240 5% 78%;
  --sidebar-border: 240 3.7% 15.9%;
  --sidebar-accent: 240 3.7% 15.9%;
  --sidebar-accent-foreground: 0 0% 98%;
}

* { border-color: hsl(var(--border)); box-sizing: border-box; }
html, body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "rlig" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

/* ============== Layout: sidebar + main =============== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 16rem;
  flex-shrink: 0;
  background: hsl(var(--sidebar));
  color: hsl(var(--sidebar-foreground));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .2s ease, transform .2s ease;
  z-index: 30;
}
.sidebar.collapsed { width: 3.5rem; }
.sidebar.collapsed .sb-label,
.sidebar.collapsed .sb-group-label,
.sidebar.collapsed .sb-meta { display: none; }
.sidebar.collapsed .sb-link { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sb-brand-name { display: none; }
.sidebar.collapsed .sb-user-info { display: none; }

.sb-header { padding: 0.5rem; border-bottom: 1px solid hsl(var(--sidebar-border)); }
.sb-brand {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.5rem; border-radius: calc(var(--radius) - 2px);
  font-weight: 600; color: hsl(var(--sidebar-foreground));
}
.sb-brand-icon {
  display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem; flex-shrink: 0;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border-radius: calc(var(--radius) - 4px);
}
.sb-content { flex: 1; overflow-y: auto; padding: 0.5rem; }
.sb-group { padding: 0.5rem 0; }
.sb-group + .sb-group { border-top: 1px solid hsl(var(--sidebar-border)); margin-top: 0.5rem; }
.sb-group-label {
  font-size: 0.75rem; font-weight: 500;
  color: hsl(var(--sidebar-foreground) / 0.7);
  padding: 0.25rem 0.625rem; margin-bottom: 0.25rem;
}
.sb-link {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem; font-weight: 500;
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
  white-space: nowrap;
}
.sb-link:hover { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-accent-foreground)); }
.sb-link.active { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-accent-foreground)); }
.sb-footer { padding: 0.5rem; border-top: 1px solid hsl(var(--sidebar-border)); }
.sb-user {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem; border-radius: calc(var(--radius) - 2px);
}
.sb-user-info { min-width: 0; flex: 1; line-height: 1.2; }
.sb-user-name { font-size: 0.8125rem; font-weight: 500; color: hsl(var(--sidebar-foreground)); }
.sb-user-meta { font-size: 0.75rem; color: hsl(var(--sidebar-foreground) / 0.65); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Site header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  height: 3rem; padding: 0 1rem;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}
.site-title { font-size: 0.9375rem; font-weight: 600; }
.site-divider { width: 1px; height: 1rem; background: hsl(var(--border)); }

/* Page content */
.page { padding: 1.5rem 1rem; max-width: 1400px; width: 100%; margin: 0 auto; }
@media (min-width: 1024px) { .page { padding: 2rem 1.5rem; } }

/* Mobile sidebar drawer */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.6);
  z-index: 25; backdrop-filter: blur(2px);
}
@media (max-width: 767px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: 16rem; transform: translateX(-100%); }
  .sidebar.collapsed.open { transform: translateX(0); }
  body.sb-open .sidebar-backdrop { display: block; }
}

/* =================== Components =================== */

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem; font-weight: 500;
  transition: all .15s ease;
  padding: 0 0.875rem; height: 2.25rem; cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  background: transparent;
  color: inherit;
}
.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.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.7); }
.btn-outline { border-color: hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); }
.btn-outline:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-ghost { color: hsl(var(--foreground)); }
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }
.btn-sm { height: 2rem; padding: 0 0.625rem; font-size: 0.8125rem; }
.btn-xs { height: 1.75rem; padding: 0 0.5rem; font-size: 0.75rem; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-icon-sm { width: 2rem; height: 2rem; padding: 0; }

/* Card */
.card {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
}
.card-header { display: flex; flex-direction: column; gap: 0.25rem; padding: 1.25rem 1.5rem 0.75rem; }
.card-title { font-size: 1rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.card-description { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.card-content { padding: 0 1.5rem 1.25rem; }
.card-footer { display: flex; align-items: center; padding: 1.25rem 1.5rem; border-top: 1px solid hsl(var(--border)); }

/* Section card (dashboard-01 style with trend badge) */
.section-card {
  background: linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--card) / 0.6) 100%);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  position: relative;
}
.section-card-desc { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.section-card-value {
  font-size: 1.875rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1;
  font-feature-settings: "tnum" 1;
}
.section-card-badge {
  position: absolute; top: 1.25rem; right: 1.5rem;
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem; font-weight: 500;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}
.section-card-footer { margin-top: auto; padding-top: 0.75rem; }
.section-card-footer-title {
  font-size: 0.8125rem; font-weight: 500; line-height: 1.3;
  display: flex; align-items: center; gap: 0.375rem;
}
.section-card-footer-desc { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }

/* Input */
.input {
  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.5rem 0.75rem; font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus-visible { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15); }
.input:disabled { cursor: not-allowed; opacity: 0.5; }
textarea.input { height: auto; min-height: 5rem; resize: vertical; line-height: 1.5; }
select.input {
  padding-right: 2rem; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23a1a1aa'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.39a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 1.25rem;
}

/* Label */
.label { font-size: 0.875rem; font-weight: 500; line-height: 1; display: block; margin-bottom: 0.5rem; color: hsl(var(--foreground)); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; font-size: 0.6875rem; font-weight: 500;
  border-radius: 9999px; border: 1px solid transparent;
  line-height: 1.1;
}
.badge-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { color: hsl(var(--foreground)); border-color: hsl(var(--border)); background: hsl(var(--background)); }
.badge-success { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.25); }
.badge-destructive { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.3); }
.badge-warning { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); border-color: hsl(var(--warning) / 0.3); }
.dark .badge-destructive { color: hsl(0 84% 70%); }
.dark .badge-warning { color: hsl(38 92% 65%); }
.text-success { color: hsl(var(--success)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-warning { color: hsl(var(--warning)); }
.dark .text-destructive { color: hsl(0 84% 70%); }
.dark .text-warning { color: hsl(38 92% 65%); }

/* Alert */
.alert {
  position: relative; width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  padding: 0.875rem 1rem;
  display: flex; align-items: flex-start; gap: 0.625rem;
  font-size: 0.875rem; background: hsl(var(--card));
}
.alert-destructive { border-color: hsl(var(--destructive) / 0.5); background: hsl(var(--destructive) / 0.08); color: hsl(var(--destructive)); }
.alert-warning { border-color: hsl(var(--warning) / 0.5); background: hsl(var(--warning) / 0.08); color: hsl(var(--warning)); }
.dark .alert-destructive { color: hsl(0 84% 75%); }
.dark .alert-warning { color: hsl(38 92% 65%); }

/* Tabs (segmented control) */
.tabs {
  display: inline-flex; align-items: center;
  background: hsl(var(--secondary));
  border-radius: calc(var(--radius) - 2px);
  padding: 0.1875rem;
  gap: 0.125rem;
}
.tab {
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem; font-weight: 500;
  border-radius: calc(var(--radius) - 4px);
  color: hsl(var(--muted-foreground));
  cursor: pointer; border: none; background: transparent;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.tab:hover { color: hsl(var(--foreground)); }
.tab.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); }

/* Table */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; caption-side: bottom; font-size: 0.875rem; border-collapse: collapse; }
.table thead { background: hsl(var(--muted) / 0.4); }
.table thead tr { border-bottom: 1px solid hsl(var(--border)); }
.table th {
  height: 2.5rem; padding: 0 1rem; text-align: left; vertical-align: middle;
  font-weight: 500; color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}
.table td { padding: 0.875rem 1rem; vertical-align: middle; }
.table tbody tr { border-bottom: 1px solid hsl(var(--border)); transition: background .12s; }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: hsl(var(--muted) / 0.35); }

/* Dialog */
.dialog-overlay {
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.7);
  z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 1rem; backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
.dialog-content {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius); padding: 1.5rem; width: 100%;
  max-width: 28rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.4);
  animation: slideIn .2s ease;
}
.dialog-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 0.25rem; }
.dialog-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-bottom: 1rem; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px) scale(0.99) } to { opacity: 1; transform: none } }

/* Checkbox */
.checkbox {
  appearance: none; width: 1rem; height: 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.25rem; background: hsl(var(--background));
  cursor: pointer; flex-shrink: 0;
  display: inline-grid; place-content: center;
  transition: background .15s, border-color .15s;
}
.checkbox:checked { background: hsl(var(--primary)); border-color: hsl(var(--primary)); }
.checkbox:checked::after {
  content: ''; width: 0.625rem; height: 0.625rem;
  background: hsl(var(--primary-foreground));
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}
.checkbox:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }

/* Avatar */
.avatar {
  display: grid; place-items: center; flex-shrink: 0;
  border-radius: 9999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-weight: 600;
}
.avatar-sm { width: 1.5rem; height: 1.5rem; font-size: 0.6875rem; }
.avatar-md { width: 2rem; height: 2rem; font-size: 0.75rem; }
.avatar-lg { width: 2.5rem; height: 2.5rem; font-size: 0.875rem; }

/* Skeleton / progress */
.progress { height: 0.375rem; width: 100%; background: hsl(var(--secondary)); border-radius: 9999px; overflow: hidden; }
.progress > div { height: 100%; background: hsl(var(--primary)); border-radius: 9999px; transition: width .3s; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.4); }

/* Icon sizes */
.icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.icon-sm { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }
.icon-lg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.icon-xl { width: 1.5rem; height: 1.5rem; flex-shrink: 0; }
