/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 15px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, filter .15s;
  text-decoration: none; color: var(--text); background: var(--surface);
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; padding: 12px 20px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }

/* ---- Inputs ---- */
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font-size: 16px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { min-height: 90px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); }
.error-text { font-size: 13px; color: var(--error); }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: var(--sp-2); }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: 4px;
}
.metric-label { font-size: 13px; color: var(--text-muted); }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-sub { font-size: 12px; color: var(--text-muted); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: var(--radius-full); font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--primary-soft); color: var(--primary-dark); }

/* ---- Empty / Error states ---- */
.state {
  padding: var(--sp-6) var(--sp-4); text-align: center;
  color: var(--text-muted); display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-3);
}
.state-title { font-size: 16px; font-weight: 600; color: var(--text); }
.state-text { font-size: 14px; max-width: 420px; }

/* ---- Toasts (FIXED: no more --bottomnav-h) ---- */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 2000;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  pointer-events: auto;
  background: #111827;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--primary); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15,23,42,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-5); box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow: auto;
  animation: sheet-up .2s ease-out;
}
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: var(--sp-3); }
.modal-actions {
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  margin-top: var(--sp-4); flex-wrap: wrap;
}
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---- Table ---- */
.table-wrap {
  overflow-x: auto; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th {
  font-weight: 600; color: var(--text-muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .02em;
}
.table tr:last-child td { border-bottom: none; }

/* ---- Skeleton & Spinner ---- */
.skeleton {
  background: linear-gradient(90deg, #E5E7EB 25%, #F1F5F9 37%, #E5E7EB 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes sk {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner-dark { border-color: rgba(17,24,39,.15); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Password field with eye toggle ---- */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  font-family: inherit;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }

/* Inline Form Error */
.form-error-box {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #991B1B;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 16px;
  display: none;
  text-align: left;
}

/* --- PREMIUM ANIMATIONS --- */
.fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.btn-press:active {
  transform: scale(0.96) !important;
}

/* Smooth page transitions */
#page {
  animation: pageEnter 0.25s ease-out forwards;
}
@keyframes pageEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}
