/*
 * GALACTIC ERP — Design System
 * Pure CSS. No JavaScript is required by anything in this file.
 * Brand palette sourced from the approved GALACTIC logo/brand sheet.
 */

:root {
  /* ---- Brand palette (from logo) ---- */
  --g-purple:  #7A3097;
  --g-magenta: #D93F9E;
  --g-blue:    #3E5AC9;
  --g-teal:    #34AFAC;
  --g-green:   #5FB65B;
  --g-yellow:  #F4D227;
  --g-red:     #E2495F;
  --g-navy:    #10142B;

  /* ---- Semantic roles ---- */
  --primary:        var(--g-purple);
  --primary-strong: #5F2179;
  --primary-soft:   #F2E7F6;
  --secondary:        var(--g-blue);
  --secondary-strong: #2D3F9C;
  --secondary-soft:   #E7EBFA;
  --success:      var(--g-green);
  --success-soft: #E7F5E6;
  --warning:      var(--g-yellow);
  --warning-soft: #FDF6DA;
  --danger:       var(--g-red);
  --danger-soft:  #FBE7EA;
  --info:         var(--g-teal);
  --info-soft:    #E4F5F4;

  /* ---- Neutrals (cool, navy-tinted) ---- */
  --ink-900: #10142B;
  --ink-800: #1B1F3B;
  --ink-700: #33365A;
  --ink-600: #4B4E72;
  --ink-500: #666A8C;
  --ink-400: #8B8EAB;
  --ink-300: #B7B9CE;
  --ink-200: #DADCE9;
  --ink-100: #EEEFF6;
  --ink-50:  #F7F7FB;
  --white:   #FFFFFF;

  --bg:            var(--ink-50);
  --surface:       var(--white);
  --surface-muted: var(--ink-100);
  --border:        var(--ink-200);
  --border-strong: var(--ink-300);
  --text:          var(--ink-900);
  --text-muted:    var(--ink-600);
  --text-faint:    var(--ink-400);

  /* ---- Typography ---- */
  --font-body: "Segoe UI", -apple-system, BlinkMacSystemFont, "Tahoma", "Cairo", "Noto Kufi Arabic", sans-serif;
  --font-display: "Segoe UI", -apple-system, BlinkMacSystemFont, "Tahoma", "Cairo", "Noto Kufi Arabic", sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;
  --fs-3xl: 2.25rem;
  --lh-tight: 1.25;
  --lh-normal: 1.55;

  /* ---- Spacing scale ---- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  /* ---- Radius / shadow / motion ---- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(16, 20, 43, 0.06);
  --shadow-sm: 0 2px 8px rgba(16, 20, 43, 0.08);
  --shadow-md: 0 8px 24px rgba(16, 20, 43, 0.10);
  --shadow-lg: 0 16px 48px rgba(16, 20, 43, 0.14);

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 160ms;

  --rainbow: conic-gradient(
    from 205deg,
    var(--g-magenta),
    var(--g-purple),
    var(--g-blue),
    var(--g-teal),
    var(--g-green),
    var(--g-yellow),
    var(--g-magenta)
  );
}

/* Optional: honor a saved dark-mode preference set server-side via body[data-theme] */
body[data-theme="dark"] {
  --bg: #0C0E1E;
  --surface: #161A33;
  --surface-muted: #1E2242;
  --border: #2A2E52;
  --border-strong: #383C68;
  --text: #F1F1F8;
  --text-muted: #B6B9D6;
  --text-faint: #8386AC;
  --primary-soft: #2A1F3A;
  --secondary-soft: #1D2447;
  --success-soft: #1B2E22;
  --warning-soft: #332E14;
  --danger-soft: #391F26;
  --info-soft: #16302F;
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
body.app-shell,
body.tenancy-body,
body.login-body,
body.hr-body,
body.cat-body,
body.sal-body,
body.crm-body,
body.pur-body,
body.prc-body,
body.inv-body,
body.imp-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text);
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-3);
  font-weight: 800;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-3); color: var(--text-muted); }
small, .text-sm { font-size: var(--fs-sm); }
hr { border: none; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }

::selection { background: var(--primary-soft); color: var(--primary-strong); }

:focus-visible {
  outline: 3px solid var(--secondary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============ Layout utilities ============ */
.container { max-width: 1200px; margin-inline: auto; padding-inline: var(--sp-5); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ============ Official GALACTIC logo (image assets in /static/brand/) ============ */
.g-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.g-brand:hover { text-decoration: none; }

.g-logo-mark {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  flex: none;
}
.g-logo-mark--sm { width: 1.85rem; height: 1.85rem; }
.g-logo-mark--lg { width: 5.75rem; height: 5.75rem; }
.g-logo-mark--side { width: 2.65rem; height: 2.65rem; }
.g-logo-mark--on-light,
.g-brand--header .g-logo-mark,
.login-hero-logo .g-logo-stacked,
.modules-hero-brand .g-logo-stacked {
  filter: drop-shadow(0 1px 2px rgba(16, 20, 43, 0.12));
}

.g-logo-wordmark {
  display: block;
  height: 0.95rem;
  width: auto;
  max-width: 9.75rem;
  object-fit: contain;
  object-position: left center;
}
[dir="rtl"] .g-logo-wordmark { object-position: right center; }
.g-logo-wordmark--side {
  height: 1.2rem;
  max-width: 11rem;
  margin-bottom: 0.55rem;
  opacity: 1;
}

.g-logo-stacked {
  display: block;
  width: min(240px, 78%);
  height: auto;
  margin-inline: auto;
}

.g-side-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding-top: 0.1rem;
}
.g-side-home {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
  text-decoration: none !important;
  color: inherit;
  border-radius: 12px;
  padding: 0.1rem 0.15rem;
  margin: -0.1rem -0.15rem;
  transition: background 160ms ease;
}
.g-side-home:hover,
.g-side-home:focus-visible {
  text-decoration: none !important;
  background: rgba(255, 255, 255, 0.08);
}
.g-side-home:focus-visible {
  outline: 2px solid rgba(167, 243, 208, 0.85);
  outline-offset: 2px;
}
.g-side-home .g-logo-mark,
.g-side-home .g-logo-mark--side {
  display: block;
  flex: none;
}
.g-side-home .g-side-copy {
  pointer-events: none;
}
.g-side-copy .g-logo-wordmark,
.g-side-copy .g-logo-wordmark--side {
  margin-bottom: 0.55rem;
}
.g-side-copy strong,
.g-side-copy .g-side-program {
  display: block;
  margin: 0;
  padding-top: 0.15rem;
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.96);
}
.g-side-copy small {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  line-height: 1.25;
  opacity: 0.72;
}

[class$="-side-brand"] .g-logo-mark {
  width: 3rem;
  height: 3rem;
  flex: none;
}
[class$="-side-brand"] .g-logo-wordmark {
  height: 1.2rem;
  max-width: 11rem;
  margin-bottom: 0.55rem;
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.55rem 1.1rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  text-decoration: none;
  line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: var(--white); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-strong); }

