/* ==========================================================================
   BUSIFY — COMPONENTS
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-body);
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  box-shadow: var(--clay-shadow-button);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--clay-shadow-button-hover);
}

.btn-primary:active {
  background: var(--color-primary-active);
  box-shadow: var(--clay-shadow-pressed);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary-subtle-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-border-subtle);
  color: var(--color-text-primary);
}

.btn-destructive {
  background: var(--color-danger);
  color: #fff;
}

.btn-destructive:hover {
  background: #a83b2f;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-icon:hover {
  background: var(--color-border-subtle);
  color: var(--color-text-primary);
}

.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-small);
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn-secondary.btn-loading::after {
  border-color: var(--color-border-subtle);
  border-top-color: var(--color-text-secondary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Inputs ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text-primary);
}

.field-hint {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.field-error {
  font-size: var(--text-caption);
  color: var(--color-danger);
}

.input, .select, .textarea {
  height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  width: 100%;
}

.textarea {
  height: auto;
  min-height: 96px;
  padding: var(--space-3) var(--space-4);
  resize: vertical;
}

.input::placeholder, .textarea::placeholder {
  color: var(--color-text-muted);
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.input.is-invalid {
  border-color: var(--color-danger);
}

.input.is-invalid:focus {
  box-shadow: 0 0 0 3px var(--color-danger-subtle);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .icon {
  position: absolute;
  left: var(--space-3);
  color: var(--color-text-muted);
}

.input-group > .icon + .input {
  padding-left: var(--space-9);
}

.input-group .input-suffix-btn {
  position: absolute;
  right: var(--space-2);
}

.input-currency-prefix {
  position: absolute;
  left: var(--space-4);
  color: var(--color-text-muted);
  font-weight: 600;
}

.input-currency .input {
  padding-left: 30px;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.checkbox-row, .radio-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.checkbox, .radio {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-border);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  transition: background var(--duration-fast), border-color var(--duration-fast);
}

.checkbox { border-radius: 5px; }
.radio { border-radius: 50%; }

input:checked + .checkbox,
input:checked + .radio {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.file-upload {
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-secondary);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.file-upload:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

/* ---------- Cards (flat by default — data stays readable) ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

/* ---------- Clay stat card — the signature element, used only here ---------- */
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-clay);
  padding: var(--space-6);
  box-shadow: var(--clay-shadow-raised);
  transition: transform var(--duration-base) var(--ease-standard),
    box-shadow var(--duration-base) var(--ease-standard);
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  box-shadow: var(--clay-shadow-pressed);
  margin-bottom: var(--space-4);
}

.stat-card-label {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: var(--space-1);
}

.stat-card-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-caption);
  font-weight: 600;
  margin-top: var(--space-3);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.stat-card-delta.up {
  color: var(--color-success);
  background: var(--color-success-subtle);
}

.stat-card-delta.down {
  color: var(--color-danger);
  background: var(--color-danger-subtle);
}

/* ---------- Quick action tiles — clay, used sparingly ---------- */
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border-radius: var(--radius-clay);
  background: var(--color-surface);
  box-shadow: var(--clay-shadow-raised);
  transition: transform var(--duration-fast) var(--ease-standard);
  text-align: left;
  width: 100%;
}

.quick-action:hover {
  transform: translateY(-2px);
}

.quick-action:active {
  box-shadow: var(--clay-shadow-pressed);
  transform: translateY(0);
}

.quick-action-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Tables (flat, scannable) ---------- */
.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 640px;
}

.table th {
  text-align: left;
  font-size: var(--text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-4);
  background: var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table th.sortable {
  cursor: pointer;
  user-select: none;
}

.table th.sortable:hover {
  color: var(--color-text-primary);
}

.table td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: var(--text-body);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--duration-fast);
}

.table tbody tr:hover {
  background: var(--color-primary-subtle);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-cell-primary {
  font-weight: 600;
}

/* Responsive card fallback for tables on mobile */
.table-cards { display: none; }

@media (max-width: 767px) {
  .table-wrap.responsive-cards .table-scroll { display: none; }
  .table-wrap.responsive-cards .table-cards { display: flex; flex-direction: column; }
}

.row-card {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.row-card:last-child { border-bottom: none; }

.row-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-caption);
  font-weight: 600;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--color-success-subtle); color: var(--color-success); }
.badge-warning { background: var(--color-warning-subtle); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-subtle); color: var(--color-danger); }
.badge-info { background: var(--color-info-subtle); color: var(--color-info); }
.badge-neutral { background: var(--color-border-subtle); color: var(--color-text-secondary); }

