/* ============================================================
   MACK Media — Internal Dashboard
   Shares design tokens with the marketing site.
   ============================================================ */
:root {
  --ink: #0D1220;
  --graphite: #1B2232;
  --cream: #F5F5F7;
  --paper: #FFFFFF;
  --line: #E5E7EB;
  --line-strong: #D1D5DB;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --accent: #FF4757;
  --accent-soft: #FFE6E9;
  --accent-2: #FF8DA0;
  --success: #10B981;
  --warn: #F59E0B;
  --danger: #E63946;

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

  --shadow-sm: 0 1px 2px rgba(10,10,11,.04), 0 2px 6px rgba(10,10,11,.03);
  --shadow-md: 0 6px 20px rgba(10,10,11,.06), 0 2px 4px rgba(10,10,11,.04);
  --shadow-lg: 0 24px 60px rgba(10,10,11,.12), 0 4px 10px rgba(10,10,11,.05);

  --font-display: "Inter Tight", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;

  --sidebar-w: 232px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4,h5 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout ---------- */
body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--ink); color: #D7D9E3;
  display: flex; flex-direction: column;
  padding: 20px 14px 18px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 20px;
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em;
  font-size: 16px; color: #fff;
}
.sidebar__mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__nav a {
  padding: 9px 12px; border-radius: 8px;
  font-size: 14px; color: #9CA3AF; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar__nav a:hover { color: #fff; background: rgba(255,255,255,.04); }
.sidebar__nav a.is-active { color: #fff; background: rgba(255,71,87,.15); }
.sidebar__footer {
  margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis;
}

.main { padding: 28px 36px 64px; min-width: 0; overflow-y: auto; }

/* ---------- View heading ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 {
  font-size: 26px; letter-spacing: -0.02em;
}
.page-head p { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 8px;
  font-weight: 500; font-size: 14px;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
  white-space: nowrap;
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: #1B2232; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: #e63946; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn--ghost:hover { background: var(--paper); border-color: var(--ink); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--accent-soft); }

/* ---------- Cards ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head h2 { font-size: 16px; font-weight: 600; }
.card__head .tools { display: flex; gap: 8px; align-items: center; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: 1fr 1fr; } }
.kpi-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi-card__label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.kpi-card__value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-card__sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 14px;
}
table.data th, table.data td {
  padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data thead th {
  background: #FAFAFB; font-weight: 600; font-size: 12px;
  color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: #FAFAFB; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: 4px; }

/* ---------- Pills / tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
  background: var(--cream); color: var(--muted); border: 1px solid var(--line);
}
.pill--active  { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.pill--inactive{ background: #F3F4F6; color: var(--muted); }
.pill--paid    { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.pill--unpaid  { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.pill--overdue { background: #FECACA; color: #991B1B; border-color: #FCA5A5; }
.pill--approved{ background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.pill--pending { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.pill--rejected{ background: #FECACA; color: #991B1B; border-color: #FCA5A5; }
.pill--WHT      { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.pill--SSO      { background: #E9D5FF; color: #6B21A8; border-color: #D8B4FE; }
.pill--QR       { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.pill--legal    { background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.pill--invoice  { background: #FFE4E6; color: #9F1239; border-color: #FCA5A5; }
.pill--receipt  { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.pill--contract { background: #E0E7FF; color: #3730A3; border-color: #A5B4FC; }
.pill--payslip  { background: #F0FDF4; color: #166534; border-color: #86EFAC; }
.pill--annual   { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.pill--sick     { background: #FEE2E2; color: #991B1B; border-color: #FCA5A5; }
.pill--other    { background: var(--cream); color: var(--muted); }

/* ---------- Clickable category filter pills ---------- */
.cat-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.cat-filter {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  cursor: pointer; border: 1.5px solid transparent;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  user-select: none;
}
.cat-filter:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.cat-filter.is-active { box-shadow: 0 0 0 2px var(--ink); }
.cat-filter .count {
  background: rgba(0,0,0,.12); border-radius: 999px;
  padding: 0 6px; font-size: 10.5px; font-weight: 700;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--line); margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 18px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Employee profile ---------- */
.emp-profile-header {
  display: flex; align-items: flex-start; gap: 18px;
  padding: 24px 28px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.emp-avatar-lg {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.02em;
}
.emp-profile-header .meta h2 { font-size: 22px; margin-bottom: 4px; }
.emp-profile-header .meta p  { color: var(--muted); font-size: 14px; margin: 0; }
.emp-profile-header .badges  { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.emp-profile-actions { margin-left: auto; display: flex; gap: 8px; align-items: flex-start; }

/* ---------- Salary history timeline ---------- */
.salary-timeline { display: flex; flex-direction: column; gap: 0; }
.salary-event {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.salary-event:last-child { border-bottom: 0; }
.salary-event__dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0; margin-top: 5px;
}
.salary-event__info { flex: 1; }
.salary-event__amount { font-weight: 700; font-size: 15px; }
.salary-event__old    { color: var(--muted); text-decoration: line-through; font-size: 13px; }
.salary-event__date   { color: var(--muted); font-size: 12px; }

/* ---------- Invoice line items editor ---------- */
.line-items { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.line-item {
  display: grid; grid-template-columns: 1fr 70px 100px 90px 28px;
  gap: 8px; align-items: center;
}
.line-item input { height: 36px; padding: 0 8px; font-size: 13.5px; }
.line-item .li-total { font-weight: 600; text-align: right; font-size: 13.5px; padding: 0 4px; font-variant-numeric: tabular-nums; }
.line-item .li-remove { width: 28px; height: 28px; border-radius: 6px; color: var(--muted); font-size: 18px; display: grid; place-items: center; }
.line-item .li-remove:hover { background: var(--accent-soft); color: var(--danger); }
.line-items-header { display: grid; grid-template-columns: 1fr 70px 100px 90px 28px; gap: 8px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; padding: 0 0 4px; border-bottom: 1px solid var(--line); }
.line-items-footer { display: flex; justify-content: flex-end; gap: 24px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13.5px; }
.line-items-footer .subtotal { color: var(--muted); }
.line-items-footer .total { font-weight: 700; font-size: 15px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink); }
.field input, .field select, .field textarea {
  height: 40px; padding: 0 12px;
  background: #FAFAFB; border: 1px solid var(--line); border-radius: 8px;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.field textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--ink); background: #fff; }
.field--row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field--row3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar select, .filter-bar input {
  height: 36px; padding: 0 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px;
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--paper);
}
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 16px; }
.empty p { font-size: 13.5px; margin-bottom: 16px; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(13,18,32,.45); backdrop-filter: blur(2px); }
.modal {
  position: relative; background: var(--paper); border-radius: var(--radius-lg);
  width: min(560px, 92vw); max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal--wide { width: min(760px, 92vw); }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal__head h3 { font-size: 17px; }
.modal__close {
  width: 32px; height: 32px; border-radius: 8px; font-size: 22px; color: var(--muted);
  display: grid; place-items: center; transition: background .15s var(--ease);
}
.modal__close:hover { background: var(--cream); color: var(--ink); }
.modal__body { padding: 22px; overflow-y: auto; display: grid; gap: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  padding: 12px 18px; background: var(--ink); color: #fff; font-size: 13.5px;
  border-radius: 10px; z-index: 200; box-shadow: var(--shadow-lg);
}
.toast--err { background: var(--danger); }

/* ---------- Calc preview box ---------- */
.calc-preview {
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px;
  font-size: 13.5px;
}
.calc-preview dt { color: var(--muted); }
.calc-preview dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.calc-preview .total-row { grid-column: 1 / -1; border-top: 1px solid var(--line-strong); padding-top: 10px; margin-top: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.calc-preview .total-row dt { font-weight: 600; color: var(--ink); }
.calc-preview .total-row dd { font-size: 16px; }

/* ---------- File input / uploader ---------- */
.file-input {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #FAFAFB; border: 1px dashed var(--line-strong);
  border-radius: 8px; font-size: 13px;
}

/* ---------- Section intro on Leave balances ---------- */
.leave-balance-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 700px) { .leave-balance-grid { grid-template-columns: 1fr; } }
.leave-balance {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.leave-balance:last-child { border-bottom: 0; }
.leave-balance small { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    padding: 10px 12px; gap: 8px; overflow-x: auto;
  }
  .sidebar__brand { padding: 6px 8px 6px 4px; }
  .sidebar__nav { flex-direction: row; gap: 4px; flex: 1; overflow-x: auto; }
  .sidebar__nav a { white-space: nowrap; }
  .sidebar__footer { display: none; }
  .main { padding: 20px 16px 48px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .field--row, .field--row3 { grid-template-columns: 1fr; }
}
