/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.1;
  transition: filter 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { filter: brightness(0.93); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Comfortable touch targets on phones/tablets (WCAG/Apple HIG ~44px) */
@media (max-width: 768px) {
  .btn { min-height: 44px; padding: 11px 18px; }
  .btn-sm { min-height: 38px; padding: 8px 14px; }
  .btn-icon { min-height: 40px; }
}

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: rgba(0,0,0,0.04); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b52f2f; }

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

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 38px; height: 38px; }
.btn-round { border-radius: 999px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}
.textarea { resize: vertical; min-height: 80px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.input-group { display: flex; gap: 8px; flex-wrap: wrap; }
.input-group > .input { flex: 1 1 120px; min-width: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.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(--info-bg); color: var(--info); }
.badge-muted { background: var(--border); color: var(--muted); }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  border: 1px solid transparent;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.alert-info { background: var(--info-bg); color: #1a4bb0; }
.alert-success { background: var(--success-bg); color: #1e7a34; }
.alert-warning { background: var(--warning-bg); color: #96690f; }
.alert-danger { background: var(--danger-bg); color: #a52a2a; }

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast .toast-close { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 1rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: translateY(0);} }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 16, 12, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fade-in 0.15s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease;
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--surface);
}
.modal-footer .btn { flex: 0 1 auto; }
@media (max-width: 480px) {
  .modal-footer { justify-content: stretch; }
  .modal-footer .btn { flex: 1 1 calc(50% - 5px); }
}
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--muted); line-height: 1; }

/* ---------- Cookie consent banner ---------- */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9998;
  background: var(--text); color: #fff;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
  animation: toast-in 0.2s ease;
}
.cookie-banner-text { font-size: 0.85rem; display: flex; align-items: center; gap: 8px; flex: 1 1 260px; }
.cookie-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data-table th {
  text-align: left; padding: 10px 12px; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--muted); border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: rgba(0,0,0,0.015); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination button {
  min-width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; }

/* ---------- Empty / Loading states ---------- */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty-state .icon { font-size: 2.2rem; margin-bottom: 10px; opacity: 0.6; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #f0ece6 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.spinner.dark { border-color: rgba(0,0,0,0.15); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
  padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); min-width: 180px; z-index: 100; overflow: hidden;
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
  display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: none; font-size: 0.88rem;
}
.dropdown-item:hover { background: rgba(0,0,0,0.04); }
