:root {
  --orange-50: #fff7ed;
  --orange-100: #ffedd5;
  --orange-200: #fed7aa;
  --orange-300: #fdba74;
  --orange-400: #fb923c;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --orange-700: #c2410c;

  --gray-50: #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-900: #18181b;

  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --border: var(--gray-200);
  --bg: #ffffff;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow: 0 1px 2px rgba(24,24,27,.04), 0 10px 28px -10px rgba(24,24,27,.10);
  --shadow-orange: 0 14px 28px -10px rgba(249, 115, 22, 0.35);
  font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--gray-50);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-600); text-decoration: none; }
svg { display: block; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Navbar */
.navbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.navbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--gray-900);
}
.brand-badge {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-orange);
  flex-shrink: 0;
}
.navbar .nav-links a {
  margin-left: 20px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.navbar .nav-links a:hover { color: var(--orange-600); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: var(--shadow-orange);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 18px 32px -10px rgba(249, 115, 22, 0.45); }
.btn:active { transform: translateY(0); }
.btn.btn-outline {
  background: transparent;
  color: var(--orange-600);
  border: 1.5px solid var(--orange-300);
  box-shadow: none;
}
.btn.btn-outline:hover { background: var(--orange-50); box-shadow: none; }
.btn.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  box-shadow: none;
}
.btn.btn-secondary:hover { background: var(--gray-200); box-shadow: none; transform: none; }
.btn.btn-danger { background: #ef4444; box-shadow: 0 14px 28px -10px rgba(239, 68, 68, 0.35); }
.btn.btn-danger:hover { background: #dc2626; }
.btn.btn-ghost { background: transparent; color: var(--gray-500); box-shadow: none; padding: 8px 10px; }
.btn.btn-ghost:hover { background: var(--gray-100); transform: none; box-shadow: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-icon { padding: 9px; border-radius: 999px; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { display: none; }
.switch-track {
  width: 40px; height: 23px;
  background: var(--gray-300);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--orange-500); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(17px); }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }

/* Hero */
.hero {
  position: relative;
  padding: 72px 0 40px;
  text-align: center;
  overflow: hidden;
  background:
    radial-gradient(480px 240px at 15% 0%, var(--orange-100), transparent 70%),
    radial-gradient(480px 240px at 85% 10%, var(--orange-50), transparent 70%);
}
.hero h1 { font-size: 2.4rem; margin: 0 0 10px; font-weight: 800; letter-spacing: -0.01em; }
.hero p { color: var(--text-muted); margin: 0; font-size: 1.05rem; }

/* Search + filters */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 18px;
  box-shadow: var(--shadow-sm);
}
.search-bar svg { color: var(--gray-400); flex-shrink: 0; }
.search-bar input {
  border: none;
  background: transparent;
  padding: 12px 4px;
}
.search-bar input:focus { box-shadow: none; }

.filter-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-row select { width: auto; min-width: 170px; }

/* Consistent view header + filter bar used across all views */
.view-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.filter-bar select { width: auto; }
.filter-bar input[type="text"] { width: 180px; }
.branches-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--orange-300); color: var(--orange-600); }
.chip.active { background: var(--orange-600); border-color: var(--orange-600); color: #fff; }

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 56px;
}
.job-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  color: var(--text);
}
.job-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-orange);
  border-color: var(--orange-200);
}
.job-card .top-row { display: flex; gap: 8px; margin-bottom: 14px; }
.job-card h3 { margin: 0 0 10px; font-size: 1.08rem; font-weight: 700; }
.job-card .meta-line { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.86rem; margin-bottom: 6px; }
.job-card .meta-line svg { flex-shrink: 0; color: var(--gray-400); }
.job-card .salary-line { display: flex; align-items: center; gap: 6px; color: var(--orange-600); font-weight: 700; margin: 12px 0 0; font-size: 0.92rem; }
.job-card .salary-line svg { color: var(--orange-500); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--orange-100);
  color: var(--orange-700);
}
.badge.gray { background: var(--gray-100); color: var(--gray-600); }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }

