@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap');

/* ══════════════════════════════════════════
   DESIGN TOKENS — Light Mode (default)
══════════════════════════════════════════ */
:root {
  /* Brand */
  --brand:        #2563eb;
  --brand-hover:  #1d4ed8;
  --brand-soft:   rgba(37,99,235,0.09);
  --brand-glow:   rgba(37,99,235,0.18);

  /* Semantic */
  --success:      #16a34a;
  --success-soft: rgba(22,163,74,0.10);
  --warning:      #d97706;
  --warning-soft: rgba(217,119,6,0.10);
  --danger:       #dc2626;
  --danger-soft:  rgba(220,38,38,0.10);
  --info:         #0891b2;
  --info-soft:    rgba(8,145,178,0.10);
  --purple:       #7c3aed;
  --purple-soft:  rgba(124,58,237,0.10);

  /* Surfaces */
  --bg:           #f8f9fc;
  --surface:      #ffffff;
  --surface-2:    #f1f4f9;
  --surface-3:    #e8ecf4;
  --sidebar-bg:   #0f172a;
  --sidebar-text: rgba(255,255,255,0.60);
  --sidebar-text-active: #ffffff;
  --sidebar-hover:rgba(255,255,255,0.07);
  --sidebar-active:rgba(37,99,235,0.25);

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  /* Borders */
  --border:       rgba(0,0,0,0.08);
  --border-focus: rgba(37,99,235,0.40);

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05);

  /* Layout */
  --sidebar-w:  252px;
  --header-h:   60px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  /* Typography */
  --font:         'Plus Jakarta Sans', sans-serif;
  --font-serif:   'Instrument Serif', serif;

  /* Transitions */
  --t: 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ══════════════════════════════════════════
   DARK MODE TOKENS
══════════════════════════════════════════ */
[data-theme="dark"] {
  --brand:        #3b82f6;
  --brand-hover:  #60a5fa;
  --brand-soft:   rgba(59,130,246,0.12);
  --brand-glow:   rgba(59,130,246,0.22);

  --success:      #22c55e;
  --success-soft: rgba(34,197,94,0.12);
  --warning:      #f59e0b;
  --warning-soft: rgba(245,158,11,0.12);
  --danger:       #f87171;
  --danger-soft:  rgba(248,113,113,0.12);
  --info:         #22d3ee;
  --info-soft:    rgba(34,211,238,0.12);
  --purple:       #a78bfa;
  --purple-soft:  rgba(167,139,250,0.12);

  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #1c2333;
  --surface-3:    #243044;
  --sidebar-bg:   #0d1117;
  --sidebar-text: rgba(255,255,255,0.55);
  --sidebar-text-active: #ffffff;
  --sidebar-hover:rgba(255,255,255,0.06);
  --sidebar-active:rgba(59,130,246,0.20);

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --border:       rgba(255,255,255,0.08);
  --border-focus: rgba(59,130,246,0.50);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.30);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.40);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.50);
}

