/* ============================================================
   ERP PRO — DESIGN SYSTEM
   ------------------------------------------------------------
   Two themes, one restrained palette.

     :root            → DARK  (default)
     html.theme-light → LIGHT

   Principles:
     1. ONE accent colour (the brand orange). Everything else is
        a neutral grey. Colour is reserved for status that the
        user must act on — not decoration.
     2. Never hardcode a colour outside the token blocks.
     3. Every text token is contrast-checked against the surface
        it sits on (WCAG AA: 4.5:1 body, 3:1 large text).
     4. Anything painted on a fixed-colour surface (sidebar,
        filled buttons, avatars) carries its OWN colour. An
        inherited `color` cannot be re-resolved by redeclaring a
        custom property further down the tree — that bug made the
        sidebar text invisible in light mode.
   ============================================================ */

/* ============================================================
   1. TOKENS — DARK (default)
   ============================================================ */
:root {
  /* Surfaces */
  --bg-primary:    #0c1119;
  --bg-secondary:  #141b26;
  --bg-card:       #141b26;
  --bg-card-hover: #1b2331;
  --bg-elevated:   #1b2331;
  --bg-input:      #10161f;
  --bg-muted:      #1b2331;

  /* Text — checked against --bg-card #141b26 */
  --text-primary:   #e9edf3;   /* 14.0:1 */
  --text-secondary: #a5b0c0;   /*  7.5:1 */
  --text-muted:     #8794a5;   /*  5.4:1 */
  --text-inverse:   #0c1119;

  /* Lines */
  --border:        #232c3a;
  --border-strong: #334052;
  --border-subtle: #1b2331;

  /* Accent — the ONLY brand colour.
     --primary       identity (thin rules, icons, focus)
     --primary-strong safe to put white text on
     --primary-text  safe as text on a page surface */
  --primary:        #f95700;
  --primary-light:  #ff7a33;
  --primary-strong: #d14700;   /* white text 4.6:1 */
  --primary-text:   #ff8a4d;   /* on --bg-card 7.0:1 */
  --primary-glow:   rgba(249,87,0,0.26);
  --primary-soft:   rgba(249,87,0,0.14);
  --on-primary:     #ffffff;
  --accent:         var(--primary);

  /* Status — restrained. `-fg` is text on `-soft`; `-btn` takes white. */
  --success:      #10b981;
  --success-fg:   #6ee7b7;
  --success-soft: #10291f;
  --success-btn:  #047857;

  --warning:      #f59e0b;
  --warning-fg:   #fcd34d;
  --warning-soft: #2a2210;
  --warning-btn:  #b45309;

  --danger:       #f43f5e;
  --danger-fg:    #fda4af;
  --danger-soft:  #2c1219;
  --danger-btn:   #dc2626;

  --neutral-fg:   #c3ccd9;
  --neutral-soft: #232c3a;

  /* Legacy aliases kept so inline styles in the JS modules
     keep resolving. All now point at the calm palette. */
  --purple:        #8794a5;
  --orange:        var(--primary);
  --success-glow:  var(--success-soft);
  --warning-glow:  var(--warning-soft);
  --danger-glow:   var(--danger-soft);

  /* Sidebar — dark in BOTH themes, so it owns its tokens */
  --sidebar-bg:     #0a1017;
  --sidebar-text:   #f2f5f8;
  --sidebar-dim:    #a5b0c0;
  --sidebar-muted:  #7b8798;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-hover:  rgba(255,255,255,0.06);
  --bg-sidebar:     var(--sidebar-bg);

  /* Chrome */
  --topbar-bg: rgba(12,17,25,0.88);
  --scrim:     rgba(0,0,0,0.66);

  /* Login */
  --login-page-bg:   #0c1119;
  --login-card-bg:   #141b26;
  --login-card-text: #e9edf3;
  --login-label:     #a5b0c0;
  --login-input-bg:  #10161f;
  --login-input-bd:  #2b3648;
  --login-tabs-bg:   #10161f;

  /* Metrics */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 68px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow:    0 4px 20px rgba(0,0,0,0.40);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.55);
  --shadow-glow: 0 0 24px var(--primary-glow);
  --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