/* Forms */
label { display: block; font-weight: 700; margin: 16px 0 6px; font-size: 0.86rem; color: var(--gray-700); }
input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange-400);
  box-shadow: 0 0 0 4px var(--orange-100);
}
textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Benefit checklist */
.benefit-checklist {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  max-height: 180px; overflow-y: auto; padding: 6px;
}
.checkbox-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; margin: 0;
}
.checkbox-row:hover { background: var(--gray-50); }
.checkbox-row input { width: auto; margin: 3px 0 0; flex-shrink: 0; }
.checkbox-row .cb-name { font-weight: 600; font-size: 0.9rem; }
.checkbox-row .cb-desc { font-size: 0.8rem; color: var(--text-muted); }
.benefit-checklist-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* File dropzone */
.dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  background: var(--gray-50);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--orange-400); background: var(--orange-50); }
.dropzone svg { color: var(--orange-500); flex-shrink: 0; }
.dropzone .dz-text { font-size: 0.88rem; color: var(--text-muted); }
.dropzone .dz-text strong { color: var(--text); }
.dropzone input[type="file"] { display: none; }

/* Job detail */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.back-link:hover { color: var(--orange-600); }
.job-detail h1 { margin: 4px 0 6px; font-size: 1.7rem; }
.job-detail .meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.job-detail section { margin-top: 24px; }
.job-detail section h3 { display: flex; align-items: center; gap: 8px; font-size: 0.98rem; color: var(--orange-600); margin-bottom: 8px; }
.job-detail section p { white-space: pre-wrap; margin: 0; color: var(--gray-700); }

.benefits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.benefit-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--orange-50); border: 1px solid var(--orange-100);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.benefit-item svg { color: var(--orange-500); flex-shrink: 0; margin-top: 2px; }
.benefit-item .b-name { font-weight: 700; font-size: 0.88rem; }
.benefit-item .b-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(600px 320px at 50% -10%, var(--orange-100), transparent 70%),
    var(--gray-50);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 40px 34px;
  text-align: center;
}
.login-card .brand-badge { margin: 0 auto 18px; width: 52px; height: 52px; border-radius: 14px; }
.login-card h1 { font-size: 1.35rem; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 26px; }
.login-card form { text-align: left; }
.login-card .btn { width: 100%; margin-top: 22px; justify-content: center; }

/* Dashboard layout */
.dash-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; font-weight: 800; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}
.sidebar nav a:hover { background: var(--gray-50); color: var(--text); }
.sidebar nav a.active { color: var(--orange-600); background: var(--orange-50); }
.sidebar nav a svg { flex-shrink: 0; }
.sidebar .nav-divider { height: 1px; background: var(--border); margin: 10px 4px; }

/* Collapsible nav group */
.nav-group { display: flex; flex-direction: column; gap: 0; }
.nav-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; border-radius: var(--radius-sm);
  color: var(--gray-600); font-weight: 700; font-size: 0.88rem; font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.nav-group-header:hover { background: var(--gray-50); color: var(--text); }
.nav-group.open .nav-group-header { color: var(--orange-600); background: var(--orange-50); }
.nav-group-label { flex: 1; }
.nav-group-chevron { font-size: 0.65rem; transition: transform 0.2s; flex-shrink: 0; }
.nav-group.open .nav-group-chevron { transform: rotate(90deg); }
.nav-group-items { display: none; flex-direction: column; gap: 1px; padding: 2px 0 2px 12px; }
.nav-group.open .nav-group-items { display: flex; }
.nav-sub { font-size: 0.85rem !important; padding: 8px 10px !important; color: var(--gray-500) !important; }
.nav-sub.active { color: var(--orange-600) !important; background: var(--orange-50) !important; }

.dash-main { flex: 1; padding: 28px 36px; max-width: 100%; }
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 26px;
  gap: 16px;
}
.dash-header h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 800; }
.dash-header .subtitle { color: var(--text-muted); font-size: 0.9rem; }
.notif-wrap { position: relative; display: inline-flex; }
.notif-badge { position: absolute; top: -5px; right: -5px; font-size: 0.68rem; padding: 1px 5px; min-width: 18px; text-align: center; pointer-events: none; line-height: 1.4; }
.mail-notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 100; overflow: hidden;
}
.mail-notif-header {
  padding: 12px 16px; font-weight: 700; font-size: 0.88rem;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.mail-notif-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.84rem; transition: background 0.1s;
}
.mail-notif-item:hover { background: var(--gray-50); }
.mail-notif-item:last-child { border-bottom: none; }
.mail-notif-section {
  padding: 6px 16px 2px; font-size: 0.75rem; font-weight: 700;
  color: var(--text-muted); letter-spacing: 0.5px; background: var(--gray-50);
}

