/* UI components */

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding-inline: var(--sp-4);
  border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--starlight); color: var(--text-on-dark);
}
.btn:hover { background: var(--starlight-90); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn--secondary { background: var(--sand); color: var(--starlight); }
.btn--secondary:hover { background: #c29a6a; }
.btn--ghost { background: transparent; color: var(--starlight); border-color: var(--border); }
.btn--ghost:hover { background: var(--starlight-10); }
.btn--danger { background: var(--danger); }
.btn--sm { min-height: 36px; padding-inline: var(--sp-3); font-size: var(--fs-sm); }

/* Form fields */
.field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.field__label { font-size: var(--fs-sm); font-weight: 600; }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field__error { font-size: var(--fs-xs); color: var(--danger); }
.input, .select {
  width: 100%; min-height: var(--tap); padding-inline: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit;
}
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--sp-4); min-width: 0; }
.card__title { font-family: var(--font-head); font-weight: 700; margin: 0 0 var(--sp-2); }
.card--accent { border-inline-start: 4px solid var(--sand); }

/* Badge */
.badge { display: inline-flex; align-items: center; padding: 2px var(--sp-2); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; background: var(--starlight-10); color: var(--starlight); white-space: nowrap; }
.badge--soon { background: var(--sand-20); color: #7a5a32; }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--blue-20); color: #36527a; }

/* Table (scrolls inside its wrapper, never the page) */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-3); text-align: start; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }

/* Empty state */
.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--text-muted); }
.empty__icon { width: 44px; height: 44px; color: var(--blue); margin-bottom: var(--sp-3); }
.empty__title { font-family: var(--font-head); font-weight: 700; color: var(--starlight); margin: 0 0 var(--sp-2); }

/* Skeleton */
.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--starlight-10), var(--starlight-05), var(--starlight-10)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Modal / Drawer */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(22, 45, 76, .5); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); width: min(480px, 100%); max-height: 90vh; overflow: auto; padding: var(--sp-5); }
.overlay--drawer { align-items: flex-end; padding: 0; }
.drawer { background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2); width: 100%; max-height: 85vh; overflow: auto; padding: var(--sp-5); }
@media (min-width: 900px) {
  .overlay--drawer { justify-content: flex-end; align-items: stretch; }
  .drawer { width: 420px; max-height: none; border-radius: 0; }
}
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.modal__head h2 { margin: 0; }
.modal__foot { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); }

/* Toast */
.toasts { position: fixed; z-index: 60; inset-inline: var(--sp-4); bottom: calc(var(--bottomnav-h) + var(--sp-3)); display: flex; flex-direction: column; gap: var(--sp-2); pointer-events: none; align-items: center; }
.toast { pointer-events: auto; max-width: 420px; width: 100%; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--starlight); color: var(--text-on-dark); box-shadow: var(--shadow-2); }
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
@media (min-width: 900px) { .toasts { bottom: var(--sp-5); } }

/* Utilities */
.stack > * + * { margin-block-start: var(--sp-3); }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.muted { color: var(--text-muted); }