/* ============================================================
   2. TOKENS — LIGHT
   ============================================================ */
html.theme-light {
  --bg-primary:    #f5f7fa;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f2f5f9;
  --bg-elevated:   #ffffff;
  --bg-input:      #ffffff;
  --bg-muted:      #f2f5f9;

  /* Text — checked against --bg-card #ffffff */
  --text-primary:   #101828;   /* 17.8:1 */
  --text-secondary: #4a5568;   /*  7.5:1 */
  --text-muted:     #5b6779;   /*  5.7:1 */
  --text-inverse:   #ffffff;

  --border:        #e4e8ee;
  --border-strong: #cbd3de;
  --border-subtle: #eef1f5;

  --primary:        #f95700;
  --primary-light:  #ff7a33;
  --primary-strong: #c2410c;   /* white text 5.2:1 */
  --primary-text:   #9a3412;   /* on white 7.3:1 */
  --primary-glow:   rgba(249,87,0,0.20);
  --primary-soft:   #fff0e6;

  --success-fg:   #065f46;
  --success-soft: #e3f5ee;
  --success-btn:  #047857;

  --warning-fg:   #92400e;
  --warning-soft: #fdf2dc;
  --warning-btn:  #b45309;

  --danger-fg:    #9f1239;
  --danger-soft:  #fdeaee;
  --danger-btn:   #dc2626;

  --neutral-fg:   #344054;
  --neutral-soft: #eef1f5;

  --purple:       #5b6779;

  --sidebar-bg:     #101828;
  --sidebar-text:   #f2f5f8;
  --sidebar-dim:    #b8c2d0;
  --sidebar-muted:  #98a4b5;
  --sidebar-border: rgba(255,255,255,0.09);
  --sidebar-hover:  rgba(255,255,255,0.07);

  --topbar-bg: rgba(255,255,255,0.90);
  --scrim:     rgba(16,24,40,0.42);

  --login-page-bg:   #eef1f6;
  --login-card-bg:   #ffffff;
  --login-card-text: #101828;
  --login-label:     #475569;
  --login-input-bg:  #f9fafb;
  --login-input-bd:  #cbd3de;
  --login-tabs-bg:   #eef1f6;

  --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --shadow:    0 4px 16px rgba(16,24,40,0.08);
  --shadow-lg: 0 24px 56px rgba(16,24,40,0.16);

  color-scheme: light;
}

