/* ============================================================
   Component styles — shadcn-aligned
   ============================================================ */

/* ============ BUTTON ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--row-h, 36px); padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .04s;
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.4); }
.btn:active { transform: translateY(0.5px); }
.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: hsl(var(--background)); 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-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }

.btn-link { background: transparent; color: hsl(var(--primary)); padding: 0; height: auto; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-icon { width: var(--row-h, 36px); padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ============ INPUT / TEXTAREA / SELECT ============ */
.input, .textarea, .select-trigger {
  width: 100%;
  height: var(--row-h, 36px);
  padding: 0 12px;
  font-family: inherit; font-size: 13px;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:hover, .textarea:hover, .select-trigger:hover { border-color: hsl(var(--muted-foreground) / 0.5); }
.input:focus, .textarea:focus, .select-trigger:focus, .select-trigger.open {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}
.input.error, .textarea.error, .select-trigger.error { border-color: hsl(var(--destructive)); }
.input.error:focus { box-shadow: 0 0 0 3px hsl(var(--destructive) / 0.18); }
.input:disabled, .textarea:disabled { background: hsl(var(--muted) / 0.5); pointer-events: none; opacity: 0.7; }

/* Time input — themed accent */
input[type=time].input { accent-color: hsl(var(--primary)); color-scheme: light; }

/* Hide native spinners — replaced by .num-input */
input[type=number].input { -moz-appearance: textfield; }
input[type=number].input::-webkit-inner-spin-button,
input[type=number].input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Number input with styled +/- buttons */
.num-input { position: relative; display: flex; }
.num-input .input { flex: 1; padding-right: 26px; border-radius: var(--radius); }
.num-btns {
  position: absolute; right: 0; top: 0; bottom: 0; width: 24px;
  display: flex; flex-direction: column;
  border-left: 1px solid hsl(var(--border));
}
.num-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: hsl(var(--muted-foreground)); padding: 0;
  transition: background .1s, color .1s;
}
.num-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.num-btn:first-child {
  border-radius: 0 var(--radius) 0 0;
  border-bottom: 1px solid hsl(var(--border));
}
.num-btn:last-child  { border-radius: 0 0 var(--radius) 0; }
.num-btn:disabled    { opacity: 0.4; cursor: not-allowed; }

/* Compact inline qty input — used inside table cells (QuantityInput component) */
.qty-input {
  width: 100%;
  font-size: 12px;
  height: 28px;
  padding: 0 6px;
  text-align: right;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: hsl(var(--foreground));
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  -moz-appearance: textfield;
  transition: border-color .1s, background .1s;
}
.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input:hover  { border-color: hsl(var(--border)); background: hsl(var(--background)); }
.qty-input:focus  { border-color: hsl(var(--primary) / 0.5); background: hsl(var(--background)); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.15); }
.qty-input:disabled { opacity: 0.5; cursor: not-allowed; }

.textarea { height: auto; padding: 8px 12px; min-height: 80px; resize: vertical; line-height: 1.5; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .icon-left { position: absolute; left: 10px; color: hsl(var(--muted-foreground)); pointer-events: none; z-index: 1; display: inline-flex; }
.input-wrap .input.with-icon-left { padding-left: 34px; }
.input-wrap .icon-right { position: absolute; right: 10px; color: hsl(var(--muted-foreground)); }
.input-wrap .input.with-icon-right { padding-right: 34px; }

.label { font-size: 12px; font-weight: 500; color: hsl(var(--foreground)); display: block; margin-bottom: 6px; }
.label .req { color: hsl(var(--destructive)); margin-left: 2px; }
.help { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 4px; }
.help.error { color: hsl(var(--destructive)); }

.field { margin-bottom: 14px; }

/* ============ SELECT (custom popup) ============ */
.select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; gap: 8px; text-align: left;
}
.select-trigger .placeholder { color: hsl(var(--muted-foreground)); }
.select-content {
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: 4px; box-shadow: 0 8px 28px -8px rgba(0,0,0,0.18), 0 4px 12px -4px rgba(0,0,0,0.08);
}
.select-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 26px; font-size: 13px; border-radius: 4px;
  cursor: pointer; position: relative;
}
.select-item:hover, .select-item.highlighted { background: hsl(var(--accent)); }
.select-item.selected .check { display: block; }
.select-item .check { position: absolute; left: 8px; display: none; color: hsl(var(--primary)); }
.select-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: hsl(var(--muted-foreground)); padding: 8px 10px 4px; }
.select-separator { height: 1px; background: hsl(var(--border)); margin: 4px 0; }

