/* ── 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: background-color 150ms, color 150ms, border-color 150ms, box-shadow 150ms;
    cursor: pointer; user-select: none;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }
.btn-default { height: 2.25rem; padding: 0 1rem; }
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-lg { height: 2.5rem; padding: 0 2rem; }
.btn-icon { height: 2.25rem; width: 2.25rem; padding: 0; }
.btn-icon-sm { height: 2rem; width: 2rem; padding: 0; }

.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.btn-primary:hover:not(:disabled) { background: hsl(var(--primary) / 0.9); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover:not(:disabled) { background: hsl(var(--secondary) / 0.8); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.btn-destructive:hover:not(:disabled) { background: hsl(var(--destructive) / 0.9); }
.btn-outline { background: hsl(var(--background)); color: hsl(var(--foreground)); border: 1px solid hsl(var(--border)); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-link { background: transparent; color: hsl(var(--primary)); text-underline-offset: 4px; }
.btn-link:hover { text-decoration: underline; }

/* ── Badge ───────────────────────────────────────────────────────────────────*/
.badge { display: inline-flex; align-items: center; gap: 0.25rem; border-radius: 9999px; padding: 0.125rem 0.625rem; font-size: 0.75rem; font-weight: 500; line-height: 1rem; white-space: nowrap; transition: background-color 150ms; }
.badge svg { width: 0.75rem; height: 0.75rem; }
.badge-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.badge-outline { border: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); }
.badge-success { background: hsl(142 71% 45% / 0.1); color: hsl(142 71% 32%); border: 1px solid hsl(142 71% 45% / 0.2); }
.badge-warning { background: hsl(38 92% 50% / 0.1); color: hsl(38 92% 35%); border: 1px solid hsl(38 92% 50% / 0.2); }
.badge-error { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 45%); border: 1px solid hsl(0 84% 60% / 0.2); }
.badge-info { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary) / 0.9); border: 1px solid hsl(var(--primary) / 0.2); }
.badge-muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* ── Card ────────────────────────────────────────────────────────────────────*/
.card { border-radius: var(--radius); border: 1px solid hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--card-foreground)); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.card-header { display: flex; flex-direction: column; gap: 0.375rem; padding: 1.5rem; }
.card-header-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; }
.card-title { font-size: 1rem; font-weight: 600; line-height: 1.5; letter-spacing: -0.01em; color: hsl(var(--foreground)); }
.card-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); line-height: 1.5; }
.card-content { padding: 1.5rem; padding-top: 0; }
.card-content-full { padding: 0; }
.card-footer { display: flex; align-items: center; padding: 1.5rem; padding-top: 0; }

/* ── Input ───────────────────────────────────────────────────────────────────*/
.input { display: flex; width: 100%; height: 2.25rem; padding: 0 0.75rem; border-radius: calc(var(--radius) - 2px); border: 1px solid hsl(var(--input)); background: hsl(var(--background)); color: hsl(var(--foreground)); font-size: 0.875rem; line-height: 1.25rem; transition: border-color 150ms, box-shadow 150ms; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }
textarea.input { height: auto; min-height: 5rem; padding: 0.5rem 0.75rem; resize: vertical; line-height: 1.5; }

/* ── Label ───────────────────────────────────────────────────────────────────*/
.label { display: inline-block; font-size: 0.875rem; font-weight: 500; line-height: 1; color: hsl(var(--foreground)); }

/* ── Checkbox ────────────────────────────────────────────────────────────────*/
.checkbox { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; }
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox-indicator { display: inline-flex; align-items: center; justify-content: center; width: 1rem; height: 1rem; flex-shrink: 0; border: 1px solid hsl(var(--primary)); border-radius: calc(var(--radius) - 4px); background: hsl(var(--background)); color: hsl(var(--primary-foreground)); transition: background-color 100ms, border-color 100ms; }
.checkbox input:focus-visible + .checkbox-indicator { box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }
.checkbox input:checked + .checkbox-indicator, .checkbox input:indeterminate + .checkbox-indicator { background: hsl(var(--primary)); }
.checkbox input:checked + .checkbox-indicator::after { content: ''; width: 5px; height: 9px; border: solid hsl(var(--primary-foreground)); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px); }
.checkbox input:indeterminate + .checkbox-indicator::after { content: ''; width: 8px; height: 2px; background: hsl(var(--primary-foreground)); }
.checkbox-label { font-size: 0.875rem; line-height: 1; }

