/* ==========================================================================
   HRMS admin backend — design system

   Deliberately a light, calm counterpart to the dark operator console: HR
   staff live in this all day, and the data (names, money, dates) should carry
   the visual weight rather than the chrome.
   ========================================================================== */

:root {
  /* Neutrals */
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #fbfbfd;
  --border:        #e3e6ec;
  --border-strong: #d2d7e0;

  /* Ink */
  --ink:        #10141c;
  --ink-2:      #414a5b;
  --ink-muted:  #6b7484;
  --ink-faint:  #949cab;

  /* Brand */
  --brand:        #4f46e5;
  --brand-hover:  #4338ca;
  --brand-soft:   #eef2ff;
  --brand-border: #c7d0fb;

  /* Semantic */
  --ok:      #0f8a5f;
  --ok-soft: #e6f6ef;
  --warn:      #b26b00;
  --warn-soft: #fdf3e2;
  --danger:      #c1332c;
  --danger-soft: #fdeceb;
  --info:      #1d6fd0;
  --info-soft: #e8f1fd;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 28, .05);
  --shadow:    0 1px 3px rgba(16, 20, 28, .07), 0 6px 16px -6px rgba(16, 20, 28, .10);
  --shadow-lg: 0 18px 44px -12px rgba(16, 20, 28, .22);

  --sidebar-w: 244px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Numeric columns line up only with tabular figures. */
.tabular, td.num, th.num, .metric__value, .money { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }

/* ==========================================================================
   Icons
   ========================================================================== */

.icon, svg use {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon { width: 18px; height: 18px; flex: none; }
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 22px; height: 22px; }

/* ==========================================================================
   Shell
   ========================================================================== */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.brand__mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #7c73f0);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .02em;
  flex: none;
}
.brand__name {
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: -.01em;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand__sub { font-size: 11.5px; color: var(--ink-faint); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__section {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
  padding: 14px 10px 5px;
}
.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7.5px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav__link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav__link.is-active { background: var(--brand-soft); color: var(--brand-hover); font-weight: 600; }
.nav__link.is-active .icon { color: var(--brand); }
.nav__label { flex: 1; }
.nav__count {
  font-size: 11px;
  font-weight: 650;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
}

.sidebar__foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ==========================================================================
   Main column
   ========================================================================== */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.page-title { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.page-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 1px; }

.userbox { display: flex; align-items: center; gap: 10px; }
.userbox__meta { text-align: right; line-height: 1.25; }
.userbox__name { font-weight: 600; font-size: 13px; }
.userbox__role { font-size: 11.5px; color: var(--ink-muted); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-hover);
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 12px;
  flex: none;
}
.avatar--sm { width: 27px; height: 27px; font-size: 10.5px; }
.avatar--lg { width: 60px; height: 60px; font-size: 19px; }

.content { padding: 22px 26px 48px; display: flex; flex-direction: column; gap: 20px; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 14px; font-weight: 650; }
.card__hint { font-size: 12px; color: var(--ink-muted); font-weight: 400; }
.card__body { padding: 18px; }
.card__foot {
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
}

.grid { display: grid; gap: 20px; }
.grid--metrics { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

/* ==========================================================================
   Metric tiles
   ========================================================================== */

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
}
.metric__top { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.metric__icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.metric__icon--ok     { background: var(--ok-soft);     color: var(--ok); }
.metric__icon--warn   { background: var(--warn-soft);   color: var(--warn); }
.metric__icon--danger { background: var(--danger-soft); color: var(--danger); }
.metric__icon--info   { background: var(--info-soft);   color: var(--info); }

.metric__label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.metric__value { font-size: 27px; font-weight: 680; letter-spacing: -.025em; line-height: 1.1; }
.metric__note { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-muted);
  background: var(--surface-2);
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

.cell-person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-person__name { font-weight: 600; line-height: 1.25; }
.cell-person__meta { font-size: 12px; color: var(--ink-muted); }

/* ==========================================================================
   Badges & pills
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge--ok     { background: var(--ok-soft);     color: var(--ok);     border-color: #bfe6d4; }
.badge--warn   { background: var(--warn-soft);   color: var(--warn);   border-color: #f2ddb6; }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c6; }
.badge--info   { background: var(--info-soft);   color: var(--info);   border-color: #c3ddf8; }
.badge--muted  { background: #f0f2f5;            color: var(--ink-muted); border-color: var(--border); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { background: var(--surface); color: var(--ink-2); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }
.btn--sm { padding: 5.5px 10px; font-size: 12.5px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field__input,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 8.5px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field__input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}
.field__help { font-size: 12px; color: var(--ink-muted); }
.field__error { font-size: 12px; color: var(--danger); font-weight: 500; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; }

/* ==========================================================================
   Alerts & banners
   ========================================================================== */

.alerts { display: flex; flex-direction: column; gap: 9px; }
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid;
}
.alert--success { background: var(--ok-soft);     color: #0b6b4a; border-color: #bfe6d4; }
.alert--error,
.alert--warning { background: var(--warn-soft);   color: #8a5300; border-color: #f2ddb6; }
.alert--danger  { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c6; }
.alert--info    { background: var(--info-soft);   color: #175aa8; border-color: #c3ddf8; }

.license-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 26px;
  font-size: 12.5px;
  font-weight: 550;
  background: var(--warn-soft);
  color: #8a5300;
  border-bottom: 1px solid #f2ddb6;
}

/* ==========================================================================
   Progress
   ========================================================================== */

.bar { height: 6px; border-radius: 999px; background: #eceef2; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar__fill--ok     { background: var(--ok); }
.bar__fill--warn   { background: var(--warn); }
.bar__fill--danger { background: var(--danger); }

/* ==========================================================================
   Misc
   ========================================================================== */

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-muted); }
.small { font-size: 12px; }
.strong { font-weight: 650; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }

.empty {
  padding: 38px 20px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}
.empty__title { font-weight: 600; color: var(--ink-2); margin-bottom: 3px; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 9px 18px; font-size: 13.5px; }
.kv dt { color: var(--ink-muted); }
.kv dd { font-weight: 550; }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ==========================================================================
   Auth screen
   ========================================================================== */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 18px;
  background:
    radial-gradient(920px 420px at 12% -8%, rgba(79, 70, 229, .10), transparent 62%),
    radial-gradient(760px 380px at 88% 4%, rgba(124, 115, 240, .09), transparent 62%),
    var(--bg);
}
.auth__card {
  width: 100%;
  max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px;
}
.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth__title { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.auth__sub { font-size: 12.5px; color: var(--ink-muted); }
.auth__note {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.55;
}

/* ==========================================================================
   Lock screen — must read clearly when nothing else in the app works
   ========================================================================== */

.lock { min-height: 100vh; display: grid; place-items: center; padding: 30px 18px; background: var(--bg); }
.lock__card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.lock__head {
  padding: 26px 30px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 15px;
  align-items: flex-start;
}
.lock__icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  display: grid;
  place-items: center;
  flex: none;
}
.lock__title { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.lock__message { font-size: 13.5px; color: var(--ink-2); margin-top: 5px; line-height: 1.55; }
.lock__body { padding: 22px 30px 26px; }

/* ==========================================================================
   Payslip
   ========================================================================== */

.payslip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.payslip__head { padding: 22px 26px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.payslip__cols { display: grid; grid-template-columns: 1fr 1fr; }
.payslip__col { padding: 0; }
.payslip__col + .payslip__col { border-left: 1px solid var(--border); }
.payslip__colhead {
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.payslip__line { display: flex; justify-content: space-between; gap: 14px; padding: 9px 20px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.payslip__total {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 12px 20px; font-weight: 650; background: var(--surface-2);
}
.payslip__net {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 26px; border-top: 1px solid var(--border);
  background: var(--brand-soft);
}
.payslip__net-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--brand-hover); }

@media print {
  .sidebar, .topbar, .no-print, .license-banner { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .payslip { border: none; box-shadow: none; }
}

/* ==========================================================================
   First-run setup checklist
   ========================================================================== */

.setup { border-color: var(--brand-border); }
.setup .card__head { background: var(--brand-soft); }

.setup__list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.setup__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
}
.setup__item + .setup__item { border-top: 1px solid var(--border); }
.setup__item--todo:hover { background: var(--surface-2); }

.setup__tick {
  width: 24px; height: 24px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: #f0f2f5;
  color: var(--ink-muted);
  border: 1px solid var(--border-strong);
}
.setup__item--done .setup__tick {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #bfe6d4;
}

.setup__tick--done { background: var(--ok-soft); color: var(--ok); border-color: #bfe6d4; }

.setup__body { flex: 1; min-width: 0; }
.setup__title { font-weight: 600; font-size: 13.5px; }
.setup__detail { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; line-height: 1.45; }
.setup__item--done .setup__title { color: var(--ink-muted); text-decoration: line-through; }
.setup__item--done .setup__detail { display: none; }

/* ==========================================================================
   Guided tour
   ========================================================================== */

body.tour-active { overflow: hidden; }

.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 28, 0.55);
  z-index: 900;
}

.tour-spotlight {
  position: fixed;
  z-index: 901;
  border-radius: 10px;
  /* The cut-out is a giant outer shadow rather than an SVG mask: one property,
     no reflow, and it follows the element wherever it is. */
  box-shadow: 0 0 0 9999px rgba(16, 20, 28, 0.55),
              0 0 0 3px rgba(79, 70, 229, 0.55);
  pointer-events: none;
  transition: top .18s ease, left .18s ease, width .18s ease, height .18s ease;
}
/* The spotlight already paints the scrim, so the overlay only needs to catch
   clicks. Keeping both visible would double the darkness. */
.tour-active .tour-overlay { background: transparent; }

.tour-pop {
  position: fixed;
  z-index: 902;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 15px 16px;
  transition: top .18s ease, left .18s ease;
}
.tour-pop__title { font-size: 14px; font-weight: 650; margin-bottom: 5px; }
.tour-pop__body { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.tour-pop__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tour-pop__count { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.tour-pop__actions { display: flex; gap: 6px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1000px) {
  .grid--sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__section { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .payslip__cols { grid-template-columns: 1fr; }
  .payslip__col + .payslip__col { border-left: none; border-top: 1px solid var(--border); }
}

/* ==========================================================================
   Multi-column form layout used by the CRUD screens
   ========================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 18px;
}
/* Long text and checkboxes read badly in a narrow column. */
.form-grid .field--check,
.form-grid .field:has(textarea) { grid-column: 1 / -1; }
.field--check { margin-bottom: 10px; }
.field--check .field__label { font-weight: 600; }

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
}