/* HR platform — design system. Brand colours are CSS variables set at runtime from the company's identity settings. */
/* Country flag emoji on Windows (which has no flag glyphs) */
@font-face {
  font-family: 'Twemoji Country Flags';
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url('https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1.8/dist/TwemojiCountryFlags.woff2') format('woff2');
  font-display: swap;
}
:root {
  --brand: #1D4ED8;
  --brand-50: #eef2fd;
  --brand-100: #dbe4fb;
  --brand-200: #b9c9f5;
  --brand-700: #173eab;
  --brand-800: #112e80;
  --brand-text: #1D4ED8;
  --on-brand: #ffffff;
  --accent: #F59E0B;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --success: #047857;
  --success-bg: #ecfdf5;
  --info-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14);
  --sidebar-bg: var(--brand-800);
  --sidebar-text: rgba(255, 255, 255, .78);
  --sidebar-text-strong: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, .14);
  --sidebar-border: rgba(255, 255, 255, .08);
  --font: 'Twemoji Country Flags', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.scroll-locked, html.scroll-locked body { overflow: hidden; }
button, a, label, select, input, textarea { -webkit-tap-highlight-color: transparent; }
button, .btn, .tab, .pill { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.gap-lg { gap: 18px; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-inline-end: 1px solid var(--sidebar-border); z-index: 30; }
.sidebar-head { padding: 18px 18px 14px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--sidebar-border); min-height: 72px; }
.sidebar-logo { max-height: 40px; max-width: 150px; object-fit: contain; }
.sidebar-logo-box { background: #fff; border-radius: 10px; padding: 6px 10px; display: flex; align-items: center; justify-content: center; }
/* Logo background choice: light box / dark box / none (transparent) */
.logobg-light { background: #fff; }
.logobg-dark { background: #0f172a !important; }
.logobg-none { background: transparent !important; }
.sidebar-logo-box.logobg-none { padding-inline: 0; justify-content: flex-start; }
.sidebar-logo-box.logobg-none .sidebar-logo { max-height: 44px; max-width: 200px; }
.sidebar-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--on-brand); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 18px; flex-shrink: 0; overflow: hidden; }
.sidebar-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.sidebar-title { color: var(--sidebar-text-strong); font-weight: 700; font-size: 15px; line-height: 1.25; }
.sidebar-sub { font-size: 11.5px; opacity: .8; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; opacity: .6; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--sidebar-text); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text-strong); }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-strong); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.sidebar-close { display: none; position: absolute; top: 16px; inset-inline-end: 12px; width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--sidebar-active-bg); color: var(--sidebar-text-strong); cursor: pointer; place-items: center; z-index: 2; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; opacity: .65; border-top: 1px solid var(--sidebar-border); }

