@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #07070e;
  --bg2: #0d0d18;
  --bg3: #131320;
  --bg4: #1a1a2c;
  --card: #0f0f1c;
  --card-hover: #141428;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.11);
  --accent: #7c3aed;
  --accent2: #8b5cf6;
  --accent3: #a78bfa;
  --accent-rgb: 124,58,237;
  --accent-glow: rgba(124,58,237,0.3);
  --accent-soft: rgba(124,58,237,0.12);
  --text: #f0eeff;
  --text2: #9d99b8;
  --text3: #5e5a7a;
  --green: #10b981;
  --green-soft: rgba(16,185,129,0.12);
  --orange: #f59e0b;
  --orange-soft: rgba(245,158,11,0.12);
  --red: #ef4444;
  --red-soft: rgba(239,68,68,0.12);
  --blue: #3b82f6;
  --blue-soft: rgba(59,130,246,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-elevated: 0 8px 28px rgba(0,0,0,0.4);
  --shadow-accent: 0 0 40px rgba(124,58,237,0.25);
  --glass-bg: rgba(13,13,24,0.75);
  --glass-bg-mobile: rgba(13,13,24,0.95);
  --glass-border: rgba(255,255,255,0.08);
  --glass-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  --btn-gradient: linear-gradient(135deg, #7c3aed, #6d28d9);
  --btn-gradient-hover: linear-gradient(135deg, #6d28d9, #7c3aed);
  --topbar-bg: rgba(8,8,15,0.88);
  --input-bg: rgba(255,255,255,0.04);
  --input-bg-focus: rgba(255,255,255,0.06);
  --hover-border: rgba(255,255,255,0.15);
  --shine: rgba(255,255,255,0.1);
  --spinner-track: rgba(255,255,255,0.15);
  --overlay-bg: rgba(0,0,0,0.65);
  --drawer-shadow: 4px 0 24px rgba(0,0,0,0.5);
  --row-hover: rgba(127,127,127,0.04);
  --swatch-ring: #fff;
  --on-accent: #fff;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent3); }

/* ── Inputs ──────────────────────────────────────────────────────── */
input, select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--input-bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.25s;
}
input:focus, select:focus, textarea:focus {
  background: var(--input-bg-focus);
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 20px rgba(124,58,237,0.08);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
select option { background: var(--bg3); }

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 0.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.form-group { margin-bottom: 1rem; }

/* ── Buttons ─────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

/* Shine sweep on hover */
.btn::after {
  content: '';
  position: absolute;
  top: -50%; left: -100%;
  width: 60%; height: 200%;
  background: linear-gradient(90deg, transparent, var(--shine), transparent);
  transform: skewX(-20deg);
  transition: none;
}
.btn:hover::after {
  left: 160%;
  transition: left 0.45s ease;
}

.btn-primary {
  background: var(--btn-gradient);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--btn-gradient-hover);
  box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 1px rgba(124,58,237,0.4);
  transform: translateY(-1px);
  color: #fff;
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(124,58,237,0.3); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--bg4); color: var(--text); border-color: var(--hover-border); transform: translateY(-1px); }

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: var(--red); color: #fff; transform: translateY(-1px); }

.btn-success {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.2);
}
.btn-success:hover { background: var(--green); color: #fff; transform: translateY(-1px); }

.btn-ghost { background: transparent; color: var(--text2); padding: 0.4rem 0.6rem; }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
button:disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.7rem; font-weight: 600;
  padding: 0.25rem 0.6rem; border-radius: 100px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue); }
.badge-purple { background: var(--accent-soft); color: var(--accent3); }
.badge-gray   { background: rgba(255,255,255,0.06); color: var(--text3); }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card-hover:hover {
  background: var(--card-hover);
  border-color: var(--border2);
  box-shadow: var(--shadow-elevated);
  transform: translateY(-2px);
}

/* Glass card */
.glass {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow);
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; width: 32px; height: 32px; padding: 0;
  min-width: 32px; min-height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; flex-shrink: 0;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg4); color: var(--text); transform: rotate(90deg); }
.modal-footer { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  display: flex; align-items: center; gap: 0.6rem;
  min-width: 260px; max-width: 380px;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
@keyframes toast-in {
  from { transform: translateX(110%) scale(0.95); opacity: 0; }
  to   { transform: translateX(0)    scale(1);    opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(110%); opacity: 0; }
}

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

/* ── Keyframes ───────────────────────────────────────────────────── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes orb-a {
  0%,100% { transform: translate(0,0) scale(1); }
  33%  { transform: translate(60px,-40px) scale(1.15); }
  66%  { transform: translate(-30px,50px) scale(0.9); }
}
@keyframes orb-b {
  0%,100% { transform: translate(0,0) scale(1); }
  33%  { transform: translate(-50px,30px) scale(1.1); }
  66%  { transform: translate(40px,-60px) scale(0.95); }
}
@keyframes orb-c {
  0%,100% { transform: translate(0,0) scale(1); }
  50%  { transform: translate(30px,40px) scale(1.2); }
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes shimmer {
  from { background-position: -600px 0; }
  to   { background-position: 600px 0; }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes border-glow {
  0%,100% { border-color: rgba(124,58,237,0.3); }
  50%     { border-color: rgba(124,58,237,0.7); }
}

/* ── Aurora background ───────────────────────────────────────────── */
.aurora-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
}
.aurora-bg .orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); pointer-events: none;
  will-change: transform;
}
.aurora-bg .orb-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.28) 0%, transparent 70%);
  top: -200px; left: -150px;
  animation: orb-a 12s ease-in-out infinite;
}
.aurora-bg .orb-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.18) 0%, transparent 70%);
  bottom: -200px; right: -100px;
  animation: orb-b 15s ease-in-out infinite;
}
.aurora-bg .orb-3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.13) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  animation: orb-c 10s ease-in-out infinite;
}

