/*
 * NAMA'AK identity for the HR system, matching نمائك المالي: navy #0B2D52 for structure, teal #00A59B for
 * growth and links, gold #F7A61C for calls to action and alerts, midnight #06182C for dark surfaces.
 * Loaded last, so it re-points the design tokens the rest of the stylesheets already use.
 */
:root, body.theme-dark {
  --nm-navy: #0B2D52;
  --nm-teal: #00A59B;
  --nm-teal-deep: #078a83;
  --nm-gold: #F7A61C;
  --nm-midnight: #06182C;

  --bg-app: var(--nm-midnight);
  --bg-surface: #0a2036;
  --bg-card: #0d2740;
  --bg-card-hover: #12304d;
  --bg-card-active: #163a5c;
  --bg-input: #081c30;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text-primary: #eef4f9;
  --text-secondary: #9fb4c8;
  --text-muted: #7890a8;

  --accent-primary: var(--nm-teal);
  --accent-primary-hover: #12bdb2;
  --accent-primary-glow: rgba(0, 165, 155, 0.25);
  --accent-amber: var(--nm-gold);
  --accent-cyan: #2b9be0;

  --nm-glass: rgba(11, 45, 82, 0.55);
  --nm-glass-line: rgba(255, 255, 255, 0.10);
  --nm-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-arabic: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
  --font-latin: 'Inter', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

body.theme-light {
  --bg-app: #f3f7fa;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f9fc;
  --bg-card-active: #edf4f9;
  --bg-input: #f8fbfd;
  --border-subtle: rgba(11, 45, 82, 0.10);
  --border-default: rgba(11, 45, 82, 0.18);
  --border-strong: rgba(11, 45, 82, 0.30);
  --text-primary: var(--nm-navy);
  --text-secondary: #4b6178;
  --text-muted: #6d8298;
  --nm-glass: rgba(255, 255, 255, 0.62);
  --nm-glass-line: rgba(11, 45, 82, 0.10);
  --nm-shadow: 0 4px 18px rgba(11, 45, 82, 0.06);
}

html, body { font-family: var(--font-arabic); }
body.theme-light {
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(0, 165, 155, .08), transparent 60%),
    radial-gradient(900px 400px at 0% 0%, rgba(11, 45, 82, .06), transparent 60%),
    var(--bg-app);
  background-attachment: fixed;
}
body.theme-light .app-layout { background: transparent; }
body.theme-light ::-webkit-scrollbar-thumb { background: rgba(11, 45, 82, .18); }
.spinner { border-color: rgba(0, 165, 155, .15); border-top-color: var(--nm-teal); }

/* Icons drawn from one outline set, sized by the text around them. */
.nm-icon { width: 1.15em; height: 1.15em; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Sidebar: the navy structure of the brand, in both modes. */
.app-sidebar { background: var(--nm-navy); border-color: transparent; }
body.theme-dark .app-sidebar { background: #071d33; }
.sidebar-header { border-color: rgba(255, 255, 255, .08); padding: 0 18px; }
.sidebar-header img { height: 34px; width: auto; }
.nav-group-title { color: rgba(255, 255, 255, .5); text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.nav-link { color: rgba(255, 255, 255, .84); border-radius: 12px; }
.nav-link .nav-icon { color: rgba(255, 255, 255, .62); font-size: 16px; }
.nav-link:hover { background: rgba(255, 255, 255, .08); border-color: transparent; color: #fff; }
.nav-link.active {
  background: linear-gradient(135deg, rgba(0, 165, 155, .95), rgba(0, 165, 155, .70));
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(0, 165, 155, .28);
}
.nav-link.active .nav-icon { color: #fff; }
.nav-badge { background: var(--nm-gold); color: var(--nm-midnight); border: 0; font-weight: 700; }
.nav-badge.nm-soon { background: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .8); }
.sidebar-footer { background: rgba(0, 0, 0, .12); border-color: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .7); font-size: 11.5px; }
.sidebar-footer img { height: 22px; opacity: .85; }

/* Top bar: frosted glass over the page. */
.app-header {
  background: var(--nm-glass);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--nm-glass-line);
}
.header-btn, .user-profile-badge { background: var(--nm-glass); border-color: var(--nm-glass-line); border-radius: 12px; }
.header-btn .nm-icon { width: 17px; height: 17px; }
.user-avatar { background: linear-gradient(135deg, var(--nm-teal), var(--nm-navy)); }
.user-info .user-role { color: var(--nm-teal); }
.breadcrumb-active { color: var(--text-primary); }

/* The customer's company in the top corner, as in the financial system. */
.nm-company { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 12px 4px 6px; border-radius: 14px; background: var(--nm-glass); border: 1px solid var(--nm-glass-line); }
.nm-company img { height: 30px; max-width: 90px; object-fit: contain; }
.nm-initials { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--nm-navy), var(--nm-teal)); }
.nm-company-name { font-size: 12.5px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; display: block; }
.nm-company-sub { font-size: 10.5px; color: var(--text-muted); display: block; }