.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:hover { background: var(--secondary-strong); }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.btn-ghost, .btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.85rem;
}
.btn-ghost:hover, .btn-link:hover {
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
}

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { filter: brightness(0.92); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 0.8rem 1.6rem; font-size: var(--fs-md); border-radius: var(--radius-lg); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============ Form controls ============ */
label, .label { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--text); margin-bottom: var(--sp-2); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="tel"], input[type="date"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-height: 7rem; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px var(--secondary-soft);
}
::placeholder { color: var(--text-faint); }

/* Checkbox / radio, styled without JS */
input[type="checkbox"], input[type="radio"] {
  width: 1.1em; height: 1.1em;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Native <select> gets a custom arrow via CSS only */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                     linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(1em + 2px), calc(100% - 13px) calc(1em + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 2.2rem;
}
[dir="rtl"] select {
  background-position: 18px calc(1em + 2px), 13px calc(1em + 2px);
  padding-inline-end: 0.85rem;
  padding-inline-start: 2.2rem;
}

.field-error { display: block; margin-top: var(--sp-1); color: var(--danger); font-size: var(--fs-xs); font-weight: 600; }
.form-row { margin-bottom: var(--sp-4); }

/* Inline "apply" control used next to a select when JS auto-submit is not used */
.inline-apply { display: inline-flex; gap: var(--sp-1); align-items: stretch; }
.inline-apply select { border-radius: var(--radius-md) 0 0 var(--radius-md); }
[dir="rtl"] .inline-apply select { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.inline-apply .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; padding-inline: 0.7rem; }
[dir="rtl"] .inline-apply .btn { border-radius: var(--radius-md) 0 0 var(--radius-md); }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
}
.card-title { font-size: var(--fs-lg); font-weight: 800; margin-bottom: var(--sp-2); }
.card-muted { color: var(--text-muted); }