/* ---------- Avatar ---------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-small);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  box-shadow: var(--clay-shadow-pressed);
  flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: var(--text-caption); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-section-title); }

/* ---------- Dropdown ---------- */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  /* Individual panels (e.g. the notification bell in shell.js) set their
     own explicit width via inline style (width:320px) — that's wider than
     the viewport itself on any phone under ~350px, and this component's
     `right:0` anchoring means it can't shift left to compensate once its
     trigger button sits near the screen's right edge (the common case,
     since this is almost always a header-right action). A comprehensive
     320–768px overflow audit found this single rule responsible for the
     overwhelming majority of all flagged horizontal-overflow issues
     across the entire app — every page with a header dropdown had it.
     This caps it without needing to touch every inline width. */
  max-width: calc(100vw - 32px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.dropdown-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* The search-results panel used to be positioned via an inline
   left:0/width:320px style relative to its trigger's own small wrapper —
   since that wrapper sits wherever the search icon happens to be in the
   header (not the viewport edge), the panel rendered up to ~150px off
   the right edge of the screen on any phone-width viewport (found via a
   320–768px overflow audit). Anchoring it to the viewport on mobile
   instead of its trigger keeps it predictably on-screen at every width. */
.search-results-panel {
  left: 0;
  right: auto;
  width: 320px;
}

@media (max-width: 1023px) {
  .search-results-panel {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  text-align: left;
}

.dropdown-item:hover {
  background: var(--color-primary-subtle);
}

.dropdown-item.danger {
  color: var(--color-danger);
}

.dropdown-item.danger:hover {
  background: var(--color-danger-subtle);
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: var(--space-2) 0;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--duration-fast);
}

.tab:hover {
  color: var(--color-text-primary);
}

.tab.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 21, 0.45);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-standard);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%) scale(0.97);
  width: min(520px, calc(100vw - 32px));
  max-height: 88vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-standard),
    transform var(--duration-base) var(--ease-standard);
}

.modal.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

@media (max-width: 767px) {
  .modal {
    top: auto;
    bottom: 0;
    left: 0;
    transform: translateY(100%);
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
  }
  .modal.is-open {
    transform: translateY(0);
  }
}

/* ---------- Drawer (mobile nav / filters) ---------- */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 84vw);
  background: var(--color-surface);
  z-index: var(--z-modal);
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-standard);
  box-shadow: var(--shadow-lg);
}

.drawer.is-open {
  transform: translateX(0);
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text-primary);
  color: #fff;
  font-size: var(--text-caption);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
  z-index: var(--z-dropdown);
}