/* Page title row. */
.nm-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.nm-page-head h2 { font-size: 22px; font-weight: 700; }
body.theme-light .nm-page-head h2 { color: var(--nm-navy); }
.nm-page-head p { color: var(--text-secondary); font-size: 13.5px; margin-top: 4px; }
.nm-page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Section tabs: glass buttons with icons; the current one is teal. */
.nm-tabs { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; }
.nm-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 14px;
  background: var(--nm-glass); border: 1px solid var(--nm-glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary); font-weight: 500; font-size: 13px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(11, 45, 82, .06); transition: transform .15s, box-shadow .15s, background .15s;
}
.nm-tab .nm-icon { color: var(--nm-teal); }
.nm-tab:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(11, 45, 82, .12); color: var(--text-primary); }
.nm-tab.active { background: linear-gradient(135deg, var(--nm-teal), var(--nm-teal-deep)); border-color: transparent; color: #fff; box-shadow: 0 8px 22px rgba(0, 165, 155, .32); }
.nm-tab.active .nm-icon { color: #fff; }
.nm-tab .nm-count { background: var(--nm-gold); color: var(--nm-midnight); border-radius: 999px; font-size: 10.5px; font-weight: 700; padding: 0 7px; line-height: 18px; }

/* The old in-page tabs follow the same look. */
.tabs-header { border: 0; gap: 9px; flex-wrap: wrap; margin-bottom: 18px; }
.tab-btn { border-radius: 14px; border: 1px solid var(--nm-glass-line); background: var(--nm-glass); color: var(--text-primary); padding: 8px 14px; }
.tab-btn.active { background: linear-gradient(135deg, var(--nm-teal), var(--nm-teal-deep)); color: #fff; border-color: transparent; }

/* Cards and tables: soft rounded surfaces. */
.card, .table-container, .kpi-card { border-radius: 18px; border-color: var(--border-subtle); box-shadow: var(--nm-shadow); }
.kpi-card::before { background: linear-gradient(180deg, var(--kpi-accent, var(--nm-teal)), var(--nm-navy)); }
.kpi-title .nm-icon { color: var(--kpi-accent, var(--nm-teal)); width: 20px; height: 20px; }
.kpi-value { font-weight: 700; }
.card-title .nm-icon { color: var(--nm-teal); }
.data-table th { text-transform: none; letter-spacing: 0; font-weight: 600; }
body.theme-light .data-table th { color: var(--nm-navy); background: #f5f9fc; }
.data-table td.num, .num { font-family: var(--font-latin); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
/* Wide tables scroll inside their card instead of widening the page. */
.app-main, .app-content { min-width: 0; }
.table-container { max-width: 100%; }

/* Buttons: teal for the main action, gold for creating something new. */
.btn { border-radius: 12px; }
.btn-primary { background: linear-gradient(135deg, var(--nm-teal), var(--nm-teal-deep)); box-shadow: 0 4px 12px rgba(0, 165, 155, .28); }
.btn-primary:hover { background: linear-gradient(135deg, #12bdb2, var(--nm-teal)); box-shadow: 0 6px 16px rgba(0, 165, 155, .38); }
.btn-create { background: var(--nm-gold); color: var(--nm-midnight); box-shadow: 0 6px 16px rgba(247, 166, 28, .30); }
.btn-create:hover { background: #ffb53a; color: var(--nm-midnight); transform: translateY(-1px); }
.btn .nm-icon { width: 16px; height: 16px; }
.btn-ghost { background: transparent; border: 0; color: var(--text-secondary); padding: 6px 8px; }
.btn-ghost:hover { color: var(--nm-teal); }

.form-input, .form-select, .form-textarea { border-radius: 12px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--nm-teal); box-shadow: 0 0 0 3px rgba(0, 165, 155, .18); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-section-title { font-size: 12.5px; font-weight: 700; color: var(--nm-teal); margin: 6px 0 10px; }

.modal-dialog { border-radius: 20px; }
.modal-body .modal-footer { background: transparent; }
.data-table .nm-person-sub { white-space: nowrap; }
.modal-overlay { background: rgba(6, 24, 44, .55); backdrop-filter: blur(3px); }

/* Status badges by meaning rather than by source. */
.badge-pending, .badge-in_review, .badge-on_leave { background: rgba(247, 166, 28, .14); color: #c98100; border: 1px solid rgba(247, 166, 28, .35); }
body.theme-dark .badge-pending, body.theme-dark .badge-in_review, body.theme-dark .badge-on_leave { color: var(--nm-gold); }
.badge-approved, .badge-active, .badge-open, .badge-completed { background: rgba(0, 165, 155, .13); color: var(--nm-teal); border: 1px solid rgba(0, 165, 155, .32); }
.badge-rejected, .badge-cancelled, .badge-terminated, .badge-failed { background: rgba(229, 86, 110, .12); color: #d9465f; border: 1px solid rgba(229, 86, 110, .3); }
.badge-locked, .badge-closed { background: rgba(11, 45, 82, .12); color: #5b7da3; border: 1px solid rgba(11, 45, 82, .25); }
body.theme-dark .badge-locked, body.theme-dark .badge-closed { color: #9fc0e3; background: rgba(159, 192, 227, .12); }
.badge-draft, .badge-calculated, .badge-suspended, .badge-inactive { background: rgba(120, 144, 168, .14); color: var(--text-secondary); border: 1px solid rgba(120, 144, 168, .3); }

/* Dashboard hero and the quick action cards, as in the financial system. */
.nm-hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 26px 28px; margin-bottom: 20px; color: #fff;
  background: linear-gradient(120deg, var(--nm-navy) 0%, #0e3d6b 55%, var(--nm-teal) 140%);
  box-shadow: 0 14px 34px rgba(11, 45, 82, .25);
}
.nm-hero h2 { color: #fff; font-size: 22px; font-weight: 700; }
.nm-hero p { color: rgba(255, 255, 255, .82); margin-top: 6px; font-size: 13.5px; max-width: 640px; }
.nm-hero-mark { position: absolute; inset-inline-end: 22px; top: 50%; transform: translateY(-50%); height: 120px; opacity: .16; filter: brightness(0) invert(1); pointer-events: none; }
.nm-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.nm-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; border-radius: 18px;
  background: var(--nm-glass); border: 1px solid var(--nm-glass-line); backdrop-filter: blur(10px);
  color: var(--text-primary); font-weight: 600; font-size: 13px; box-shadow: var(--nm-shadow); transition: transform .15s, box-shadow .15s;
}
.nm-action:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(11, 45, 82, .14); color: var(--text-primary); }
.nm-action-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.nm-action-icon .nm-icon { width: 20px; height: 20px; }
.nm-c-teal { background: linear-gradient(135deg, var(--nm-teal), var(--nm-teal-deep)); }
.nm-c-navy { background: linear-gradient(135deg, #12406f, var(--nm-navy)); }
.nm-c-gold { background: linear-gradient(135deg, #ffbf4d, var(--nm-gold)); color: var(--nm-midnight); }
.nm-c-rose { background: linear-gradient(135deg, #ef7088, #d9465f); }
.nm-c-sky { background: linear-gradient(135deg, #56b4ee, #2b9be0); }
.nm-c-violet { background: linear-gradient(135deg, #8f7cf0, #6a55d8); }

.nm-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }
.nm-list { display: flex; flex-direction: column; }
.nm-list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border-subtle); }
.nm-list-row:last-child { border-bottom: 0; }
.nm-list-main { min-width: 0; }
.nm-list-title { font-weight: 600; }
.nm-list-sub { font-size: 11.5px; color: var(--text-muted); }
.nm-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: rgba(247, 166, 28, .10); border: 1px solid rgba(247, 166, 28, .32); margin-bottom: 16px; font-size: 13px; }
.nm-alert .nm-icon { color: var(--nm-gold); width: 20px; height: 20px; margin-top: 1px; }
.nm-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: rgba(0, 165, 155, .08); border: 1px solid rgba(0, 165, 155, .25); font-size: 13px; color: var(--text-secondary); }
.nm-note .nm-icon { color: var(--nm-teal); width: 20px; height: 20px; margin-top: 1px; }
.empty-state .nm-icon { width: 38px; height: 38px; color: var(--nm-teal); opacity: .7; margin-bottom: 6px; }

.nm-person { display: flex; align-items: center; gap: 10px; }
.nm-person-avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--nm-navy), var(--nm-teal)); flex-shrink: 0; }
.nm-person-name { font-weight: 600; }
.nm-person-sub { font-size: 11px; color: var(--text-muted); }

.nm-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 14px 16px; margin-bottom: 16px; }
.nm-toolbar .form-input, .nm-toolbar .form-select { margin: 0; }
.nm-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Sign-in page: navy background with the full mark, as in the financial system. */
.login-wrapper { background: radial-gradient(900px 500px at 80% 0%, rgba(0, 165, 155, .28), transparent 60%), linear-gradient(160deg, var(--nm-navy), var(--nm-midnight)); }
.login-card { border-radius: 24px; }
.nm-login-logo { display: block; height: 76px; margin: 0 auto 10px; }
.nm-tagline { text-align: center; color: var(--nm-teal); font-weight: 600; font-size: 13px; margin-bottom: 4px; }

/* Payslip print: only the slip, on white. */
.nm-payslip { background: #fff; color: #0B2D52; padding: 28px; border-radius: 16px; font-size: 13px; }
.nm-payslip table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.nm-payslip td, .nm-payslip th { padding: 7px 8px; border-bottom: 1px solid #e3ebf2; text-align: start; }
.nm-payslip .total td { font-weight: 700; border-top: 2px solid #0B2D52; }
.nm-payslip-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #00A59B; padding-bottom: 12px; margin-bottom: 12px; }
.nm-payslip-head img { height: 40px; }
@media print {
  body * { visibility: hidden !important; }
  .nm-print-area, .nm-print-area * { visibility: visible !important; }
  .nm-print-area { position: absolute; inset: 0; padding: 0; }
  .modal-overlay { background: #fff !important; backdrop-filter: none !important; }
  .modal-dialog { box-shadow: none !important; border: 0 !important; max-width: none !important; width: 100% !important; }
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .nm-grid-2 { grid-template-columns: 1fr; }
  .nm-company-name { max-width: 110px; }
  .header-btn span.nm-label, .user-info { display: none; }
  .nm-hero { padding: 20px; }
  .nm-hero-mark { height: 80px; }
  .app-content { padding: 16px; }
}