/* ============================================================
   3. BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; background: var(--bg-primary); }

body {
  font-family: var(--font-family, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }
a { color: var(--primary-text); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

/* ============================================================
   4. LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh; width: 100vw; display: flex;
  position: relative; overflow-x: hidden;
  background: var(--login-page-bg);
  transition: background-color 0.2s ease;
}
.login-split-container { display: flex; width: 100%; min-height: 100vh; }

.login-hero-panel {
  flex: 1; min-width: 50%;
  background: var(--login-banner-bg, linear-gradient(150deg, #d14700 0%, #f95700 55%, #ff7a33 100%));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 48px; color: #ffffff; position: relative; overflow: hidden;
}
.hero-banner-content { max-width: 520px; width: 100%; text-align: center; z-index: 2; }
.hero-title {
  font-size: 30px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  color: #ffffff; margin-bottom: 8px; line-height: 1.25;
}
.hero-sub {
  font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,0.92);
  letter-spacing: 1.6px; text-transform: uppercase; margin-bottom: 40px;
}
.hero-illustration { width: 100%; max-width: 420px; margin: 0 auto; }

.login-form-panel {
  flex: 1; min-width: 50%; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
.login-card-light {
  width: 100%; max-width: 440px;
  background: var(--login-card-bg); color: var(--login-card-text);
  border: 1px solid var(--border);
  border-radius: 18px; padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-header-brand { text-align: center; margin-bottom: 26px; }
.brand-icon-box {
  width: 58px; height: 58px; margin: 0 auto 16px;
  border-radius: 15px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-strong); color: #ffffff;
  box-shadow: 0 6px 18px var(--primary-glow);
}
.brand-title { font-size: 20px; font-weight: 800; letter-spacing: -0.2px; color: var(--login-card-text); line-height: 1.3; }
.brand-subtitle {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-muted); margin-top: 6px;
}

.login-role-tabs-light {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
  background: var(--login-tabs-bg); border: 1px solid var(--border);
  border-radius: 11px; padding: 3px; margin-bottom: 24px;
}
.role-tab-light {
  padding: 9px 4px; border: none; background: transparent; border-radius: 9px;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.role-tab-light:hover { color: var(--text-primary); }
.role-tab-light.active { background: var(--primary-strong); color: #ffffff; }

.login-form-light { display: flex; flex-direction: column; gap: 18px; }
.login-form-light .form-group { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.login-form-light label {
  font-size: 11px; font-weight: 700; color: var(--login-label);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.login-form-light input, .login-form-light select {
  background: var(--login-input-bg);
  border: 1px solid var(--login-input-bd);
  border-radius: 9px; padding: 12px 14px;
  color: var(--login-card-text);
  font-family: inherit; font-size: 14px; font-weight: 500;
  outline: none; width: 100%; transition: var(--transition);
}
.login-form-light input:focus, .login-form-light select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.login-form-light input::placeholder { color: var(--text-muted); }

.btn-login-submit {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: var(--login-btn-start, var(--primary-strong));
  color: #ffffff; font-family: inherit;
  font-size: 14.5px; font-weight: 700; letter-spacing: 0.3px;
  cursor: pointer; transition: var(--transition); margin-top: 4px;
}
.btn-login-submit:hover { filter: brightness(1.1); }
.btn-login-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.login-hint-light {
  font-size: 12px; color: var(--text-secondary); text-align: center;
  background: var(--bg-muted); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 8px; font-weight: 500;
}
.login-footer-light { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 24px; }
.login-theme-toggle { position: absolute; top: 20px; right: 24px; z-index: 5; }

@media (max-width: 900px) {
  .login-split-container { flex-direction: column; }
  .login-hero-panel { min-height: 200px; padding: 32px 20px; }
  .hero-illustration { display: none; }
  .hero-sub { margin-bottom: 0; }
  .login-form-panel { padding: 24px 16px; }
  .login-card-light { padding: 28px 22px; }
}

/* ============================================================
   5. APP LAYOUT
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* ---- Sidebar --------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);              /* descendants inherit THIS */
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: width 0.18s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .user-badge { justify-content: center; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px; border-bottom: 1px solid var(--sidebar-border);
  min-height: 72px; flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; overflow: hidden; flex: 1; min-width: 0; }
.logo-icon-sm {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--primary-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #ffffff; flex-shrink: 0;
}
.sidebar-brand {
  font-size: 15.5px; font-weight: 700; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-toggle {
  background: none; border: none; color: var(--sidebar-dim);
  cursor: pointer; font-size: 18px; padding: 6px; border-radius: 6px;
  transition: var(--transition); flex-shrink: 0; margin-left: auto;
}
.sidebar-toggle:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }

.sidebar-nav { flex: 1 1 auto; padding: 12px 10px; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border: none; }

