/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.1px;
  transition: transform var(--dur-sm) var(--ease), box-shadow var(--dur-sm) var(--ease),
              background var(--dur-sm) var(--ease), color var(--dur-sm) var(--ease),
              border-color var(--dur-sm) var(--ease);
  user-select: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn .spin { display: none; }
.btn.loading .spin { display: inline-block; }
.btn.loading .label { opacity: 0; }
.btn[disabled], .btn.disabled { opacity: 0.55; pointer-events: none; }

.btn-primary {
  background: var(--grad-navy);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 31, 69, 0.22);
}
.btn-primary:hover { box-shadow: 0 14px 32px rgba(0, 31, 69, 0.32); transform: translateY(-2px); }

.btn-gold {
  background: var(--grad-gold);
  color: var(--navy-900);
  box-shadow: 0 10px 24px rgba(255, 195, 0, 0.35);
}
.btn-gold:hover { box-shadow: 0 16px 32px rgba(255, 195, 0, 0.5); transform: translateY(-2px); }

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--bg-soft); border-color: var(--muted-2); }

.btn-soft {
  background: var(--bg-soft);
  color: var(--navy-800);
  border: 1px solid transparent;
}
.btn-soft:hover { background: var(--cream-300); }

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

.btn-sm { height: 36px; padding: 0 16px; font-size: 12.5px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* ripple hook */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255, 255, 255, 0.45);
  animation: ripple var(--dur-lg) var(--ease-out);
  pointer-events: none;
}
.btn-gold .ripple, .btn-ghost .ripple, .btn-soft .ripple { background: rgba(0, 31, 69, 0.15); }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-md) var(--ease), box-shadow var(--dur-md) var(--ease), border-color var(--dur-md) var(--ease);
}
.card.interactive { cursor: pointer; }
.card.interactive:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--cream-300); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { font-weight: 700; font-size: 15px; color: var(--ink); }
.card-sub { font-size: 12.5px; color: var(--muted); }

.card-feature {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.card-feature .cf-top {
  height: 120px;
  position: relative;
  overflow: hidden;
}
.card-feature .cf-body { padding: 18px 20px 22px; }
.card-feature .cf-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.card-feature .cf-desc { font-size: 12.5px; color: var(--muted); line-height: 1.6; min-height: 38px; }
.card-feature .cf-cta {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy-700);
  transition: gap var(--dur-sm) var(--ease);
}
.card-feature:hover .cf-cta { gap: 10px; }

.cf-grad-1 { background: linear-gradient(135deg, #a78bfa, #60a5fa, #34d399); }
.cf-grad-2 { background: linear-gradient(135deg, #fb7185, #fbbf24, #f97316); }
.cf-grad-3 { background: linear-gradient(135deg, #60a5fa, #4f46e5, #a855f7); }
.cf-grad-4 { background: linear-gradient(135deg, #10b981, #06b6d4, #3b82f6); }
.cf-grad-5 { background: var(--grad-navy-rich); }
.cf-grad-6 { background: var(--grad-gold-rich); }

.cf-top::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.4), transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(0, 0, 0, 0.15), transparent 60%);
}
.cf-top .cf-ic {
  position: absolute;
  bottom: -22px;
  right: 18px;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
  font-size: 26px;
}

/* ---------- INPUTS ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-label .optional { color: var(--muted-2); font-weight: 400; font-size: 11px; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field-error { font-size: 11.5px; color: var(--danger); margin-top: 3px; }

.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  transition: border var(--dur-sm) var(--ease), box-shadow var(--dur-sm) var(--ease), background var(--dur-sm) var(--ease);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 4px rgba(0, 31, 69, 0.08);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { resize: vertical; line-height: 1.7; min-height: 100px; }

.input-group { position: relative; }
.input-group .input { padding-inline-start: 42px; }
.input-group .ig-ic {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}
.input-group .ig-action {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
  transition: background var(--dur-sm) var(--ease), color var(--dur-sm) var(--ease);
}
.input-group .ig-action:hover { background: var(--bg-soft); color: var(--navy-700); }

/* ---------- CHIPS ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--dur-sm) var(--ease);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover { border-color: var(--muted-2); transform: translateY(-1px); }
.chip.on {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
  box-shadow: 0 6px 16px rgba(0, 31, 69, 0.2);
}
.chip.gold.on {
  background: var(--grad-gold);
  color: var(--navy-900);
  border-color: var(--gold-500);
  box-shadow: 0 6px 16px rgba(255, 195, 0, 0.3);
}

/* ---------- TILES (grid choices) ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.tile {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px 14px;
  cursor: pointer;
  transition: all var(--dur-sm) var(--ease);
  position: relative;
  overflow: hidden;
}
.tile:hover { border-color: var(--muted-2); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tile.on {
  border-color: var(--navy-800);
  background: linear-gradient(135deg, #f5f7fb, #ffffff);
  box-shadow: 0 0 0 2px rgba(0, 31, 69, 0.12);
}
.tile .tile-ic { font-size: 22px; margin-bottom: 6px; }
.tile .tile-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.tile .tile-desc { font-size: 11px; color: var(--muted); line-height: 1.45; }
.tile.on::before {
  content: '✓';
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--grad-gold);
  color: var(--navy-900);
  font-size: 11px;
  font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- UPLOAD ---------- */
.upload {
  border: 2px dashed var(--line);
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  transition: border var(--dur-sm) var(--ease), background var(--dur-sm) var(--ease);
  position: relative;
}
.upload:hover { border-color: var(--navy-700); background: rgba(0, 31, 69, 0.02); }
.upload.drag { border-color: var(--gold-500); background: rgba(255, 195, 0, 0.06); }
.upload .up-ic { font-size: 28px; margin-bottom: 8px; }
.upload .up-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.upload .up-desc { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.preview {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  margin-top: 10px;
  width: fit-content;
}
.preview img { width: 180px; height: 120px; object-fit: cover; }
.preview .clear {
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  width: 26px; height: 26px;
  background: rgba(10, 22, 40, 0.7);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
  transition: background var(--dur-sm) var(--ease);
}
.preview .clear:hover { background: var(--danger); }

/* ---------- OUTPUT BOX ---------- */
.output {
  margin-top: 18px;
  border-radius: var(--r-lg);
  background: var(--grad-navy-rich);
  color: #e6edf8;
  padding: 20px;
  position: relative;
  overflow: hidden;
  animation: pageIn var(--dur-md) var(--ease-out);
}
.output::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 195, 0, 0.18), transparent 65%);
  filter: blur(30px);
  pointer-events: none;
}
.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}
.output-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-400);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.output-label::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold-500);
  box-shadow: 0 0 10px var(--gold-500);
  animation: pulse 2s ease-in-out infinite;
}
.output-actions { display: flex; gap: 6px; }
.output-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background var(--dur-sm) var(--ease);
}
.output-btn:hover { background: rgba(255, 195, 0, 0.18); border-color: var(--gold-500); }
.output-body {
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  z-index: 1;
  min-height: 80px;
}