/* ── Select ──────────────────────────────────────────────────────────────────*/
.select { display: flex; align-items: center; width: 100%; height: 2.25rem; padding: 0 2rem 0 0.75rem; border-radius: calc(var(--radius) - 2px); border: 1px solid hsl(var(--input)); background: hsl(var(--background)); color: hsl(var(--foreground)); font-size: 0.875rem; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 0.75rem center; cursor: pointer; }
.select:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15); }
.select-sm { height: 1.875rem; font-size: 0.8125rem; padding-left: 0.625rem; padding-right: 1.75rem; }

/* ── Separator ───────────────────────────────────────────────────────────────*/
.separator { background: hsl(var(--border)); height: 1px; width: 100%; border: none; }

/* ── Alert ───────────────────────────────────────────────────────────────────*/
.alert { position: relative; display: grid; grid-template-columns: 1.25rem 1fr; gap: 0.75rem; padding: 1rem; border-radius: var(--radius); border: 1px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); font-size: 0.875rem; }
.alert > svg { width: 1rem; height: 1rem; color: hsl(var(--foreground)); }
.alert-title { font-weight: 500; margin-bottom: 0.25rem; line-height: 1.25; }
.alert-description { color: hsl(var(--muted-foreground)); line-height: 1.5; }
.alert-destructive { border-color: hsl(var(--destructive) / 0.5); color: hsl(var(--destructive)); background: hsl(var(--destructive) / 0.05); }
.alert-destructive > svg { color: hsl(var(--destructive)); }
.alert-destructive .alert-description { color: hsl(var(--destructive) / 0.9); }
.alert-success { border-color: hsl(142 71% 45% / 0.5); background: hsl(142 71% 45% / 0.05); color: hsl(142 71% 32%); }
.alert-success > svg { color: hsl(142 71% 45%); }
.alert-warning { border-color: hsl(38 92% 50% / 0.5); background: hsl(38 92% 50% / 0.05); color: hsl(38 92% 30%); }
.alert-warning > svg { color: hsl(38 92% 50%); }
.alert-warning .alert-description { color: hsl(38 92% 35%); }

/* ── Progress ────────────────────────────────────────────────────────────────*/
.progress { position: relative; height: 0.5rem; width: 100%; overflow: hidden; border-radius: 9999px; background: hsl(var(--secondary)); }
.progress-indicator { height: 100%; width: 0; background: hsl(var(--primary)); transition: width 200ms ease; border-radius: 9999px; }

/* ── Skeleton ────────────────────────────────────────────────────────────────*/
.skeleton { background: hsl(var(--muted)); border-radius: calc(var(--radius) - 2px); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Tabs ────────────────────────────────────────────────────────────────────*/
.tabs-list { display: inline-flex; align-items: center; justify-content: center; height: 2.5rem; padding: 0.25rem; border-radius: var(--radius); background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); gap: 0.25rem; flex-wrap: wrap; }
.tabs-trigger { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; padding: 0.375rem 0.75rem; border-radius: calc(var(--radius) - 2px); font-size: 0.8125rem; font-weight: 500; white-space: nowrap; transition: all 150ms; color: hsl(var(--muted-foreground)); }
.tabs-trigger:hover { color: hsl(var(--foreground)); }
.tabs-trigger[data-state="active"] { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.tabs-trigger svg { width: 0.875rem; height: 0.875rem; }

/* ── Table ───────────────────────────────────────────────────────────────────*/
.table-wrapper { position: relative; width: 100%; overflow-x: auto; }
.table { width: 100%; caption-side: bottom; font-size: 0.875rem; border-collapse: collapse; }
.table thead { border-bottom: 1px solid hsl(var(--border)); }
.table tr { border-bottom: 1px solid hsl(var(--border)); transition: background-color 100ms; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: hsl(var(--muted) / 0.5); }
.table tbody tr[data-state="selected"] { background: hsl(var(--primary) / 0.04); }
.table th { height: 2.75rem; padding: 0 1rem; text-align: left; font-weight: 500; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); white-space: nowrap; vertical-align: middle; }
.table td { padding: 0.875rem 1rem; vertical-align: middle; color: hsl(var(--foreground)); }
.table-cell-actions { text-align: right; white-space: nowrap; }