.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  color: #fff; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Header right group (user + mail) */
.header-right { display: flex; align-items: center; gap: 10px; }
.header-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  color: var(--text-muted); transition: background 0.12s, color 0.12s;
}
.header-icon-btn:hover { background: var(--gray-50); color: var(--orange-600); }
.header-user { position: relative; }
.sidebar-user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s;
}
.sidebar-user-chip:hover { background: var(--gray-50); }
.sidebar-user-chip .uname { font-size: 0.84rem; font-weight: 700; line-height: 1.15; color: var(--text); }
.sidebar-user-chip .urole {
  font-size: 0.73rem;
  background: var(--orange-50); color: var(--orange-600);
  border-radius: 20px; padding: 1px 7px; display: inline-block; font-weight: 600; margin-top: 2px;
}
.sidebar-user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; left: auto;
  min-width: 220px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 6px; z-index: 50;
}
.sidebar-user-dropdown a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 0.86rem; font-weight: 600; color: var(--gray-700);
}
.sidebar-user-dropdown a:hover { background: var(--gray-50); }

.charts-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Stat cards */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px;
}
.stat-card .stat-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--orange-50); color: var(--orange-600);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; }
table thead th { text-align: left; padding: 13px 16px; font-size: 0.78rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.03em; background: var(--gray-50); border-bottom: 1px solid var(--border); }
table thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
table thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.89rem; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--orange-50); }
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.row-person { display: flex; align-items: center; gap: 10px; }

/* Kebab action menu */
.kebab { position: relative; display: inline-flex; }
.kebab-btn {
  background: none; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 9px; cursor: pointer; color: var(--gray-600);
  display: flex; align-items: center; line-height: 0;
}
.kebab-btn:hover { background: var(--gray-50); border-color: var(--gray-300); }
.kebab-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); min-width: 180px; padding: 6px; z-index: 30;
}
.kebab-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 0.86rem; font-weight: 600;
  color: var(--gray-700); background: none; border: none; cursor: pointer; font-family: inherit;
}
.kebab-menu button:hover { background: var(--gray-50); }
.kebab-menu button.danger { color: #dc2626; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(24,24,27,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 30px;
  max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.3);
}
.modal h2 { margin-top: 0; font-size: 1.2rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.hidden { display: none !important; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.empty-state svg { margin: 0 auto 12px; color: var(--gray-300); }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.alert { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 0.86rem; margin-bottom: 14px; font-weight: 600; }
.alert.error { background: #fee2e2; color: #b91c1c; }
.alert.success { background: #dcfce7; color: #15803d; }

footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 28px 0;
}

/* ---- Organization Chart ---- */
.org-wrap {
  overflow: auto;
  padding: 32px 24px 40px;
  min-height: 300px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap;
}
.org-node-group { display: inline-flex; flex-direction: column; align-items: center; }
.org-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  width: 162px;
  text-align: center;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
  position: relative;
  flex-shrink: 0;
  user-select: none;
}
.org-card.clickable { cursor: pointer; }
.org-card.clickable:hover { box-shadow: var(--shadow); border-color: var(--orange-300); transform: translateY(-2px); }
.org-card.is-me { border-color: var(--orange-400); background: var(--orange-50); }
.org-card .org-avatar {
  width: 44px; height: 44px; border-radius: 999px;
  margin: 0 auto 8px;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  color: #fff; font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.org-card .org-name { font-weight: 700; font-size: 0.82rem; line-height: 1.3; color: var(--gray-900); }
.org-card .org-title { font-size: 0.73rem; color: var(--orange-600); margin-top: 3px; font-weight: 600; }
.org-card .org-dept {
  display: inline-flex; margin-top: 6px; font-size: 0.68rem;
  padding: 2px 8px; border-radius: 999px; font-weight: 600;
  background: var(--gray-100); color: var(--gray-600);
}
.org-card .org-sub-count { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; }
.org-card .org-edit-badge {
  position: absolute; top: 7px; right: 7px;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--orange-100); color: var(--orange-600);
  border: none; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; cursor: pointer; opacity: 0;
  transition: opacity 0.15s;
}
.org-card:hover .org-edit-badge { opacity: 1; }
.org-connector-v { width: 2px; height: 22px; background: var(--gray-200); flex-shrink: 0; }
.org-children-row { display: flex; align-items: flex-start; }
.org-child-col {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 14px; position: relative;
}
/* Vertical line: horizontal bar → child card */
.org-child-col::before {
  content: ''; display: block;
  width: 2px; height: 22px;
  background: var(--gray-200);
  flex-shrink: 0;
}
/* Horizontal bar segments */
.org-child-col::after {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--gray-200);
}
.org-child-col:first-child::after { left: 50%; }
.org-child-col:last-child::after { right: 50%; }
.org-dept-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 16px 0 0; justify-content: center;
}
.org-dept-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--gray-600); }