.nav-section-label {
  font-size: 10px; font-weight: 700; color: var(--sidebar-muted);
  letter-spacing: 1px; padding: 16px 8px 6px; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--sidebar-dim);
  cursor: pointer; transition: var(--transition); white-space: nowrap;
  margin-bottom: 2px; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-item.active {
  background: var(--sidebar-hover); color: #ffffff; font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}
/* The emoji glyphs used as icons were the loudest colour in the UI.
   Desaturating them keeps the affordance and removes the noise. */
.nav-icon {
  font-size: 15px; flex-shrink: 0; width: 20px; text-align: center;
  filter: grayscale(1); opacity: 0.75;
}
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.nav-label { font-size: 13.5px; font-weight: 500; }

.sidebar-footer {
  padding: 14px 12px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-badge { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #ffffff; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 600; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--sidebar-muted); }
.btn-logout {
  background: none; border: none; color: var(--sidebar-muted);
  cursor: pointer; font-size: 17px; padding: 6px; border-radius: 6px;
  transition: var(--transition); flex-shrink: 0;
}
.btn-logout:hover { color: #ffffff; background: var(--danger-btn); }

/* ---- Main ------------------------------------------------- */
.main-content {
  flex: 1; margin-left: var(--sidebar-width);
  min-height: 100vh; display: flex; flex-direction: column;
  transition: margin-left 0.18s cubic-bezier(0.4,0,0.2,1); min-width: 0;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.topbar {
  min-height: var(--topbar-height); padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-title { font-size: 19px; font-weight: 700; color: var(--text-primary); }
.breadcrumb { font-size: 12px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.search-bar {
  display: flex; align-items: center; gap: 8px; position: relative;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 99px; padding: 8px 16px; min-width: 240px; transition: var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-bar input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-family: inherit; font-size: 13px; width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1;
  color: var(--text-secondary); transition: var(--transition); padding: 0;
}
.theme-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-strong); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
html.theme-light .theme-toggle .icon-sun  { display: block; }
html.theme-light .theme-toggle .icon-moon { display: none; }

.notif-btn {
  position: relative; cursor: pointer; font-size: 18px; padding: 8px;
  border-radius: var(--radius-sm); transition: var(--transition); display: flex; align-items: center;
}
.notif-btn:hover { background: var(--bg-card-hover); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger-btn); color: #ffffff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-primary);
}
.notif-dropdown {
  position: absolute; top: 46px; right: 0; width: 300px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200;
  overflow: hidden; text-align: left;
}
.notif-header {
  padding: 13px 16px; font-size: 13px; font-weight: 700;
  border-bottom: 1px solid var(--border); color: var(--text-primary);
}
.notif-item {
  padding: 12px 16px; font-size: 13px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border); cursor: pointer; transition: var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.topbar-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.content-area { flex: 1; padding: 28px; overflow-x: hidden; animation: fadeIn 0.2s ease; min-width: 0; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   6. CARDS & KPI
   ------------------------------------------------------------
   One surface treatment. No coloured stripes, no per-card hues —
   hierarchy comes from type scale and spacing, not from paint.
   ============================================================ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: var(--transition); position: relative; box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--border-strong); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  position: relative; overflow: hidden; cursor: default;
  transition: var(--transition); box-shadow: var(--shadow-sm);
}
/* Every KPI card gets the same hairline. Colour variants are
   flattened to neutral so a dashboard reads as one object. */
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--border-strong);
}
.kpi-card.blue::before, .kpi-card.green::before, .kpi-card.amber::before,
.kpi-card.rose::before, .kpi-card.purple::before { background: var(--border-strong); }
.kpi-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }

.kpi-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; margin-bottom: 14px;
  background: var(--bg-muted); border: 1px solid var(--border);
  filter: grayscale(1); opacity: 0.8;
}
.kpi-card.blue .kpi-icon, .kpi-card.green .kpi-icon, .kpi-card.amber .kpi-icon,
.kpi-card.rose .kpi-icon, .kpi-card.purple .kpi-icon { background: var(--bg-muted); }

.kpi-value { font-size: 28px; font-weight: 800; line-height: 1.15; margin-bottom: 4px; color: var(--text-primary); letter-spacing: -0.5px; }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); }
.kpi-change { font-size: 12px; font-weight: 600; margin-top: 8px; display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.kpi-change.up   { color: var(--success-fg); }
.kpi-change.down { color: var(--danger-fg); }

.kpi-card-sm { padding: 16px; border-radius: var(--radius-sm); }
.kpi-card-sm .kpi-icon { width: 32px; height: 32px; font-size: 15px; margin-bottom: 12px; }
.kpi-card-sm .kpi-value { font-size: 21px; margin-bottom: 2px; }
.kpi-card-sm .kpi-label { font-size: 12px; }
.kpi-card-sm .kpi-change { font-size: 11px; margin-top: 6px; }

.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stat-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.stat-value { font-size: 23px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }

/* ============================================================
   7. GRIDS
   ============================================================ */
.grid   { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-cols-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   8. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: var(--transition); text-decoration: none; white-space: nowrap; line-height: 1.45;
}
.btn:disabled, .btn-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--primary-strong); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.1); }

