/* ============================================================
   Energy Homeland HR — "Engineered" futuristic theme
   Dark command-center shell + bright glass content cards.
   EHL blue (#15549e / bright #2f8fe0) + leaf green (#6cb33f).
   ============================================================ */
/* ---- Self-hosted fonts (offline-safe; no external CDN at runtime) ---- */
@font-face { font-family:'Inter'; font-style:normal; font-weight:400; font-display:swap; src:url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:500; font-display:swap; src:url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap; src:url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:700; font-display:swap; src:url('/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:800; font-display:swap; src:url('/fonts/inter-800.woff2') format('woff2'); }
@font-face { font-family:'Plex Arabic'; font-style:normal; font-weight:400; font-display:swap; src:url('/fonts/plexar-400.woff2') format('woff2'); }
@font-face { font-family:'Plex Arabic'; font-style:normal; font-weight:500; font-display:swap; src:url('/fonts/plexar-500.woff2') format('woff2'); }
@font-face { font-family:'Plex Arabic'; font-style:normal; font-weight:600; font-display:swap; src:url('/fonts/plexar-600.woff2') format('woff2'); }
@font-face { font-family:'Plex Arabic'; font-style:normal; font-weight:700; font-display:swap; src:url('/fonts/plexar-700.woff2') format('woff2'); }

:root {
  /* ---- Brand (unchanged identity) ---- */
  --brand: #15549e;
  --brand-bright: #2f8fe0;
  --brand-dark: #0e3d73;
  --brand-light: #e8eef8;
  --accent: #6cb33f;
  --accent-bright: #7fe0a6;

  /* ---- Apple-light surfaces (glassy) ---- */
  --ink: #1d1d1f;          /* Apple text black */
  --muted: #56565c;
  --muted-strong: #424248;
  --border: rgba(0,0,0,.08);
  --card: rgba(255,255,255,.78);
  --card-alt: rgba(255,255,255,.55);

  /* ---- Chrome (dark shell + frosted dark sidebar/topbar) ---- */
  --shell: #0a111d;
  --shell-2: #0d1726;
  --panel: rgba(13,23,40,.62);
  --panel-line: rgba(255,255,255,.09);
  --chrome-text: #e3ebf7;
  --chrome-muted: #9fb2c9;

  /* ---- Glass material ---- */
  --glass: rgba(255,255,255,.66);
  --glass-strong: rgba(255,255,255,.82);
  --glass-line: rgba(255,255,255,.55);
  --blur: saturate(180%) blur(22px);

  /* ---- Status (non-brand, status-only) ---- */
  --success: #1f8a4c;
  --warning: #9a7400;
  --danger: #d23b3b;
  --info: var(--brand);

  /* ---- Gradient: used sparingly (login rail, active nav) ---- */
  --grad: linear-gradient(135deg, var(--brand) 0%, var(--brand-bright) 60%, var(--accent) 140%);
  --grad-rail: linear-gradient(90deg, var(--brand-bright), var(--accent));

  /* ---- Type ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-ar: 'Plex Arabic', 'Inter', -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 15px;
  --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 24px; --fs-stat: 30px;
  --tracking-eyebrow: .04em;

  /* ---- Spacing scale ---- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;

  /* ---- Radius scale (Apple roundness) ---- */
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --radius: var(--r-md); /* back-compat alias */

  /* ---- Elevation ladder (soft, diffuse) ---- */
  --elev-1: 0 8px 24px rgba(20,30,50,.08), 0 1px 2px rgba(20,30,50,.05);
  --elev-2: 0 14px 36px rgba(20,30,50,.12), 0 2px 6px rgba(20,30,50,.06);
  --elev-3: 0 28px 70px rgba(20,30,50,.28);
  --ring-focus: 0 0 0 3px rgba(47,143,224,.30);
  --shadow: var(--elev-1);  /* back-compat alias */
  --glow: 0 10px 30px rgba(21,84,158,.14), 0 2px 8px rgba(20,30,50,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
/* Arabic UI gets a designed Arabic face instead of the OS fallback */
[lang="ar"] body, [dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] textarea, [dir="rtl"] button { font-family: var(--font-ar); }
/* Align figures in money / stat / numeric columns */
.stat .value, .big-clock, .num, td .money { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--chrome-text);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 600px at 78% -10%, rgba(47,143,224,.16), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(108,179,63,.12), transparent 55%),
    linear-gradient(180deg, var(--shell), var(--shell-2));
  background-attachment: fixed;
  min-height: 100vh;
}
#app { position: relative; z-index: 1; }
a { color: var(--brand-bright); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.brand-lockup { display: inline-flex; align-items: center; gap: 10px; }
.brand-lockup svg { flex: none; }
.brand-lockup .txt { font-weight: 800; letter-spacing: -.5px; line-height: 1; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index: 1; }
.login-card {
  background: rgba(255,255,255,.85); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  color: var(--ink); padding: 38px; border-radius: var(--r-lg); width: 372px;
  box-shadow: var(--elev-2), inset 0 1px 0 rgba(255,255,255,.8); border: 1px solid var(--glass-line); position: relative; overflow: hidden;
}
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--grad-rail); }
.login-card h1 { font-size: 20px; color: var(--brand); margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.login-card .logo { font-size: 26px; font-weight: 800; color: var(--brand); letter-spacing: -1px; }
.login-card .logo span { color: var(--accent); }
.hint { margin-top: 16px; font-size: var(--fs-xs); color: var(--muted-strong); background: var(--brand-light); padding: 11px 12px; border-radius: var(--r-sm); line-height: 1.6; }

/* ---------- Login split layout ---------- */
.login-split { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; position: relative; z-index: 1; }
.login-brand { position: relative; overflow: hidden; padding: 56px 56px 28px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, #0e3d73 0%, #15549e 55%, #123a6b 100%); color: #eaf2ff; }
.login-brand::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 30px 30px; }
.login-brand::after { content: ""; position: absolute; width: 460px; height: 460px; right: -140px; top: -120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(108,179,63,.32), transparent 65%); pointer-events: none; }
.login-brand .lb-inner { position: relative; z-index: 1; max-width: 440px; }
.login-brand .lb-logo { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); width: 88px; height: 88px; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; }
.login-brand .lb-word { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 22px 0 26px; }
.login-brand .lb-word span { color: var(--accent-bright); }
.login-brand .lb-tag { font-size: 30px; line-height: 1.18; font-weight: 800; letter-spacing: -.6px; color: #fff; }
.login-brand .lb-sub { margin-top: 14px; font-size: var(--fs-md); line-height: 1.6; color: #c5d7f0; }
.login-brand .lb-foot { position: relative; z-index: 1; font-size: var(--fs-xs); color: #a9c1e0; letter-spacing: .02em; }
.login-formcol { display: grid; place-items: center; padding: 24px; }
.login-formcol .login-card { box-shadow: var(--elev-2); }
.login-mark { margin-bottom: 14px; }
.login-card h1 { font-size: var(--fs-2xl); }
.login-top { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.login-lang { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-pill); overflow: hidden; }
.login-lang button { background: #fff; border: none; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login-lang button.active { background: var(--brand); color: #fff; }
.login-alert { background: #fdeaea; border: 1px solid #f1c7c7; color: #b3201d; border-radius: var(--r-sm); padding: 10px 12px; font-size: var(--fs-sm); margin-bottom: 14px; }
.login-forgot { font-size: var(--fs-xs); font-weight: 600; }
.pw-wrap, .input-ico { position: relative; display: block; }
.pw-wrap input { padding-inline-end: 42px; }
/* Leading field icon (username / password) */
.input-ico > .ii-lead, .pw-wrap > .ii-lead { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: inline-flex; align-items: center; pointer-events: none; }
.input-ico > input, .pw-wrap > input { padding-inline-start: 38px; }
.caps-hint { margin-top: 6px; font-size: var(--fs-xs); color: #b3201d; display: inline-flex; align-items: center; gap: 5px; }
/* Brand-panel footer */
.login-brand .lb-foot { display: flex; align-items: center; gap: 6px; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); display: inline-flex; padding: 6px; border-radius: var(--r-sm); }
.pw-toggle:hover { color: var(--ink); background: var(--card-alt); }
.btn-spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; display: inline-block; vertical-align: -2px; margin-inline-end: 8px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spin { animation: none; } }
@media (max-width: 820px) {
  .login-split { grid-template-columns: 1fr; }
  /* keep brand identity on mobile as a compact top strip instead of hiding it */
  .login-brand { padding: 22px 22px 18px; }
  .login-brand .lb-tag, .login-brand .lb-sub, .login-brand .lb-foot { display: none; }
  .login-brand { flex-direction: row; align-items: center; gap: 14px; }
  .login-brand .lb-inner { display: flex; align-items: center; gap: 14px; }
  .login-brand .lb-word { margin: 0; }
  .login-brand .lb-logo { width: 56px; height: 56px; }
  .login-brand .lb-word { margin: 12px 0 0; font-size: 20px; }
  /* Comfortable touch targets on mobile (≥44px) */
  .pw-toggle { padding: 11px; }
  .login-lang button { padding: 10px 15px; }
}

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-right: 1px solid var(--panel-line);
  color: var(--chrome-text); display: flex; flex-direction: column; position: relative;
}
/* Brand lockup */
.brand-lock { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.brand-lock .brand-mark { background: #fff; border-radius: var(--r-sm); padding: 5px; display: inline-flex; flex: none; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.brand-lock .brand-word { font-weight: 700; font-size: 16px; letter-spacing: -.4px; color: #fff; white-space: nowrap; }
.brand-lock .brand-word span { color: var(--accent-bright); }
.nav-collapse { margin-inline-start: auto; background: none; border: none; color: var(--chrome-muted); display: inline-flex; padding: 6px; border-radius: var(--r-sm); transition: .15s; }
.nav-collapse:hover { color: #fff; background: rgba(255,255,255,.1); }

.nav { flex: 1; padding: 8px 10px; position: relative; overflow-y: auto; }
.nav-group { margin-bottom: 6px; }
.nav-grouphead { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--chrome-muted); opacity: .7; padding: 12px 14px 5px; }
/* macOS-style sliding selection pill (dark chrome) */
.nav-indicator { position: absolute; inset-inline: 10px; width: auto; border-radius: var(--r-sm); background: linear-gradient(90deg, rgba(47,143,224,.28), rgba(108,179,63,.12)); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); top: 0; height: 0; opacity: 0;
  transition: top .28s cubic-bezier(.32,.72,0,1), height .28s cubic-bezier(.32,.72,0,1), opacity .2s; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; margin: 2px 0; border-radius: var(--r-sm);
  color: var(--chrome-muted); font-size: 14px; font-weight: 500; transition: background .15s, color .15s; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a:hover .ico { transform: translateY(-1px); }
.nav a.active { background: transparent; color: #fff; font-weight: 600; }
.nav .ico { width: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--chrome-muted); flex: none; transition: color .15s, transform .15s; }
.nav a:hover .ico, .nav a.active .ico { color: var(--accent-bright); }
.ic { flex: none; vertical-align: middle; }
.btn .ic { vertical-align: -3px; margin-inline-end: 6px; }

/* Collapsed icon rail */
/* Collapsed icon rail — desktop only (mobile uses the full slide-in drawer) */
@media (min-width: 901px) {
  .layout.nav-collapsed { grid-template-columns: 68px 1fr; }
  /* NOTE: .nav-collapse stays visible so the rail can be expanded again */
  .nav-collapsed .sidebar .brand-word, .nav-collapsed .nav .lbl, .nav-collapsed .nav-grouphead,
  .nav-collapsed .user-meta, .nav-collapsed .user-chip .chev { display: none; }
  .nav-collapsed .brand-lock { flex-direction: column; justify-content: center; gap: 8px; padding: 14px 0 12px; }
  .nav-collapsed .nav-collapse { margin-inline-start: 0; }
  .nav-collapsed .nav a { justify-content: center; padding: 11px 0; }
  .nav-collapsed .nav-group { border-top: 1px solid var(--panel-line); padding-top: 4px; }
  .nav-collapsed .nav-group:first-child { border-top: none; }
  .nav-collapsed .user-chip { justify-content: center; }
  .nav-collapsed .user-menu { left: 8px; right: auto; min-width: 210px; z-index: 30; }
}

/* User chip + menu */
.sidebar .userbox { padding: 12px; border-top: 1px solid var(--panel-line); position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--panel-line); border-radius: var(--r-md); padding: 8px 10px; transition: background .15s; }
.user-chip:hover { background: rgba(255,255,255,.1); }
.user-chip .avatar { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.2); }
.user-chip .user-meta { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.user-chip .name { color: #fff; font-weight: 600; font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role { color: var(--accent-bright); text-transform: capitalize; font-size: 11px; }
.user-chip .chev { margin-inline-start: auto; color: var(--chrome-muted); }
.user-menu { position: absolute; bottom: calc(100% - 4px); left: 12px; right: 12px; background: rgba(17,30,52,.85); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--panel-line); border-radius: var(--r-md); box-shadow: var(--elev-3); padding: 6px; z-index: 20; }
.user-menu a, .user-menu button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; color: var(--chrome-text); font-size: 13px; padding: 9px 10px; border-radius: var(--r-sm); text-align: start; transition: background .12s; }
.user-menu a:hover, .user-menu button:hover { background: rgba(255,255,255,.1); color: #fff; }
.user-menu .ico { color: var(--chrome-muted); display: inline-flex; }
.user-menu .danger-item { color: #ff9a9a; }
.topbar-logo { background: #fff; border-radius: 6px; padding: 3px 7px; display: inline-flex; }

.main { padding: 26px 30px; overflow-y: auto; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: #f1f6ff; margin-bottom: 3px; }
.page-sub { color: var(--chrome-muted); margin-bottom: 22px; font-size: 13.5px; }
.main > h3, .section-gap > h3 { color: #e7eefb; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: rgba(255,255,255,.95); color: var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.85);
  padding: 18px; border: 1px solid var(--glass-line); position: relative; transition: transform .15s, box-shadow .15s;
}
.card h3 { font-size: var(--fs-sm); color: var(--ink); margin-bottom: var(--space-3); font-weight: 600; letter-spacing: -.1px; }
.stat { overflow: hidden; }
.stat::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--grad-rail); opacity: .9; }
.stat .value { font-size: var(--fs-stat); font-weight: 800; letter-spacing: -.5px; color: var(--brand); }
.stat .label { color: var(--ink); font-size: var(--fs-sm); margin-top: 2px; font-weight: 600; }
.stat .sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; }
.card[onclick], .stat[onclick] { cursor: pointer; }
.card[onclick]:hover, .stat[onclick]:hover { transform: translateY(-3px); box-shadow: var(--glow); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(21,84,158,.05); }
.table-card { background: rgba(255,255,255,.95); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.85); border: 1px solid var(--glass-line); overflow: hidden; position: relative; }
.table-card .head { padding: 15px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.45); }
.table-card .head h3 { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -.2px; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--brand); }
.sort-ind { color: var(--brand); font-size: 10px; }
tbody.dense th, tbody.dense td { padding: 6px 13px; }
tbody.dense .cell-person .muted { display: none; }
tr.rowlink { cursor: pointer; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--brand); background: var(--brand-light); border: 1px solid #d3e0f3; letter-spacing: .3px; }
.search-wrap { position: relative; flex: 1; min-width: 240px; max-width: 440px; }
.search-wrap .search-ic { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: inline-flex; }
.search-wrap input { padding-inline-start: 36px; }
.table-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: var(--fs-xs); }
.btn.small.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge.green { background: #e6f7ec; color: #167a41; border-color: #bce8cd; }
.badge.red { background: #fdeaea; color: #c0322f; border-color: #f6cccc; }
.badge.amber { background: #fdf3da; color: #856300; border-color: #f1e0ac; }
.badge.gray { background: #eef1f6; color: var(--muted-strong); border-color: #e0e6ee; }
.badge.blue { background: #e7f0fc; color: var(--brand); border-color: #c7ddf6; }

/* ---------- Buttons ---------- */
.btn { background: linear-gradient(180deg, #3b9bea 0%, var(--brand) 90%); color: #fff; border: none; padding: 9px 18px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; letter-spacing: .1px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.38), 0 1px 3px rgba(21,84,158,.3); transition: filter .15s, box-shadow .15s, transform .15s; }
.btn:hover { filter: brightness(1.07); box-shadow: inset 0 1px 0 rgba(255,255,255,.38), 0 4px 12px rgba(21,84,158,.3); transform: translateY(-1px); }
.btn.secondary { background: rgba(0,0,0,.05); color: var(--brand); border: none; box-shadow: none; }
.btn.secondary:hover { background: rgba(0,0,0,.09); filter: none; transform: none; box-shadow: none; }
.btn.danger { background: linear-gradient(180deg, #ff5b52 0%, var(--danger) 90%); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 1px 3px rgba(210,59,59,.3); }
.btn.danger:hover { filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 12px rgba(210,59,59,.28); }
.btn.small { padding: 6px 14px; font-size: var(--fs-xs); border-radius: var(--r-pill); min-height: 32px; }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: none; }
.btn.danger.ghost-danger { background: rgba(210,59,59,.08); color: var(--danger); border: none; box-shadow: none; }
.btn.danger.ghost-danger:hover { background: rgba(210,59,59,.15); filter: none; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { width: 36px; height: 20px; background: #cdd6e4; border-radius: var(--r-pill); position: relative; transition: background .2s; flex: none; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: #34c759; } /* iOS green */
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { box-shadow: var(--ring-focus); }
.switch-lbl { font-size: var(--fs-xs); font-weight: 600; color: var(--ink); }
[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-16px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; filter: none; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: var(--space-3); }
label.field span { display: block; font-size: var(--fs-xs); color: var(--muted-strong); margin-bottom: 5px; font-weight: 600; }
label.field span.req::after { content: " *"; color: var(--danger); font-weight: 700; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid rgba(0,0,0,.14); border-radius: var(--r-sm); font-size: var(--fs-base); font-family: inherit; background: rgba(255,255,255,.85); color: var(--ink); transition: border-color .15s, box-shadow .15s; min-height: 40px; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(210,59,59,.14); }
.field-error { color: var(--danger); font-size: var(--fs-xs); margin-top: 4px; font-weight: 600; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-bright); box-shadow: var(--ring-focus); }

/* ---------- Focus visibility (WCAG 2.4.7 / 2.4.11) ---------- */
:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 2px; border-radius: inherit; }
.btn:focus-visible { outline-offset: 3px; }
.sidebar a:focus-visible, .tabbar button:focus-visible, .topbar .hamb:focus-visible { outline-color: #cdd9ea; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(8,14,26,.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: rgba(255,255,255,.9); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--ink); border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--elev-3), inset 0 1px 0 rgba(255,255,255,.8); border: 1px solid var(--glass-line); }
.modal .m-head { padding: 17px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,.5); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.modal .m-head h3 { font-size: 17px; color: var(--ink); }
.modal .m-body { padding: 22px; }
.modal .m-foot { padding: 15px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal .card { background: rgba(255,255,255,.6); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none; }
.close-x { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; min-width: 36px; min-height: 36px; border-radius: var(--r-sm); }
.close-x:hover { background: var(--card-alt); color: var(--ink); }

/* ---------- Misc ---------- */
.toast { position: fixed; bottom: 24px; right: 24px; display: none; align-items: center; gap: 10px; background: rgba(28,30,36,.78); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: #fff; padding: 12px 14px 12px 16px; border-radius: var(--r-md); box-shadow: var(--elev-3), inset 0 1px 0 rgba(255,255,255,.12); opacity: 0; transform: translateY(20px); transition: opacity .25s, transform .25s; z-index: 200; max-width: 380px; border: 1px solid rgba(255,255,255,.16); border-left: 3px solid var(--accent-bright); }
.toast.show { display: flex; opacity: 1; transform: translateY(0); }
.toast.err { background: rgba(64,18,20,.82); border-left-color: #ff7a7a; }
.toast .t-ico { display: inline-flex; flex: none; color: var(--accent-bright); }
.toast.err .t-ico { color: #ff7a7a; }
.toast .t-msg { font-size: var(--fs-sm); line-height: 1.45; }
.toast .t-close { background: none; border: none; color: rgba(255,255,255,.7); font-size: 20px; line-height: 1; padding: 0 2px; margin-inline-start: auto; min-width: 28px; min-height: 28px; }
.toast .t-close:hover { color: #fff; }
[dir="rtl"] .toast { right: auto; left: 24px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
/* muted text sitting directly on the dark canvas (not inside a light card) */
#empCount, #pipeCount, #lv > .muted, .main > .muted { color: var(--chrome-muted); }
.section-gap { margin-top: 24px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
/* iOS-style segmented control (on dark canvas) */
.tabbar { display: inline-flex; gap: 2px; margin-bottom: 18px; background: rgba(255,255,255,.1); border-radius: var(--r-sm); padding: 3px; max-width: 100%; overflow-x: auto; }
.tabbar button { background: none; border: none; padding: 8px 16px; font-size: var(--fs-sm); color: var(--chrome-muted); font-weight: 600; border-radius: 8px; white-space: nowrap; transition: background .18s, color .18s, box-shadow .18s; }
.tabbar button:hover { color: #fff; }
.tabbar button.active { color: var(--ink); background: rgba(255,255,255,.95); box-shadow: 0 1px 4px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.9); }
.empty { text-align: center; padding: 40px; color: var(--chrome-muted); }
.card .empty, .table-card .empty, .modal .empty { color: var(--muted); }
.empty-state { text-align: center; padding: 40px 24px; max-width: 440px; margin: 0 auto; }
.empty-state .es-icon { font-size: 40px; line-height: 1; margin-bottom: 12px; opacity: .9; }
.empty-state .es-title { font-size: var(--fs-md); font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-state .es-body { font-size: var(--fs-sm); color: var(--muted); line-height: 1.55; }
.empty-state .es-action { margin-top: 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.checkin-card { text-align: center; padding: 32px; }
.checkin-card .big-clock { font-size: 40px; font-weight: 800; font-family: var(--mono); background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 1px; }
.navbadge { box-shadow: 0 0 8px rgba(214,69,69,.6); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.icon-btn { background: rgba(255,255,255,.85); border: 1px solid var(--border); color: var(--muted); border-radius: var(--r-pill); padding: 5px; display: inline-flex; min-width: 30px; min-height: 30px; align-items: center; justify-content: center; }
.icon-btn:hover:not(:disabled) { color: var(--brand); border-color: var(--brand-bright); }
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }
.stars { display: inline-flex; gap: 1px; }
.star-btn { background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 0 1px; }
.star-btn:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 1px; border-radius: 3px; }
[dir="rtl"] .cand-foot .icon-btn svg { transform: scaleX(-1); }

/* ---------- Recruitment funnel + kanban pipeline ---------- */
.funnel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: rgba(255,255,255,.95); border: 1px solid var(--glass-line); border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--elev-1), inset 0 1px 0 rgba(255,255,255,.85); }
.funnel-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink); }
.funnel-arrow { color: var(--muted); }
.ts-bar { height: 5px; background: rgba(0,0,0,.08); border-radius: var(--r-pill); overflow: hidden; margin-top: 5px; max-width: 130px; }
.ts-bar > div { height: 100%; border-radius: var(--r-pill); transition: width .3s; }
.pipe-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; align-items: flex-start; }
.pipe-col { flex: 0 0 250px; min-width: 250px; background: rgba(255,255,255,.88); border: 1px solid var(--glass-line); box-shadow: var(--elev-1); border-radius: var(--r-md); display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.pipe-col.muted-col { opacity: .8; }
.pipe-col.drag-over { outline: 2px dashed var(--brand-bright); outline-offset: -2px; background: rgba(47,143,224,.12); }
.pipe-colhead { position: sticky; top: 0; background: rgba(255,255,255,.92); display: flex; align-items: center; justify-content: space-between; padding: 11px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: var(--fs-sm); border-radius: var(--r-md) var(--r-md) 0 0; z-index: 1; }
.pipe-cards { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.pipe-empty { color: var(--muted); font-size: var(--fs-xs); text-align: center; padding: 14px 0; }
.cand-card { background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 11px; box-shadow: 0 1px 2px rgba(8,16,30,.06); cursor: grab; transition: box-shadow .15s, transform .15s; }
.cand-card:hover { box-shadow: var(--elev-2); }
.cand-card.dragging { opacity: .5; }
.cand-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 2px; color: var(--muted); }
.cand-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
@media (max-width: 680px) { .pipe-col { flex-basis: 80vw; min-width: 80vw; } }
.page-title:focus { outline: none; }

/* ---------- Mobile top bar + slide-in nav ---------- */
.topbar { display: none; }
.nav-backdrop { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: 1fr 1fr; }            /* KPIs sit 2x2, not a tall stack */
  .main { padding: 18px 16px; }
  .card { padding: 14px; }
  .stat .value { font-size: 24px; }
  .checkin-card { padding: 22px; }
  .checkin-card .big-clock { font-size: 32px; }
  .topbar { display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; height: 56px; background: var(--panel); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid var(--panel-line); padding: 0 16px; z-index: 400; }
  .topbar .hamb { background: none; border: none; color: #fff; font-size: 24px; line-height: 1; padding: 4px 8px; min-width: 44px; min-height: 44px; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 244px; transform: translateX(-100%); transition: transform .25s ease; z-index: 500; }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 450; }
  .main { padding-top: 72px; }
  /* Page headers (title + action buttons) wrap instead of pushing buttons off-screen.
     :has(.page-title) targets only the header row; the title takes the full first row and the
     buttons drop below and wrap among themselves. */
  .main .flex.between:has(.page-title) { flex-wrap: wrap; gap: 12px; align-items: flex-start; }
  .main .flex.between:has(.page-title) > :first-child { flex: 1 1 100%; }
  .main .flex.between:has(.page-title) > .flex { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .cols-4 { grid-template-columns: 1fr; }
}

/* ---------- Subtle motion ---------- */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-enter { animation: viewIn .26s cubic-bezier(.4,0,.2,1); }
@keyframes modalIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.modal { animation: modalIn .18s cubic-bezier(.4,0,.2,1); }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay { animation: overlayIn .18s ease; }

/* ---------- Reduced motion (WCAG 2.3.3) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .card[onclick]:hover, .btn:hover { transform: none !important; }
}
[dir="rtl"] .sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--panel-line); }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] td[style*="text-align:right"] { text-align: left !important; }
[dir="rtl"] .tabbar button.active::after { left: 8px; right: 8px; }
@media (max-width: 900px) {
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="rtl"] .layout.nav-open .sidebar { transform: none; }
}

/* ---------- Skeleton loading (layout-matched shimmer) ---------- */
.skeleton { position: relative; overflow: hidden; background: #e9eef5; border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-row { display: flex; gap: 14px; padding: 12px 13px; border-bottom: 1px solid var(--border); }
.sk-row .skeleton { height: 14px; }
.sk-stat { height: 96px; }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }

/* ---------- Touch targets (WCAG 2.5.8 / Apple 44 / Material 48) ---------- */
@media (pointer: coarse) {
  .btn.small { padding: 9px 14px; font-size: var(--fs-sm); min-height: 40px; }
  .close-x { min-width: 44px; min-height: 44px; }
  .nav a { padding: 13px 14px; }
  .row-actions { gap: 8px; }
  .tabbar button { padding: 12px 16px; }
}

/* ---------- Mobile tables ---------- */
/* Tablets / landscape phones (641–900px): wide tables scroll horizontally inside their card. */
@media (min-width: 641px) and (max-width: 900px) {
  .table-card { overflow: visible; }
  .table-card > table, .table-card > .tbl-scroll > table { min-width: 600px; }
  .table-card > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* Portrait phones (≤640px): tables reflow into stacked, labeled cards — fully usable vertically,
   with no sideways scrolling. Each row becomes a card; each cell shows its column label
   (labelMobileTables() in app.js copies the header onto each cell as data-label). Only tables
   that have a <thead> are converted; small label-less utility tables keep their natural flow. */
@media (max-width: 640px) {
  .table-card { overflow: visible; }
  .main table:has(> thead), .modal table:has(> thead) { display: block; width: 100%; min-width: 0 !important; }
  .main table:has(> thead) > thead, .modal table:has(> thead) > thead { display: none; }
  .main table:has(> thead) > tbody, .modal table:has(> thead) > tbody { display: block; }
  .main table:has(> thead) > tbody > tr, .modal table:has(> thead) > tbody > tr {
    display: block; padding: 10px 2px; border-bottom: 1px solid var(--border); }
  .main table:has(> thead) > tbody > tr:last-child, .modal table:has(> thead) > tbody > tr:last-child { border-bottom: none; }
  .main table:has(> thead) td, .modal table:has(> thead) td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    padding: 5px 12px; border: none; text-align: end; min-height: 0; }
  .main table:has(> thead) td[data-label]::before, .modal table:has(> thead) td[data-label]::before {
    content: attr(data-label); flex: 0 0 38%; text-align: start; font-weight: 600;
    color: var(--muted-strong); font-size: 12px; }
  /* full-width / special cells */
  .main table:has(> thead) td:not([data-label]), .modal table:has(> thead) td:not([data-label]) { justify-content: flex-start; }
  .main table:has(> thead) td.empty, .main table:has(> thead) td[colspan] { display: block; text-align: center; }
  .main table:has(> thead) td:has(.cell-person), .modal table:has(> thead) td:has(.cell-person) { display: block; }
  .main table:has(> thead) td:has(.cell-person)::before, .modal table:has(> thead) td:has(.cell-person)::before { display: none; }
  .main table:has(> thead) td.row-actions, .modal table:has(> thead) td.row-actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
  .main table:has(> thead) td.row-actions::before, .modal table:has(> thead) td.row-actions::before { display: none; }
}

/* ---------- Print (payslip) ---------- */
@media print {
  body { background: #fff; }
  body::before { display: none; }
  .sidebar, .topbar, .nav, .btn, .no-print { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .modal-overlay { position: static; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .modal { box-shadow: none; max-width: 100%; background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .card, .table-card { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