/* ── Avatar ──────────────────────────────────────────────────────────────────*/
.avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; border-radius: 9999px; background: hsl(var(--muted)); font-size: 0.8125rem; font-weight: 500; user-select: none; }
.avatar-sm { width: 2rem; height: 2rem; font-size: 0.75rem; }
.avatar-md { width: 2.25rem; height: 2.25rem; font-size: 0.8125rem; }
.avatar-lg { width: 2.5rem; height: 2.5rem; font-size: 0.875rem; }
.avatar-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }

/* ── Dropdown ────────────────────────────────────────────────────────────────*/
.dropdown { position: relative; display: inline-block; }
.dropdown-trigger { display: inline-flex; }
.dropdown-content { position: absolute; z-index: 50; min-width: 12rem; padding: 0.25rem; margin-top: 0.5rem; border-radius: calc(var(--radius) - 2px); border: 1px solid hsl(var(--border)); background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); box-shadow: 0 10px 38px -10px rgb(0 0 0 / 0.15), 0 10px 20px -15px rgb(0 0 0 / 0.1); opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity 150ms, transform 150ms; }
.dropdown-content-right { right: 0; }
.dropdown[data-state="open"] .dropdown-content { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dropdown-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.5rem; border-radius: calc(var(--radius) - 4px); font-size: 0.875rem; color: hsl(var(--foreground)); cursor: pointer; transition: background-color 100ms; width: 100%; text-align: left; }
.dropdown-item:hover, .dropdown-item:focus { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); outline: none; }
.dropdown-item svg { width: 1rem; height: 1rem; color: hsl(var(--muted-foreground)); }
.dropdown-item-destructive { color: hsl(var(--destructive)); }
.dropdown-item-destructive:hover { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }
.dropdown-item-destructive svg { color: hsl(var(--destructive)); }
.dropdown-label { padding: 0.375rem 0.5rem; font-size: 0.75rem; font-weight: 600; color: hsl(var(--muted-foreground)); }
.dropdown-separator { margin: 0.25rem -0.25rem; height: 1px; background: hsl(var(--border)); }

/* ── Dialog ──────────────────────────────────────────────────────────────────*/
.dialog { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 1rem; }
.dialog[data-state="open"] { display: flex; }
.dialog-overlay { position: absolute; inset: 0; background: rgb(0 0 0 / 0.5); backdrop-filter: blur(4px); animation: fadeIn 200ms ease; }
.dialog-content { position: relative; width: 100%; max-width: 32rem; background: hsl(var(--background)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25); animation: scaleIn 200ms ease; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.dialog-content-lg { max-width: 64rem; }
.dialog-content-xl { max-width: 80rem; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.5rem; border-bottom: 1px solid hsl(var(--border)); }
.dialog-header-info { min-width: 0; flex: 1; }
.dialog-title { font-size: 1rem; font-weight: 600; color: hsl(var(--foreground)); line-height: 1.25; }
.dialog-description { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.dialog-body { flex: 1; overflow: auto; padding: 1.5rem; }
.dialog-body-flush { padding: 0; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid hsl(var(--border)); }
.dialog-close { width: 1.5rem; height: 1.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: calc(var(--radius) - 4px); color: hsl(var(--muted-foreground)); transition: color 150ms, background-color 150ms; }
.dialog-close:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ── Tooltip ─────────────────────────────────────────────────────────────────*/
.has-tooltip { position: relative; }
.has-tooltip::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); padding: 0.375rem 0.625rem; background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 4px); font-size: 0.75rem; white-space: nowrap; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); opacity: 0; pointer-events: none; transition: opacity 150ms; z-index: 10; }
.has-tooltip:hover::after { opacity: 1; }

/* ── Toast ───────────────────────────────────────────────────────────────────*/
.toast-region { position: fixed; bottom: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; max-width: 24rem; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.875rem 1rem; border-radius: var(--radius); background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); border: 1px solid hsl(var(--border)); box-shadow: 0 4px 12px rgb(0 0 0 / 0.15); pointer-events: auto; font-size: 0.875rem; line-height: 1.4; transform: translateX(120%); opacity: 0; transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms; }
.toast[data-show="true"] { transform: translateX(0); opacity: 1; }
.toast-icon { flex-shrink: 0; margin-top: 0.0625rem; }
.toast-icon svg { width: 1rem; height: 1rem; }
.toast-success .toast-icon { color: hsl(142 71% 45%); }
.toast-error .toast-icon { color: hsl(var(--destructive)); }
.toast-info .toast-icon { color: hsl(var(--primary)); }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 500; }