/* ============ CHECKBOX / RADIO / SWITCH ============ */
.checkbox {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 4px;
  border: 1px solid hsl(var(--input)); background: hsl(var(--background));
  cursor: pointer; position: relative; flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.checkbox:hover { border-color: hsl(var(--primary) / 0.6); }
.checkbox:checked { background: hsl(var(--primary)); border-color: hsl(var(--primary)); }
.checkbox:checked::after {
  content: ''; position: absolute; left: 5px; top: 2px;
  width: 4px; height: 8px; border: 1.5px solid white; border-top: 0; border-left: 0;
  transform: rotate(45deg);
}
.checkbox:focus-visible { outline: 2px solid hsl(var(--ring) / 0.4); outline-offset: 2px; }

.radio {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid hsl(var(--input)); background: hsl(var(--background));
  cursor: pointer; position: relative; flex-shrink: 0;
}
.radio:checked { border-color: hsl(var(--primary)); }
.radio:checked::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--primary));
}

.switch {
  width: 36px; height: 20px; border-radius: 999px;
  background: hsl(var(--input)); cursor: pointer; position: relative;
  border: 0; padding: 0;
  transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform .18s cubic-bezier(.4,.0,.2,1);
}
.switch.on { background: hsl(var(--primary)); }
.switch.on::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid hsl(var(--ring) / 0.4); outline-offset: 2px; }