.btn-success { background: var(--success-btn); color: #ffffff; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger { background: var(--danger-btn); color: #ffffff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-warning { background: var(--warning-btn); color: #ffffff; }
.btn-warning:hover { filter: brightness(1.1); }

.btn-ghost { background: var(--bg-muted); color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-strong); }

.btn-outline { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--bg-card-hover); border-color: var(--primary); color: var(--primary-text); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* ============================================================
   9. FORMS
   ------------------------------------------------------------
   `.form-control` is used 23× across the modules and previously
   had no definition at all — every input rendered as a raw
   browser default. All input primitives are covered here.
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group > label, .form-label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.2px;
}

.form-control, .input,
.app input[type="text"], .app input[type="email"], .app input[type="password"],
.app input[type="number"], .app input[type="date"], .app input[type="month"],
.app input[type="time"], .app input[type="tel"], .app input[type="url"], .app input[type="search"],
.app select, .app textarea,
.modal-box input[type="text"], .modal-box input[type="email"], .modal-box input[type="password"],
.modal-box input[type="number"], .modal-box input[type="date"], .modal-box input[type="month"],
.modal-box input[type="time"], .modal-box input[type="tel"], .modal-box input[type="url"],
.modal-box select, .modal-box textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text-primary);
  font-family: inherit; font-size: 13.5px; line-height: 1.5;
  outline: none; transition: var(--transition);
}
.app textarea, .modal-box textarea, textarea.form-control { min-height: 88px; resize: vertical; }
.form-control:hover, .app input:hover, .app select:hover, .app textarea:hover { border-color: var(--text-muted); }
.form-control:focus, .input:focus,
.app input:focus, .app select:focus, .app textarea:focus,
.modal-box input:focus, .modal-box select:focus, .modal-box textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control::placeholder, .app input::placeholder, .app textarea::placeholder { color: var(--text-muted); }
.form-control:disabled, .app input:disabled, .app select:disabled {
  opacity: 0.55; cursor: not-allowed; background: var(--bg-muted);
}

.app select, .modal-box select, select.form-control {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
.app select option, .modal-box select option { background: var(--bg-elevated); color: var(--text-primary); }

.app input[type="checkbox"], .app input[type="radio"] {
  width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
}
.app input[type="file"] {
  padding: 8px; font-size: 12.5px; color: var(--text-secondary);
  background: var(--bg-input); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); width: 100%;
}
.app input[type="range"] { accent-color: var(--primary); width: 100%; }
.app input[type="color"] {
  width: 44px; height: 34px; padding: 2px; cursor: pointer;
  background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.app input[type="date"]::-webkit-calendar-picker-indicator,
.app input[type="month"]::-webkit-calendar-picker-indicator,
.app input[type="time"]::-webkit-calendar-picker-indicator {
  filter: var(--picker-filter, invert(0.7)); cursor: pointer;
}
html.theme-light { --picker-filter: none; }

.salary-input, .edit-salary-input, .cand-select { max-width: 170px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-section { margin-bottom: 26px; }
.form-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.7px;
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.form-actions {
  display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border);
}

/* ============================================================
   10. TABLES
   ============================================================ */
.table-container, .table-responsive {
  overflow-x: auto; overflow-y: visible;
  border-radius: var(--radius); border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.card > .table-container, .card > .table-responsive { border: none; border-radius: 0; }

table, .table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-muted); border-bottom: 1px solid var(--border); }
th {
  padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap;
}
td {
  padding: 12px 16px; font-size: 13.5px; color: var(--text-primary);
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 0.12s ease; }
tbody tr:hover { background: var(--bg-card-hover); }
tfoot td { font-weight: 700; background: var(--bg-muted); }

