/* ==========================================================================
   Rocket Genie HRMS - design system
   Tokens are derived from the Rocket Genie logo gradient:
   #547FFF (blue) -> #6E5CFF (indigo) -> #A055FF (violet)
   Every page loads this file first; nothing below defines its own colours.
   ========================================================================== */

:root {
  /* Brand */
  --rg-blue: #547FFF;
  --rg-indigo: #6E5CFF;
  --rg-violet: #A055FF;
  --rg-gradient: linear-gradient(120deg, var(--rg-blue), var(--rg-indigo) 55%, var(--rg-violet));

  /* Deep indigo family - the logo's dark counterpart, not a tinted black */
  --ink: #151A38;
  --ink-2: #1E2550;
  --ink-3: #2A3266;
  --ink-4: #3A4278;

  /* Surfaces */
  --surface: #F4F6FC;
  --card: #FFFFFF;
  --card-alt: #FAFBFE;
  --line: #E3E7F3;
  --line-strong: #CFD6EA;

  /* Text */
  --text: #1B2143;
  --text-2: #4A5280;
  --muted: #6B739B;
  --on-dark: #FFFFFF;
  --on-dark-muted: #A6AED6;

  /* Status */
  --ok: #0E9F6E;
  --ok-bg: #E6F6EF;
  --warn: #B4700A;
  --warn-bg: #FDF3E2;
  --bad: #DC2B43;
  --bad-bg: #FDECEF;
  --info: #3C63D8;
  --info-bg: #ECF1FE;
  --neutral: #6B739B;
  --neutral-bg: #EFF1F8;

  /* Shape */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Elevation - three levels only, used by hierarchy not decoration */
  --sh-1: 0 1px 2px rgba(21, 26, 56, .06);
  --sh-2: 0 4px 16px rgba(21, 26, 56, .08);
  --sh-3: 0 18px 48px rgba(21, 26, 56, .16);

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Type */
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 16px;
  --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 34px;

  --sidebar-w: 252px;
  --sidebar-w-collapsed: 72px;
  --header-h: 64px;
  --t-fast: 120ms ease;
  --t: 200ms cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

/* Numbers line up in every table and KPI */
.num, td.num, .kpi-value, .money { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--s-3); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--rg-indigo);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- Layout shell ---------- */
.app { min-height: 100vh; }
.workspace {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t);
}
body.sidebar-collapsed .workspace { margin-left: var(--sidebar-w-collapsed); }
.page { padding: var(--s-5) var(--s-6) var(--s-7); max-width: 1440px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5);
}
.page-head .sub { color: var(--muted); margin: var(--s-1) 0 0; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: var(--fs-base); }
.card-head .hint { color: var(--muted); font-size: var(--fs-xs); }
.card-body { padding: var(--s-5); }
.card-body.tight { padding: var(--s-3) var(--s-4); }
.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  font: 600 var(--fs-base)/1 var(--font);
  padding: 10px 16px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
  cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--card-alt); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn-primary {
  background: var(--ink); border-color: var(--ink); color: var(--on-dark);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-brand { background: var(--rg-gradient); border: none; color: var(--on-dark); }
.btn-brand:hover { background: var(--rg-gradient); border: none; filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--neutral-bg); border-color: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); filter: brightness(1.06); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.05); }
.btn-sm { padding: 6px 11px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.6;
  background: var(--neutral-bg); color: var(--neutral);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.plain::before { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--card); font-size: var(--fs-xs); color: var(--text-2);
}

/* ---------- Avatars ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden;
  background: var(--rg-gradient); color: #fff;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 72px; height: 72px; font-size: var(--fs-lg); }
.avatar.sm { width: 28px; height: 28px; font-size: 10px; }
.identity { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.identity .name { font-weight: 600; }
.identity .meta { color: var(--muted); font-size: var(--fs-xs); }
.identity > div { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: var(--r-pill); background: var(--neutral-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--rg-gradient); transition: width var(--t); }
.bar.thin { height: 5px; }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.meter-label { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 6px; }

/* Donut ring drawn with conic-gradient - no library needed */
.ring {
  --pct: 0;
  width: 104px; height: 104px; border-radius: 50%;
  background: conic-gradient(var(--rg-indigo) calc(var(--pct) * 1%), var(--neutral-bg) 0);
  display: grid; place-items: center; position: relative; flex: 0 0 auto;
}
.ring::after {
  content: ""; position: absolute; inset: 10px; background: var(--card); border-radius: 50%;
}
.ring > div { position: relative; text-align: center; line-height: 1.2; }
.ring .pct { font-size: var(--fs-md); font-weight: 700; font-variant-numeric: tabular-nums; }
.ring .cap { font-size: 10px; color: var(--muted); }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 90;
  display: flex; flex-direction: column; gap: var(--s-2); max-width: 380px;
}
.toast {
  display: flex; gap: var(--s-3); align-items: flex-start;
  background: var(--ink); color: var(--on-dark);
  padding: 12px 14px; border-radius: var(--r); box-shadow: var(--sh-3);
  animation: toast-in 180ms cubic-bezier(.2, .7, .3, 1);
}
.toast .t-title { font-weight: 700; font-size: var(--fs-sm); }
.toast .t-msg { font-size: var(--fs-sm); color: var(--on-dark-muted); }
.toast.ok { background: #0B7D57; }
.toast.bad { background: #B02036; }
.toast .t-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; font-size: 16px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(21, 26, 56, .48);
  display: grid; place-items: center; padding: var(--s-4);
  overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  width: min(680px, 100%); max-height: 92vh; display: flex; flex-direction: column;
  animation: modal-in 180ms cubic-bezier(.2, .7, .3, 1);
}
.modal.sm { width: min(460px, 100%); }
.modal.lg { width: min(920px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line);
}
.modal-body { padding: var(--s-5); overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); background: var(--card-alt);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- Loading / empty / error states ---------- */
.skeleton {
  background: linear-gradient(90deg, #E9EDF8 25%, #F3F5FC 37%, #E9EDF8 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-row { height: 44px; margin-bottom: 8px; border-radius: var(--r); }
.sk-card { height: 96px; border-radius: var(--r-lg); }

.state {
  padding: var(--s-7) var(--s-5); text-align: center; color: var(--muted);
}
.state .state-icon {
  width: 44px; height: 44px; margin: 0 auto var(--s-3); border-radius: var(--r);
  display: grid; place-items: center; background: var(--neutral-bg); color: var(--text-2);
}
.state h4 { color: var(--text); margin-bottom: 6px; }
.state.error .state-icon { background: var(--bad-bg); color: var(--bad); }
.state .btn { margin-top: var(--s-4); }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: var(--s-3); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); } .mb-0 { margin-bottom: 0; } .mb-4 { margin-bottom: var(--s-4); }
.mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.divider { height: 1px; background: var(--line); margin: var(--s-4) 0; }
.kv { display: grid; grid-template-columns: 168px 1fr; gap: 10px var(--s-4); }
.kv dt { color: var(--muted); font-size: var(--fs-sm); }
.kv dd { margin: 0; font-weight: 600; }