/* ============ CARD ============ */
.card {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
.card-header { padding: var(--pad-card) var(--pad-card) calc(var(--pad-card) - 4px); }
.card-header.with-border { border-bottom: 1px solid hsl(var(--border)); padding-bottom: var(--pad-card); }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-description { font-size: 13px; color: hsl(var(--muted-foreground)); margin-top: 4px; }
.card-content { padding: var(--pad-card); }
.card-content.no-pt { padding-top: 0; }
.card-footer { padding: 14px var(--pad-card); border-top: 1px solid hsl(var(--border)); display: flex; justify-content: flex-end; gap: 8px; }

/* ============ BADGE ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-default { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-primary { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); border-color: hsl(var(--primary) / 0.25); }
.badge-success { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.25); }
.badge-warn { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); border-color: hsl(var(--warning) / 0.3); }
.badge-info { background: hsl(var(--info) / 0.1); color: hsl(var(--info)); border-color: hsl(var(--info) / 0.25); }
.badge-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }
.badge-destructive { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.25); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============ TABLE ============ */
.tbl-wrap { border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); }
.tbl { border-collapse: separate; border-spacing: 0; }
.tbl thead th:first-child { border-top-left-radius: var(--radius); }
.tbl thead th:last-child { border-top-right-radius: var(--radius); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th {
  text-align: left; padding: 10px 14px;
  font-weight: 600; font-size: 11px;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tbl thead th:last-child { border-right: none; }
.tbl thead th.tbl-num { text-align: right; }
.tbl thead th.tbl-num .th-inner { justify-content: flex-end; }
.tbl thead th.sortable { cursor: pointer; user-select: none; }
.tbl thead th.sortable:hover { color: hsl(var(--foreground)); }
.tbl thead th .sort-icon { display: inline-flex; vertical-align: middle; margin-left: 4px; opacity: 0.5; }
.tbl thead th.sorted .sort-icon { opacity: 1; color: hsl(var(--primary)); }
.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  border-right: 1px solid hsl(var(--border) / 0.5);
  vertical-align: middle;
}
.tbl tbody td:last-child { border-right: none; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:nth-child(even) { background: hsl(var(--muted) / 0.35); }
.tbl tbody tr:hover { background: hsl(var(--primary) / 0.05); }
.tbl tbody tr.selected { background: hsl(var(--primary) / 0.08); }
.tbl-num { text-align: right; font-variant-numeric: tabular-nums; font-family: 'Geist Mono', monospace; }

/* Flush DataGrid inside a Card — removes tbl-wrap double-border */
.card-table-flush .tbl-wrap { border: none; border-radius: 0; background: transparent; box-shadow: none; }
.card-table-flush .tbl thead th:first-child { border-top-left-radius: 0; }
.card-table-flush .tbl thead th:last-child  { border-top-right-radius: 0; }

/* filterable headers: funnel icon appears on hover or when active */
.th-cell .th-filter-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  border: 0; background: transparent; cursor: pointer;
  color: hsl(var(--muted-foreground));
  opacity: 0; transition: opacity .12s, background .12s, color .12s;
  position: relative; padding: 0;
}
.tbl-filterable thead tr:hover .th-filter-btn,
.th-cell:hover .th-filter-btn,
.th-cell .th-filter-btn.th-filter-active { opacity: 1; }
.th-cell .th-filter-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.th-cell .th-filter-btn.th-filter-active { color: hsl(var(--primary)); background: hsl(var(--primary) / 0.08); }
.th-cell .th-filter-dot {
  position: absolute; top: 1px; right: 1px;
  width: 5px; height: 5px; border-radius: 999px; background: hsl(var(--primary));
}
.th-popover {
  background: hsl(var(--popover)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  box-shadow: 0 10px 30px -10px hsl(var(--foreground) / 0.18), 0 4px 12px -4px hsl(var(--foreground) / 0.08);
  min-width: 200px; text-transform: none; letter-spacing: 0; font-weight: 400;
  animation: scaleIn .12s ease-out;
}

/* ============ TABS ============ */
.tabs-list {
  display: inline-flex; gap: 2px; padding: 4px;
  background: hsl(var(--muted)); border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}
.tab-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: calc(var(--radius) - 2px);
  border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.tab-trigger:hover { color: hsl(var(--foreground)); }
.tab-trigger.active {
  background: hsl(var(--background)); color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.tabs-underline { display: flex; gap: 0; border-bottom: 1px solid hsl(var(--border)); }
.tabs-underline .tab-trigger {
  padding: 10px 16px; border-radius: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent;
}
.tabs-underline .tab-trigger.active {
  color: hsl(var(--primary));
  border-bottom-color: hsl(var(--primary));
  background: transparent; box-shadow: none;
}

/* ============ DIALOG / MODAL ============ */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 100; animation: overlayIn .15s ease-out;
}
[data-theme="dark"] .dialog-overlay { background: rgba(0,0,0,0.7); }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  position: fixed; inset: 0; margin: auto;
  z-index: 110;
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.25);
  width: 100%; max-width: 500px;
  animation: dialogIn .18s cubic-bezier(.16,.84,.44,1);
  max-height: 85vh; height: fit-content; display: flex; flex-direction: column;
}
@keyframes dialogIn { from { opacity: 0; } to { opacity: 1; } }
.dialog-header { padding: 20px 20px 12px; }
.dialog-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-description { font-size: 13px; color: hsl(var(--muted-foreground)); margin-top: 6px; }
.dialog-body { padding: 0 20px 16px; overflow-y: auto; flex: 1; min-height: 0; }
.dialog-footer { padding: 14px 20px; border-top: 1px solid hsl(var(--border)); display: flex; justify-content: flex-end; gap: 8px; }
.dialog-close { position: absolute; top: 14px; right: 14px; background: transparent; border: 0; cursor: pointer; padding: 4px; border-radius: 4px; color: hsl(var(--muted-foreground)); }
.dialog-close:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }

