@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }

:root {
  --primary: #00288e;
  --primary-dark: #001e70;
  --primary-soft: #dce9ff;
  --accent: #006a61;
  --accent-dark: #005049;
  --navy: #0b1c30;
  --font-ar: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-en: "IBM Plex Sans", sans-serif;
  --navy-ink: #0b1c30;
  --teal-soft: #d9f8f2;
  --sky-1: #f8f9ff;
  --sky-2: #eff4ff;
  --sky-3: #dce9ff;
  --bg: #f8f9ff;
  --card: #ffffff;
  --border: #d3e4fe;
  --text: #0b1c30;
  --text-muted: #444653;
  --success: #006a61;
  --success-bg: #d9f8f2;
  --danger: #ba1a1a;
  --danger-bg: #ffdad6;
  --warning: #b25f2b;
  --warning-bg: #fff2e8;
  --sidebar-bg: #ffffff;
  --sidebar-text: #0b1c30;
  --sidebar-text-dim: #444653;
  --sidebar-active-bg: #eff4ff;
  --sidebar-border: #d3e4fe;
  --tile-blue: #00288e;
  --tile-green: #087f70;
  --tile-aqua: #006a61;
  --tile-orange: #c46a00;
  --tile-violet: #6f35b5;
  --tile-red: #ba1a1a;
}