/* ── Skeleton loading ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
.sk-text  { height: 14px; border-radius: 4px; margin-bottom: 8px; }
.sk-title { height: 22px; border-radius: 4px; margin-bottom: 12px; width: 60%; }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Utility ─────────────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; }
.text-sm { font-size: 0.875rem; } .text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text2); } .text-dim { color: var(--text3); }
.font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Light theme ─────────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg:   #f7f5ff;
    --bg2:  #f0edff;
    --bg3:  #e8e3f8;
    --bg4:  #dbd5f0;
    --card: #ffffff;
    --card-hover: #f8f6ff;
    --border:  rgba(100,80,200,0.1);
    --border2: rgba(100,80,200,0.17);
    --accent-glow:  rgba(124,58,237,0.2);
    --accent-soft:  rgba(124,58,237,0.09);
    --text:  #19112e;
    --text2: #483d6e;
    --text3: #8a80ae;
    --green: #059669;
    --green-soft:   rgba(5,150,105,0.1);
    --orange: #d97706;
    --orange-soft:  rgba(217,119,6,0.1);
    --red: #dc2626;
    --red-soft:     rgba(220,38,38,0.1);
    --blue: #2563eb;
    --blue-soft:    rgba(37,99,235,0.1);
    --shadow:       0 8px 32px rgba(100,80,200,0.1);
    --shadow-elevated: 0 8px 28px rgba(100,80,200,0.12);
    --shadow-accent: 0 0 40px rgba(124,58,237,0.12);
    --glass-bg:        rgba(255,255,255,0.82);
    --glass-bg-mobile: rgba(255,255,255,0.97);
    --glass-border:    rgba(100,80,200,0.12);
    --glass-shadow: 0 8px 36px rgba(100,80,200,0.12), inset 0 1px 0 rgba(255,255,255,0.8);
    --topbar-bg: rgba(247,245,255,0.92);
    --input-bg: rgba(255,255,255,0.72);
    --input-bg-focus: rgba(255,255,255,0.95);
    --hover-border: rgba(100,80,200,0.24);
    --shine: rgba(255,255,255,0.35);
    --spinner-track: rgba(25,17,46,0.14);
    --overlay-bg: rgba(25,17,46,0.42);
    --drawer-shadow: 4px 0 24px rgba(100,80,200,0.16);
    --row-hover: rgba(100,80,200,0.055);
    --swatch-ring: #19112e;
  }

  input, select, textarea { border-color: rgba(100,80,200,0.18); }

  .badge-gray { background: rgba(0,0,0,0.06); }

  .aurora-bg .orb-1 { background: radial-gradient(circle, rgba(124,58,237,0.12) 0%, transparent 70%); }
  .aurora-bg .orb-2 { background: radial-gradient(circle, rgba(124,58,237,0.08) 0%, transparent 70%); }
  .aurora-bg .orb-3 { background: radial-gradient(circle, rgba(124,58,237,0.06) 0%, transparent 70%); }
}

/* ── Entry animations ────────────────────────────────────────────── */
.animate-in { animation: fade-in-up 0.35s cubic-bezier(0.16,1,0.3,1) both; }
.animate-scale { animation: scale-in 0.25s cubic-bezier(0.34,1.56,0.64,1) both; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.empty-state svg { margin: 0 auto 1rem; opacity: 0.25; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── Mobile ──────────────────────────────────────────────────────── */
.mob-only { display: none !important; }

@media (max-width: 768px) {
  .mob-only  { display: flex !important; }
  .desk-only { display: none !important; }

  .modal { max-width: 100% !important; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 560px; }

  #toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
  .toast { min-width: unset; max-width: 100%; }

  input, select, textarea { font-size: 16px; }
  button, .btn { min-height: 40px; }
  .modal-close { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
  .btn-send { width: 36px; height: 36px; min-width: 36px; min-height: 36px; flex: 0 0 36px; }

  /* Reduce GPU load on mobile */
  .aurora-bg .orb { filter: blur(40px) !important; animation: none !important; }
  .aurora-bg .orb-1 { width: 280px !important; height: 280px !important; }
  .aurora-bg .orb-2 { width: 220px !important; height: 220px !important; }
  .aurora-bg .orb-3 { display: none !important; }
  .glass { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: var(--glass-bg-mobile) !important; }
}
