/* ===== CSS VARIABLES & THEME ===== */
:root {
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --shadow: 0 4px 24px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.25);
}

[data-theme="dark"] {
  --bg: #0d0f14;
  --bg-2: #13161e;
  --bg-3: #1a1e2a;
  --bg-4: #222636;
  --border: #2a2f42;
  --text: #e8eaf0;
  --text-2: #8890a8;
  --text-3: #555e78;
  --accent: #4f6ef7;
  --accent-hover: #3d5cf5;
  --accent-soft: rgba(79,110,247,0.12);
  --success: #34d399;
  --success-soft: rgba(52,211,153,0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251,191,36,0.12);
  --danger: #f87171;
  --danger-soft: rgba(248,113,113,0.12);
  --info: #60a5fa;
  --info-soft: rgba(96,165,250,0.12);
}

[data-theme="light"] {
  --bg: #f0f2f8;
  --bg-2: #ffffff;
  --bg-3: #f5f7fc;
  --bg-4: #e8ecf5;
  --border: #d4d9ec;
  --text: #1a1e2a;
  --text-2: #4a5270;
  --text-3: #8890a8;
  --accent: #4f6ef7;
  --accent-hover: #3d5cf5;
  --accent-soft: rgba(79,110,247,0.10);
  --success: #059669;
  --success-soft: rgba(5,150,105,0.10);
  --warning: #d97706;
  --warning-soft: rgba(217,119,6,0.10);
  --danger: #dc2626;
  --danger-soft: rgba(220,38,38,0.10);
  --info: #2563eb;
  --info-soft: rgba(37,99,235,0.10);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font-display); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-display); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 1000;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.theme-toggle:hover { border-color: var(--accent); transform: scale(1.05); }
.theme-icon { font-size: 16px; line-height: 1; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(79,110,247,0.35); }
.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #1a1e2a; }
.btn-warning:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon {
  position: absolute; left: 14px;
  color: var(--text-3); font-size: 14px;
  pointer-events: none;
}
.input-wrap input,
.input-wrap select {
  width: 100%;
  padding: 12px 16px 12px 40px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
}
.input-wrap input:focus,
.input-wrap select:focus {
  border-color: var(--accent);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-wrap input::placeholder { color: var(--text-3); }
.input-eye {
  position: absolute; right: 12px;
  background: none; border: none;
  cursor: pointer; font-size: 14px;
  opacity: 0.5;
  padding: 4px;
}
.input-eye:hover { opacity: 1; }
input[type="text"]:not(.input-wrap input),
input[type="password"]:not(.input-wrap input),
input[type="email"]:not(.input-wrap input),
input[type="date"]:not(.input-wrap input),
select:not(.input-wrap select),
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: all var(--transition);
}
input[type="text"]:not(.input-wrap input):focus,
input[type="password"]:not(.input-wrap input):focus,
input[type="email"]:not(.input-wrap input):focus,
input[type="date"]:not(.input-wrap input):focus,
select:not(.input-wrap select):focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 80px; font-family: var(--font-display); }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); border: 1px solid var(--info); }

/* ===== CARDS ===== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--bg-4); color: var(--text-2); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer;
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--danger); color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ===== STAT CARD ===== */
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-delta { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== TOAST ===== */
#toastContainer {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  min-width: 260px;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid var(--info); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ===== UTILS ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-2); font-size: 13px; }
.text-sm { font-size: 13px; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.hidden { display: none !important; }