/* ============================================================
   11. BADGES
   ------------------------------------------------------------
   Default is neutral. Colour only where the state is actionable.
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
  border: 1px solid transparent; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-fg);
}
.badge-success { background: var(--success-soft); color: var(--success-fg); }
.badge-warning, .badge-amber { background: var(--warning-soft); color: var(--warning-fg); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-fg); }
.badge-blue, .badge-info { background: var(--neutral-soft); color: var(--neutral-fg); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-purple  { background: var(--neutral-soft); color: var(--neutral-fg); }
.badge-gray    { background: var(--neutral-soft); color: var(--neutral-fg); }
.badge-ghost   { background: transparent; color: var(--text-secondary); border-color: var(--border-strong); }
.badge-outline { background: transparent; color: var(--text-primary);  border-color: var(--border-strong); }

/* ============================================================
   12. AVATARS
   ------------------------------------------------------------
   Backgrounds arrive as inline styles from the database, so the
   text colour can't be tuned per avatar. A fixed dark overlay
   composites over whatever colour is supplied, lifting white
   initials past 4.5:1 for every palette entry in use, and at the
   same time desaturating the wall-of-colour effect.
   ============================================================ */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
  /* Avatar colours arrive as inline styles from the database, which
     produced a wall of six random hues AND put white initials on
     mid-tone fills at 2.2:1. One opaque neutral fill, painted as a
     background-IMAGE, covers the inline background-color entirely —
     calmer, and legible at 8:1 in both themes. */
  /* !important is required: the inline `background:` shorthand from the
     database resets background-image, so nothing else can override it. */
  background-image: linear-gradient(var(--avatar-fill), var(--avatar-fill)) !important;
  color: var(--avatar-ink);
  box-shadow: inset 0 0 0 1px var(--border);
}
:root { --avatar-fill: #26313f; --avatar-ink: #d7dee8; }
html.theme-light { --avatar-fill: #e7ebf1; --avatar-ink: #37455a; }
.avatar-sm { width: 27px; height: 27px; font-size: 11px; }
.avatar-lg { width: 50px; height: 50px; font-size: 19px; }

/* ============================================================
   13. TABS
   ============================================================ */
.tab-nav {
  display: flex; gap: 2px; background: transparent;
  padding: 0; margin-bottom: 22px; border-bottom: 1px solid var(--border);
  overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none;
  /* Settings has eleven tabs. Without wrapping, the last few scrolled out
     of sight with no visible affordance that they were there at all. */
  flex-wrap: wrap;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 16px; border: none; border-radius: 0;
  background: transparent; color: var(--text-secondary); flex-shrink: 0;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: transparent; color: var(--primary-text); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============================================================
   14. MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); z-index: 500;
}
.modal-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 30px; z-index: 501;
  min-width: min(500px, 92vw); max-width: 820px; width: 92vw;
  max-height: 88vh; overflow-y: auto;
  animation: modalIn 0.2s cubic-bezier(0.22,1,0.36,1); box-shadow: var(--shadow-lg);
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-muted); border: 1px solid var(--border);
  color: var(--text-secondary); width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; font-size: 14px;
  transition: var(--transition); display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--danger-btn); color: #ffffff; border-color: var(--danger-btn); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); padding-right: 36px; }
.modal-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }

/* ============================================================
   15. TOASTS
   ============================================================ */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 999; }