/* ============ DROPDOWN MENU ============ */
.dropdown-menu {
  min-width: 180px;
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: 4px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,0.18), 0 4px 12px -4px rgba(0,0,0,0.08);
  animation: scaleIn .12s ease-out;
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 4px;
  font-size: 13px; cursor: pointer;
  color: hsl(var(--foreground));
}
.dropdown-item:hover { background: hsl(var(--accent)); }
.dropdown-item.destructive { color: hsl(var(--destructive)); }
.dropdown-item.destructive:hover { background: hsl(var(--destructive) / 0.1); }
.dropdown-label { font-size: 11px; color: hsl(var(--muted-foreground)); padding: 6px 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.dropdown-separator { height: 1px; background: hsl(var(--border)); margin: 4px 0; }
.dropdown-shortcut { margin-left: auto; font-size: 11px; color: hsl(var(--muted-foreground)); font-family: 'Geist Mono', monospace; }

/* ============ TOOLTIP ============ */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip-bubble {
  position: absolute; z-index: 200; white-space: nowrap;
  background: hsl(var(--foreground)); color: hsl(var(--background));
  font-size: 11px; font-weight: 500; padding: 5px 8px; border-radius: 4px;
  pointer-events: none; opacity: 0; transition: opacity .12s;
}
.tooltip-wrap:hover .tooltip-bubble { opacity: 1; }
.tooltip-bubble.tooltip-top    { bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.tooltip-bubble.tooltip-bottom { top:    calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.tooltip-bubble.tooltip-left   { right: calc(100% + 6px); top: 50%;  transform: translateY(-50%); }
.tooltip-bubble.tooltip-right  { left:  calc(100% + 6px); top: 50%;  transform: translateY(-50%); }

/* ============ TOAST ============ */
.toast-region {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: max-content; max-width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: hsl(var(--card)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 8px 24px -6px rgba(0,0,0,0.18);
  animation: toastIn .22s cubic-bezier(.16,.84,.44,1);
  display: flex; align-items: flex-start; gap: 10px;
  pointer-events: all;
}
.toast.exiting {
  animation: toastOut .4s ease forwards;
  pointer-events: none;
}
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast.success { border-left: 3px solid hsl(var(--success));     background: hsl(var(--success) / 0.06); }
.toast.error   { border-left: 3px solid hsl(var(--destructive)); background: hsl(var(--destructive) / 0.06); }
.toast.warn    { border-left: 3px solid hsl(var(--warning));     background: hsl(var(--warning) / 0.06); }
.toast.info    { border-left: 3px solid hsl(var(--info));        background: hsl(var(--info) / 0.06); }
.toast.success .toast-icon { color: hsl(var(--success)); }
.toast.error   .toast-icon { color: hsl(var(--destructive)); }
.toast.warn    .toast-icon { color: hsl(var(--warning)); }
.toast.info    .toast-icon { color: hsl(var(--info)); }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-desc { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.toast-close { background: transparent; border: 0; cursor: pointer; padding: 2px; color: hsl(var(--muted-foreground)); margin-left: auto; }

/* ============ STEPPER ============ */
.stepper { display: flex; align-items: center; gap: 0; }
.stepper-step { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.stepper-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
  font-size: 12px; font-weight: 600;
  border: 1px solid hsl(var(--border));
  transition: all .2s;
}
.stepper-step.active .stepper-dot { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.stepper-step.done .stepper-dot { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); border-color: hsl(var(--primary) / 0.4); }
.stepper-label { font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.stepper-step.active .stepper-label { color: hsl(var(--foreground)); }
.stepper-step.done .stepper-label { color: hsl(var(--foreground)); }
.stepper-line { flex: 1; height: 1px; background: hsl(var(--border)); margin: 0 12px; min-width: 24px; }
.stepper-step.done + .stepper-line, .stepper-step.active + .stepper-line { background: hsl(var(--primary) / 0.4); }

/* ============ PROGRESS ============ */
.progress { height: 6px; background: hsl(var(--muted)); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: hsl(var(--primary)); border-radius: 999px; transition: width .35s cubic-bezier(.4,.0,.2,1); }

/* ============ POPOVER (combobox / date picker) ============ */
.popover {
  position: absolute; z-index: 70;
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  box-shadow: 0 8px 28px -8px rgba(0,0,0,0.18), 0 4px 12px -4px rgba(0,0,0,0.08);
  padding: 8px;
  animation: scaleIn .12s ease-out;
}

/* ============ AVATAR ============ */
.avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }

/* ============ KBD ============ */
.kbd {
  font-family: 'Geist Mono', monospace; font-size: 10px;
  padding: 1px 5px; border-radius: 4px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

/* ============ SEGMENTED ============ */
.seg-control {
  display: inline-flex; padding: 2px;
  background: hsl(var(--muted)); border-radius: 6px;
  border: 1px solid hsl(var(--border));
}
.seg-control button {
  border: 0; background: transparent; padding: 4px 10px;
  font-size: 11px; font-weight: 500;
  color: hsl(var(--muted-foreground)); cursor: pointer;
  border-radius: 4px; font-family: inherit;
}
.seg-control button.active {
  background: hsl(var(--background)); color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ============ DATE PICKER ============ */
.dp-cal { display: flex; flex-direction: column; gap: 4px; width: 240px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; padding: 4px; }
.dp-title { font-size: 12px; font-weight: 600; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { font-size: 10px; color: hsl(var(--muted-foreground)); text-align: center; padding: 4px 0; font-weight: 500; }
.dp-day {
  height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; border-radius: 4px; cursor: pointer; border: 0;
  background: transparent; color: hsl(var(--foreground));
  font-family: inherit;
}
.dp-day:hover { background: hsl(var(--accent)); }
.dp-day.muted { color: hsl(var(--muted-foreground) / 0.5); }
.dp-day.today { font-weight: 700; color: hsl(var(--primary)); }
.dp-day.selected { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.dp-day.selected:hover { background: hsl(var(--primary) / 0.9); }

/* ============ LOADER — ring ============ */
.loader {
  display: inline-block; border-radius: 50%; flex-shrink: 0;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  width: 20px; height: 20px;
  animation: spin .65s linear infinite;
}
.loader.loader-sm { width: 14px; height: 14px; border-width: 1.5px; }
.loader.loader-lg { width: 32px; height: 32px; border-width: 3px; }
.loader.loader-xl { width: 48px; height: 48px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-flex; transform-origin: center; }

/* ============ LOADER — dots ============ */
.loader-dots { display: inline-flex; align-items: center; gap: 5px; }
.loader-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: hsl(var(--primary));
  animation: dot-bounce .9s ease-in-out infinite;
}
.loader-dots.loader-sm .loader-dot { width: 5px; height: 5px; gap: 3px; }
.loader-dots.loader-lg .loader-dot { width: 12px; height: 12px; }
.loader-dot:nth-child(1) { animation-delay: 0s; }
.loader-dot:nth-child(2) { animation-delay: .18s; }
.loader-dot:nth-child(3) { animation-delay: .36s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%            { transform: translateY(-8px); opacity: 1; }
}

/* ============ LOADER — bars ============ */
.loader-bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 24px; }
.loader-bar {
  width: 4px; border-radius: 2px;
  background: hsl(var(--primary));
  animation: bar-wave .9s ease-in-out infinite;
}
.loader-bar:nth-child(1) { height: 12px; animation-delay: 0s; }
.loader-bar:nth-child(2) { height: 20px; animation-delay: .15s; }
.loader-bar:nth-child(3) { height: 24px; animation-delay: .3s; }
.loader-bar:nth-child(4) { height: 20px; animation-delay: .45s; }
.loader-bar:nth-child(5) { height: 12px; animation-delay: .6s; }
@keyframes bar-wave {
  0%, 100% { transform: scaleY(.4); opacity: .5; }
  50%       { transform: scaleY(1);  opacity: 1; }
}

/* ============ LOADER — pulse ============ */
.loader-pulse {
  display: inline-block; position: relative;
  width: 32px; height: 32px; flex-shrink: 0;
}
.loader-pulse::before, .loader-pulse::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: hsl(var(--primary) / 0.35);
  animation: pulse-ring 1.6s ease-out infinite;
}
.loader-pulse::after { animation-delay: .8s; }
.loader-pulse-core {
  position: absolute; inset: 25%; border-radius: 50%;
  background: hsl(var(--primary));
}
.loader-pulse.loader-sm { width: 20px; height: 20px; }
.loader-pulse.loader-lg { width: 48px; height: 48px; }
@keyframes pulse-ring {
  0%   { transform: scale(.35); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ============ SKELETON ============ */
.skeleton {
  background: linear-gradient(
    90deg,
    hsl(var(--muted))             0%,
    hsl(var(--border))            50%,
    hsl(var(--muted))            100%
  );
  background-size: 300% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius);
  display: block;
}
.skeleton.circle { border-radius: 50%; }
.skeleton.text   { height: 13px; }
.skeleton.title  { height: 20px; }
@keyframes shimmer {
  0%   { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

/* ============ SPLASHSCREEN ============ */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  background: hsl(var(--background));
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  transition: opacity .35s ease-out;
}
.splash.splash-out { opacity: 0; pointer-events: none; }
.splash-brand {
  width: 64px; height: 64px; border-radius: 14px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px -8px hsl(var(--primary) / 0.5);
}
.splash-msg {
  font-size: 13px; color: hsl(var(--muted-foreground));
  margin-top: 16px; letter-spacing: .02em;
}

/* ============ ALERT ============ */
.alert {
  display: flex; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid; font-size: 13.5px; line-height: 1.5;
}
.alert-icon  { flex-shrink: 0; margin-top: 1px; }
.alert-body  { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; font-size: 13.5px; }
.alert-desc  { font-size: 13px; }
.alert-dismiss {
  flex-shrink: 0; background: transparent; border: 0;
  cursor: pointer; color: inherit; opacity: .55; padding: 2px;
  display: flex; align-items: flex-start; line-height: 1;
  transition: opacity .15s;
}
.alert-dismiss:hover { opacity: 1; }

.alert-neutral { border-color: hsl(var(--border));            background: hsl(var(--muted) / 0.5);          color: hsl(var(--foreground)); }
.alert-info    { border-color: hsl(var(--info) / 0.4);        background: hsl(var(--info) / 0.08);          color: hsl(var(--foreground)); }
.alert-success { border-color: hsl(var(--success) / 0.4);     background: hsl(var(--success) / 0.08);       color: hsl(var(--foreground)); }
.alert-warn    { border-color: hsl(var(--warning) / 0.4);     background: hsl(var(--warning) / 0.08);       color: hsl(var(--foreground)); }
.alert-error   { border-color: hsl(var(--destructive) / 0.4); background: hsl(var(--destructive) / 0.08);   color: hsl(var(--foreground)); }

.alert-info    .alert-icon { color: hsl(var(--info)); }
.alert-success .alert-icon { color: hsl(var(--success)); }
.alert-warn    .alert-icon { color: hsl(var(--warning)); }
.alert-error   .alert-icon { color: hsl(var(--destructive)); }

/* ============ PAGINATION ============ */
.pagination { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.pg-btn {
  min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: var(--radius); border: 1px solid hsl(var(--border));
  background: transparent; color: hsl(var(--foreground));
  font-size: 13px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
}
.pg-btn:hover:not(:disabled) { background: hsl(var(--accent)); border-color: hsl(var(--accent)); }
.pg-btn.pg-active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); font-weight: 600; }
.pg-btn:disabled  { opacity: .4; cursor: default; }
.pg-nav { border-color: transparent; }
.pg-ellipsis { padding: 0 4px; color: hsl(var(--muted-foreground)); font-size: 14px; user-select: none; }
.pg-info { font-size: 12px; color: hsl(var(--muted-foreground)); margin-left: 8px; white-space: nowrap; }

/* ============ EMPTY STATE ============ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px;
  text-align: center; gap: 6px;
}
.empty-icon    { color: hsl(var(--muted-foreground)); margin-bottom: 4px; opacity: .6; }
.empty-title   { font-size: 15px; font-weight: 600; color: hsl(var(--foreground)); }
.empty-desc    { font-size: 13px; color: hsl(var(--muted-foreground)); max-width: 380px; line-height: 1.6; }
.empty-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ============ TAG / CHIP ============ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 9999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6;
  white-space: nowrap;
}
.tag-remove {
  background: transparent; border: 0; cursor: pointer; padding: 0;
  display: flex; color: inherit; opacity: .6; margin-left: 1px;
  align-items: center; line-height: 1; transition: opacity .15s;
}
.tag-remove:hover { opacity: 1; }
.tag-default   { background: hsl(var(--primary));   color: hsl(var(--primary-foreground)); }
.tag-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.tag-outline   { background: transparent; border: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); }
.tag-muted     { background: hsl(var(--muted));     color: hsl(var(--muted-foreground)); }

/* ============ BREADCRUMB ============ */
.breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.bc-item    { display: flex; align-items: center; gap: 4px; }
.bc-link, .bc-link:visited { font-size: 13.5px; color: hsl(var(--muted-foreground)); text-decoration: none; transition: color .15s; }
.bc-link:hover, .bc-link:focus { color: hsl(var(--primary)); text-decoration: none; outline: none; }
.bc-current { font-size: 13.5px; color: hsl(var(--foreground)); font-weight: 500; }
.bc-sep     { color: hsl(var(--muted-foreground)); display: inline-flex; }

/* ============ ACCORDION ============ */
.accordion { display: flex; flex-direction: column; border: 1px solid hsl(var(--border)); border-radius: var(--radius); overflow: hidden; }
.accordion-item { border-bottom: 1px solid hsl(var(--border)); }
.accordion-item:last-child { border-bottom: 0; }
.accordion-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-size: 14px; font-weight: 500;
  background: transparent; border: 0; cursor: pointer;
  color: hsl(var(--foreground)); text-align: left; font-family: inherit;
  transition: background .15s;
}
.accordion-trigger:hover { background: hsl(var(--accent) / 0.6); }
.accordion-icon { transition: transform .2s ease; flex-shrink: 0; color: hsl(var(--muted-foreground)); }
.accordion-icon.open { transform: rotate(180deg); }
.accordion-body-inner { padding: 2px 16px 16px; font-size: 13.5px; color: hsl(var(--muted-foreground)); line-height: 1.65; }

/* ============ STAT CARD ============ */
.stat-card {
  padding: 20px 22px; border-radius: var(--radius);
  border: 1px solid hsl(var(--border)); background: hsl(var(--card));
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label   { font-size: 11.5px; color: hsl(var(--muted-foreground)); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-value   { font-size: 28px; font-weight: 700; letter-spacing: -.025em; color: hsl(var(--foreground)); line-height: 1.1; margin: 2px 0; }
.stat-change  { font-size: 12.5px; display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.stat-up      { color: hsl(var(--success)); }
.stat-down    { color: hsl(var(--destructive)); }
.stat-neutral { color: hsl(var(--muted-foreground)); }
.stat-desc    { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }

/* ============ FILE UPLOAD ============ */
.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 32px 24px; border-radius: var(--radius);
  border: 2px dashed hsl(var(--border)); cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative; text-align: center;
}
.file-drop:hover,
.file-drop.drag-over { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.04); }
.file-drop-icon  { color: hsl(var(--muted-foreground)); opacity: .6; margin-bottom: 2px; }
.file-drop-label { font-size: 13.5px; font-weight: 500; color: hsl(var(--foreground)); }
.file-drop-sub   { font-size: 12px; color: hsl(var(--muted-foreground)); }
.file-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius);
  background: hsl(var(--muted) / 0.5); font-size: 12.5px;
  color: hsl(var(--foreground));
}
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: hsl(var(--muted-foreground)); white-space: nowrap; font-size: 11.5px; }
.file-remove {
  background: transparent; border: 0; cursor: pointer;
  color: hsl(var(--muted-foreground)); display: flex; padding: 0;
  transition: color .15s;
}
.file-remove:hover { color: hsl(var(--destructive)); }

/* ============ INPUT SELECTION ============ */
.input::selection { background: hsl(var(--primary) / 0.25); color: hsl(var(--foreground)); }

/* ============ TIME PICKER ============ */
.time-picker {
  display: inline-flex; align-items: center; gap: 4px;
}
.time-picker .time-part {
  width: 52px; text-align: center; padding: 0 8px;
  font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
.time-sep {
  font-size: 15px; font-weight: 600;
  color: hsl(var(--muted-foreground)); user-select: none;
}
.time-picker-disabled { opacity: .5; pointer-events: none; }

/* ============ DATE RANGE PICKER ============ */
.date-range-picker { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-range-sep    { color: hsl(var(--muted-foreground)); display: inline-flex; flex-shrink: 0; }

/* ============ COMMAND PALETTE ============ */
.cmd-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: hsl(var(--foreground) / 0.25);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 10vh;
}
.cmd-panel {
  width: 100%; max-width: 560px;
  background: hsl(var(--popover)); border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 20px 60px -12px rgba(0,0,0,0.35);
  overflow: hidden;
  animation: scaleIn .12s ease-out;
}
.cmd-search-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid hsl(var(--border));
}
.cmd-search-icon { color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.cmd-input {
  flex: 1; background: transparent; border: 0; outline: none;
  font-size: 15px; color: hsl(var(--foreground));
  font-family: inherit;
}
.cmd-input::placeholder { color: hsl(var(--muted-foreground)); }
.cmd-esc-hint {
  font-size: 10px; color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border)); border-radius: 4px;
  padding: 2px 5px; font-family: inherit; flex-shrink: 0;
}
.cmd-results { max-height: 380px; overflow-y: auto; padding: 4px; }
.cmd-group-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: hsl(var(--muted-foreground));
  padding: 8px 10px 4px;
}
/* kbd hint inside buttons (e.g. "Salva Ctrl+S") */
.btn-kbd {
  font-size: 10px;
  font-family: inherit;
  font-weight: 400;
  opacity: 0.65;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.6;
  letter-spacing: 0;
}

.cmd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13.5px; color: hsl(var(--foreground));
  transition: background .1s;
}
.cmd-item:hover, .cmd-item.cmd-item-active {
  background: hsl(var(--accent));
}
.cmd-item-content { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cmd-item-label  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-item-desc   { font-size: 11px; color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-item-arrow  { color: hsl(var(--muted-foreground)); flex-shrink: 0; opacity: 0; transition: opacity .1s; }
.cmd-item:hover .cmd-item-arrow,
.cmd-item.cmd-item-active .cmd-item-arrow { opacity: 1; }
.cmd-shortcut {
  font-size: 11px; color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border)); border-radius: 4px;
  padding: 1px 5px; font-family: inherit;
}
.cmd-empty {
  padding: 32px 16px; text-align: center;
  font-size: 13px; color: hsl(var(--muted-foreground));
}

/* ============ TIMELINE ============ */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: 14px;
  padding-bottom: 20px;
}
.timeline-item-last { padding-bottom: 0; }
.timeline-track {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0; width: 24px;
}
.timeline-dot {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid hsl(var(--primary));
  background: hsl(var(--background));
  display: flex; align-items: center; justify-content: center;
  color: hsl(var(--primary)); flex-shrink: 0;
  font-size: 10px;
}
.timeline-line {
  flex: 1; width: 2px; background: hsl(var(--border));
  margin-top: 4px; margin-bottom: -4px; min-height: 16px;
}
.timeline-body   { flex: 1; padding-top: 2px; }
.timeline-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.timeline-label  { font-size: 14px; font-weight: 500; color: hsl(var(--foreground)); }
.timeline-time   { font-size: 11.5px; color: hsl(var(--muted-foreground)); white-space: nowrap; flex-shrink: 0; }
.timeline-desc   { font-size: 13px; color: hsl(var(--muted-foreground)); line-height: 1.6; }