/* Branch cards */
.branch-card { transition: box-shadow 0.15s, transform 0.15s; }
.branch-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* Table responsive */
@media (max-width: 900px) {
  .charts-row-2 { grid-template-columns: 1fr; }
}

/* Role split-panel list item */
.role-list-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1.5px solid transparent;
  transition: background 0.15s;
}
.role-list-item:hover { background: var(--gray-100); }
.role-list-item.selected { background: #fff7ed; border-color: #fdba74; }

/* Mini Confirm Dialog */
.mini-confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.mini-confirm {
  background: #fff; border-radius: var(--radius);
  padding: 28px 32px; box-shadow: var(--shadow);
  max-width: 360px; width: 90%; text-align: center;
}
.mini-confirm-msg { font-weight: 600; margin-bottom: 20px; line-height: 1.6; font-size: 0.95rem; color: var(--text); }
.mini-confirm-actions { display: flex; gap: 10px; justify-content: center; }
.mini-confirm-ok { background: #ef4444 !important; box-shadow: none !important; }
.mini-confirm-ok:hover { background: #dc2626 !important; }

/* ── Skeleton loader ─────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
.skeleton-row td { padding: 10px 14px; }
.skeleton-cell { height: 14px; border-radius: 6px; }
.skeleton-cell.w-20 { width: 20%; }
.skeleton-cell.w-30 { width: 30%; }
.skeleton-cell.w-50 { width: 50%; }
.skeleton-cell.w-70 { width: 70%; }
.skeleton-cell.w-full { width: 90%; }

/* ── Toast notifications ─────────────────────────── */
#toastWrap {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0)   scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0)   scale(1); max-height: 80px; margin: 0; }
  to   { opacity: 0; transform: translateX(40px) scale(0.95); max-height: 0; margin: -4px 0; }
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px;
  font-size: 0.875rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.14);
  pointer-events: auto; min-width: 240px; max-width: 360px;
  animation: toast-in 0.28s cubic-bezier(.22,.68,0,1.2) forwards;
  border-left: 4px solid transparent;
}
.toast.success { background:#f0fdf4; color:#15803d; border-left-color:#22c55e; }
.toast.error   { background:#fef2f2; color:#b91c1c; border-left-color:#ef4444; }
.toast.info    { background:#eff6ff; color:#1d4ed8; border-left-color:#3b82f6; }
.toast.leaving { animation: toast-out 0.22s ease forwards; }

/* ── Modal entrance animation ────────────────────── */
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.modal-overlay:not(.hidden) .modal {
  animation: modal-pop 0.22s cubic-bezier(.22,.68,0,1.2) forwards;
}

/* ── Button loading state ────────────────────────── */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute; inset: 0;
  margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; }
  .dash-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar .brand { padding: 0; margin-right: 12px; }
  .sidebar nav { flex-direction: row; }
  .sidebar-user { display: none; }
  .dash-main { padding: 20px; }
  .hero h1 { font-size: 1.8rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ---- Manpower redesign ---- */
.mp-summary-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 12px 18px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.mp-summary-pill { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.mp-summary-val { font-size: 1.4rem; font-weight: 800; line-height: 1.1; color: var(--gray-800); }
.mp-summary-lbl { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; margin-top: 1px; }
.mp-summary-pill.active .mp-summary-val { color: #15803d; }
.mp-summary-pill.incoming .mp-summary-val { color: #1d4ed8; }
.mp-summary-pill.shortage .mp-summary-val { color: #b91c1c; }
.mp-summary-pill.full .mp-summary-val { color: #15803d; }

/* Compact branch cards */
.mp-compact-card { padding: 10px 14px; margin-bottom: 6px !important; }
.mp-compact-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mp-compact-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 200px; }
.mp-compact-name { font-weight: 700; font-size: 0.9rem; }
.mp-compact-region { font-size: 0.76rem; }
.mp-compact-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.mp-branch-code { font-family: monospace; font-size: 0.73rem; background: var(--gray-100); padding: 2px 6px; border-radius: 4px; color: var(--gray-600); flex-shrink: 0; }

.mp-mini-stats { display: flex; gap: 4px; }
.mp-mini-pill { display: flex; flex-direction: column; align-items: center; padding: 4px 8px; border-radius: 6px; background: var(--gray-50); border: 1px solid var(--border); min-width: 44px; }
.mp-mini-val { font-size: 0.95rem; font-weight: 800; line-height: 1.1; color: var(--gray-800); }
.mp-mini-lbl { font-size: 0.62rem; color: var(--text-muted); font-weight: 600; }
.mp-mini-pill.active { background: #f0fdf4; border-color: #bbf7d0; }
.mp-mini-pill.active .mp-mini-val { color: #15803d; }
.mp-mini-pill.incoming { background: #eff6ff; border-color: #bfdbfe; }
.mp-mini-pill.incoming .mp-mini-val { color: #1d4ed8; }
.mp-mini-pill.shortage { background: #fef2f2; border-color: #fecaca; }
.mp-mini-pill.shortage .mp-mini-val { color: #b91c1c; }
.mp-mini-pill.full { background: #f0fdf4; border-color: #bbf7d0; }
.mp-mini-pill.full .mp-mini-val { color: #15803d; }

.mp-mini-bar { width: 72px; height: 6px; background: var(--gray-100); border-radius: 999px; position: relative; overflow: hidden; flex-shrink: 0; }
.mp-mini-fill { position: absolute; left: 0; top: 0; height: 100%; background: #22c55e; border-radius: 999px; }
.mp-mini-incoming { position: absolute; top: 0; height: 100%; background: #93c5fd; border-radius: 999px; }

.mp-compact-shortage { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 6px 0 2px; border-top: 1px solid #fee2e2; margin-top: 6px; }
.mp-shortage-tag { font-size: 0.72rem; font-weight: 700; background: #fee2e2; color: #b91c1c; padding: 2px 7px; border-radius: 999px; }

/* Branch detail modal tabs */
.bd-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 0; }
.bd-tab { padding: 8px 18px; font-size: 0.85rem; font-weight: 700; color: var(--gray-500); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; transition: color 0.15s; }
.bd-tab:hover { color: var(--orange-600); }
.bd-tab.active { color: var(--orange-600); border-bottom-color: var(--orange-500); }

/* Roster grid (used in detail modal) */
.mp-roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.mp-roster-card { display: flex; align-items: center; gap: 8px; padding: 9px 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mp-roster-card.onboarding { border-color: #bfdbfe; background: #eff6ff; }
.mp-roster-avatar { width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0; background: linear-gradient(135deg, var(--orange-400), var(--orange-600)); color: #fff; font-weight: 700; font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }
.mp-roster-card.onboarding .mp-roster-avatar { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.mp-roster-info { min-width: 0; flex: 1; }
.mp-roster-name { font-size: 0.8rem; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-roster-pos { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-roster-badge { font-size: 0.62rem; font-weight: 700; color: #1d4ed8; background: #dbeafe; padding: 1px 5px; border-radius: 999px; display: inline-block; margin-top: 2px; }

/* Shared manpower table styles */
.mp-dept-header td { font-size: 0.73rem; font-weight: 700; color: var(--gray-500); background: var(--gray-50); padding: 4px 14px !important; text-transform: uppercase; letter-spacing: 0.03em; }
.mp-row-shortage { background: #fff9f9; }
.mp-row-shortage:hover { background: #fef2f2 !important; }
.danger-hover:hover { color: #dc2626 !important; }

/* ---- Manpower unified page ---- */
.mp-page-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin: 12px 0 0; }
.mp-page-tab { padding: 8px 20px; font-size: 0.85rem; font-weight: 700; color: var(--gray-500); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; transition: color 0.15s; }
.mp-page-tab:hover { color: var(--orange-600); }
.mp-page-tab.active { color: var(--orange-600); border-bottom-color: var(--orange-500); }

/* Split layout */
.mp-split-layout { display: flex; gap: 0; height: calc(100vh - 260px); min-height: 480px; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }

/* Branch list (left panel) */
.mp-branch-list { width: 270px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid var(--border); background: var(--gray-50); padding: 6px; }
.mp-branch-item { padding: 10px 10px 8px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.12s; margin-bottom: 3px; border: 1px solid transparent; }
.mp-branch-item:hover { background: #fff; border-color: var(--border); }
.mp-branch-item.selected { background: #fff7ed; border-color: var(--orange-300); }
.mp-branch-item-top { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; }
.mp-branch-item-name { font-weight: 700; font-size: 0.83rem; flex: 1; min-width: 0; }
.mp-branch-item-stats { display: flex; gap: 10px; font-size: 0.74rem; color: var(--text-muted); }

/* Detail panel (right) */
.mp-detail-panel { flex: 1; overflow-y: auto; padding: 18px 20px; }
.mp-detail-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 0.9rem; }
.mp-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.mp-detail-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mp-detail-pills { display: flex; gap: 6px; flex-shrink: 0; }

/* Sections inside detail panel */
.mp-detail-section { margin-bottom: 20px; }
.mp-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mp-section-title { font-size: 0.8rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }

/* Position + employees merged table */
.mp-pos-table { width: 100%; }
.mp-emp-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mp-emp-chip { font-size: 0.73rem; font-weight: 600; background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.mp-emp-chip.onboarding { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.mp-emp-shortage-slot { font-size: 0.73rem; font-weight: 700; background: #fee2e2; border: 1px solid #fecaca; color: #b91c1c; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

/* Request items inside detail panel */
.mp-req-list { display: flex; flex-direction: column; gap: 8px; }
.mp-req-item { padding: 10px 12px; background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--radius-sm); }

@media (max-width: 768px) {
  .mp-split-layout { flex-direction: column; height: auto; }
  .mp-branch-list { width: 100%; max-height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---- Leaves / OT / Shifts / Payroll ---- */
.leaves-tabs-bar { display: flex; gap: 2px; flex-wrap: wrap; }
.leaves-tab, .payroll-tab, .reports-tab {
  padding: 7px 16px; font-size: 0.84rem; font-weight: 700; color: var(--gray-500);
  background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; transition: background 0.12s, color 0.12s;
}
.leaves-tab:hover, .payroll-tab:hover, .reports-tab:hover { color: var(--orange-600); background: var(--orange-50); }
.leaves-tab.active, .payroll-tab.active, .reports-tab.active { background: var(--orange-500); color: #fff; border-color: var(--orange-500); }

/* Leave balance cards */
.lb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.lb-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.lb-card-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
.lb-bar-track { height: 4px; background: var(--gray-100); margin: 0; }
.lb-bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s; }

/* Shift grid */
.shift-grid-wrap { overflow-x: auto; margin-top: 8px; }
.shift-grid { border-collapse: collapse; min-width: 700px; }
.shift-grid th, .shift-grid td { border: 1px solid var(--border); }
.shift-emp-th { min-width: 160px; padding: 8px 12px; font-size: 0.78rem; font-weight: 700; color: var(--gray-500); background: var(--gray-50); text-align: left; position: sticky; left: 0; z-index: 2; }
.shift-day-th { min-width: 90px; padding: 6px 4px; text-align: center; font-size: 0.78rem; font-weight: 700; color: var(--gray-600); background: var(--gray-50); }
.shift-day-th.weekend { background: #fef9f0; color: var(--orange-600); }
.shift-emp-cell { padding: 8px 12px; background: #fff; position: sticky; left: 0; z-index: 1; min-width: 160px; border-right: 2px solid var(--border); }
.shift-cell-td { padding: 3px; text-align: center; transition: background 0.15s; }
.shift-cell-td.weekend { background: #fef9f044; }
.shift-cell-select { width: 100%; font-size: 0.78rem; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; background: transparent; cursor: pointer; font-family: inherit; }
.shift-type-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.shift-type-dot { width: 12px; height: 12px; border-radius: 999px; flex-shrink: 0; }

/* Payslip print styles */
.payslip-wrap { font-family: inherit; }
.payslip-header-bar { text-align: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--border); }
.payslip-company { font-size: 1.1rem; font-weight: 800; }
.payslip-month { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.payslip-emp-info { background: var(--gray-50); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; }
.payslip-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.payslip-col-title { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.payslip-row { display: flex; justify-content: space-between; font-size: 0.84rem; padding: 3px 0; border-bottom: 1px solid var(--gray-100); }
.payslip-row.deduct { color: #b91c1c; }
.payslip-subtotal { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.88rem; padding: 6px 0; margin-top: 4px; border-top: 1.5px solid var(--border); }
.payslip-subtotal.deduct { color: #b91c1c; }
.payslip-net-bar { background: var(--orange-500); color: #fff; border-radius: var(--radius-sm); padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; font-size: 1rem; font-weight: 700; }
.payslip-net-bar strong { font-size: 1.25rem; }
@media print { .modal-overlay { position: static; background: none; } .modal { box-shadow: none; max-width: none; } .modal-actions { display: none; } }

/* ---- System Config ---- */
.sysconfig-db-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--orange-50), #fff);
  border: 1.5px solid var(--orange-200); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.sysconfig-db-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  background: var(--orange-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