/* ══════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--t), color var(--t);
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
img { display: block; max-width: 100%; }

/* ══════════════════════════════════════════
   TYPOGRAPHY
══════════════════════════════════════════ */
.serif { font-family: var(--font-serif); }
.text-xs  { font-size: 11px; }
.text-sm  { font-size: 12px; }
.text-md  { font-size: 14px; }
.text-lg  { font-size: 16px; }
.text-xl  { font-size: 20px; }
.text-2xl { font-size: 24px; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-brand     { color: var(--brand) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.text-danger    { color: var(--danger) !important; }
.text-purple    { color: var(--purple) !important; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  border-radius: var(--radius); border: none; cursor: pointer;
  transition: all var(--t); white-space: nowrap;
  padding: 9px 18px; line-height: 1;
}
.btn-brand {
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.btn-brand:hover { background: var(--brand-hover); transform: translateY(-1px); box-shadow: 0 4px 16px var(--brand-glow); color: #fff; }
.btn-brand:active { transform: translateY(0); }

.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

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

.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); gap: 5px; }
.btn-lg  { padding: 12px 24px; font-size: 14px; }
.btn-icon { padding: 8px; border-radius: var(--radius); width: 36px; height: 36px; }
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 5px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow-sm); transition: border-color var(--t), box-shadow var(--t);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-flat { box-shadow: none; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-brand   { background: var(--brand-soft);   color: var(--brand);   }
.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-purple  { background: var(--purple-soft);  color: var(--purple);  }
.badge-neutral { background: var(--surface-2);    color: var(--text-secondary); }
.badge-dot::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

/* ══════════════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 7px; letter-spacing: 0.02em;
}
.pass-group { position: relative; }
.pass-group .form-control { padding-left: 38px; }
.pass-group.has-right .form-control { padding-right: 38px; }
.input-icon-left  { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; display: flex; align-items: center; }
.input-icon-right { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); cursor: pointer; display: flex; align-items: center; }

.form-control {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  color: var(--text-primary); font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-glow); outline: none; }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }
.input-group .form-control { padding-left: 38px; }
.input-group.has-right .form-control { padding-right: 38px; }
select.form-control {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm); transition: all var(--t);
  position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-focus); }
.stat-icon-wrap {
  width: 42px; height: 42px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.stat-val { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-change { font-size: 11px; font-weight: 600; margin-top: 10px; display: flex; align-items: center; gap: 4px; }

/* ══════════════════════════════════════════
   TABLE
══════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); padding: 10px 14px;
  border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap;
}
.tbl tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: 13px; vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--t); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl-scroll { overflow-x: auto; }

/* ══════════════════════════════════════════
   AVATAR
══════════════════════════════════════════ */
.avatar {
  border-radius: 50%; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; font-family: var(--font);
}
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }

/* ══════════════════════════════════════════
   PROGRESS
══════════════════════════════════════════ */
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 1.2s cubic-bezier(0.4,0,0.2,1); }

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

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex !important; align-items: flex-start; gap: 12px;
  opacity: 1 !important;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 16px; min-width: 270px; max-width: 360px;
  box-shadow: var(--shadow-lg); animation: toastIn 0.3s ease forwards;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-error   { border-left: 3px solid var(--danger);  }
.toast-info    { border-left: 3px solid var(--brand);   }
.toast-icon    { flex-shrink: 0; margin-top: 1px; }
.toast-body    { flex: 1; font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.toast-close   { flex-shrink: 0; color: var(--text-muted); cursor: pointer; padding: 2px; }
.toast-close:hover { color: var(--text-primary); }

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }
.toast.out { animation: toastOut 0.25s ease forwards; }

/* ══════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════ */
@keyframes fadeUp  { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes spin    { to { transform:rotate(360deg); } }
@keyframes pulse   { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.fade-up { animation: fadeUp 0.45s ease both; }
.delay-1 { animation-delay: 0.06s; }
.delay-2 { animation-delay: 0.12s; }
.delay-3 { animation-delay: 0.18s; }
.delay-4 { animation-delay: 0.24s; }
.delay-5 { animation-delay: 0.30s; }
.delay-6 { animation-delay: 0.36s; }

.spin { animation: spin 0.8s linear infinite; }

/* ══════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════ */
.d-flex    { display: flex; }
.d-grid    { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1    { flex: 1; }
.gap-4     { gap: 4px; }
.gap-6     { gap: 6px; }
.gap-8     { gap: 8px; }
.gap-10    { gap: 10px; }
.gap-12    { gap: 12px; }
.gap-14    { gap: 14px; }
.gap-16    { gap: 16px; }
.gap-20    { gap: 20px; }
.mt-4      { margin-top: 4px; }
.mt-8      { margin-top: 8px; }
.mt-12     { margin-top: 12px; }
.mt-16     { margin-top: 16px; }
.mt-20     { margin-top: 20px; }
.mb-4      { margin-bottom: 4px; }
.mb-8      { margin-bottom: 8px; }
.mb-12     { margin-bottom: 12px; }
.mb-16     { margin-bottom: 16px; }
.mb-20     { margin-bottom: 20px; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full    { width: 100%; }
.rounded   { border-radius: var(--radius); }
.rounded-full { border-radius: 50%; }
.cursor-pointer { cursor: pointer; }