/* ============ Badges / chips ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--surface-muted);
  color: var(--text-muted);
}
.badge-primary { background: var(--primary-soft); color: var(--primary-strong); }
.badge-success { background: var(--success-soft); color: #266B27; }
.badge-warning { background: var(--warning-soft); color: #8A6A00; }
.badge-danger  { background: var(--danger-soft);  color: #9C2338; }
.badge-info    { background: var(--info-soft);    color: #1D6E6B; }

/* ============ Alerts ============ */
.alert {
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
}
.alert-info    { background: var(--info-soft);    border-color: #BFE4E2; color: #1D6E6B; }
.alert-success { background: var(--success-soft); border-color: #C7E6C4; color: #266B27; }
.alert-warning { background: var(--warning-soft); border-color: #F1E29C; color: #8A6A00; }
.alert-danger  { background: var(--danger-soft);  border-color: #F3C1CA; color: #9C2338; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: var(--fs-sm); }
thead th {
  text-align: start;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--surface-muted);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-muted); }

/* ============ Navigation / topbar ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 0;
  background:
    radial-gradient(720px 180px at 8% 0%, rgba(122, 48, 151, 0.28), transparent 60%),
    radial-gradient(560px 160px at 92% 0%, rgba(62, 90, 201, 0.22), transparent 55%),
    linear-gradient(180deg, #171B39 0%, #10142B 55%, #0C0F22 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 32px rgba(8, 10, 22, 0.28);
}
.app-header__inner {
  width: min(1280px, 100%);
  margin-inline: auto;
  padding: 0.7rem 1.15rem;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.app-header__brand {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: none;
}
.app-header__brand .g-brand { gap: 0.55rem; }
.app-header__brand .g-logo-mark { width: 2.15rem; height: 2.15rem; }
.app-header__brand .g-logo-wordmark {
  height: 0.78rem;
  max-width: 8.2rem;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}

.app-header__actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
  min-width: 0;
  flex: 1 1 auto;
}
.header-nav,
.header-tools {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
}
.header-nav {
  padding: 0.25rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex: none;
}
.header-tools {
  padding-inline-start: 0.35rem;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.12);
  flex: none;
}
.header-ai-dropdown {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  flex: none;
}

.header-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: rgba(237, 238, 245, 0.9);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}
@media (max-width: 1280px) {
  .header-msg-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}
.wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin-inline-start: 0.35rem;
  padding: 0.18rem 0.55rem 0.18rem 0.4rem;
  border-radius: 999px;
  background: #128C7E;
  color: #fff !important;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
}
.wa-btn svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
  flex: none;
}
.wa-btn:hover { background: #075E54; color: #fff !important; }
.wa-btn[hidden] { display: none !important; }
.header-msg-badge {
  position: absolute;
  top: 0.05rem;
  inset-inline-end: 0.2rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #e2495f;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.header-btn .side-ico {
  width: 1.05rem;
  height: 1.05rem;
  opacity: 0.95;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}
.header-btn:active { transform: translateY(0); }
.header-btn:focus-visible {
  outline: 2px solid #3E5AC9;
  outline-offset: 2px;
}
.header-btn--accent {
  background: linear-gradient(145deg, rgba(154, 63, 190, 0.35), rgba(62, 90, 201, 0.28));
  border-color: rgba(217, 63, 158, 0.28);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.header-btn--accent:hover {
  background: linear-gradient(145deg, rgba(154, 63, 190, 0.55), rgba(62, 90, 201, 0.42));
  border-color: rgba(217, 63, 158, 0.45);
  color: #fff;
}
.header-ai-dropdown > .header-btn {
  cursor: pointer;
  font: inherit;
}
.header-ai-dropdown > .dropdown-menu {
  inset-inline-start: auto;
  inset-inline-end: 0;
  min-width: 240px;
  padding: 0.45rem;
}
.header-ai-menu a {
  display: grid;
  gap: 0.12rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  line-height: 1.25;
}
.header-ai-menu a strong {
  font-size: 0.92rem;
  color: var(--text);
}
.header-ai-menu a small {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.header-ai-menu__all {
  margin-top: 0.2rem;
  border-top: 1px solid var(--border);
  color: var(--brand, #7A3097) !important;
  font-weight: 700;
  font-size: 0.82rem !important;
}
.header-btn--danger,
.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.45rem 0.9rem;
  border-radius: 11px;
  border: 1px solid #C93A4F;
  background: linear-gradient(180deg, #EE5A6E 0%, #E2495F 48%, #C93A4F 100%);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow:
    0 8px 18px rgba(226, 73, 95, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}
.header-btn--danger .side-ico,
.btn-logout .side-ico {
  width: 1.05rem;
  height: 1.05rem;
  opacity: 1;
  stroke: currentColor;
}
.header-btn--danger:hover,
.btn-logout:hover {
  background: linear-gradient(180deg, #F46B7D 0%, #E2495F 45%, #B83245 100%);
  border-color: #B83245;
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow:
    0 12px 24px rgba(226, 73, 95, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  filter: brightness(1.03);
}
.header-btn--danger:active,
.btn-logout:active {
  transform: translateY(0);
  filter: brightness(0.97);
}
.header-btn--danger:focus-visible,
.btn-logout:focus-visible {
  outline: 2px solid #E2495F;
  outline-offset: 2px;
}
.logout-form {
  display: inline;
  margin: 0;
}
[class$="-side-foot"] .logout-form {
  display: block;
  width: 100%;
  margin: 0;
}
[class$="-side-foot"] .btn-logout {
  width: 100%;
  justify-content: flex-start;
  min-height: 2.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-size: 0.86rem;
}

.tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(260px, 36vw);
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #EDEEF5;
  margin-inline-start: 0;
}
.tenant-chip__mark {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #34AFAC, #7A3097);
  box-shadow: 0 0 0 3px rgba(52, 175, 172, 0.18);
  flex: none;
}
.tenant-chip__text {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}
.tenant-chip__text strong,
.tenant-chip__text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tenant-chip__text strong {
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.15;
}
.tenant-chip__text small {
  font-size: 0.66rem;
  color: rgba(237, 238, 245, 0.65);
}

.net-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.72rem;
  font-weight: 750;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(237, 238, 245, 0.78);
}
.net-status::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: rgba(237, 238, 245, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}
.net-status.online {
  background: rgba(95, 182, 91, 0.16);
  border-color: rgba(95, 182, 91, 0.28);
  color: #C8F0C4;
}
.net-status.online::before {
  background: #5FB65B;
  box-shadow: 0 0 0 3px rgba(95, 182, 91, 0.22);
}
.net-status.offline {
  background: rgba(244, 210, 39, 0.14);
  border-color: rgba(244, 210, 39, 0.28);
  color: #F8E8A0;
}
.net-status.offline::before {
  background: #F4D227;
  box-shadow: 0 0 0 3px rgba(244, 210, 39, 0.2);
}

.lang-form select { padding: 0.4rem 2rem 0.4rem 0.7rem; font-size: var(--fs-sm); }

/* ============ Language switch — two-button segmented toggle, no JS ============ */
.lang-switch {
  display: inline-flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  padding: 3px;
  gap: 2px;
}
.lang-switch-form { display: contents; }
.lang-switch-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--fs-xs);
  line-height: 1;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lang-switch-btn:hover { color: var(--text); }
.lang-switch-btn.is-active {
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow-xs);
  cursor: default;
}
/* Dark-header contexts (app / login / tenancy) */
.app-header .lang-switch,
.login-topbar .lang-switch,
.tenancy-top .lang-switch {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}
.app-header .lang-switch-btn,
.login-topbar .lang-switch-btn,
.tenancy-top .lang-switch-btn {
  color: rgba(237, 238, 245, 0.72);
}
.app-header .lang-switch-btn:hover,
.login-topbar .lang-switch-btn:hover,
.tenancy-top .lang-switch-btn:hover {
  color: #fff;
}
.app-header .lang-switch-btn.is-active {
  background: linear-gradient(145deg, #9A3FBE, #3E5AC9);
  color: #fff;
}

@media (max-width: 980px) {
  .header-btn span,
  .app-header .btn-logout__label { display: none; }
  .header-btn,
  .app-header .btn-logout { padding: 0.5rem; min-width: 2.2rem; justify-content: center; }
  .tenant-chip { max-width: 140px; }
  .app-header__inner,
  .app-header__actions,
  .header-nav,
  .header-tools,
  .app-header__brand {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }
}
@media (max-width: 720px) {
  /* Keep one horizontal header row — never stack brand / buttons */
  .app-header__inner {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
  }
  .app-header__actions {
    justify-content: flex-end;
    gap: 0.45rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }
  .app-header__actions::-webkit-scrollbar { display: none; }
  .header-tools {
    border-inline-start: 1px solid rgba(255, 255, 255, 0.12);
    padding-inline-start: 0.35rem;
    width: auto;
    justify-content: flex-end;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }
  .header-nav,
  .app-header__brand {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }
  .net-status { display: none; }
  .app-header__brand .g-logo-wordmark { max-width: 6.5rem; }
}

/* ============ Module page topbars (unified across all programs) ============ */
.hr-topbar,
.cat-topbar,
.sal-topbar,
.pur-topbar,
.prc-topbar,
.inv-topbar,
.imp-topbar,
.crm-topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.95rem 1.35rem;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 247, 252, 0.9));
  border-bottom: 1px solid rgba(23, 27, 57, 0.08);
  box-shadow: 0 8px 24px rgba(16, 20, 43, 0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.g-topbar-lead {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}
.g-page-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  margin-top: 0.15rem;
  min-height: 2.35rem;
  padding: 0.4rem 0.85rem 0.4rem 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(23, 27, 57, 0.12);
  background: #fff;
  color: #171B39;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 4px 12px rgba(16, 20, 43, 0.05);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.g-page-back__ico {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 8px;
  background: rgba(23, 27, 57, 0.06);
}
.g-page-back__ico svg {
  display: block;
}
html[dir="rtl"] .g-page-back__ico svg,
.dir-rtl .g-page-back__ico svg {
  transform: scaleX(-1);
}
.g-page-back:hover {
  background: #f4f6fb;
  border-color: rgba(23, 27, 57, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(16, 20, 43, 0.08);
}
.g-page-back:active {
  transform: translateY(0);
}
.g-page-back:focus-visible {
  outline: 2px solid #1FA86A;
  outline-offset: 2px;
}
@media (max-width: 640px) {
  .g-page-back__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .g-page-back {
    padding: 0.4rem;
    min-width: 2.35rem;
    justify-content: center;
  }
}
.hr-top-title,
.cat-top-title,
.sal-top-title,
.pur-top-title,
.prc-top-title,
.inv-top-title,
.imp-top-title,
.crm-top-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #171B39;
  line-height: 1.2;
}
.hr-top-sub,
.cat-top-sub,
.sal-top-sub,
.pur-top-sub,
.prc-top-sub,
.inv-top-sub,
.imp-top-sub,
.crm-top-sub {
  margin: 0.3rem 0 0;
  color: rgba(23, 27, 57, 0.55);
  font-size: 0.84rem;
  font-weight: 600;
}
.hr-top-actions,
.cat-top-actions,
.sal-top-actions,
.pur-top-actions,
.prc-top-actions,
.inv-top-actions,
.imp-top-actions,
.crm-top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.hr-top-actions .lang-switch,
.cat-top-actions .lang-switch,
.sal-top-actions .lang-switch,
.pur-top-actions .lang-switch,
.prc-top-actions .lang-switch,
.inv-top-actions .lang-switch,
.imp-top-actions .lang-switch,
.crm-top-actions .lang-switch {
  border-color: rgba(23, 27, 57, 0.12);
  background: rgba(23, 27, 57, 0.04);
}
.hr-top-actions .lang-switch-btn.is-active,
.cat-top-actions .lang-switch-btn.is-active,
.sal-top-actions .lang-switch-btn.is-active,
.pur-top-actions .lang-switch-btn.is-active,
.prc-top-actions .lang-switch-btn.is-active,
.inv-top-actions .lang-switch-btn.is-active,
.imp-top-actions .lang-switch-btn.is-active,
.crm-top-actions .lang-switch-btn.is-active {
  background: linear-gradient(145deg, #7A3097, #3E5AC9);
  color: #fff;
}

/* ============ App shell ============ */
.app-main { max-width: 1280px; margin-inline: auto; padding: var(--sp-6) var(--sp-5); min-height: calc(100vh - 140px); }

/* ============ Full-width site footer (GALACTIC + Hailat) ============ */
.site-footer {
  width: 100%;
  margin-top: auto;
  margin-inline: 0;
  padding: 0;
  border-top: 1px solid rgba(23, 27, 57, 0.1);
  background: linear-gradient(180deg, #FFFFFF 0%, #F4F5FB 100%);
  box-shadow: 0 -10px 28px rgba(16, 20, 43, 0.04);
}
.site-footer__inner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-footer--with-user .site-footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem 1.25rem;
}
.site-footer--with-user .site-footer__brand {
  justify-self: start;
}
.site-footer--with-user .site-footer__user {
  justify-self: center;
  text-align: center;
}
.site-footer--with-user .site-footer__dev {
  justify-self: end;
}
.site-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.site-footer .g-logo-mark,
.site-footer .g-logo-mark--sm {
  width: 1.85rem;
  height: 1.85rem;
}
.site-footer__brand-copy { display: grid; gap: 0.1rem; }
.site-footer__project {
  font-size: 0.95rem;
  font-weight: 850;
  letter-spacing: -0.02em;
  color: #10142B;
  line-height: 1.2;
}
.site-footer__role {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(23, 27, 57, 0.52);
}
.site-footer__user {
  display: grid;
  gap: 0.12rem;
  justify-items: center;
  min-width: 0;
  max-width: min(22rem, 100%);
  padding: 0.35rem 0.85rem;
}
.site-footer__user-label {
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(23, 27, 57, 0.48);
}
.site-footer__user-name {
  font-size: 0.92rem;
  font-weight: 850;
  color: #10142B;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.site-footer__user-handle {
  font-size: 0.74rem;
  font-weight: 650;
  color: rgba(23, 27, 57, 0.55);
}
.site-footer__dev {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
  padding: 0.4rem 0.85rem 0.4rem 0.4rem;
  border-radius: 16px;
  background: rgba(23, 27, 57, 0.035);
  border: 1px solid rgba(23, 27, 57, 0.08);
}
.site-footer__dev-logo {
  width: 4rem;
  height: 4rem;
  flex: none;
  display: block;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 18px rgba(16, 20, 43, 0.1);
}
.site-footer__dev-line {
  margin: 0;
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.25;
  color: rgba(23, 27, 57, 0.78);
  white-space: nowrap;
}
.site-footer__dev-credit {
  display: inline;
  white-space: nowrap;
  color: rgba(23, 27, 57, 0.78);
}
.site-footer__dev-credit strong,
.site-footer__dev-line strong {
  color: #5F2179;
  font-weight: 850;
}
.site-footer__dev-sep {
  color: rgba(23, 27, 57, 0.35);
  font-weight: 700;
}
.site-footer__phone {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  width: fit-content;
  flex: none;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #3E5AC9;
  text-decoration: none;
  direction: ltr;
  white-space: nowrap;
}
.site-footer__phone::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #34AFAC;
  box-shadow: 0 0 0 3px rgba(52, 175, 172, 0.18);
}
.site-footer__phone:hover {
  color: #7A3097;
  text-decoration: none;
}