/* ---------- LOADER ---------- */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}
.spin {
  width: 40px; height: 40px;
  border: 3px solid var(--cream-300);
  border-top-color: var(--navy-700);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.loader .spin-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold-500);
  animation: bounce 1.2s ease-in-out infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 0%, var(--cream-300) 50%, var(--bg-soft) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skeleton-line { height: 12px; }
.skeleton-block { height: 140px; }

/* ---------- TABS ---------- */
.seg {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
}
.seg button {
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  transition: all var(--dur-sm) var(--ease);
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-gold { background: rgba(255, 195, 0, 0.14); color: #a97d00; }
.badge-navy { background: rgba(0, 31, 69, 0.08); color: var(--navy-800); }
.badge-green { background: var(--success-soft); color: #065f46; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-rose { background: #ffe4e6; color: #9f1239; }

/* ---------- TIP / CALLOUT ---------- */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #fff7dc, #fffbef);
  border: 1px solid #fbe5a0;
  font-size: 12.5px;
  color: #6a5000;
  line-height: 1.65;
}
.callout .c-ic { flex-shrink: 0; }
.callout-info {
  background: #ecf4ff;
  border-color: #bfd7ff;
  color: #1e40af;
}

/* ---------- TOAST ---------- */
#toast-root {
  position: fixed;
  top: 80px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: toastIn var(--dur-md) var(--ease-out);
}
.toast.out { animation: toastOut var(--dur-md) var(--ease-in) forwards; }
.toast-ic {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 13px;
}
.toast-success .toast-ic { background: var(--success-soft); color: #065f46; }
.toast-error .toast-ic { background: var(--danger-soft); color: #991b1b; }
.toast-info .toast-ic { background: #dbeafe; color: #1e40af; }
.toast-gold .toast-ic { background: rgba(255, 195, 0, 0.18); color: #a97d00; }

/* ---------- MODAL ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 17, 41, 0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
  animation: modalBg var(--dur-md) var(--ease-out);
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--dur-md) var(--ease-out);
  border: 1px solid var(--line);
}
.modal-head { margin-bottom: 6px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-desc { font-size: 13px; color: var(--muted); margin-top: 4px; margin-bottom: 18px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ---------- STATS ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.stat .s-label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.stat .s-value { font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.stat .s-delta { font-size: 11.5px; margin-top: 2px; color: var(--success); font-weight: 600; }
.stat .s-delta.down { color: var(--danger); }
.stat .s-ic {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  width: 36px; height: 36px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 16px;
}

/* ---------- AVATAR ---------- */
.av {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-gold);
  color: var(--navy-900);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.av-lg { width: 80px; height: 80px; font-size: 28px; border-radius: 22px; }
.av-xl { width: 112px; height: 112px; font-size: 40px; border-radius: 28px; }

/* ---------- DIVIDER ---------- */
.hr { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* ---------- LIST ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border var(--dur-sm) var(--ease), transform var(--dur-sm) var(--ease);
}
.list-item:hover { border-color: var(--muted-2); transform: translateX(-2px); }
.list-item .li-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.list-item .li-sub { font-size: 11.5px; color: var(--muted); }

/* ---------- DROPDOWN ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: all var(--dur-sm) var(--ease);
  z-index: 30;
}
.dropdown.open .dropdown-menu { opacity: 1; pointer-events: auto; transform: translateY(0); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-sm) var(--ease);
}
.dropdown-item:hover { background: var(--bg-soft); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* ---------- PROGRESS ---------- */
.progress {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--grad-gold);
  border-radius: 999px;
  transition: width var(--dur-lg) var(--ease-out);
  position: relative;
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 2s linear infinite;
}