.sidebar.style-light { --sidebar-bg: #ffffff; --sidebar-text: #334155; --sidebar-text-strong: var(--brand-text); --sidebar-active-bg: var(--brand-50); --sidebar-border: var(--border); }
.sidebar.style-light .sidebar-mark { background: var(--brand); color: var(--on-brand); }
.sidebar.style-dark { --sidebar-bg: #0f172a; --sidebar-text: rgba(255,255,255,.72); --sidebar-text-strong: #fff; --sidebar-active-bg: rgba(255,255,255,.08); --sidebar-border: rgba(255,255,255,.06); }
.sidebar.style-dark .nav a.active { box-shadow: inset 3px 0 0 var(--brand); }
[dir="rtl"] .sidebar.style-dark .nav a.active { box-shadow: inset -3px 0 0 var(--brand); }
.sidebar.style-brand { --sidebar-bg: var(--brand-800); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
/* Sidebar head: company logo on top (links to the home page), name below */
.sidebar-head { flex-direction: column; align-items: center; justify-content: flex-start; text-align: center; gap: 8px; padding-top: 10px; padding-bottom: 14px; }
.sidebar-head-text .sidebar-title { font-size: 14.5px; line-height: 1.5; white-space: normal; }
.sidebar-head-text .sidebar-sub { margin-top: 3px; font-size: 12.5px; line-height: 1.6; white-space: normal; opacity: .85; }
.sidebar-home { display: flex; justify-content: center; text-decoration: none; transition: transform .15s ease, opacity .15s ease; }
.sidebar-home:hover { text-decoration: none; transform: scale(1.04); opacity: .95; }
.sidebar-home .sidebar-logo-box { padding: 8px 14px; }
.sidebar-home .sidebar-logo { max-height: 56px; max-width: 190px; }
.sidebar-home .sidebar-logo-box.logobg-none { justify-content: center; }
.sidebar-home .sidebar-logo-box.logobg-none .sidebar-logo { max-height: 60px; max-width: 210px; }
.sidebar-head-text { min-width: 0; width: 100%; }
/* Keep the head and menu at full height: the sidebar scrolls instead of squeezing the head text over the menu */
.sidebar-head, .sidebar .nav, .sidebar-foot { flex-shrink: 0; }
.sidebar-head-text .sidebar-title { display: block; font-size: 16px; font-weight: 800; }
.sidebar-head-text .sidebar-sub { display: block; }
/* Menu: section titles clearly larger than their items */
.sidebar .nav-label { font-size: 15.5px; font-weight: 800; text-transform: none; letter-spacing: 0; opacity: 1; color: var(--sidebar-text-strong); padding: 18px 12px 8px; margin-top: 6px; border-top: 1px solid var(--sidebar-border); }
.sidebar .nav-label:first-child { margin-top: 0; border-top: 0; padding-top: 6px; }
.sidebar .nav a { font-size: 13.5px; padding-inline-start: 18px; }
.topbar-brand { display: none; align-items: center; flex-shrink: 0; text-decoration: none; }
.topbar-brand:hover { text-decoration: none; }
.tb-logo { height: 34px; padding: 3px 8px; border-radius: 9px; display: flex; align-items: center; background: #fff; border: 1px solid var(--border); }
.tb-logo.logobg-dark { background: #0f172a; border-color: #0f172a; }
.tb-logo img { max-height: 26px; max-width: 84px; object-fit: contain; display: block; }
.tb-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 16px; overflow: hidden; }
.tb-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.content { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

.org-switch { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; max-width: 320px; }
.org-switch:hover { border-color: var(--border-strong); }
.flag { font-size: 16px; line-height: 1; }
.lang-btn { min-width: 40px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 10px; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 260px; padding: 6px; z-index: 50; }
.dropdown-menu.start { inset-inline-end: auto; inset-inline-start: 0; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: start; color: var(--text); }
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item.active { background: var(--brand-50); color: var(--brand-text); font-weight: 600; }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--border-strong); text-decoration: none; background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-soft { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-text); }
.btn-soft:hover { background: var(--brand-100); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: #fecaca; }
.btn-destructive { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-destructive:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.kpi { padding: 18px 20px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-text); flex-shrink: 0; }
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: 13px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--danger); margin-inline-start: 3px; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); }
.field .ok { font-size: 12px; color: var(--success); }
.input, .select, .textarea { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.invalid { border-color: var(--danger); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-inline-start: 0; border-start-end-radius: 9px; border-end-end-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.section-title { font-size: 13px; font-weight: 700; color: var(--brand-text); text-transform: uppercase; letter-spacing: .02em; margin: 6px 0 2px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.daypick { display: flex; flex-wrap: wrap; gap: 6px; }
.daypick button { height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 13px; }
.daypick button.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 11px 16px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-text); border-bottom-color: var(--brand); }
.pills { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.pill { padding: 6px 14px; border-radius: 8px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.pill.active { background: var(--surface); color: var(--brand-text); box-shadow: var(--shadow); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.brand { background: var(--brand-50); color: var(--brand-text); border-color: var(--brand-100); }
.badge.green { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.badge.amber { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.badge.red { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.badge.gray { background: #f1f5f9; color: #475569; }
/* Insurance / tax switches on the employee form */
.st-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.st-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.st-row:last-child { border-bottom: 0; padding-bottom: 0; }
.st-row .st-rule { flex-basis: 100%; }
.st-date { display: flex; align-items: center; gap: 8px; }
.st-date .input { width: 170px; }
.tgl { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.tgl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tgl-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--border); transition: background .15s; flex-shrink: 0; }
.tgl-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: inset-inline-start .15s; }
.tgl input:checked + .tgl-track { background: var(--brand); }
.tgl input:checked + .tgl-track::after { inset-inline-start: 21px; }
.tgl input:focus-visible + .tgl-track { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 600px) { .st-date { width: 100%; } .st-date .input { flex: 1; width: auto; } }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Avatar ---------- */
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-100); color: var(--brand-text); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; overflow: hidden; font-size: 14px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

/* ---------- Profile header ---------- */
.profile-hero { position: relative; overflow: hidden; }
.profile-cover { height: 96px; background: linear-gradient(120deg, var(--brand) 0%, var(--brand-800) 100%); }
.profile-main { display: flex; gap: 18px; align-items: flex-end; padding: 0 22px 18px; margin-top: -44px; flex-wrap: wrap; }
.profile-main .info { flex: 1; min-width: 220px; padding-top: 50px; }
.photo-wrap { position: relative; }
.photo-edit { position: absolute; bottom: 2px; inset-inline-end: 2px; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; border: 2px solid #fff; cursor: pointer; }
.photo-edit svg { width: 14px; height: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0; }
.fact { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.fact .k { font-size: 12px; color: var(--muted); }
.fact .v { font-weight: 600; word-break: break-word; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 22px; }
.dl .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.dl .v { font-weight: 600; word-break: break-word; }
.dl .v.empty { color: var(--border-strong); font-weight: 400; padding: 0; text-align: start; }

/* ---------- Lists / timeline ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -21px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }

/* ---------- Bars ---------- */
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 40px; align-items: center; gap: 10px; padding: 6px 0; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.split { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.split span { display: block; height: 100%; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--brand-100) 0); display: grid; place-items: center; flex-shrink: 0; }
.ring > div { width: 70px; height: 70px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 18px; }

/* ---------- Empty, spinner, alerts ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; color: var(--border-strong); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert.info { background: var(--info-bg); border-color: #bfdbfe; color: #1e3a8a; }
.alert.warn { background: var(--warning-bg); border-color: #fde68a; color: #78350f; }
.alert.err { background: var(--danger-bg); border-color: #fecaca; color: #7f1d1d; }
.alert.ok { background: var(--success-bg); border-color: #a7f3d0; color: #064e3b; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 16px 16px; }

/* ---------- Toasts (in-app notifications) ---------- */
.toasts { position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); inset-inline: 0; margin-inline: auto; width: min(420px, calc(100vw - 24px)); z-index: 400; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { --tc: var(--brand); --tbg: var(--brand-50); pointer-events: auto; position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 14px 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-inline-start: 4px solid var(--tc); border-radius: 12px; box-shadow: 0 14px 34px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .06); animation: toastIn .28s cubic-bezier(.2, .9, .3, 1.15); }
[dir="rtl"] .toast { padding: 12px 14px 14px 12px; }
.toast.leaving { animation: toastOut .2s ease forwards; }
.toast.ok { --tc: #059669; --tbg: #d1fae5; }
.toast.err { --tc: #dc2626; --tbg: #fee2e2; }
.toast.warn { --tc: #d97706; --tbg: #fef3c7; }
.toast-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--tbg); color: var(--tc); flex-shrink: 0; }
.toast-text { flex: 1; min-width: 0; padding-top: 1px; }
.toast-title { font-weight: 700; font-size: 14px; line-height: 1.45; }
.toast-msg { font-size: 13.5px; color: var(--text-2); line-height: 1.55; word-break: break-word; }
.toast-text > .toast-msg:only-child { font-weight: 600; color: var(--text); padding-top: 5px; }
.toast-x { border: 0; background: none; color: var(--muted); width: 28px; height: 28px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.toast-x:hover { background: var(--surface-2); color: var(--text); }
.toast-bar { position: absolute; inset-inline-start: 0; bottom: 0; height: 3px; width: 100%; background: var(--tc); opacity: .35; transform-origin: left; animation: toastBar var(--dur, 3s) linear forwards; }
[dir="rtl"] .toast-bar { transform-origin: right; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Dialogs (confirm / alert / prompt) ---------- */
.dlg-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .16s ease; }
.dlg { --dc: var(--brand-text); --dbg: var(--brand-100); --dring: var(--brand-50); width: 100%; max-width: 440px; background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); overflow: hidden; animation: dlgIn .22s cubic-bezier(.2, .9, .3, 1.15); }
.dlg.tone-danger { --dc: #dc2626; --dbg: #fee2e2; --dring: #fef2f2; }
.dlg.tone-warn { --dc: #d97706; --dbg: #fef3c7; --dring: #fffbeb; }
.dlg.tone-success { --dc: #059669; --dbg: #d1fae5; --dring: #ecfdf5; }
.dlg-main { display: flex; gap: 16px; padding: 22px 22px 18px; }
.dlg-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--dbg); color: var(--dc); box-shadow: 0 0 0 6px var(--dring); margin-top: 2px; }
.dlg-content { flex: 1; min-width: 0; }
.dlg h2 { font-size: 17px; line-height: 1.45; }
.dlg p { margin-top: 6px; color: var(--text-2); font-size: 14px; line-height: 1.75; }
.dlg-field { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; text-align: start; }
.dlg-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.dlg-label .req { color: var(--danger); margin-inline-start: 3px; }
.dlg-field .err { font-size: 12px; color: var(--danger); }
.dlg-field .input.invalid, .dlg-field .textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px #fee2e2; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--border); }
.dlg-actions .btn { min-width: 96px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dlgIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-back { animation: fadeIn .16s ease; }
.modal { animation: dlgIn .22s cubic-bezier(.2, .9, .3, 1.1); }

/* ---------- Country picker ---------- */
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.choice { border: 2px solid var(--border); border-radius: 14px; padding: 20px; cursor: pointer; background: var(--surface); text-align: start; transition: border-color .15s, box-shadow .15s; }
.choice:hover { border-color: var(--border-strong); }
.choice.on { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-100); }
.choice .big-flag { font-size: 36px; line-height: 1; }
.choice ul { margin: 10px 0 0; padding-inline-start: 18px; color: var(--muted); font-size: 13px; }
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); }
[dir="rtl"] .step { padding: 6px 6px 6px 12px; }
.step .n { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; }
.step.on { color: var(--brand-text); border-color: var(--brand-200); }
.step.on .n, .step.done .n { background: var(--brand); color: var(--on-brand); }

/* ---------- Identity settings ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; position: relative; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.color-input { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); cursor: pointer; }
.logo-drop { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 18px; display: flex; align-items: center; gap: 16px; background: var(--surface-2); }
.logo-preview { width: 150px; height: 72px; border-radius: 10px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.logo-preview.dark { background: #0f172a; }
.logo-preview.square { width: 72px; }
.logo-preview img { max-width: 90%; max-height: 80%; object-fit: contain; }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%), linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e2e8f0 75%), linear-gradient(-45deg, transparent 75%, #e2e8f0 75%); background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0; }
.bg-opts { display: flex; flex-wrap: wrap; gap: 10px; }
.bg-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 6px 8px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text-2); font-size: 12.5px; font-weight: 600; transition: border-color .15s, box-shadow .15s; }
.bg-opt:hover { border-color: var(--border-strong); }
.bg-opt.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); color: var(--text); }
.bg-opt .logo-preview { width: 116px; height: 58px; }
.bg-opt .tile-split { width: 116px; height: 58px; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; }
.bg-opt .tile-split > div { display: grid; place-items: center; overflow: hidden; }
.bg-opt .tile-split img { max-width: 92%; max-height: 70%; object-fit: contain; }
.bg-opt .lbl { display: inline-flex; align-items: center; gap: 4px; }
.bg-opt .lbl svg { width: 14px; height: 14px; color: var(--brand); }
.mock { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: 150px 1fr; height: 260px; font-size: 11px; background: var(--bg); }
.mock-side { padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.mock-side .m-item { padding: 6px 8px; border-radius: 6px; }
.mock-main { display: flex; flex-direction: column; }
.mock-top { height: 38px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 12px; gap: 8px; }
.mock-body { padding: 12px; display: grid; gap: 10px; }
.mock-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.mock-btn { display: inline-block; padding: 5px 12px; border-radius: 6px; font-weight: 600; }

/* ---------- Org chart ---------- */
.orgchart { overflow: auto; padding: 10px 4px 30px; }
.oc-tree, .oc-tree ul { list-style: none; margin: 0; padding: 0; }
.oc-tree ul { padding-inline-start: 34px; position: relative; }
.oc-tree li { position: relative; padding: 6px 0; }
.oc-tree ul > li::before { content: ''; position: absolute; inset-inline-start: -20px; top: 0; bottom: 0; border-inline-start: 2px solid var(--border); }
.oc-tree ul > li:last-child::before { bottom: auto; height: 34px; }
.oc-tree ul > li::after { content: ''; position: absolute; inset-inline-start: -20px; top: 34px; width: 18px; border-top: 2px solid var(--border); }
.oc-node { display: inline-flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px 8px 10px; box-shadow: var(--shadow); min-width: 240px; cursor: pointer; border-inline-start: 4px solid var(--brand); }
.oc-node:hover { border-color: var(--brand-200); }
.oc-toggle { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; display: grid; place-items: center; font-size: 13px; line-height: 1; }

/* ---------- Employee ID card ---------- */
.idcard { width: 340px; height: 214px; border-radius: 16px; overflow: hidden; position: relative; color: #fff; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-800) 100%); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.idcard::after { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.07); inset-inline-end: -90px; top: -110px; }
.idcard-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; position: relative; z-index: 1; }
.idcard-logo { background: #fff; border-radius: 8px; padding: 4px 8px; height: 34px; display: flex; align-items: center; }
.idcard-logo.logobg-none { padding-inline: 0; }
.idcard-logo img { max-height: 26px; max-width: 120px; object-fit: contain; }
.idcard-body { display: flex; gap: 14px; padding: 8px 16px; align-items: center; position: relative; z-index: 1; flex: 1; }
.idcard-photo { width: 78px; height: 92px; border-radius: 10px; background: rgba(255,255,255,.2); overflow: hidden; display: grid; place-items: center; font-size: 30px; font-weight: 700; border: 2px solid rgba(255,255,255,.6); flex-shrink: 0; }
.idcard-photo img { width: 100%; height: 100%; object-fit: cover; }
.idcard-foot { background: rgba(0,0,0,.18); padding: 7px 16px; display: flex; justify-content: space-between; font-size: 11.5px; position: relative; z-index: 1; }

/* ---------- Payroll sheet ---------- */
.sheet-wrap { max-height: 72vh; overflow: auto; }
.sheet { font-size: 13px; }
.sheet th, .sheet td { padding: 8px 10px; white-space: nowrap; }
.sheet thead th { position: sticky; top: 0; z-index: 2; }
.sheet th.in { background: var(--brand-50); color: var(--brand-text); }
.sheet .tot { background: var(--surface-2); font-weight: 700; }
.sheet .sticky { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; min-width: 190px; box-shadow: inset -1px 0 0 var(--border); }
[dir="rtl"] .sheet .sticky { box-shadow: inset 1px 0 0 var(--border); }
.sheet thead th.sticky { background: var(--surface-2); z-index: 3; }
.sheet tfoot td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border-strong); position: sticky; bottom: 0; }
.cell-input { width: 88px; height: 30px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; font: inherit; font-variant-numeric: tabular-nums; text-align: end; }
.cell-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; text-align: start; color: inherit; font: inherit; }
.link-btn:hover .strong { color: var(--brand-text); text-decoration: underline; }
.kpi-value.sm { font-size: 20px; }

/* ---------- Payslip ---------- */
.payslip { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 26px; color: #0f172a; }
.slip-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 3px solid var(--brand); padding-bottom: 14px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.slip-head img { max-height: 54px; max-width: 200px; object-fit: contain; }
.slip-title { font-size: 20px; font-weight: 700; color: var(--brand-text); }
.slip-info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.slip-info > div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 16px 0; }
.slip-h { font-weight: 700; color: var(--brand-text); padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.slip-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.slip-total { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--border-strong); margin-top: 4px; }
.slip-net { display: flex; justify-content: space-between; align-items: center; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 12px; padding: 14px 18px; font-size: 18px; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.slip-page { margin-bottom: 22px; }
@media print { .slip-page { break-after: page; margin: 0; } .payslip { border: 0; padding: 0; } }
@media (max-width: 900px) { .slip-info { grid-template-columns: 1fr 1fr; } .slip-cols { grid-template-columns: 1fr; } }

/* ---------- Login / gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, var(--brand-100), transparent 45%), var(--bg); }
.gate-card { width: 100%; max-width: 440px; }

/* ---------- Print ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .tabs, .btn { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  .print-only { display: block; }
  #overlays { display: none !important; }
  .idcard { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none; }
  .profile-cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--brand); padding-bottom: 10px; margin-bottom: 16px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-head img { max-height: 54px; max-width: 200px; }

/* ---------- Responsive ---------- */
html, body { overflow-x: hidden; }
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 25; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet & phone: off-canvas menu, compact top bar */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(86vw, 304px); height: 100vh; height: 100dvh; transform: translateX(-102%); visibility: hidden; transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility .26s; z-index: 60; overscroll-behavior: contain; }
  [dir="rtl"] .sidebar { transform: translateX(102%); }
  .sidebar.open { transform: none !important; visibility: visible; box-shadow: 0 0 48px rgba(15, 23, 42, .35); }
  .sidebar-close { display: grid; }
  .sidebar-head { padding-inline-end: 58px; }
  .nav a { padding: 11px 12px; }
  .app > .scrim { z-index: 55; background: rgba(15, 23, 42, .45); animation: fadeIn .2s ease; }
  .topbar { height: 58px; padding: 0 10px; gap: 6px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar-brand { display: flex; }
  .topbar > .dropdown:not(:last-child) { min-width: 0; flex: 0 1 auto; }
  .org-switch { max-width: 100%; min-width: 0; padding: 6px 9px; gap: 7px; }
  .user-chip { padding: 4px; gap: 4px; }
  .user-chip > svg:last-child { display: none; }
  .hide-sm { display: none !important; }
  .lang-btn { display: none !important; }
  .content { padding: 18px 16px 76px; }
  .mock { grid-template-columns: 110px 1fr; }
  .dropdown-menu { position: fixed; top: 62px; inset-inline: 10px; min-width: 0; max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); overflow-y: auto; }
  .dropdown-menu.start { inset-inline: 10px; }
  .choice-grid { grid-template-columns: 1fr; }
  /* sticky preview columns make no sense once columns stack */
  .grid-2 > .col[style*="sticky"] { position: static !important; }
}

/* Phone */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
  .content { padding: 14px 12px 80px; }
  .grid { gap: 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-4:has(> .kpi), .grid-3:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gap-lg { gap: 14px; }
  .mb { margin-bottom: 12px; }
  .mt { margin-top: 12px; }

  /* Page header: title on top, actions as a full-width button row */
  .page-head { margin-bottom: 14px; gap: 12px; }
  .page-head > div:first-child { min-width: 0; }
  .page-head p { font-size: 13.5px; }
  .page-actions { width: 100%; gap: 8px; }
  .page-actions > .btn, .page-actions > label.btn, .page-actions > .dropdown, .page-actions > div { flex: 1 1 auto; }
  .page-actions > .btn-icon { flex: 0 0 auto; }

  /* Touch-friendly controls (16px text stops iOS zooming into fields) */
  .btn { height: 42px; padding: 0 14px; }
  .btn-sm { height: 36px; padding: 0 12px; }
  .btn-icon { width: 42px; padding: 0; }
  .btn-icon.btn-sm { width: 36px; }
  .input, .select, .textarea { font-size: 16px; }
  .input, .select { height: 44px; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; gap: 12px; }
  .span-2 { grid-column: auto; }
  .check input { width: 20px; height: 20px; }
  .tab { padding: 12px 14px; }
  .tabs { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 26px); mask-image: linear-gradient(to left, transparent 0, #000 26px); }
  [dir="rtl"] .tabs { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 26px); mask-image: linear-gradient(to right, transparent 0, #000 26px); }
  .pills { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .pill { padding: 7px 12px; white-space: nowrap; }
  .daypick button { height: 38px; }

  /* Cards */
  .card { border-radius: 14px; }
  .card-head { padding: 12px 14px; flex-wrap: wrap; }
  .card-body, .card-pad { padding: 14px; }
  .card-foot { padding: 12px 14px; flex-wrap: wrap; }
  .card-foot > .btn { flex: 1 1 auto; }
  .list-item { padding: 12px 14px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
  .kpi-icon svg { width: 18px; height: 18px; }
  .kpi-value { font-size: 20px; }
  .kpi-value.sm { font-size: 16px; }
  .kpi-label { font-size: 12px; line-height: 1.45; }
  .alert { font-size: 13px; padding: 11px 12px; }
  .grid-4:has(> .kpi) .kpi-value { font-size: 18px; }
  .grid-4:has(> .kpi) .kpi-value.sm { font-size: 15.5px; }
  .stat-strip { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px !important; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
  .stat-strip > span { display: flex; flex-direction: column; gap: 1px; line-height: 1.4; }
  .stat-strip b { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }

  /* Filter toolbars: search full width, filters two per row */
  .toolbar { gap: 8px; }
  .toolbar > * { flex: 1 1 calc(50% - 4px); width: auto !important; min-width: 0 !important; }
  .toolbar > .input-group { flex-basis: 100%; }
  .toolbar > .grow:empty { display: none; }
  .toolbar > .btn { flex-basis: 100%; }
  .allow-row { gap: 8px; }
  .allow-row > div:first-child { width: auto !important; flex: 1 1 56%; min-width: 0; }
  .allow-row > .grow { flex: 1 1 40%; }

  /* Lists in tables become stacked cards */
  .table-wrap:not(.sheet-wrap) { overflow: visible; }
  table.table:not(.sheet), table.table:not(.sheet) > tbody, table.table:not(.sheet) > tfoot,
  table.table:not(.sheet) > tbody > tr, table.table:not(.sheet) > tfoot > tr, table.table:not(.sheet) > tbody > tr > td, table.table:not(.sheet) > tfoot > tr > td { display: block; width: 100%; }
  table.table:not(.sheet) > thead { display: none; }
  table.table:not(.sheet) > tbody > tr, table.table:not(.sheet) > tfoot > tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.table:not(.sheet) > tbody > tr:last-child { border-bottom: 0; }
  table.table:not(.sheet) > tbody > tr > td, table.table:not(.sheet) > tfoot > tr > td { border: 0; padding: 4px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: end; min-height: 30px; background: none !important; }
  table.table:not(.sheet) td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: start; flex-shrink: 0; max-width: 48%; }
  table.table:not(.sheet) > tbody > tr > td:first-child { display: block; text-align: start; padding: 0 0 9px; margin-bottom: 5px; border-bottom: 1px dashed var(--border); }
  table.table:not(.sheet) > tbody > tr > td:first-child:last-child { border-bottom: 0; margin: 0; padding: 0; }
  table.table:not(.sheet) td:first-child::before, table.table:not(.sheet) td[data-label=""]::before { display: none; }
  table.table:not(.sheet) td[data-label=""] { justify-content: flex-end; }
  table.table:not(.sheet) td:empty { display: none; }
  [dir="rtl"] table.table:not(.sheet) > tbody > tr > td.ltr:not(:first-child) { flex-direction: row-reverse; }
  table.table:not(.sheet) td.hide-sm { display: none !important; }
  table.table:not(.sheet) td > .row { justify-content: flex-end; flex-wrap: wrap; }
  table.table:not(.sheet) > tbody > tr > td:first-child > .row { justify-content: flex-start; flex-wrap: nowrap; }
  /* icon-only action cells sit in the card's corner instead of taking a row */
  table.table:not(.sheet) > tbody > tr { position: relative; }
  table.table:not(.sheet) > tbody > tr > td[data-label=""]:last-child:not(:first-child):not(:has(.btn:not(.btn-icon))) { position: absolute; top: 8px; right: 10px; width: auto; padding: 0; min-height: 0; }
  [dir="rtl"] table.table:not(.sheet) > tbody > tr > td[data-label=""]:last-child:not(:first-child):not(:has(.btn:not(.btn-icon))) { right: auto; left: 10px; }
  table.table:not(.sheet) > tbody > tr:has(> td[data-label=""]:last-child:not(:first-child):not(:has(.btn:not(.btn-icon)))) > td:first-child { padding-right: 88px; }
  [dir="rtl"] table.table:not(.sheet) > tbody > tr:has(> td[data-label=""]:last-child:not(:first-child):not(:has(.btn:not(.btn-icon)))) > td:first-child { padding-right: 0; padding-left: 88px; }
  [dir="rtl"] table.table:not(.sheet) > tbody > tr > td.ltr:first-child { text-align: right !important; }
  table.table:not(.sheet) tr.click { cursor: pointer; }
  table.table:not(.sheet) tr.click:active { background: var(--surface-2); }
  table.table:not(.sheet) .ellipsis { white-space: normal; }

  /* Payroll sheet keeps its spreadsheet layout with a narrower frozen name column */
  .sheet-wrap { max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); }
  .sheet { font-size: 12.5px; }
  .sheet th, .sheet td { padding: 7px 8px; }
  .sheet .sticky { min-width: 118px; max-width: 132px; }
  .sheet .sticky .ellipsis { max-width: 112px !important; }
  .cell-input { width: 78px; height: 34px; font-size: 16px; }

  /* Modals: centred sheet that never hides behind the screen edges */
  .modal-back { align-items: center; padding: 14px 10px 64px; }
  .modal, .modal.wide { max-width: none; max-height: calc(100vh - 78px); max-height: calc(100dvh - 78px); display: flex; flex-direction: column; border-radius: 16px; }
  .modal-head { padding: 14px 16px; flex-shrink: 0; }
  .modal-body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; flex-shrink: 0; }
  .modal-foot > .btn { flex: 1 1 0; }
  .dlg-back { padding: 14px 12px 64px; }
  .dlg-main { flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 24px 18px 18px; }
  .dlg-icon { width: 48px; height: 48px; }
  .dlg-content { width: 100%; }
  .dlg-actions { padding: 12px 16px; }
  .dlg-actions .btn { flex: 1 1 0; min-width: 0; height: 44px; }
  .toasts { top: calc(10px + env(safe-area-inset-top, 0px)); width: calc(100vw - 20px); }

  /* Employee profile */
  .profile-cover { height: 84px; }
  .profile-main { flex-direction: column; align-items: center; text-align: center; padding: 0 16px 16px; margin-top: -48px; gap: 10px; }
  .profile-main .info { padding-top: 0; min-width: 0; width: 100%; }
  .profile-main .info > .row { justify-content: center; gap: 8px; }
  .profile-main .info .ltr { text-align: center !important; }
  .profile-main > .row { justify-content: center; width: 100%; }
  .profile-main > .row > .btn:not(.btn-icon) { flex: 1 1 auto; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact { padding: 10px 14px; }
  .fact:nth-child(odd):last-child { grid-column: 1 / -1; }
  .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 14px; }
  .dl .v { font-size: 14px; }

  /* Wizard steps: compact chips, only the current step keeps its label */
  .steps { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .step { flex-shrink: 0; }
  .step:not(.on) { font-size: 0; gap: 0; padding: 4px !important; }
  .step:not(.on) .n { font-size: 12px; }

  /* Identity & logos */
  .logo-drop { flex-wrap: wrap; padding: 14px; }
  .bg-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .bg-opt { padding: 6px 4px 8px; font-size: 12px; }
  .bg-opt .logo-preview, .bg-opt .tile-split { width: 100%; height: 50px; }
  .mock { grid-template-columns: 96px 1fr; height: 230px; font-size: 10px; }
  .swatch { width: 36px; height: 36px; }

  /* Org chart / ID card / bars */
  .oc-node { min-width: 200px; }
  .orgchart { margin-inline: -4px; }
  .idcard { width: min(340px, 100%); }
  .bar-row { grid-template-columns: minmax(80px, 120px) 1fr 34px; }

  /* Payslip */
  .payslip { padding: 16px; border-radius: 12px; }
  .slip-head { flex-wrap: wrap; }
  .slip-info { grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .slip-net { font-size: 16px; padding: 12px 14px; }
}

@media (max-width: 380px) {
  .topbar-brand { display: none; }
  .grid-4:has(> .kpi) .kpi-icon { display: none; }
  .dl { grid-template-columns: 1fr; }
}

/* Coarse pointers (touch screens of any size) get roomier hit areas */
@media (pointer: coarse) {
  .btn-icon.btn-sm { min-width: 36px; height: 36px; }
  .dropdown-item { padding: 12px 10px; }
}