/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #2563eb;
  --blue-hover:  #1d4ed8;
  --blue-light:  #eff6ff;
  --green:       #16a34a;
  --green-hover: #15803d;
  --green-light: #f0fdf4;
  --red:         #dc2626;
  --red-hover:   #b91c1c;
  --red-light:   #fef2f2;
  --yellow:      #d97706;
  --yellow-light:#fffbeb;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);
}

body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: none;
  font-family: var(--font); font-size: .875rem; font-weight: 500; line-height: 1.4;
  cursor: pointer; transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--blue);  color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-hover); }
.btn-danger  { background: var(--red);   color: #fff; }
.btn-danger:hover:not(:disabled)  { background: var(--red-hover); }
.btn-outline { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost   { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled)   { background: var(--gray-100); }

.btn-sm   { padding: 6px 12px; font-size: .8125rem; }
.btn-lg   { padding: 12px 28px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 6px; border-radius: 6px; line-height: 1; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 6px; }
.form-label  { font-size: .875rem; font-weight: 500; color: var(--gray-700); }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-family: var(--font); font-size: .875rem; color: var(--gray-800);
  background: #fff; transition: border-color .15s, box-shadow .15s; width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-select  { cursor: pointer; }
.form-textarea { resize: vertical; min-height: 72px; }
.form-hint  { font-size: .8125rem; color: var(--gray-500); }
.form-error { font-size: .8125rem; color: var(--red); }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--gray-100);
}
.toggle-row:last-child { border-bottom: none; padding-bottom: 0; }
.toggle-info .toggle-label { font-size: .875rem; font-weight: 500; color: var(--gray-800); }
.toggle-info .toggle-hint  { font-size: .8125rem; color: var(--gray-500); margin-top: 2px; }

.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; margin-top: 1px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--gray-300); border-radius: 999px; transition: background .2s;
}
.toggle-track::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-track { background: var(--blue); }
.toggle input:checked + .toggle-track::before { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px rgba(37,99,235,.25); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200); box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body   { padding: 20px; }
.card-footer {
  padding: 12px 20px; border-top: 1px solid var(--gray-100);
  background: var(--gray-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-gray   { background: var(--gray-100);     color: var(--gray-600); }

/* ── Status dot ──────────────────────────────────────────────────────────── */
.dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}
.dot-green  { background: var(--green); }
.dot-red    { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-gray   { background: var(--gray-400); }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  transform: scale(.95) translateY(8px); transition: transform .2s;
}
.modal-backdrop.open .modal { transform: none; }
.modal-header {
  padding: 20px 24px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h2 { font-size: 1.0625rem; }
.modal-body   { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--gray-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 1.25rem; line-height: 1;
  padding: 4px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-600); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--gray-900); color: #fff; padding: 11px 16px;
  border-radius: var(--radius); font-size: .875rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px); transition: all .25s;
  pointer-events: all; max-width: 320px; min-width: 180px;
}
.toast.show    { opacity: 1; transform: none; }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-track {
  height: 8px; background: var(--gray-200); border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--blue); border-radius: 999px; transition: width .4s ease;
}
.progress-fill.complete { background: var(--green); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--gray-200);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin .65s linear infinite; display: inline-block; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 2.25rem; margin-bottom: 10px; }
.empty-state p { font-size: .9375rem; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.text-sm  { font-size: .875rem; }
.text-xs  { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
