/* ---------- Design tokens ---------- */
:root {
  --sidebar-top: #1e40e8;
  --sidebar-bottom: #0b1450;
  --sidebar-active: #2f6bf6;

  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --brand-soft: #eff5ff;

  --ink: #17224d;
  --ink-2: #475569;
  --muted: #6b7794;
  --muted-2: #94a3b8;

  --line: #e5e9f2;
  --line-2: #eef1f7;
  --bg: #f9fafc;
  --card: #ffffff;

  --green: #16a34a;
  --amber: #f59e0b;
  --red: #ef4444;
  --pink: #f43f5e;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .16);

  --sidebar-w: 212px;
  --topbar-h: 56px;
  --content-w: 880px;

  --font: 'Poppins', 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Poppins', 'Segoe UI Variable Display', 'Segoe UI Semibold', 'Segoe UI', -apple-system, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 30px; letter-spacing: -.025em; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { display: block; flex: none; }
ul { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-ghost { background: #fff; color: var(--brand); border-color: #cfe0fd; }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-outline:hover:not(:disabled) { background: #f8fafc; border-color: #d7dded; }
.btn-plain { background: transparent; color: var(--ink-2); border-color: transparent; padding: 0 10px; }
.btn-plain:hover:not(:disabled) { background: #f1f5f9; color: var(--ink); }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-upgrade {
  background: linear-gradient(180deg, #fb6b80, #f43f5e);
  color: #fff; height: 32px; padding: 0 13px; font-size: 13px; border-radius: 7px;
  box-shadow: 0 1px 3px rgba(244, 63, 94, .4);
}
.btn-upgrade:hover { filter: brightness(1.05); }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  outline: none; transition: border-color .15s, box-shadow .15s; color: var(--ink);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 90px; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 130, 246, .15); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m7 9 5-5 5 5M7 15l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}

/* Toggle switch */
.switch { position: relative; width: 34px; height: 19px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: background .18s;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(15px); }

/* ---------- Utility ---------- */
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 9000; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #101b3d; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.21,1.02,.73,1);
  max-width: 460px;
}
.toast.ok svg { color: #4ade80; } .toast.err svg { color: #fb7185; }
.toast.out { animation: toastOut .2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 8000; padding: 24px;
  animation: fadeIn .15s;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: calc(100vh - 60px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn .2s cubic-bezier(.21,1.02,.73,1);
}
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line-2); display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: #fcfdfe; }
.icon-x { background: none; border: 0; padding: 4px; border-radius: 6px; color: var(--muted); display: flex; }
.icon-x:hover { background: #f1f5f9; color: var(--ink); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