body {
  margin: 0;
  font-family: var(--font-ar);
  background: radial-gradient(circle at 15% 0%, #ffffff 0, var(--bg) 42%, #eef4ff 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

:lang(en), :lang(en) * {
  font-family: var(--font-en);
}

button, input, textarea, select {
  font: inherit;
}

button {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

:lang(ar), :lang(ar) * {
  font-family: var(--font-ar);
}

h1, h2, h3, .content h2, .welcome-banner h2 {
  font-family: var(--font-ar);
}

:lang(en) h1, :lang(en) h2, :lang(en) h3, :lang(en) .content h2, :lang(en) .welcome-banner h2 {
  font-family: var(--font-en);
}

button, input, textarea, select, table {
  font-family: inherit;
}

.hidden { display: none !important; }

.top-bar {
  display: none;
}

.lang-toggle-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.lang-toggle-btn:hover {
  background: #f3fbff;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  text-align: center;
  color: var(--navy);
}

.login-card .subtitle {
  margin: 0 0 26px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

.login-card label {
  display: block;
  font-size: 13px;
  margin: 12px 0 4px;
  color: var(--text-muted);
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(34, 48, 74, 0.12);
  border-radius: 14px;
  font-size: 15px;
}

.login-card button, .btn-primary {
  width: 100%;
  margin-top: 22px;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #3072d0 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(33, 88, 199, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-card button:hover, .btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1f4db7 100%);
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(33, 88, 199, 0.22);
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 8px;
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}


.sidebar {
  width: 300px;
  min-width: 300px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 18px 20px;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 12px 0 36px rgba(11, 28, 48, 0.06);
}

.sidebar-footer {
  padding: 0 10px;
  margin-top: auto;
}

.sidebar-footer .lang-toggle-btn {
  width: 100%;
  margin: 18px 0 0;
}

.profile-trigger {
  border: 0;
  background: transparent;
  padding: 0 4px 12px;
  margin: 0 0 8px;
  width: 100%;
  text-align: start;
  cursor: pointer;
}

.profile-trigger:hover .brand {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 18px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 18px;
  background: var(--sky-2);
  border: 1px solid var(--border);
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar .brand .avatar {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(0, 40, 142, 0.2);
}

.sidebar .brand .brand-text { min-width: 0; }
.sidebar .brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .brand .brand-role {
  font-size: 12px;
  color: var(--text-muted);
}

.profile-menu {
  padding: 0 14px 10px;
}

.profile-card {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 24px rgba(4, 18, 34, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(4, 18, 34, 0.24);
}

.profile-card-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(248, 251, 255, 0.72);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.profile-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}

.profile-card-role {
  font-size: 12px;
  color: rgba(248, 251, 255, 0.72);
  margin-bottom: 10px;
}

.profile-logout-btn,
.logout-btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #2ab2ff 0%, #0b6f9c 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(7, 74, 106, 0.24);
}

.profile-logout-btn:hover,
.logout-btn:hover {
  background: linear-gradient(135deg, #3dc5ff 0%, #0c85b7 100%);
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* Flexbox gotcha: without min-height:0 a flex child with overflow refuses
     to shrink below its content height, so the nav grows past the sidebar
     and clips items toward the bottom (e.g. the Operations group). */
  min-height: 0;
}

.nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 2px;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #000000;
  background: #bfe9ff;
  border: 1px solid rgba(0, 100, 130, 0.25);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.nav-group-label:hover {
  color: #000000;
  background: #d3f1ff;
  border-color: rgba(0, 100, 130, 0.40);
}

.nav-group-label.collapsed {
  background: #a8ddf5;
}

.nav-group-arrow {
  font-size: 10px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 100, 130, 0.18);
  color: #000000;
  transition: transform 0.15s ease, background 0.2s ease;
  transform: rotate(0deg);
}

.nav-group-label:hover .nav-group-arrow {
  background: rgba(0, 100, 130, 0.26);
}

.nav-group-label.collapsed .nav-group-arrow { transform: rotate(-90deg); }

.nav-group-links {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav-group-links.collapsed { display: none; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  padding: 11px 12px;
  border-radius: 14px;
  color: var(--sidebar-text-dim);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sidebar nav a::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  flex-shrink: 0;
  transition: transform 0.2s ease, background 0.2s ease;
}

.sidebar nav a:hover {
  background: var(--sky-2);
  color: var(--primary);
  transform: translateX(3px);
  border-color: var(--border);
}

.sidebar nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 40, 142, 0.12);
}

.sidebar nav a.active::before {
  background: var(--primary);
  transform: scale(1.2);
}

.logout-btn {
  margin: 16px 0 0;
  padding: 12px 14px;
  background: linear-gradient(135deg, #2ab2ff 0%, #0b6f9c 100%);
  border: none;
  color: #fff;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(7, 74, 106, 0.24);
}

.logout-btn:hover {
  background: linear-gradient(135deg, #3dc5ff 0%, #0c85b7 100%);
}

.content {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1680px;
}

.content h2 {
  margin-top: 0;
  color: var(--navy);
  font-size: 28px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Dashboard */
.welcome-banner {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: 0 10px 28px rgba(11, 28, 48, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.welcome-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(22, 35, 61, 0.1);
}

.welcome-banner h2 {
  margin: 0 0 6px;
  color: var(--navy);
  font-size: 23px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}

.welcome-banner p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 14px;
}

.welcome-banner .quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.welcome-banner .quick-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--navy);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.welcome-banner .quick-actions a:hover { background: var(--teal-soft); border-color: var(--primary); }
.welcome-banner .quick-actions a.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.welcome-banner .quick-actions a.primary:hover { background: var(--primary-dark); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 16px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 6px 16px rgba(11, 28, 48, 0.05);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.stat-tile[data-goto]:hover {
  box-shadow: 0 14px 28px rgba(22, 35, 61, 0.12);
  transform: translateY(-3px);
  border-color: rgba(15, 127, 168, 0.3);
}

.stat-tile .stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--font-en);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-tile .stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.stat-tile.tile-blue .stat-value { color: var(--tile-blue); }
.stat-tile.tile-green .stat-value { color: var(--tile-green); }
.stat-tile.tile-aqua .stat-value { color: var(--tile-aqua); }
.stat-tile.tile-orange .stat-value { color: var(--tile-orange); }
.stat-tile.tile-violet .stat-value { color: var(--tile-violet); }
.stat-tile.tile-red .stat-value { color: var(--tile-red); }
.stat-tile.tile-red { background: #fff0f2; border-color: #ff6b86; }
.stat-tile.tile-orange { background: #fff7dc; border-color: #f4ad19; }
.stat-tile.tile-green { background: #e5f8ef; border-color: #55c99d; }
.stat-tile.tile-aqua { background: #e1f8f6; border-color: #53c7bb; }
.stat-tile.tile-violet { background: #f1e9ff; border-color: #a776e7; }

/* Dashboard widgets */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}
.dash-panel-wide { grid-column: 1 / -1; }
.dash-panel { padding: 20px; }
.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.dash-panel-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
}
.dash-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}
.dash-link:hover { text-decoration: underline; }
.dash-panel .scroll-table-wrap { max-height: 330px; }

.stat-note {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 3px;
}

.dashboard-section-title {
  margin: 26px 0 12px;
  font-size: 17px;
  color: var(--navy);
}
.dashboard-section-title:first-of-type { margin-top: 0; }

/* Accounts screen */
.page-heading { margin-bottom: 18px; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.breadcrumbs b { color: var(--border); font-size: 18px; font-weight: 400; }
.breadcrumbs strong { color: var(--primary); }
.page-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading-row h2 { margin: 0 0 5px; }
.page-heading-row p { margin: 0; color: var(--text-muted); font-size: 13px; }
.heading-actions { display: flex; gap: 8px; }
.heading-actions .btn { white-space: nowrap; }
.account-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.account-kpi { position: relative; display: flex; flex-direction: column; gap: 7px; min-height: 104px; padding: 16px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 5px 16px rgba(11, 28, 48, .05); overflow: hidden; }
.account-kpi::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--primary); opacity: .35; }
.account-kpi-success::after { background: var(--accent); opacity: .65; }
.account-kpi span { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.account-kpi strong { color: var(--navy); font-family: var(--font-en); font-size: 27px; line-height: 1.1; }
.account-kpi strong b { font-size: 22px; }
.account-kpi strong em { color: var(--border); font-style: normal; font-size: 16px; }
.account-kpi small { color: var(--text-muted); font-size: 11px; }
.account-kpi-success strong, .account-kpi-success small { color: var(--accent); }
.account-provisioning { padding: 22px; margin-bottom: 22px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.section-heading h3 { margin: 0 0 4px; color: var(--navy); font-size: 17px; }
.section-heading p { margin: 0; color: var(--text-muted); font-size: 12px; }
.section-heading > span { padding: 5px 10px; border-radius: 999px; background: var(--sky-2); color: var(--primary); font-size: 11px; font-weight: 600; white-space: nowrap; }
.account-form { margin-top: 17px; align-items: end; }
.account-form label { color: var(--navy); font-weight: 600; }
.account-form label small { color: var(--text-muted); font-weight: 400; }
.role-submit { display: flex; gap: 8px; }
.role-submit select { flex: 1; min-width: 0; }
.role-submit .btn-primary { width: auto; margin: 0; white-space: nowrap; }
.account-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.filter-pills { display: flex; gap: 7px; overflow-x: auto; }
.filter-pill { border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; background: var(--card); color: var(--text-muted); font-size: 12px; white-space: nowrap; cursor: pointer; }
.filter-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.account-search { display: flex; gap: 8px; min-width: 330px; }
.account-search input { min-width: 210px; }
.account-search select { width: 130px; }
.accounts-table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 5px 16px rgba(11, 28, 48, .05); }
.accounts-table { min-width: 920px; border: 0; border-radius: 0; box-shadow: none; }
.accounts-table th { background: var(--sky-2); color: var(--text-muted); font-size: 11px; }
.accounts-table td { vertical-align: middle; font-size: 12px; }
.user-identity { display: flex; align-items: center; gap: 9px; }
.user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--sky-3); color: var(--primary); font-size: 11px; font-weight: 700; }
.user-identity strong { display: block; color: var(--navy); }
.user-identity small { display: block; color: var(--text-muted); font-size: 10px; margin-top: 2px; }
.accounts-table select { min-width: 100px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--sky-2); color: var(--text); font-size: 11px; }
.switch { display: inline-flex; position: relative; width: 35px; height: 19px; vertical-align: middle; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(-16px); }
.account-status { display: block; color: var(--text-muted); font-size: 10px; margin-top: 3px; }
.account-status.is-active { color: var(--accent); }
.password-action { display: flex; gap: 5px; }
.password-action input { width: 125px; padding: 6px 8px; font-size: 11px; }
.password-action .btn { padding: 6px 9px; font-size: 11px; }
.icon-action { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 17px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(22, 35, 61, 0.04);
}

th, td {
  padding: 10px 14px;
  text-align: start;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12.5px;
}

tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }

.scroll-table-wrap {
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.scroll-table-wrap table {
  border: none;
  border-radius: 0;
}

.scroll-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 5;
}

.scroll-table-wrap .card {
  margin-bottom: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

@keyframes softLift {
  from { transform: translateY(4px); opacity: 0.95; }
  to { transform: translateY(0); opacity: 1; }
}

/* Header table (fixed) + body table (scrolls on its own) -- the native
   scrollbar this produces only ever runs alongside the rows, never the
   header, unlike a single overflow:auto wrapper around one table. */
.frozen-table {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.frozen-table table {
  width: 100%;
  table-layout: fixed;
  border: none;
  border-radius: 0;
}

.frozen-table-header table { margin-bottom: -1px; }

.frozen-table-body {
  max-height: 65vh;
  overflow-y: auto;
}

.frozen-table-body tr:last-child td { border-bottom: none; }

.attendance-frozen-table th:nth-child(1), .attendance-frozen-table td:nth-child(1) { width: 13%; }
.attendance-frozen-table th:nth-child(2), .attendance-frozen-table td:nth-child(2) { width: 8%; }
.attendance-frozen-table th:nth-child(3), .attendance-frozen-table td:nth-child(3) { width: 8%; }
.attendance-frozen-table th:nth-child(4), .attendance-frozen-table td:nth-child(4) { width: 15%; }
.attendance-frozen-table th:nth-child(5), .attendance-frozen-table td:nth-child(5) { width: 19%; }
.attendance-frozen-table th:nth-child(6), .attendance-frozen-table td:nth-child(6) { width: 8%; }
.attendance-frozen-table th:nth-child(7), .attendance-frozen-table td:nth-child(7) { width: 7%; }
.attendance-frozen-table th:nth-child(8), .attendance-frozen-table td:nth-child(8) { width: 7%; }
.attendance-frozen-table th:nth-child(9), .attendance-frozen-table td:nth-child(9) { width: 6%; }
.attendance-frozen-table th:nth-child(10), .attendance-frozen-table td:nth-child(10) { width: 9%; }

/* .selectable prepends a checkbox column, shifting every named column one
   slot right -- same 10 proportions as above, just re-indexed from nth-child(2). */
.attendance-frozen-table.selectable th:nth-child(1), .attendance-frozen-table.selectable td:nth-child(1) { width: 32px; }
.attendance-frozen-table.selectable th:nth-child(2), .attendance-frozen-table.selectable td:nth-child(2) { width: 13%; }
.attendance-frozen-table.selectable th:nth-child(3), .attendance-frozen-table.selectable td:nth-child(3) { width: 8%; }
.attendance-frozen-table.selectable th:nth-child(4), .attendance-frozen-table.selectable td:nth-child(4) { width: 8%; }
.attendance-frozen-table.selectable th:nth-child(5), .attendance-frozen-table.selectable td:nth-child(5) { width: 14%; }
.attendance-frozen-table.selectable th:nth-child(6), .attendance-frozen-table.selectable td:nth-child(6) { width: 18%; }
.attendance-frozen-table.selectable th:nth-child(7), .attendance-frozen-table.selectable td:nth-child(7) { width: 7%; }
.attendance-frozen-table.selectable th:nth-child(8), .attendance-frozen-table.selectable td:nth-child(8) { width: 6%; }
.attendance-frozen-table.selectable th:nth-child(9), .attendance-frozen-table.selectable td:nth-child(9) { width: 6%; }
.attendance-frozen-table.selectable th:nth-child(10), .attendance-frozen-table.selectable td:nth-child(10) { width: 6%; }
.attendance-frozen-table.selectable th:nth-child(11), .attendance-frozen-table.selectable td:nth-child(11) { width: 9%; }

.btn {
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  margin-inline-start: 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.btn-approve { background: var(--success); color: #fff; border-color: var(--success); }
.btn-reject { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger { color: var(--danger); border-color: var(--danger); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-grid.wide { grid-template-columns: 1fr; }

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}

.filter-actions .btn {
  background: #f4fbff;
  border-color: rgba(15, 127, 168, 0.18);
}

.filter-actions .btn:hover {
  background: #e8f7ff;
}

.form-grid label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(34, 48, 74, 0.12);
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none;
  border-color: rgba(15, 127, 168, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 127, 168, 0.12);
}

.form-grid-full {
  grid-column: 1 / -1;
}

.approvals-filter-card {
  position: static;
  z-index: 1;
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(215, 227, 238, 0.9);
}

/* On a wide screen, let the filter fields reflow into more columns instead
   of two columns stretching to fill the wider .content area -- keeps each
   input/select a sensible width while using the extra horizontal space. */
.approvals-filter-card .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.approvals-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 0 12px;
  margin-bottom: 12px;
}

.summary-block {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}

.badge-filter {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef7ff;
  color: #165c8c;
  border: 1px solid rgba(15, 127, 168, 0.16);
  font-size: 12px;
}

.detail-popover {
  position: fixed;
  z-index: 1200;
  min-width: 240px;
  max-width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  padding: 16px;
  pointer-events: auto;
}

.detail-popover.hidden {
  display: none;
}

.detail-popover .popover-content h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.employee-link {
  border: none;
  background: none;
  color: var(--primary-dark);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}

.employee-link:hover {
  color: #0a5f7a;
}

.empty-state {
  color: var(--text-muted);
  padding: 30px;
  text-align: center;
}

.emp-picker { position: relative; }

.emp-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.emp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
}

.emp-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  padding: 2px 6px;
}

.emp-chip button:hover { color: var(--danger); }

.emp-picker-dropdown {
  position: absolute;
  z-index: 20;
  top: 100%;
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.emp-picker-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.emp-picker-option:hover { background: var(--bg); }

.emp-picker-empty {
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Single-select searchable employee dropdown -- replaces a plain <select>
   wherever the employee list is long enough that scrolling through it beats
   typing a name/code. Reuses .emp-picker-dropdown/-option/-empty above for
   the same look as the multi-select picker. */
.emp-search-select { position: relative; }

.toast {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
}

/* ---------------------------------------------------------------------
   Mobile layout -- below this width the sidebar becomes an off-canvas
   drawer: it sits over the content (beside it, sliding in from the side)
   instead of stacking above it as a full-width strip. A hamburger button
   in the top bar opens/closes it, with a backdrop to dismiss.
   --------------------------------------------------------------------- */
.mobile-topbar {
  display: none;
}

@media (max-width: 860px) {
  .app-shell { display: block; }

  /* Hamburger + top bar above the content */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 14px;
    background: linear-gradient(135deg, #071c2f 0%, #0f2d43 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(2, 12, 24, 0.2);
  }
  .mobile-topbar .menu-toggle {
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }
  .mobile-topbar .mobile-brand {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Off-canvas drawer -- the WHOLE drawer scrolls as one unit (nav + footer
     + logout), so nothing is ever cut off even when many groups are open.
     Relying on the inner nav to scroll proved unreliable in mobile browsers. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 60;
    width: 300px;
    min-width: 300px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    border-top-right-radius: 0;
    border-bottom-right-radius: 30px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Lock the page behind so scrolling inside the drawer doesn't scroll the
     background (which makes the drawer look cut off at the bottom). */
  body.sidebar-open {
    overflow: hidden;
  }

  /* Let the whole drawer scroll instead of compressing the nav: */
  .sidebar nav {
    flex: none;
    overflow: visible;
  }
  .sidebar-footer {
    margin-top: 0;
  }

  /* Backdrop to dismiss the drawer */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(2, 12, 24, 0.5);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .content {
    padding: 24px 16px 24px;
    max-width: 100%;
  }

  .page-heading-row, .account-toolbar { align-items: stretch; flex-direction: column; }
  .heading-actions { display: none; }
  .account-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { flex-direction: column; }
  .account-search { min-width: 0; width: 100%; }
  .account-search input { flex: 1; min-width: 0; }
  .account-search select { width: 130px; }

  .form-grid { grid-template-columns: 1fr; }

  .dash-grid { grid-template-columns: 1fr; }
  .dash-panel-wide { grid-column: auto; }

  table { display: block; overflow-x: auto; white-space: nowrap; }
}