.toast {
  padding: 13px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; min-width: 280px; max-width: 420px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.28s cubic-bezier(0.22,1,0.36,1);
  box-shadow: var(--shadow-lg); border: 1px solid;
  background: var(--bg-elevated); border-color: var(--border); color: var(--text-primary);
}
.toast-success { background: var(--success-soft); border-color: var(--success); color: var(--success-fg); }
.toast-error   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--danger-fg); }
.toast-warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning-fg); }
.toast-info    { background: var(--bg-elevated);  border-color: var(--border-strong); color: var(--text-primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ============================================================
   16. MISC COMPONENTS
   ============================================================ */
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-val { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.progress-bar-wrap { background: var(--bg-muted); border: 1px solid var(--border); border-radius: 99px; height: 7px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--primary); transition: width 0.5s ease; }

.pipeline { display: flex; gap: 0; overflow-x: auto; margin-bottom: 20px; }
.pipeline-stage { flex: 1; min-width: 170px; background: var(--bg-card); border: 1px solid var(--border); padding: 16px; position: relative; }
.pipeline-stage:not(:last-child)::after {
  content: ''; position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; border-left: 12px solid var(--bg-card);
  border-top: 18px solid transparent; border-bottom: 18px solid transparent; z-index: 1;
}
.pipeline-stage:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.pipeline-stage:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.pipeline-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.pipeline-count { font-size: 25px; font-weight: 800; color: var(--text-primary); }

.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot { position: absolute; left: -20px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg-primary); }
.timeline-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.timeline-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.mini-cal { width: 100%; }
.mini-cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-day-name { font-size: 11px; font-weight: 600; color: var(--text-secondary); padding: 4px; }
.cal-day {
  font-size: 12.5px; padding: 6px; border-radius: 6px; color: var(--text-primary);
  cursor: pointer; transition: var(--transition); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
}
.cal-day:hover { background: var(--bg-card-hover); }
.cal-day.today { background: var(--primary-strong); color: #ffffff; font-weight: 700; }
.cal-day.has-event { position: relative; }
.cal-day.has-event::after {
  content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.cal-day.weekend   { color: var(--text-muted); }
.cal-day.leave-day { background: var(--warning-soft); color: var(--warning-fg); }
.cal-day.holiday   { background: var(--danger-soft);  color: var(--danger-fg); }
.cal-day.wfh       { background: var(--neutral-soft); color: var(--neutral-fg); }

.compliance-cal { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.compliance-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; border-left: 3px solid var(--border-strong);
}
.compliance-item.urgent   { border-left-color: var(--danger); }
.compliance-item.due-soon { border-left-color: var(--warning); }
.compliance-item.done     { border-left-color: var(--success); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 320px; overflow-y: auto; z-index: 300;
}
.search-result-item {
  padding: 10px 16px; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-primary);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-card-hover); }

.profile-hero {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; display: flex; gap: 22px; align-items: center; margin-bottom: 20px; flex-wrap: wrap;
}
.profile-avatar-lg {
  width: 76px; height: 76px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; flex-shrink: 0;
  /* !important is required: the inline `background:` shorthand from the
     database resets background-image, so nothing else can override it. */
  background-image: linear-gradient(var(--avatar-fill), var(--avatar-fill)) !important;
  color: var(--avatar-ink);
  box-shadow: inset 0 0 0 1px var(--border);
}
.profile-name { font-size: 21px; font-weight: 800; color: var(--text-primary); }
.profile-role { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.profile-meta { display: flex; gap: 20px; margin-top: 12px; flex-wrap: wrap; }
.profile-meta-item { font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }

.score-ring { width: 88px; height: 88px; position: relative; display: flex; align-items: center; justify-content: center; }
.score-ring svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.score-text { font-size: 19px; font-weight: 800; z-index: 1; color: var(--text-primary); }

.checklist-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-radius: var(--radius-sm); transition: var(--transition); cursor: pointer; border: 1px solid transparent;
}
.checklist-item:hover { background: var(--bg-card-hover); }
.checklist-item.done { opacity: 0.6; }
.checklist-check {
  width: 21px; height: 21px; border-radius: 50%;
  border: 2px solid var(--border-strong); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.checklist-item.done .checklist-check { background: var(--success-btn); border-color: var(--success-btn); color: #ffffff; }

.watermark {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 60px; font-weight: 900; letter-spacing: 6px;
  color: var(--text-primary); opacity: 0.05; pointer-events: none;
  transform: rotate(-28deg); text-transform: uppercase; user-select: none;
}

.loading-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%; animation: skeleton 1.5s infinite; border-radius: var(--radius-sm);
}
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 32px; opacity: 0.45; margin-bottom: 10px; filter: grayscale(1); }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

.emp-accent::before { background: var(--border-strong) !important; }
.card canvas { max-width: 100%; }

/* ============================================================
   17. PAYSLIP
   ------------------------------------------------------------
   The payslip is a document: it stays paper-white in both themes
   and carries every colour it needs. It renders INLINE inside the
   app, so nothing here may leak upward — note there is
   deliberately NO bare `body` rule in this section.
   ============================================================ */
.payslip {
  background: #ffffff; color: #101828;
  padding: 36px; border-radius: var(--radius);
  max-width: 760px; margin: 0 auto; font-family: 'Inter', sans-serif;
  border: 1px solid #e2e8f0; box-shadow: var(--shadow-sm);
}
.payslip-confidential { text-align: center; font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: #64748b; margin-bottom: 12px; text-transform: uppercase; }
.payslip-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 16px; }
.payslip-company-logo { max-height: 46px; max-width: 180px; object-fit: contain; margin-bottom: 6px; }
.payslip-company { font-size: 19px; font-weight: 800; color: #b83c00; }
.payslip-title { font-size: 13px; color: #475569; margin-top: 4px; }
.payslip-sub { font-size: 12px; color: #475569; margin-top: 2px; line-height: 1.4; }
.payslip-period { text-align: right; font-size: 13px; color: #334155; }
.payslip-period-badge { background: #b83c00; color: #ffffff; padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; display: inline-block; }
.payslip-divider { border: none; border-top: 2px solid #b83c00; margin: 16px 0; }
.payslip-emp, .payslip-emp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-bottom: 18px; }
.payslip-emp-grid { background: #f8fafc; padding: 14px 18px; border-radius: 8px; border: 1px solid #e2e8f0; }
.payslip-field { font-size: 13px; }
.payslip-key { color: #475569; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.payslip-val { color: #101828; font-weight: 700; margin-top: 1px; }
.payslip-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.payslip-table th { background: #f1f5f9; padding: 10px 14px; font-size: 12px; text-align: left; font-weight: 700; color: #334155; text-transform: none; letter-spacing: 0; }
.payslip-table td { padding: 9px 14px; font-size: 13px; color: #101828; border-bottom: 1px solid #e5e7eb; }
.payslip-table tbody tr:hover { background: transparent; }
.payslip-net {
  background: #b83c00; color: #ffffff; padding: 16px 20px; border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center; margin-top: 16px;
}
.payslip-net-label { font-size: 14px; font-weight: 600; }
.payslip-net-amount { font-size: 23px; font-weight: 800; }

/* ============================================================
   18. UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }

.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; }

.mt-4 { margin-top: 4px; }   .mt-6 { margin-top: 6px; }   .mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }

.mb-4 { margin-bottom: 4px; }   .mb-6 { margin-bottom: 6px; }   .mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; } .mb-32 { margin-bottom: 32px; }

.pb-12 { padding-bottom: 12px; }
.p-6 { padding: 6px; } .p-12 { padding: 12px; } .p-16 { padding: 16px; } .p-24 { padding: 24px; }

.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted   { color: var(--text-secondary); }
.text-dim     { color: var(--text-muted); }
.text-success { color: var(--success-fg); }
.text-danger  { color: var(--danger-fg); }
.text-warning { color: var(--warning-fg); }
.text-primary { color: var(--primary-text); }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.relative { position: relative; }

/* ============================================================
   19. RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
  .grid-2, .grid-cols-3-1, .compliance-cal { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .search-bar { min-width: 160px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content, .sidebar.collapsed ~ .main-content { margin-left: 0; }
  .kpi-grid, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-cols-3-1 { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .modal-box { min-width: unset; padding: 22px 18px; }
  .content-area { padding: 18px 14px; }
  .topbar { padding: 0 16px; }
  .search-bar { display: none; }
  .toast-container { left: 14px; right: 14px; bottom: 14px; }
  .toast { min-width: 0; width: 100%; }
}
@media (max-width: 520px) {
  .kpi-grid, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-title { font-size: 17px; }
}

/* ============================================================
   20. MOTION & PRINT
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar, .toast-container, .modal-overlay,
  .theme-toggle, #app-footer, .btn { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  body { background: #ffffff !important; color: #000000 !important; }
  .card, .kpi-card { break-inside: avoid; border-color: #d0d5dd !important; box-shadow: none !important; }
}