.site-footer--dark {
  background: linear-gradient(180deg, #14182F 0%, #0C0F22 100%);
  border-top-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}
.site-footer--dark .site-footer__project { color: #fff; }
.site-footer--dark .site-footer__role { color: rgba(237, 238, 245, 0.55); }
.site-footer--dark .site-footer__user-label { color: rgba(237, 238, 245, 0.5); }
.site-footer--dark .site-footer__user-name { color: #fff; }
.site-footer--dark .site-footer__user-handle { color: rgba(237, 238, 245, 0.62); }
.site-footer--dark .site-footer__dev {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}
.site-footer--dark .site-footer__dev-line,
.site-footer--dark .site-footer__dev-credit { color: rgba(237, 238, 245, 0.88); }
.site-footer--dark .site-footer__dev-line strong { color: #E9D5F5; }
.site-footer--dark .site-footer__dev-sep { color: rgba(237, 238, 245, 0.4); }
.site-footer--dark .site-footer__dev-logo {
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}
.site-footer--dark .site-footer__phone { color: #A8B6F0; }
.site-footer--dark .site-footer__phone:hover { color: #fff; }

.site-footer--glass {
  background: rgba(12, 15, 34, 0.55);
  border-top-color: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: none;
}
.site-footer--glass .site-footer__project { color: #fff; }
.site-footer--glass .site-footer__role { color: rgba(237, 238, 245, 0.6); }
.site-footer--glass .site-footer__user-label { color: rgba(237, 238, 245, 0.55); }
.site-footer--glass .site-footer__user-name { color: #fff; }
.site-footer--glass .site-footer__user-handle { color: rgba(237, 238, 245, 0.66); }
.site-footer--glass .site-footer__dev {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}
.site-footer--glass .site-footer__dev-line,
.site-footer--glass .site-footer__dev-credit { color: rgba(237, 238, 245, 0.92); }
.site-footer--glass .site-footer__dev-line strong { color: #F3E8FF; }
.site-footer--glass .site-footer__dev-sep { color: rgba(237, 238, 245, 0.45); }
.site-footer--glass .site-footer__dev-logo { background: #fff; }
.site-footer--glass .site-footer__phone { color: #C7D2FE; }

.app-footer,
.module-page-footer,
.tenancy-hailat-footer,
.pos-hailat-footer,
.admin-hailat-footer,
.login-footer {
  width: 100%;
  margin: 0;
  margin-top: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: block;
}
.app-footer__brand,
.login-footer__brand { display: none; }

@media (max-width: 720px) {
  .site-footer__inner {
    flex-direction: column;
    align-items: stretch;
    text-align: start;
    gap: 0.75rem;
  }
  .site-footer--with-user .site-footer__inner {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .site-footer--with-user .site-footer__brand,
  .site-footer--with-user .site-footer__user,
  .site-footer--with-user .site-footer__dev {
    justify-self: stretch;
  }
  .site-footer--with-user .site-footer__user {
    order: -1;
    text-align: center;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: rgba(122, 48, 151, 0.06);
    border: 1px solid rgba(122, 48, 151, 0.12);
  }
  .site-footer__dev {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .site-footer__dev-line {
    font-size: 0.8rem;
  }
  .site-footer__dev-logo {
    width: 3.5rem;
    height: 3.5rem;
  }
}

.hr-main,
.cat-main,
.sal-main,
.crm-main,
.pur-main,
.prc-main,
.inv-main,
.imp-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ============ Shared collapsible nav folders ============ */
.g-nav-folder {
  display: grid;
  gap: 0.08rem;
  margin-top: 0.2rem;
}
.g-nav-folder__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(238, 244, 245, 0.92);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  border-inline-start: 3px solid transparent;
  opacity: 0.96;
}
.g-nav-folder__toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
}
.g-nav-folder.has-active > .g-nav-folder__toggle,
.g-nav-folder.is-open > .g-nav-folder__toggle {
  background: rgba(255, 255, 255, 0.07);
  border-inline-start-color: rgba(196, 163, 90, 0.55);
  opacity: 1;
}
.g-nav-folder__toggle .side-label { flex: 1; }
.g-nav-folder__chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-inline-end: 2px solid rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.55);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
  margin-inline-end: 0.15rem;
}
[dir="rtl"] .g-nav-folder__chevron { transform: rotate(45deg); }
.g-nav-folder.is-open > .g-nav-folder__toggle .g-nav-folder__chevron {
  transform: rotate(45deg);
}
[dir="rtl"] .g-nav-folder.is-open > .g-nav-folder__toggle .g-nav-folder__chevron {
  transform: rotate(-45deg);
}
.g-nav-folder__items {
  display: none;
  gap: 0.06rem;
  padding-inline-start: 0.55rem;
  margin-inline-start: 0.35rem;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.12);
}
.g-nav-folder.is-open > .g-nav-folder__items { display: grid; }
.g-nav-folder__items a { font-size: 0.84rem; }

[class$="-shell"].is-side-collapsed .g-nav-folder__toggle { display: none; }
[class$="-shell"].is-side-collapsed .g-nav-folder__items {
  display: grid !important;
  padding-inline-start: 0;
  margin-inline-start: 0;
  border-inline-start: 0;
}

/* ============ Shared program sidebar: icons + collapse ============ */
.hr-shell, .cat-shell, .sal-shell, .crm-shell,
.pur-shell, .prc-shell, .inv-shell, .imp-shell {
  transition: grid-template-columns 220ms cubic-bezier(0.2, 0.7, 0.3, 1);
  flex: 1;
  min-height: 0;
}
.hr-shell.is-side-collapsed,
.cat-shell.is-side-collapsed,
.sal-shell.is-side-collapsed,
.crm-shell.is-side-collapsed,
.pur-shell.is-side-collapsed,
.prc-shell.is-side-collapsed,
.inv-shell.is-side-collapsed,
.imp-shell.is-side-collapsed {
  grid-template-columns: 78px 1fr !important;
}

[class$="-side-brand"] {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.85rem;
  row-gap: 0.65rem;
}
[class$="-side-brand"] .side-toggle {
  margin-inline-start: auto;
  align-self: flex-start;
}

/* Keep program title under the enlarged GALACTIC wordmark */
[class$="-side-brand"] {
  align-items: flex-start !important;
}
[class$="-side-brand"] .g-side-copy .g-side-program,
[class$="-side-brand"] .g-side-copy > strong {
  margin-top: 0.1rem;
  font-size: 0.9rem !important;
  font-weight: 750 !important;
  line-height: 1.3 !important;
}
[class$="-side-brand"] .g-logo-wordmark,
[class$="-side-brand"] .g-logo-wordmark--side {
  height: 1.2rem !important;
  max-width: 11rem !important;
  margin-bottom: 0.55rem !important;
}
[class$="-side-brand"] .g-logo-mark,
[class$="-side-brand"] .g-logo-mark--side {
  width: 3rem !important;
  height: 3rem !important;
}

.side-ico {
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
}
[class$="-side-nav"] a,
[class$="-side-foot"] > a,
[class$="-side-foot"] .linkish {
  display: flex !important;
  align-items: center;
  gap: 0.65rem;
}
[class$="-side-nav"] a .side-label,
[class$="-side-foot"] .side-label {
  min-width: 0;
  line-height: 1.25;
}

/* ---- Shared green hub actions (All programs / AI / Change company) ---- */
.side-hub-actions {
  display: grid;
  gap: 0.55rem;
  width: 100%;
  margin: 0.1rem 0 0.25rem;
  padding: 0.15rem 0 0.25rem;
}
.side-hub-btn {
  --hub-green: #1FA86A;
  --hub-green-deep: #148556;
  --hub-green-soft: rgba(31, 168, 106, 0.22);
  position: relative;
  isolation: isolate;
  display: flex !important;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 2.65rem;
  padding: 0.62rem 0.85rem !important;
  border-radius: 14px;
  border: 1px solid rgba(95, 214, 150, 0.45);
  background:
    linear-gradient(145deg, #2BC27A 0%, var(--hub-green) 48%, var(--hub-green-deep) 100%);
  color: #fff !important;
  font-weight: 750;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 10px 22px rgba(20, 133, 86, 0.28);
  transition:
    transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1),
    box-shadow 180ms ease,
    filter 180ms ease,
    border-color 180ms ease;
  overflow: hidden;
}
.side-hub-btn__glow {
  position: absolute;
  inset: auto -30% -60% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 68%);
  pointer-events: none;
  z-index: -1;
  opacity: 0.7;
  transition: transform 220ms ease, opacity 220ms ease;
}
.side-hub-btn__ico {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.side-hub-btn__ico .side-ico {
  width: 1.05rem;
  height: 1.05rem;
  stroke: #fff;
  opacity: 1;
}
.side-hub-btn__label {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-hub-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  border-color: rgba(180, 255, 210, 0.65);
  color: #fff !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 14px 28px rgba(20, 133, 86, 0.38);
  text-decoration: none !important;
}
.side-hub-btn:hover .side-hub-btn__glow {
  opacity: 1;
  transform: scale(1.15) translate(-10%, -8%);
}
.side-hub-btn:active {
  transform: translateY(0);
  filter: brightness(0.98);
}
.side-hub-btn:focus-visible {
  outline: 2px solid #A7F3D0;
  outline-offset: 2px;
}
.side-hub-btn--company {
  --hub-green: #18A36B;
  --hub-green-deep: #0F7A50;
  background:
    linear-gradient(145deg, #26C488 0%, #18A36B 52%, #0F7A50 100%);
}
.side-hub-btn--ai {
  --hub-green: #1B9E6A;
  --hub-green-deep: #117A52;
  background:
    linear-gradient(145deg, #2AB87A 0%, #1B9E6A 50%, #117A52 100%);
}

/* Override generic side-foot link styles that would flatten these buttons */
[class$="-side-foot"] .side-hub-actions .side-hub-btn,
[class$="-side-foot"] a.side-hub-btn {
  color: #fff !important;
  background: linear-gradient(145deg, #2BC27A 0%, #1FA86A 48%, #148556 100%) !important;
  border: 1px solid rgba(95, 214, 150, 0.45) !important;
  padding: 0.62rem 0.85rem !important;
  font-size: 0.9rem !important;
  font-weight: 750 !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 10px 22px rgba(20, 133, 86, 0.28) !important;
  width: 100%;
  text-align: start;
}
[class$="-side-foot"] .side-hub-actions .side-hub-btn--company,
[class$="-side-foot"] a.side-hub-btn--company {
  background: linear-gradient(145deg, #26C488 0%, #18A36B 52%, #0F7A50 100%) !important;
}
[class$="-side-foot"] .side-hub-actions .side-hub-btn--ai,
[class$="-side-foot"] a.side-hub-btn--ai {
  background: linear-gradient(145deg, #2AB87A 0%, #1B9E6A 50%, #117A52 100%) !important;
}
[class$="-side-foot"] .side-hub-actions .side-hub-btn:hover,
[class$="-side-foot"] a.side-hub-btn:hover {
  color: #fff !important;
  filter: brightness(1.05);
  background: linear-gradient(145deg, #34D189 0%, #22B574 48%, #17925E 100%) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 14px 28px rgba(20, 133, 86, 0.38) !important;
}

.is-side-collapsed .side-hub-actions {
  padding-inline: 0;
  gap: 0.45rem;
}
.is-side-collapsed .side-hub-btn {
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.55rem !important;
  border-radius: 12px;
}
.is-side-collapsed .side-hub-btn__label {
  display: none !important;
}
.is-side-collapsed .side-hub-btn__ico {
  width: 1.7rem;
  height: 1.7rem;
}

.side-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(237, 238, 245, 0.9);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}
.side-toggle:hover {
  background: rgba(217, 63, 158, 0.28);
  border-color: rgba(217, 63, 158, 0.45);
  color: #fff;
}
.side-toggle:focus-visible {
  outline: 2px solid #3E5AC9;
  outline-offset: 2px;
}
.side-toggle__ico {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}
.side-toggle__expand { display: none; }
.side-toggle__text {
  display: none;
  font-size: 0.7rem;
  font-weight: 700;
}

.is-side-collapsed [class$="-side-brand"] {
  flex-direction: column;
  align-items: center;
  padding-inline: 0.2rem;
  gap: 0.55rem;
}
.is-side-collapsed [class$="-side-brand"] .g-side-copy,
.is-side-collapsed [class$="-side-brand"] .g-logo-wordmark,
.is-side-collapsed [class$="-side-brand"] .g-side-home .g-side-copy,
.is-side-collapsed [class$="-nav-group"],
.is-side-collapsed [class$="-side-note"],
.is-side-collapsed .side-label {
  display: none !important;
}
.is-side-collapsed [class$="-side-brand"] .g-side-home {
  justify-content: center;
  padding: 0.15rem;
  margin: 0;
}
.is-side-collapsed [class$="-side-foot"] .btn-logout {
  display: inline-flex !important;
  width: 100%;
  justify-content: center;
  padding: 0.55rem;
  min-width: 2.35rem;
}
.is-side-collapsed [class$="-side-foot"] .btn-logout .btn-logout__label {
  display: none !important;
}
.is-side-collapsed [class$="-sidebar"] {
  padding-inline: 0.55rem;
  align-items: center;
}
.is-side-collapsed [class$="-side-nav"],
.is-side-collapsed [class$="-side-foot"] {
  width: 100%;
}
.is-side-collapsed [class$="-side-nav"] a,
.is-side-collapsed [class$="-side-foot"] > a {
  justify-content: center;
  padding-inline: 0.55rem !important;
}
.is-side-collapsed .side-toggle {
  width: 2.2rem;
  margin-inline: 0;
}
.is-side-collapsed .side-toggle__collapse { display: none; }
.is-side-collapsed .side-toggle__expand { display: block; }
.is-side-collapsed [class$="-side-brand"] .g-logo-mark,
.is-side-collapsed [class$="-side-brand"] .g-logo-mark--side {
  width: 2.2rem;
  height: 2.2rem;
}
[dir="rtl"] .side-toggle__collapse { transform: scaleX(-1); }
[dir="rtl"] .side-toggle__expand { transform: scaleX(-1); }
[dir="rtl"].is-side-collapsed .side-toggle__expand,
[dir="rtl"] .is-side-collapsed .side-toggle__expand { transform: none; }
[dir="rtl"].is-side-collapsed .side-toggle__collapse,
[dir="rtl"] .is-side-collapsed .side-toggle__collapse { transform: none; }

@media (max-width: 900px) {
  .hr-shell.is-side-collapsed,
  .cat-shell.is-side-collapsed,
  .sal-shell.is-side-collapsed,
  .crm-shell.is-side-collapsed,
  .pur-shell.is-side-collapsed,
  .prc-shell.is-side-collapsed,
  .inv-shell.is-side-collapsed,
  .imp-shell.is-side-collapsed {
    grid-template-columns: 1fr !important;
  }
}

/* ============ Tabs — pure CSS via radio inputs ============ */
.tabs { display: flex; border-bottom: 1px solid var(--border); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.tabs input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.tabs label {
  margin: 0; padding: var(--sp-2) 0.1rem; cursor: pointer;
  font-weight: 700; color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tabs input[type="radio"]:checked + label { color: var(--primary); border-color: var(--primary); }
.tab-panels > .tab-panel { display: none; }
/* Panel visibility pairs with the general sibling selector when radios and panels share a parent — see design docs for wiring */

/* ============ Accordion — native, no JS ============ */
details.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--sp-2);
}
details.accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 700;
  background: var(--surface-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.accordion > summary::-webkit-details-marker { display: none; }
details.accordion > summary::after { content: "+"; color: var(--text-muted); font-weight: 900; }
details.accordion[open] > summary::after { content: "−"; }
details.accordion > .accordion-body { padding: var(--sp-4); border-top: 1px solid var(--border); }

/* ============ Dropdown — CSS :focus-within, no JS ============ */
.dropdown { position: relative; display: inline-block; }
.dropdown > .dropdown-menu {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
  z-index: 30;
}
.dropdown:hover > .dropdown-menu,
.dropdown:focus-within > .dropdown-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.dropdown-menu a, .dropdown-menu button {
  display: block; width: 100%; text-align: start;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  color: var(--text); background: transparent; border: none; font-size: var(--fs-sm); cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-muted); text-decoration: none; }

/* ============ Modal — CSS :target, no JS ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 20, 43, 0.5);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility var(--dur);
  z-index: 50;
}
.modal-overlay:target { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-width: 480px; width: 100%; padding: var(--sp-5); position: relative;
}
.modal-close {
  position: absolute; top: var(--sp-3); inset-inline-end: var(--sp-3);
  width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface-muted); color: var(--text-muted); text-decoration: none; font-weight: 900;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); text-decoration: none; }

/* ============ Tooltip — CSS :hover, no JS ============ */
.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--ink-900); color: var(--white); font-size: var(--fs-xs); font-weight: 600;
  padding: 0.35rem 0.6rem; border-radius: var(--radius-sm); white-space: nowrap;
  opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease); pointer-events: none;
}
.tooltip:hover::after, .tooltip:focus-visible::after { opacity: 1; visibility: visible; }

/* ============ Stat / KPI tiles ============ */
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--sp-4); box-shadow: var(--shadow-xs);
}
.stat-tile .stat-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile .stat-value { font-size: var(--fs-2xl); font-weight: 900; color: var(--text); margin-top: var(--sp-1); }
.stat-tile .stat-delta { font-size: var(--fs-xs); font-weight: 700; margin-top: var(--sp-1); }
.stat-tile .stat-delta.up { color: var(--success); }
.stat-tile .stat-delta.down { color: var(--danger); }

/* ============ Progress ============ */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-muted); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

/* ============ Empty state ============ */
.empty-state { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--text-muted); }
.empty-state .g-logo-mark { margin-inline: auto; margin-bottom: var(--sp-4); opacity: 0.85; }

/* ============ Avatars ============ */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-strong);
  font-weight: 800; font-size: var(--fs-sm);
}

/* ============ Utility text/color helpers ============ */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 800; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

/* ============ Record row actions (edit / delete on every table) ============ */
.g-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.g-row-del { display: inline; margin: 0; }
.g-row-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-800);
  font-size: 0.78rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}
.g-row-btn:hover { border-color: var(--g-teal); color: var(--g-teal); }
.g-row-btn--danger {
  border-color: rgba(226, 73, 95, 0.35);
  color: var(--danger);
}
.g-row-btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

@media print {
  .app-header, .site-footer, .app-footer, .no-print { display: none !important; }
  .dir-rtl, .dir-rtl body {
    direction: rtl;
    font-family: Tahoma, "Segoe UI", "Noto Naskh Arabic", sans-serif;
  }
}

/* ---- Shared Excel import panel (templates/includes/excel_import_panel.html) ---- */
.xlimp-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  margin-bottom: 1rem;
}
.xlimp-panel__summary {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 1rem 1.15rem; cursor: pointer; list-style: none;
}
.xlimp-panel__summary::-webkit-details-marker { display: none; }
.xlimp-panel__summary strong { display: block; font-size: 1.02rem; color: var(--primary); }
.xlimp-panel__summary small { display: block; margin-top: 0.15rem; color: var(--text-muted); font-size: 0.85rem; }
.xlimp-panel__summary::after {
  content: ""; margin-inline-start: auto; flex: none; width: 0.6rem; height: 0.6rem;
  border-inline-end: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); opacity: 0.55; transition: transform 180ms ease;
}
.xlimp-panel[open] > .xlimp-panel__summary::after { transform: rotate(-135deg); }
.xlimp-panel__icon {
  display: grid; place-items: center; flex: none; width: 2.6rem; height: 2.6rem;
  border-radius: 12px; color: #fff; background: linear-gradient(145deg, #1D8A4F, #107C41);
  box-shadow: 0 6px 14px rgba(16, 124, 65, 0.25);
}
.xlimp-panel__steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 0.9rem; margin: 0; padding: 0 1.15rem 1.15rem; list-style: none;
}
.xlimp-panel__steps > li {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.9rem; border: 1px solid var(--border); border-radius: 14px;
  background: linear-gradient(180deg, var(--surface), var(--surface-muted));
}
.xlimp-panel__steps > li > b {
  display: grid; place-items: center; flex: none; width: 1.8rem; height: 1.8rem;
  border-radius: 50%; color: #fff; font-size: 0.9rem; background: var(--primary);
}
.xlimp-panel__steps strong { display: block; margin-bottom: 0.2rem; }
.xlimp-panel__steps p { margin: 0 0 0.6rem; font-size: 0.86rem; line-height: 1.5; color: var(--text-muted); }
.xlimp-panel__row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.xlimp-panel__row input[type="file"] {
  flex: 1 1 100%; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
  padding: 0.35rem; font: inherit; font-size: 0.85rem;
  border: 1.5px dashed var(--border-strong); border-radius: 10px; background: #fff;
}
.xlimp-panel__row input[type="file"]::file-selector-button {
  margin-inline-end: 0.6rem; padding: 0.4rem 0.8rem; border: 0; border-radius: 8px;
  font: inherit; font-weight: 700; color: #fff; background: #107C41; cursor: pointer;
}
.xlimp-panel__muted { color: var(--text-muted); font-size: 0.86rem; margin: 0.3rem 0 0; }