.tooltip:hover::after,
.tooltip:focus-visible::after {
  opacity: 1;
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-toast);
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--color-text-primary);
  color: #fff;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--duration-slow) var(--ease-standard);
}

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast.success .toast-icon { color: #6bd6a0; }
.toast.error .toast-icon { color: #ef9086; }
.toast.warning .toast-icon { color: #f0c675; }
.toast.info .toast-icon { color: #8ec3ec; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Alert ---------- */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-small);
}

.alert-success { background: var(--color-success-subtle); color: #1f5c3d; border-color: #bfe4cf; }
.alert-warning { background: var(--color-warning-subtle); color: #7a5010; border-color: #f0dab0; }
.alert-danger { background: var(--color-danger-subtle); color: #8c3226; border-color: #f0c3bc; }
.alert-info { background: var(--color-info-subtle); color: #204d70; border-color: #bcd8ec; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pagination-pages {
  display: flex;
  gap: var(--space-1);
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.page-btn:hover { background: var(--color-border-subtle); }
.page-btn.is-active { background: var(--color-primary); color: #fff; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.breadcrumb a:hover { color: var(--color-text-primary); }
.breadcrumb .current { color: var(--color-text-primary); font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  gap: var(--space-4);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-title {
  font-size: var(--text-section-title);
  font-weight: 600;
}

.empty-state-desc {
  color: var(--color-text-secondary);
  max-width: 360px;
  font-size: var(--text-small);
}

/* ---------- Skeleton loading ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--color-border-subtle) 25%, var(--color-border) 37%, var(--color-border-subtle) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-title { height: 18px; width: 40%; margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- Confirmation dialog (uses .modal) ---------- */
.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.confirm-icon.danger { background: var(--color-danger-subtle); color: var(--color-danger); }
.confirm-icon.warning { background: var(--color-warning-subtle); color: var(--color-warning); }

/* ---------- Tab panels: only the active panel is shown ---------- */
.team-panel, .report-panel, .inventory-panel, .profile-panel, .notif-subpanel, .help-subpanel, .automation-panel { display: none; }
.team-panel.is-active, .report-panel.is-active, .inventory-panel.is-active, .profile-panel.is-active,
.notif-subpanel.is-active, .help-subpanel.is-active, .automation-panel.is-active { display: block; }

/* Search fields: icon sits inside the input, never beside it */
.input-group > [data-icon] {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  display: flex; pointer-events: none; color: var(--color-text-muted); z-index: 1;
}
.input-group > [data-icon] + .input { padding-left: var(--space-8); }

/* ==========================================================================
   MOTION: subtle, fast, transform/opacity only. Off for reduced-motion users.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  /* Page entrance: content eases in once */
  @keyframes vf-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  .app-main > * { animation: vf-rise 0.32s var(--ease-standard) both; }
  .app-main > *:nth-child(2) { animation-delay: 0.04s; }
  .app-main > *:nth-child(3) { animation-delay: 0.08s; }
  .app-main > *:nth-child(4) { animation-delay: 0.12s; }
  .app-main > *:nth-child(n+5) { animation-delay: 0.16s; }

  /* Feedback on interaction */
  .btn { transition: transform 0.12s var(--ease-standard), box-shadow 0.2s, background-color 0.2s; }
  .btn:active:not(:disabled) { transform: scale(0.97); }
  .stat-card, .quick-action, .card { transition: transform 0.2s var(--ease-standard), box-shadow 0.2s; }
  @media (hover: hover) {
    .stat-card:hover { transform: translateY(-2px); }
  }
  .nav-item { transition: background-color 0.15s, color 0.15s, transform 0.15s; }
  .nav-item:active { transform: scale(0.98); }
  .tab { transition: color 0.15s, border-color 0.2s; }

  /* Error and success transitions */
  @keyframes vf-shake { 0%,100% { transform: none; } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
  .input.is-invalid, .select.is-invalid, .textarea.is-invalid { animation: vf-shake 0.32s; }
  @keyframes vf-pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
  .toast .icon, .toast svg { animation: vf-pop 0.3s var(--ease-standard) both; }

  /* Empty states: soft floating icon with a pulsing halo */
  @keyframes vf-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
  @keyframes vf-halo { 0% { transform: scale(0.85); opacity: 0.5; } 100% { transform: scale(1.5); opacity: 0; } }
  .empty-state-icon { position: relative; animation: vf-float 4s ease-in-out infinite; }
  .empty-state-icon::before, .empty-state-icon::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    background: var(--color-primary-subtle); z-index: -1; animation: vf-halo 2.8s ease-out infinite;
  }
  .empty-state-icon::after { animation-delay: 1.4s; }

  /* Scroll reveal (class added by js/motion.js only) */
  .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.5s var(--ease-standard), transform 0.5s var(--ease-standard); transition-delay: var(--reveal-delay, 0ms); }
  .reveal.is-visible { opacity: 1; transform: none; }

  /* Charts draw in */
  @keyframes vf-draw { from { stroke-dashoffset: var(--len, 1200); } to { stroke-dashoffset: 0; } }
  @keyframes vf-fade { from { opacity: 0; } to { opacity: 1; } }
  .chart-line { stroke-dasharray: 1200; animation: vf-draw 1s var(--ease-standard) both; }
  .chart-area { animation: vf-fade 0.9s 0.3s both; }

  /* Homepage hero illustration: it "runs" a tiny live dashboard */
  @keyframes vf-slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes vf-toast { 0%, 8% { opacity: 0; transform: translateY(-14px); } 14%, 78% { opacity: 1; transform: none; } 86%, 100% { opacity: 0; transform: translateY(-14px); } }
  @keyframes vf-pulse { 0%,100% { r: 5; opacity: 1; } 50% { r: 9; opacity: 0.35; } }
  .hv-stats, .hv-row, .hv-area { animation: vf-slide-in 0.6s both; }
  .hv-stats { animation-delay: 0.3s; }
  .hv-area { animation: vf-fade 1s 1s both; }
  .hv-row { animation-delay: var(--d, 900ms); }
  .hv-line { stroke-dasharray: 600; animation: vf-draw 1.4s 0.6s var(--ease-standard) both; --len: 600; }
  .hv-dot { animation: vf-pulse 2.4s 2s ease-in-out infinite; }
  .hv-tip { animation: vf-fade 0.4s 1.8s both; }
  .hv-toast { animation: vf-toast 9s 2.2s ease-in-out infinite; }
}

/* Chart tooltip (dashboard) */
[data-sales-chart] { position: relative; }
.chart-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none; white-space: nowrap;
  background: #1f2420; color: #fff; font-size: 12px; font-weight: 500; padding: 6px 10px; border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}
.chart-tip[hidden] { display: none; }
.chart-dot { transition: r 0.12s; cursor: pointer; }
.hv-toast { transform-box: fill-box; }

/* Stat grid: a lone last card fills the row on phones instead of leaving a hole */
@media (max-width: 767px) {
  .stat-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* A table or empty state inside a card should not draw a second box */
.card > .table-wrap { border: 0; box-shadow: none; background: transparent; padding: 0; }