/* ============ DIVIDER ============ */
hr.divider {
  border: none; border-top: 1px solid hsl(var(--border));
  margin: 0;
}
.divider-label {
  display: flex; align-items: center; gap: 12px;
  color: hsl(var(--muted-foreground));
}
.divider-label::before,
.divider-label::after {
  content: ''; flex: 1; height: 1px; background: hsl(var(--border));
}
.divider-text { font-size: 12px; white-space: nowrap; }
.divider-v {
  display: inline-block; width: 1px;
  background: hsl(var(--border)); align-self: stretch;
}

/* ============ GRID UTILITIES ============ */
.row  { display: flex;  flex-direction: row;    flex-wrap: wrap; }
.col  { display: flex;  flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); }
.grid-auto-sm { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid-auto-md { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-auto-lg { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.gap-1 { gap:  4px; } .gap-2 { gap:  8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.items-start   { align-items: flex-start;  } .items-center  { align-items: center;  }
.items-end     { align-items: flex-end;    } .items-stretch { align-items: stretch; }
.justify-start   { justify-content: flex-start;   } .justify-center { justify-content: center; }
.justify-end     { justify-content: flex-end;     } .justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }
.span-2    { grid-column: span 2; }
.span-3    { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }
@media (max-width: 640px)  { .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; } }
@media (max-width: 960px)  { .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); } }
