@import url("../common/brand.css");

/* ==========================================================================
   TM Madar Design Tokens & Shell Core
   ========================================================================== */
:root {
  --portal-navy-950: var(--madar-navy-950, #090d16);
  --portal-navy-900: var(--madar-navy-900, #0f172a);
  --portal-navy-850: var(--madar-navy-850, #172033);
  --portal-navy-800: var(--madar-navy-800, #1e293b);
  --portal-navy-700: var(--madar-navy-700, #334155);
  --portal-slate-600: var(--madar-slate-600, #475569);
  --portal-slate-500: var(--madar-slate-500, #64748b);
  --portal-slate-400: var(--madar-slate-400, #94a3b8);
  --portal-slate-300: var(--madar-slate-300, #cbd5e1);
  --portal-slate-200: var(--madar-slate-200, #e2e8f0);
  --portal-slate-100: var(--madar-slate-100, #f1f5f9);
  --portal-slate-50:  var(--madar-slate-50, #f8fafc);

  --portal-accent-blue: var(--madar-blue-500, #0284c7);
  --portal-accent-blue-hover: var(--madar-blue-600, #0369a1);
  --portal-accent-blue-light: var(--madar-blue-100, #e0f2fe);

  --portal-success: var(--madar-success, #059669);
  --portal-success-bg: var(--madar-success-bg, #ecfdf5);
  --portal-success-border: var(--madar-success-border, #a7f3d0);

  --portal-warning: var(--madar-warning, #d97706);
  --portal-warning-bg: var(--madar-warning-bg, #fffbeb);
  --portal-warning-border: var(--madar-warning-border, #fde68a);

  --portal-danger: #dc2626;
  --portal-danger-bg: #fef2f2;
  --portal-danger-border: #fecaca;

  --portal-info: #0284c7;
  --portal-info-bg: #f0f9ff;
  --portal-info-border: #bae6fd;

  /* Override Django Admin root tokens to align entire app to new theme */
  --primary: #0284c7 !important;
  --secondary: #0f172a !important;
  --accent: #0284c7 !important;
  --primary-fg: #ffffff !important;
  --body-fg: #0f172a !important;
  --body-bg: #f8fafc !important;
  --body-quiet-color: #64748b !important;
  --body-loud-color: #090d16 !important;
  --header-color: #ffffff !important;
  --header-bg: #0f172a !important;
  --header-link-color: #ffffff !important;
  --breadcrumbs-fg: #64748b !important;
  --breadcrumbs-link-fg: #0284c7 !important;
  --breadcrumbs-bg: #ffffff !important;
  --link-fg: #0284c7 !important;
  --link-hover-color: #0369a1 !important;
  --link-selected-fg: #0284c7 !important;
  --hairline-color: #e2e8f0 !important;
  --border-color: #e2e8f0 !important;
  --button-fg: #0f172a !important;
  --button-bg: #ffffff !important;
  --button-hover-bg: #f1f5f9 !important;
  --default-button-bg: #0284c7 !important;
  --default-button-hover-bg: #0369a1 !important;
}

/* ==========================================================================
   Dark Mode Removal & Permanent Light Canvas
   ========================================================================== */
:root,
html,
html[data-theme="dark"],
html[data-theme="light"],
html[data-theme="auto"] {
  color-scheme: light !important;
}

@media (prefers-color-scheme: dark) {
  :root,
  html,
  body.portal-shell {
    color-scheme: light !important;
    --primary: #0284c7 !important;
    --secondary: #0f172a !important;
    --accent: #0284c7 !important;
    --primary-fg: #ffffff !important;
    --body-fg: #0f172a !important;
    --body-bg: #f8fafc !important;
    --body-quiet-color: #64748b !important;
    --body-loud-color: #090d16 !important;
    --header-color: #ffffff !important;
    --header-bg: #0f172a !important;
    --header-link-color: #ffffff !important;
    --breadcrumbs-fg: #64748b !important;
    --breadcrumbs-link-fg: #0284c7 !important;
    --breadcrumbs-bg: #ffffff !important;
    --link-fg: #0284c7 !important;
    --link-hover-color: #0369a1 !important;
    --hairline-color: #e2e8f0 !important;
    --border-color: #e2e8f0 !important;
    --darkened-bg: #f1f5f9 !important;
    --selected-bg: #e2e8f0 !important;
  }
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  color-scheme: light !important;
  --primary: #0284c7 !important;
  --secondary: #0f172a !important;
  --accent: #0284c7 !important;
  --primary-fg: #ffffff !important;
  --body-fg: #0f172a !important;
  --body-bg: #f8fafc !important;
  --body-quiet-color: #64748b !important;
  --body-loud-color: #090d16 !important;
  --header-color: #ffffff !important;
  --header-bg: #0f172a !important;
  --header-link-color: #ffffff !important;
  --breadcrumbs-fg: #64748b !important;
  --breadcrumbs-link-fg: #0284c7 !important;
  --breadcrumbs-bg: #ffffff !important;
  --link-fg: #0284c7 !important;
  --link-hover-color: #0369a1 !important;
  --hairline-color: #e2e8f0 !important;
  --border-color: #e2e8f0 !important;
  --darkened-bg: #f1f5f9 !important;
  --selected-bg: #e2e8f0 !important;
}

.theme-toggle,
button.theme-toggle,
#theme-toggle {
  display: none !important;
}

/* ==========================================================================
   Global Reset & Anti-Underline for Portal Shell
   Django admin 5+ adds a:not(...) { text-decoration: underline; }
   We override it globally so the portal looks like a modern business web app.
   ========================================================================== */
body.portal-shell a,
body.portal-shell a:link,
body.portal-shell a:visited,
body.portal-shell a:hover,
body.portal-shell a:focus,
body.portal-shell a:active {
  text-decoration: none !important;
}

body.portal-shell a {
  color: var(--portal-accent-blue);
  transition: color 0.15s ease, background-color 0.15s ease;
}

body.portal-shell a:hover {
  color: var(--portal-accent-blue-hover);
}

body.portal-shell {
  background-color: var(--portal-slate-50) !important;
  color: var(--portal-navy-900);
}

#header,
body.portal-shell #header {
  background: var(--portal-navy-900, #0f172a) !important;
  border-bottom: 1px solid var(--portal-navy-800, #1e293b) !important;
  color: #ffffff !important;
}

body.portal-shell #header a:not(.portal-user-menu-item),
body.portal-shell #header a:link:not(.portal-user-menu-item),
body.portal-shell #header a:visited:not(.portal-user-menu-item),
#header a:not(.portal-user-menu-item),
#header a:link:not(.portal-user-menu-item),
#header a:visited:not(.portal-user-menu-item) {
  color: #f1f5f9 !important;
}

body.portal-shell #header a:hover:not(.portal-user-menu-item),
#header a:hover:not(.portal-user-menu-item) {
  color: #38bdf8 !important;
}

body.portal-shell #user-tools {
  color: #94a3b8 !important;
  font-size: 0.85rem !important;
}

body.portal-shell #user-tools strong {
  color: #ffffff !important;
}

body.portal-shell #user-tools a {
  color: #38bdf8 !important;
}

body.portal-shell #user-tools a:hover {
  color: #7dd3fc !important;
}

body.portal-shell .breadcrumbs {
  background: #ffffff !important;
  border-bottom: 1px solid var(--portal-slate-200) !important;
  color: var(--portal-slate-500) !important;
  padding: 10px 24px !important;
  font-size: 0.85rem !important;
}

body.portal-shell .breadcrumbs a {
  color: var(--portal-accent-blue) !important;
  text-decoration: none !important;
  font-weight: 500;
}

body.portal-shell .breadcrumbs a:hover {
  color: var(--portal-accent-blue-hover) !important;
  text-decoration: none !important;
}

/* Connected Wi‑Fi in admin top bar (next to product name) */
.portal-branding-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.portal-branding-row #site-name {
  margin: 0;
  display: flex;
  align-items: center;
}

.portal-brand-text {
  display: flex;
  align-items: center;
  min-width: 0;
}

.portal-brand-text #site-name a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
  color: #ffffff !important;
}

.portal-brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.portal-brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(2, 132, 199, 0.25);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  line-height: 1.2;
}

.portal-brand-tagline {
  display: none;
}

.portal-topbar-wifi a {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--header-link-color, #fff);
  text-decoration: none;
  font-size: 0.9rem;
}

.portal-topbar-wifi a:hover {
  background: rgba(255, 255, 255, 0.2);
  text-decoration: none;
}

.portal-topbar-wifi-label {
  opacity: 0.75;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portal-topbar-wifi strong {
  font-weight: 700;
}

.portal-topbar-wifi-meta {
  opacity: 0.85;
  font-size: 0.85rem;
}

/* Admin-aligned portal layout */
.portal-layout {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 24px;
  width: 100%;
  box-sizing: border-box;
}

.portal-sidebar {
  flex: 0 0 240px;
  width: 240px;
  max-width: 240px;
  position: sticky;
  top: 16px;
  border: 1px solid var(--portal-navy-800);
  border-radius: 8px;
  background: var(--portal-navy-900);
  padding: 8px 0 0;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  color: var(--portal-slate-300);
  overflow: hidden;
}

.portal-sidebar-section {
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--portal-navy-800);
}

.portal-sidebar-section:last-of-type {
  border-bottom: none;
}

.portal-sidebar-heading {
  padding: 6px 16px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--portal-slate-400);
}

.portal-side-link {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  margin: 1px 8px;
  text-decoration: none !important;
  color: var(--portal-slate-300);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border-inline-start: 3px solid transparent;
}

.portal-side-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  text-decoration: none;
}

.portal-side-link.active {
  font-weight: 600;
  background: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
  border-inline-start-color: #38bdf8;
}

/* ==========================================================================
   TM MADAR Unified SVG Icon System
   Standard outline style (2px stroke), standard sizing (16px, 20px, 24px)
   ========================================================================== */
.tm-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

/* Sizing Standards: 16px inline, 20px actions/nav, 24px cards */
.tm-icon-sm,
.tm-icon-inline {
  width: 16px;
  height: 16px;
}

.tm-icon-md,
.tm-icon-action,
.tm-icon-nav {
  width: 20px;
  height: 20px;
}

.tm-icon-lg,
.tm-icon-card {
  width: 24px;
  height: 24px;
}

.tm-icon-xl {
  width: 32px;
  height: 32px;
}

/* Icon & Label alignment helper */
.tm-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  vertical-align: middle;
}

/* Directional icons in RTL */
[dir="rtl"] .tm-icon-directional,
.portal-rtl .tm-icon-directional {
  transform: scaleX(-1);
}

/* Semantic & Accent colors */
.tm-icon-success {
  stroke: var(--madar-success, #059669);
  color: var(--madar-success, #059669);
}

.tm-icon-danger {
  stroke: var(--madar-danger, #dc2626);
  color: var(--madar-danger, #dc2626);
}

.tm-icon-warning {
  stroke: var(--madar-warning, #d97706);
  color: var(--madar-warning, #d97706);
}

.tm-icon-info,
.tm-icon-brand {
  stroke: var(--madar-blue-500, #0284c7);
  color: var(--madar-blue-500, #0284c7);
}

.portal-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-inline-end: 10px;
  flex-shrink: 0;
  color: var(--portal-slate-400, #94a3b8);
  transition: color 0.15s ease;
}

.portal-side-link:hover .portal-nav-icon,
.portal-side-link:focus-visible .portal-nav-icon {
  color: #ffffff;
}

.portal-side-link.active .portal-nav-icon {
  color: #38bdf8;
}


.portal-sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--portal-navy-800);
  background: var(--portal-navy-950);
}

.portal-lang-switch label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--portal-slate-400);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portal-lang-switch select,
body.portal-shell .portal-sidebar-foot select,
body.portal-shell .portal-lang-switch select {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  width: 100% !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

body.portal-shell .portal-sidebar-foot select option,
body.portal-shell .portal-lang-switch select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
  font-size: 0.85rem !important;
  padding: 6px 10px !important;
}

body.portal-shell .portal-sidebar-foot select:focus,
body.portal-shell .portal-lang-switch select:focus {
  border-color: #0284c7 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25) !important;
}

.portal-main {
  flex: 1 1 auto;
  min-width: 0;
}

.portal-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.portal-toolbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.portal-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.portal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.portal-guide-steps {
  margin: 0.5rem 0 0.75rem 1.25rem;
  line-height: 1.55;
}

.portal-guide-steps li {
  margin-bottom: 0.65rem;
}

.portal-card {
  background: #ffffff;
  border: 1px solid var(--portal-slate-200);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.portal-card .label {
  color: var(--portal-slate-500);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portal-card .value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--portal-navy-900);
  margin-top: 4px;
  line-height: 1.25;
}

/* Badges */
.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 3px 8px;
  border-radius: 9999px;
  background: var(--portal-slate-100);
  color: var(--portal-navy-700);
  border: 1px solid var(--portal-slate-200);
  white-space: nowrap;
}

.portal-badge.present,
.portal-badge.success {
  background: var(--portal-success-bg);
  color: var(--portal-success);
  border-color: var(--portal-success-border);
}

.portal-badge.pending,
.portal-badge.warning {
  background: var(--portal-warning-bg);
  color: var(--portal-warning);
  border-color: var(--portal-warning-border);
}

.portal-badge.absent,
.portal-badge.late,
.portal-badge.danger {
  background: var(--portal-danger-bg);
  color: var(--portal-danger);
  border-color: var(--portal-danger-border);
}

.portal-badge.leave {
  background: #f5f3ff;
  color: #7c3aed;
  border-color: #ddd6fe;
}


.portal-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background: var(--darkened-bg, #f8f8f8);
}

.portal-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  margin: 0;
}

.portal-filters input,
.portal-filters select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.portal-filters .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-top: 0;
  align-self: end;
  min-height: 32px;
}

.portal-filters .filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 0;
  align-self: end;
}

.portal-filters .filter-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  padding-top: 4px;
}

.portal-filters .filter-presets .button {
  padding: 4px 10px;
  font-size: 0.85rem;
}

.portal-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.portal-inline-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  margin: 0;
}

.portal-inline-form input[type="text"],
.portal-toolbar-actions input[type="text"] {
  min-height: 32px;
  padding: 4px 10px;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  font: inherit;
  background: var(--body-bg, #fff);
  color: var(--body-fg, #333);
}

/* ==========================================================================
   Portal Buttons — Executive Business Palette & Hierarchy
   ========================================================================== */
body.portal-shell .button,
body.portal-shell a.button,
body.portal-shell button:not(.portal-user-trigger):not(.portal-user-menu-item),
body.portal-shell input[type="submit"],
body.portal-shell input[type="button"],
body.portal-shell .submit-row input,
body.portal-shell .object-tools a {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.35rem !important;
  min-height: 34px !important;
  padding: 6px 14px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  line-height: 1.25 !important;
  vertical-align: middle !important;
  text-decoration: none !important;
  cursor: pointer !important;
  border-radius: 6px !important;
  border: 1px solid var(--portal-slate-300, #cbd5e1) !important;
  background: #ffffff !important;
  color: var(--portal-navy-900, #0f172a) !important;
  font-weight: 500 !important;
  font-size: 0.85rem !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
  transition: all 0.15s ease !important;
}

body.portal-shell .button:hover,
body.portal-shell a.button:hover,
body.portal-shell button:not(.portal-user-trigger):not(.portal-user-menu-item):hover,
body.portal-shell input[type="submit"]:hover,
body.portal-shell input[type="button"]:hover,
body.portal-shell .submit-row input:hover,
body.portal-shell .object-tools a:hover {
  background: var(--portal-slate-100, #f1f5f9) !important;
  border-color: var(--portal-slate-400, #94a3b8) !important;
  color: var(--portal-navy-950, #090d16) !important;
  text-decoration: none !important;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08) !important;
}

/* Primary Default Buttons */
body.portal-shell .button.default,
body.portal-shell a.button.default,
body.portal-shell button.default,
body.portal-shell input[type="submit"].default,
body.portal-shell input[type="button"].default,
body.portal-shell .submit-row input.default {
  background: var(--portal-accent-blue, #0284c7) !important;
  border-color: var(--portal-accent-blue, #0284c7) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.25) !important;
}

body.portal-shell .button.default:hover,
body.portal-shell a.button.default:hover,
body.portal-shell button.default:hover,
body.portal-shell input[type="submit"].default:hover,
body.portal-shell input[type="button"].default:hover,
body.portal-shell .submit-row input.default:hover {
  background: var(--portal-accent-blue-hover, #0369a1) !important;
  border-color: var(--portal-accent-blue-hover, #0369a1) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35) !important;
}

/* Danger / Delete Buttons */
body.portal-shell .button.portal-btn-danger,
body.portal-shell a.button.portal-btn-danger,
body.portal-shell button.portal-btn-danger,
body.portal-shell .button.deletelink,
body.portal-shell a.deletelink {
  background: #ffffff !important;
  border-color: var(--portal-danger-border, #fecaca) !important;
  color: var(--portal-danger, #dc2626) !important;
  text-decoration: none !important;
}

body.portal-shell .button.portal-btn-danger:hover,
body.portal-shell a.button.portal-btn-danger:hover,
body.portal-shell button.portal-btn-danger:hover,
body.portal-shell .button.deletelink:hover,
body.portal-shell a.deletelink:hover {
  background: var(--portal-danger-bg, #fef2f2) !important;
  border-color: var(--portal-danger, #dc2626) !important;
  color: var(--portal-danger, #dc2626) !important;
  text-decoration: none !important;
}

body.portal-shell .button:disabled,
body.portal-shell a.button:disabled,
body.portal-shell button:disabled,
body.portal-shell input[type="submit"]:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* Segmented View Switcher (List vs Board) */
.portal-view-switcher {
  display: inline-flex;
  border: 1px solid var(--portal-slate-300, #cbd5e1);
  border-radius: 6px;
  overflow: hidden;
  background: var(--portal-slate-100, #f1f5f9);
  padding: 2px;
  gap: 2px;
}

.portal-view-switcher .button,
.portal-view-switcher a.button,
.portal-view-switcher span.button {
  border: none !important;
  border-radius: 4px !important;
  padding: 4px 10px !important;
  min-height: 28px !important;
  font-size: 0.82rem !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--portal-slate-500, #64748b) !important;
  text-decoration: none !important;
}

.portal-view-switcher .button.default,
.portal-view-switcher span.button.default {
  background: #ffffff !important;
  color: var(--portal-navy-900, #0f172a) !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08) !important;
}

/* Form controls matching new theme */
body.portal-shell .form-control,
body.portal-shell .portal-input,
body.portal-shell .portal-select,
body.portal-shell input[type="text"],
body.portal-shell input[type="search"],
body.portal-shell input[type="email"],
body.portal-shell input[type="password"],
body.portal-shell input[type="number"],
body.portal-shell input[type="date"],
body.portal-shell input[type="datetime-local"],
body.portal-shell input[type="tel"],
body.portal-shell input[type="url"],
body.portal-shell select,
body.portal-shell textarea {
  border: 1px solid var(--portal-slate-300, #cbd5e1) !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 0.875rem !important;
  background-color: #ffffff !important;
  color: var(--portal-navy-900, #0f172a) !important;
  box-sizing: border-box !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

body.portal-shell select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

body.portal-shell .form-control:focus,
body.portal-shell .portal-input:focus,
body.portal-shell .portal-select:focus,
body.portal-shell input:focus,
body.portal-shell select:focus,
body.portal-shell textarea:focus {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: var(--portal-accent-blue, #0284c7) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15) !important;
}

.portal-toolbar-actions {
  align-items: center;
}

.portal-toolbar-actions form {
  margin: 0;
}

.portal-main .module {
  margin-bottom: 1rem;
  overflow: hidden;
}

.portal-main .module > h2:first-child,
.portal-main .module > h3:first-child {
  margin-top: 0;
}

/* Reset Django admin's .module h2 / h3 dark background & padding inside portal */
body.portal-shell .module h2,
body.portal-shell .module h3,
body.portal-shell .portal-main .module h2,
body.portal-shell .portal-main .module h3,
.portal-main .module h2,
.portal-main .module h3,
.portal-card-box h2,
.portal-card-box h3 {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-weight: inherit;
  font-size: inherit;
}

body.portal-shell .portal-main .module p,
body.portal-shell .portal-main .module ul,
body.portal-shell .portal-main .module ol {
  padding-left: 0;
  padding-right: 0;
}

/* Portal accessible tables inside modules & details */
.portal-datatable {
  width: 100%;
  border-collapse: collapse;
}

.portal-datatable th {
  background: #f8fafc !important;
  color: #475569 !important;
  font-weight: 600 !important;
  padding: 6px 10px !important;
  border-bottom: 1px solid #e2e8f0 !important;
  font-size: 0.8rem !important;
  text-align: start;
}

.portal-datatable td {
  padding: 6px 10px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  color: #1e293b !important;
  font-size: 0.8rem !important;
  vertical-align: middle;
}

.portal-datatable tr:hover td {
  background: #f8fafc !important;
}

.portal-table-wrap td .button,
.portal-table-wrap td button {
  white-space: nowrap;
  padding: 4px 10px;
  min-height: 28px;
  font-size: 0.85rem;
}

.portal-code-block {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--darkened-bg, #f8f8f8);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  padding: 0.75rem 0.85rem;
  margin: 0.5rem 0;
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-x: auto;
}

.portal-guide-highlight {
  border-inline-start: 4px solid var(--header-bg, #417690);
  padding-inline-start: 1rem;
}

.portal-secret-box {
  border: 1px solid #d4a017;
  background: #fffbeb;
  border-radius: 4px;
  padding: 0.7rem 0.85rem;
  margin: 0 0 1rem;
}

.portal-secret-box-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.55rem;
}

.portal-secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-top: 0.4rem;
}

.portal-secret-label {
  font-weight: 600;
  min-width: 7.5rem;
}

.portal-secret-value {
  background: #fff;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 3px;
  padding: 0.25rem 0.45rem;
  word-break: break-all;
}

.portal-guide-details {
  margin-top: 0.75rem;
}

.portal-guide-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--body-quiet-color, #666);
}

.portal-guide-details ul {
  margin: 0.5rem 0 0 1.1rem;
}

.portal-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.portal-chart-box {
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  padding: 12px;
  background: var(--body-bg, #fff);
}

.portal-chart-box h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.portal-chart-box canvas {
  width: 100% !important;
  max-height: 260px;
}

.portal-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.portal-detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline-color, #eee);
}

.portal-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}

.portal-badge.present { background: #d1fae5; color: #065f46; }
.portal-badge.late { background: #fee2e2; color: #991b1b; }
.portal-badge.pending { background: #fef3c7; color: #92400e; }
.portal-badge.missing { background: #ffedd5; color: #9a3412; }
.portal-badge.absent { background: #e5e7eb; color: #374151; }
.portal-badge.leave { background: #dbeafe; color: #1e40af; }

.portal-late-mins {
  font-weight: 700;
  color: #b91c1c;
  font-variant-numeric: tabular-nums;
}

.portal-late-mins.is-zero {
  font-weight: 500;
  color: var(--body-quiet-color, #666);
}

.portal-ot-mins {
  font-weight: 700;
  color: #1d4ed8;
  font-variant-numeric: tabular-nums;
}

.portal-ot-mins.is-zero {
  font-weight: 500;
  color: var(--body-quiet-color, #666);
}

.portal-card-link.portal-kpi-late .value,
.portal-kpi-late .value {
  color: #b91c1c;
}

.portal-card-link.portal-kpi-missing .value,
.portal-kpi-missing .value {
  color: #c2410c;
}

.portal-card-link.portal-kpi-ot .value,
.portal-kpi-ot .value {
  color: #1d4ed8;
}

/* DataTables — stable layout inside Django admin portal */
.portal-table-wrap.results,
.portal-table-wrap {
  overflow-x: visible;
}

.portal-table-wrap .dataTables_wrapper {
  width: 100%;
  clear: both;
  margin-bottom: 16px;
}

.portal-table-wrap .portal-dt-toolbar,
.portal-table-wrap .portal-dt-footer,
.ess-table-wrap .portal-dt-toolbar,
.ess-table-wrap .portal-dt-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0.35rem 0 0.75rem;
}

.portal-table-wrap .portal-dt-footer,
.ess-table-wrap .portal-dt-footer {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.portal-table-wrap .dataTables_length,
.portal-table-wrap .dataTables_filter,
.portal-table-wrap .dataTables_info,
.portal-table-wrap .dataTables_paginate,
.ess-table-wrap .dataTables_length,
.ess-table-wrap .dataTables_filter,
.ess-table-wrap .dataTables_info,
.ess-table-wrap .dataTables_paginate {
  float: none !important;
  text-align: start;
  font-size: 0.9rem;
  color: var(--body-quiet-color, #666);
  margin: 0;
  padding: 0;
}

.portal-table-wrap .dataTables_filter,
.ess-table-wrap .dataTables_filter {
  margin-inline-start: auto;
}

.portal-table-wrap .dataTables_wrapper .dataTables_filter input,
.portal-table-wrap .dataTables_wrapper .dataTables_length select,
.ess-table-wrap .dataTables_wrapper .dataTables_filter input,
.ess-table-wrap .dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border-color, #ccc);
  border-radius: 3px;
  padding: 0.3rem 0.45rem;
  margin-inline-start: 0.35rem;
  background: #fff;
  color: var(--body-fg, #333);
  max-width: 14rem;
}

.portal-table-wrap .dataTables_scroll,
.ess-table-wrap .dataTables_scroll {
  clear: both;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background: #fff;
}

.portal-table-wrap .dataTables_scrollHead,
.ess-table-wrap .dataTables_scrollHead {
  background: var(--darkened-bg, #f8f8f8);
}

.portal-table-wrap .dataTables_scrollBody,
.ess-table-wrap .dataTables_scrollBody {
  overflow-x: auto !important;
}

.portal-table-wrap table.dataTable,
.ess-table-wrap table.dataTable {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: collapse !important;
}

.portal-table-wrap table.dataTable thead th,
.ess-table-wrap table.dataTable thead th {
  border-bottom: 1px solid var(--border-color, #ccc);
  white-space: nowrap;
  vertical-align: middle;
}

.portal-table-wrap table.dataTable tbody td,
.ess-table-wrap table.dataTable tbody td {
  vertical-align: middle;
  white-space: nowrap;
}

.portal-table-wrap table.dataTable.no-footer,
.ess-table-wrap table.dataTable.no-footer {
  border-bottom: 0;
}

.portal-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button,
.ess-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 0.25rem 0.5rem !important;
  margin: 0 2px !important;
  border: 1px solid transparent !important;
  border-radius: 3px !important;
  background: transparent !important;
  color: var(--link-fg, #447e9b) !important;
  box-shadow: none !important;
}

.portal-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.ess-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button.current {
  border-color: var(--border-color, #ccc) !important;
  background: var(--darkened-bg, #f8f8f8) !important;
  color: var(--body-fg, #333) !important;
  font-weight: 700;
}

.portal-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.ess-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--selected-bg, #e4f0f5) !important;
  border-color: var(--border-color, #ccc) !important;
  color: var(--body-fg, #333) !important;
}

.portal-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.portal-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,
.ess-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.ess-table-wrap .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  color: #aaa !important;
  background: transparent !important;
  border-color: transparent !important;
}

.portal-row-connected {
  background: color-mix(in srgb, var(--selected-bg, #e4f0f5) 80%, transparent);
}

.portal-table-wrap {
  overflow-x: visible;
  margin-bottom: 16px;
}

.portal-table-wrap table {
  width: 100%;
}

.portal-result-meta {
  margin: 0 0 12px;
  color: var(--body-quiet-color, #666);
}

.portal-home-module {
  margin-bottom: 20px;
}

.portal-link-list {
  margin: 12px 16px 16px;
  padding: 0;
  list-style: none;
}

.portal-records-note {
  margin: 0 0 12px;
  color: var(--body-quiet-color, #666);
}

.portal-records-group {
  margin-bottom: 16px;
}

.portal-records-group h2 {
  margin: 0;
}

.portal-records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding: 12px;
}

.portal-record-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background: var(--body-bg, #fff);
  padding: 12px;
  min-height: 110px;
}

.portal-record-title {
  display: inline-block;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--link-fg, #447e9b);
}

.portal-record-title:hover {
  text-decoration: underline;
}

.portal-record-card-body p {
  margin: 6px 0 0;
  font-size: 0.85rem;
}

.portal-record-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.portal-record-card-actions .button {
  padding: 4px 10px;
  font-size: 0.85rem;
}

.paginator {
  margin: 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.paginator a,
.paginator .this-page {
  display: inline-block;
  min-width: 1.5rem;
  text-align: center;
  padding: 4px 8px;
  border-radius: 4px;
}

.paginator .this-page {
  font-weight: 700;
  background: var(--selected-bg, #e4f0f5);
}

/* Hide Django admin app-list sidebar — we use portal-sidebar instead */
body.portal-shell #nav-sidebar,
body.portal-shell .toggle-nav-sidebar,
body.portal-shell #toggle-nav-sidebar {
  display: none !important;
}

body.portal-shell #main {
  margin-left: 0 !important;
}

@media (max-width: 900px) {
  .portal-layout {
    flex-direction: column;
  }

  .portal-sidebar {
    position: static;
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 8px;
  }

  .portal-sidebar-section {
    border-bottom: none;
    padding: 0 8px 0 0;
    min-width: 140px;
  }

  .portal-profile-grid {
    grid-template-columns: 1fr;
  }
}

/* Action Center (Phase 10A) */
.portal-section {
  margin-bottom: 1.5rem;
}

.portal-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.portal-attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-attention-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color, #ccc);
  border-left-width: 4px;
  border-radius: 4px;
  background: var(--body-bg, #fff);
}

.portal-attention-item.severity-high {
  border-left-color: #dc2626;
}

.portal-attention-item.severity-medium {
  border-left-color: #d97706;
}

.portal-attention-item.severity-low {
  border-left-color: #6b7280;
}

.portal-attention-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1 1 220px;
}

.portal-attention-count {
  flex: 0 0 auto;
  min-width: 2rem;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.portal-attention-title {
  font-weight: 600;
}

.portal-attention-detail {
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--body-quiet-color, #666);
}

.portal-attention-empty p {
  margin: 0.5rem 0;
}

.portal-card-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.portal-card-link:hover {
  border-color: var(--link-fg, #417690);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--link-fg, #417690) 25%, transparent);
}

.portal-jump-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.75rem;
}

.portal-attention-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.portal-attention-actions .portal-inline-form {
  margin: 0;
}

/* Compact stacked forms used by checklist / asset editors */
.portal-stack-form {
  display: grid;
  gap: 0.65rem;
  max-width: 720px;
}

.portal-stack-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
  align-items: end;
}

.portal-stack-form label,
.module label {
  display: block;
  margin-bottom: 0.55rem;
  font-weight: 600;
}

.portal-stack-form input[type="text"],
.portal-stack-form input[type="number"],
.portal-stack-form input[type="date"],
.portal-stack-form input[type="datetime-local"],
.portal-stack-form select,
.portal-stack-form textarea,
.module input[type="text"],
.module input[type="number"],
.module input[type="date"],
.module input[type="datetime-local"],
.module select,
.module textarea {
  width: 100%;
  max-width: 100%;
  margin-top: 0.25rem;
  box-sizing: border-box;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500 !important;
}

.checkbox-row input {
  width: auto !important;
  margin: 0 !important;
}

.portal-item-editor {
  display: grid;
  gap: 0.5rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--hairline-color, #e8e8e8);
}

.portal-item-editor:last-child {
  border-bottom: none;
}

.portal-item-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.portal-sidebar-foot {
  padding: 10px 14px 6px;
  border-top: 1px solid var(--hairline-color, #e8e8e8);
  margin-top: 4px;
}

.portal-lang-switch {
  display: block;
}

.portal-lang-switch label {
  display: block;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--body-quiet-color, #666);
}

.portal-lang-switch select {
  width: 100%;
  margin-top: 4px;
  max-width: 100%;
}

/* RTL: keep natural document direction; only tweak text alignment */
.portal-rtl .portal-sidebar,
html[dir="rtl"] .portal-sidebar {
  text-align: right;
}

.portal-rtl table,
html[dir="rtl"] table {
  text-align: right;
}

/* Mobile polish for approve queues / portal tables */
@media (max-width: 900px) {
  .portal-layout {
    flex-direction: column !important;
  }

  .portal-sidebar {
    position: static;
    width: 100%;
    max-width: none;
    flex: none;
  }

  .portal-sidebar-section {
    padding: 8px 10px;
  }

  .portal-sidebar-heading {
    padding: 4px 4px 6px;
  }

  .portal-side-link {
    display: inline-block;
    margin: 0 2px 4px 0;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    border-inline-start-width: 1px;
    background: var(--body-bg, #fff);
  }

  .portal-side-link.active {
    border-color: var(--link-fg, #447e9b);
    background: var(--selected-bg, #e4f0f5);
  }

  .portal-sidebar-foot {
    border-top: none;
    padding-top: 0;
  }

  .portal-lang-switch select {
    max-width: 12rem;
  }

  .portal-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .portal-toolbar-actions,
  .portal-toolbar > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .portal-filters {
    grid-template-columns: 1fr !important;
  }

  .portal-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .portal-table-wrap table {
    min-width: 520px;
  }

  .portal-attention-actions {
    width: 100%;
  }

  .portal-attention-actions .button,
  .portal-attention-actions button {
    flex: 1 1 auto;
    min-height: 40px;
  }

  .portal-profile-grid {
    grid-template-columns: 1fr !important;
  }

  .portal-stack-form-row {
    grid-template-columns: 1fr;
  }
}

/* —— Browser print (office printers via OS dialog) —— */
.print-only {
  display: none !important;
}

@media print {
  @page {
    margin: 12mm;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt !important;
  }

  .print-only {
    display: block !important;
  }

  .no-print,
  #header,
  .breadcrumbs,
  .portal-sidebar,
  .portal-filters,
  .portal-toolbar-actions,
  .portal-guide,
  .messagelist,
  .filter-presets,
  .filter-actions,
  .portal-attention-actions,
  .dataTables_length,
  .dataTables_filter,
  .dataTables_info,
  .dataTables_paginate,
  .dataTables_processing,
  .dt-buttons {
    display: none !important;
  }

  .portal-layout {
    display: block !important;
  }

  .portal-main {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .portal-toolbar {
    margin-bottom: 0.5rem !important;
    border-bottom: 1px solid #999;
    padding-bottom: 0.35rem;
  }

  .portal-toolbar h1 {
    font-size: 16pt !important;
    margin: 0 !important;
  }

  .print-doc-header {
    display: flex !important;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #333;
    font-size: 10pt;
  }

  .print-doc-header strong {
    font-size: 12pt;
  }

  .portal-cards {
    break-inside: avoid;
  }

  .portal-card,
  .module {
    box-shadow: none !important;
    break-inside: avoid;
  }

  .portal-table-wrap,
  .dataTables_wrapper,
  .dataTables_scroll,
  .dataTables_scrollBody {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    width: 100% !important;
  }

  .dataTables_scrollHead {
    display: none !important;
  }

  table {
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: collapse !important;
  }

  table th,
  table td {
    border: 1px solid #bbb !important;
    padding: 4px 6px !important;
    font-size: 9pt !important;
    color: #000 !important;
    background: #fff !important;
  }

  table thead th {
    background: #eee !important;
    font-weight: 700 !important;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  a[href]::after {
    content: none !important;
  }
}

/* Fingerprint enrollment (employee profile) */
.fp-device-card {
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  padding: 12px 14px;
  margin: 0 0 12px;
  background: var(--body-bg, #fff);
}
.fp-device-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  margin-bottom: 8px;
}
.fp-device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.fp-finger-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fp-finger-item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
}
.fp-finger-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Attendance onboarding readiness */
.onboarding-panel {
  border-bottom: 1px solid var(--border-color, #ddd);
  padding-bottom: 1rem;
  margin-bottom: 0.5rem;
}
.onboarding-overall {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  letter-spacing: 0.01em;
}
.onboarding-overall--ready { background: #d1fae5; color: #065f46; }
.onboarding-overall--attention_required { background: #fee2e2; color: #991b1b; }
.onboarding-overall--in_progress { background: #fef3c7; color: #92400e; }
.onboarding-overall--not_started { background: #e5e7eb; color: #4b5563; }
.onboarding-steps {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.onboarding-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.onboarding-step-mark {
  width: 1.25rem;
  text-align: center;
  font-weight: 700;
  flex-shrink: 0;
}
.onboarding-step--complete .onboarding-step-mark { color: #047857; }
.onboarding-step--failed .onboarding-step-mark { color: #b91c1c; }
.onboarding-step--warning .onboarding-step-mark { color: #b45309; }
.onboarding-step--pending .onboarding-step-mark { color: #6b7280; }
.onboarding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-top: 0.75rem;
}
.onboarding-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.onboarding-ready-msg {
  margin: 0;
  color: #047857;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: color-mix(in srgb, #d1fae5 55%, var(--body-bg, #fff));
  border: 1px solid color-mix(in srgb, #047857 18%, #e5e7eb);
}
.attendance-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
}
.attendance-badge--ready { background: #d1fae5; color: #065f46; }
.attendance-badge--attention { background: #fee2e2; color: #991b1b; }
.attendance-badge--setup { background: #fef3c7; color: #92400e; }

/* Employees list — directory layout */
.employees-page__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1.1rem;
}
.employees-page__header h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.employees-page__subtitle {
  margin: 0.25rem 0 0;
  color: var(--body-quiet-color, #667);
  font-size: 0.9rem;
}
.employees-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.employees-page__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  align-items: center;
  margin: 0 0 1rem;
}
.employees-page__filters input[type="search"] {
  flex: 1 1 14rem;
  min-width: min(100%, 14rem);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color, #d0d0d0);
  border-radius: 6px;
  background: var(--body-bg, #fff);
}
.employees-page__filters select {
  min-width: 11rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-color, #d0d0d0);
  border-radius: 6px;
  background: var(--body-bg, #fff);
}
.employees-page__clear {
  color: var(--body-quiet-color, #666);
  text-decoration: none;
  font-size: 0.88rem;
}
.employees-page__clear:hover { text-decoration: underline; }
.employees-page__table-wrap {
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  background: var(--body-bg, #fff);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.employees-page__table {
  margin: 0 !important;
  width: 100% !important;
  border-collapse: collapse;
}
.employees-page__table thead th {
  padding: 0.7rem 1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--body-quiet-color, #6b7280);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color, #e8e8e8);
  background: color-mix(in srgb, var(--body-bg, #fff) 94%, #000 6%);
  text-align: start;
}
.employees-page__table tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-top: 1px solid var(--hairline-color, #f0f0f0);
}
.employees-page__table tbody tr:first-child td { border-top: 0; }
.employees-page__table tbody tr {
  transition: background 0.12s ease;
}
.employees-page__table tbody tr:hover td {
  background: color-mix(in srgb, var(--body-bg, #fff) 93%, #2563eb 7%);
}
.employees-page__person {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: inherit;
}
.employees-page__name {
  font-weight: 600;
  color: var(--body-fg, #111);
  letter-spacing: -0.01em;
}
.employees-page__person:hover .employees-page__name {
  color: var(--link-fg, #2563eb);
}
.employees-page__code {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--body-quiet-color, #6b7280);
}
.employees-page__col-status {
  text-align: end;
  white-space: nowrap;
}
.employees-page__empty {
  padding: 3rem 1.25rem;
  text-align: center;
  color: var(--body-quiet-color, #666);
}
.employees-page__empty .button { margin-top: 0.85rem; }
.employees-page__pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.9rem;
}
.employees-page__help {
  margin-top: 1.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color, #ececec);
  color: var(--body-quiet-color, #666);
  font-size: 0.88rem;
}
.employees-page__help summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.employees-page__help summary::-webkit-details-marker { display: none; }
.employees-page__help-body { margin-top: 0.5rem; max-width: 36rem; }

/* Employee profile — hero + two-column setup */
.employee-profile {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.employee-profile > .module,
.employee-profile > details.module {
  margin-bottom: 0;
}
/* Default reading order: setup → attendance → extras */
.employee-profile__hero { order: 0; }
.employee-profile__grid { order: 1; }
.employee-profile__attendance { order: 2; }
.employee-profile__charts { order: 3; }
.employee-profile__checklists { order: 4; }
.employee-profile__recent-attendance { order: 5; }
.employee-profile__recent-punches { order: 6; }
/* Once ready, prioritize attendance history over setup */
.employee-profile--ready .employee-profile__attendance { order: 1; }
.employee-profile--ready .employee-profile__grid { order: 2; }
.employee-profile--ready .onboarding-panel {
  padding-bottom: 0.65rem;
  margin-bottom: 0.15rem;
}
.employee-profile--ready .onboarding-steps--grid {
  margin-bottom: 0.4rem;
}
.employee-profile__hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, #e8e8e8);
}
.employee-profile__back {
  display: inline-block;
  margin-bottom: 0.45rem;
  font-size: 0.84rem;
  color: var(--body-quiet-color, #6b7280);
  text-decoration: none;
}
.employee-profile__back:hover { color: var(--link-fg, #2563eb); }
.employee-profile__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
}
.employee-profile__title-row h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.employee-profile__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.35rem;
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
}
.employee-profile__meta li {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--body-bg, #fff) 92%, #000 8%);
  font-size: 0.84rem;
}
.employee-profile__meta-label {
  color: var(--body-quiet-color, #6b7280);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.employee-profile__hero-actions {
  display: flex;
  gap: 0.5rem;
}
.employee-profile__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(16rem, 0.9fr);
  gap: 1.15rem;
  align-items: start;
}
.employee-profile__primary > .module {
  margin: 0;
}
.employee-profile__aside .module {
  margin: 0;
  position: sticky;
  top: 0.75rem;
}
.employee-profile__dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.employee-profile__dl > div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}
.employee-profile__dl dt {
  margin: 0;
  color: var(--body-quiet-color, #6b7280);
  font-size: 0.8rem;
  font-weight: 500;
}
.employee-profile__dl dd {
  margin: 0;
  font-size: 0.92rem;
}
.employee-profile__hint { margin: 0.2rem 0 0.85rem; }
.employee-profile__h2 {
  margin: 1.1rem 0 0.55rem;
  font-size: 1rem;
  font-weight: 650;
}
.employee-profile__h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.employee-profile__filters {
  margin: 0 0 0.85rem;
  padding: 0;
  border: 0;
  background: transparent;
}
.employee-profile__kpis {
  margin: 0 0 1rem;
  gap: 0.6rem;
}
.employee-profile__kpis .portal-card {
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.employee-profile__kpis .portal-card .label { font-size: 0.74rem; }
.employee-profile__kpis .portal-card .value { font-size: 1.2rem; }

.onboarding-panel {
  border-bottom: 1px solid var(--border-color, #ececec);
  padding-bottom: 1rem;
  margin-bottom: 0.35rem;
}
.onboarding-panel__head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.onboarding-steps--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.55rem;
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
}
.onboarding-steps--grid .onboarding-step {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  background: color-mix(in srgb, var(--body-bg, #fff) 97%, #000 3%);
  min-height: 4.25rem;
}
.onboarding-steps--grid .onboarding-step-mark {
  width: auto;
  font-size: 0.9rem;
}
.onboarding-steps--grid .onboarding-step-body strong {
  display: block;
  font-size: 0.84rem;
  line-height: 1.25;
}
.onboarding-steps--grid .onboarding-step-body .quiet {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  line-height: 1.35;
}
.onboarding-step--complete {
  border-color: color-mix(in srgb, #047857 28%, #e5e7eb);
  background: color-mix(in srgb, #d1fae5 35%, var(--body-bg, #fff));
}
.onboarding-step--failed {
  border-color: color-mix(in srgb, #b91c1c 30%, #e5e7eb);
}
.onboarding-step--warning {
  border-color: color-mix(in srgb, #b45309 30%, #e5e7eb);
}
.employee-profile--ready .onboarding-steps--grid .onboarding-step--complete .quiet {
  display: none;
}

.fp-device-card {
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.employee-profile__charts > summary {
  cursor: pointer;
  list-style: none;
}
.employee-profile__charts > summary::-webkit-details-marker { display: none; }
.employee-profile__charts > summary h2 {
  display: inline;
  margin: 0;
  font-size: 1.05rem;
}
.employee-profile__charts > summary::before {
  content: "▸ ";
  color: var(--body-quiet-color, #666);
}
.employee-profile__charts[open] > summary::before { content: "▾ "; }
.employee-profile__charts .portal-charts { margin-top: 0.85rem; }
.employee-profile__charts .portal-chart-box h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

@media (max-width: 960px) {
  .employee-profile__grid {
    grid-template-columns: 1fr;
  }
  .employee-profile__aside .module {
    position: static;
  }
}

@media (max-width: 640px) {
  .employees-page__table thead th:nth-child(3),
  .employees-page__table tbody td:nth-child(3) {
    display: none;
  }
  .onboarding-steps--grid {
    grid-template-columns: 1fr 1fr;
  }
  .employee-profile__dl > div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .employee-profile__meta li {
    font-size: 0.8rem;
  }
}

.fp-enroll-modal[hidden] { display: none !important; }

/* Setup wizard (Phase 1.1) */
.setup-wizard-shell #container {
  max-width: 52rem;
  margin: 0 auto;
}
.setup-wizard {
  padding: 1.25rem 1rem 2.5rem;
}
.setup-wizard__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.setup-wizard__eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--body-quiet-color, #6b7280);
  font-weight: 600;
}
.setup-wizard__header h1 {
  margin: 0;
  font-size: 1.45rem;
}
.setup-wizard__lead {
  margin: 0.35rem 0 0;
  max-width: 36rem;
}
.setup-wizard__progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
}
.setup-wizard__step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--body-bg, #fff) 92%, #000 8%);
  font-size: 0.8rem;
  color: var(--body-quiet-color, #6b7280);
}
.setup-wizard__step.is-current {
  background: color-mix(in srgb, #2563eb 18%, var(--body-bg, #fff));
  color: var(--body-fg, #111);
  font-weight: 600;
}
.setup-wizard__step.is-done:not(.is-current) {
  color: #047857;
}
.setup-wizard__step-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.setup-wizard__body {
  padding: 1rem 1.1rem 1.15rem;
}
.setup-wizard__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.setup-wizard__next {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
}
.setup-weekend {
  margin: 1rem 0;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}
.setup-weekend__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}
.setup-weekend__item,
.setup-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 0;
}
.setup-summary {
  margin-bottom: 1rem;
}
.setup-complete ul {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}
.setup-complete li {
  margin: 0.4rem 0;
}
.fp-enroll-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.fp-enroll-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.fp-enroll-dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--body-bg, #fff);
  color: var(--body-fg, #333);
  border-radius: 6px;
  padding: 18px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.fp-enroll-steps {
  list-style: none;
  margin: 12px 0;
  padding: 0;
}
.fp-enroll-steps li {
  padding: 4px 0 4px 18px;
  position: relative;
  opacity: 0.45;
}
.fp-enroll-steps li::before {
  content: "?";
  position: absolute;
  left: 0;
}
.fp-enroll-steps li.is-active {
  opacity: 1;
  font-weight: 600;
}
.fp-enroll-steps li.is-active::before { content: "?"; }
.fp-enroll-steps li.is-done {
  opacity: 0.85;
}
.fp-enroll-steps li.is-done::before { content: "?"; }
.fp-enroll-message.is-success { color: #047857; }
.fp-enroll-message.is-error { color: #b91c1c; }
.fp-enroll-message.is-info { color: inherit; }
.fp-enroll-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
body.fp-enroll-open {
  overflow: hidden;
}

/* Phase 1.3 workflow empty states + payroll steps */
.portal-empty {
  padding: 2rem 1.25rem;
  text-align: center;
}
.portal-empty__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.85rem;
}
.payroll-steps {
  list-style: none;
  margin: 0 0 1.15rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.65rem;
}
.payroll-steps__item {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  background: var(--body-bg, #fff);
}
.payroll-steps__item.is-attention {
  border-color: color-mix(in srgb, #b45309 35%, #e5e7eb);
}
.payroll-steps__num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: color-mix(in srgb, #2563eb 18%, var(--body-bg, #fff));
}
.payroll-steps__item p.help {
  margin: 0.2rem 0 0;
}

/* ==========================================================================
   Responsive Shell (Mobile & Tablet) + RTL Support
   ========================================================================== */
@media (max-width: 900px) {
  .portal-layout {
    flex-direction: column !important;
    gap: 16px;
  }
  .portal-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
  }
  .portal-sidebar-section {
    flex: 1 1 200px;
    border-bottom: none;
    border-inline-end: 1px solid var(--portal-navy-800);
    padding: 0 8px;
  }
  .portal-sidebar-foot {
    flex: 1 1 100%;
    border-top: 1px solid var(--portal-navy-800);
    margin-top: 8px;
    border-radius: 6px;
  }
}

@media (max-width: 600px) {
  .portal-sidebar-section {
    flex: 1 1 100%;
    border-inline-end: none;
    border-bottom: 1px solid var(--portal-navy-800);
    padding-bottom: 8px;
  }
  .portal-cards {
    grid-template-columns: 1fr;
  }
  .portal-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   User Menu Dropdown & Profile UI (Phase 2B)
   ========================================================================== */
body.portal-shell #header,
body.portal-shell #header .portal-branding-row,
body.portal-shell #user-tools {
  overflow: visible !important;
}

body.portal-shell #user-tools.portal-user-tools {
  display: flex !important;
  align-items: center !important;
  margin-inline-start: auto !important;
  position: relative !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
}

.portal-user-dropdown {
  position: relative !important;
  display: inline-block !important;
}

body.portal-shell #header #user-tools button.portal-user-trigger,
body.portal-shell #user-tools button.portal-user-trigger,
body.portal-shell button.portal-user-trigger,
#header button.portal-user-trigger,
button.portal-user-trigger {
  display: inline-flex !important;
  align-items: center !important;
  gap: 9px !important;
  padding: 4px 14px 4px 6px !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  border-radius: 9999px !important;
  color: #ffffff !important;
  cursor: pointer !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  outline: none !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12) !important;
}

body.portal-shell #header #user-tools button.portal-user-trigger:hover,
body.portal-shell #header #user-tools button.portal-user-trigger:focus-visible,
body.portal-shell #user-tools button.portal-user-trigger:hover,
body.portal-shell #user-tools button.portal-user-trigger:focus-visible,
body.portal-shell button.portal-user-trigger:hover,
body.portal-shell button.portal-user-trigger:focus-visible,
#header button.portal-user-trigger:hover,
#header button.portal-user-trigger:focus-visible,
button.portal-user-trigger:hover,
button.portal-user-trigger:focus-visible {
  background: rgba(255, 255, 255, 0.26) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35) !important;
}

body.portal-shell #header #user-tools button.portal-user-trigger .portal-user-avatar,
body.portal-shell button.portal-user-trigger .portal-user-avatar,
button.portal-user-trigger .portal-user-avatar,
.portal-user-avatar {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
  color: #ffffff !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
  flex-shrink: 0 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
}

body.portal-shell #header #user-tools button.portal-user-trigger .portal-user-name,
body.portal-shell button.portal-user-trigger .portal-user-name,
button.portal-user-trigger .portal-user-name,
.portal-user-name {
  max-width: 150px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

body.portal-shell #header #user-tools button.portal-user-trigger .portal-user-chevron,
body.portal-shell button.portal-user-trigger .portal-user-chevron,
button.portal-user-trigger .portal-user-chevron,
.portal-user-chevron {
  font-size: 0.7rem !important;
  opacity: 0.85 !important;
  transition: transform 0.2s ease !important;
  color: #ffffff !important;
}

body.portal-shell button.portal-user-trigger[aria-expanded="true"] .portal-user-chevron,
button.portal-user-trigger[aria-expanded="true"] .portal-user-chevron {
  transform: rotate(180deg) !important;
}

/* Dropdown Menu Container */
.portal-user-menu {
  position: absolute !important;
  top: calc(100% + 8px) !important;
  right: 0 !important;
  min-width: 230px !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.18), 0 6px 12px -4px rgba(15, 23, 42, 0.08) !important;
  z-index: 1050 !important;
  display: none !important;
  overflow: hidden !important;
  animation: portalDropdownFadeIn 0.15s ease-out !important;
}

@keyframes portalDropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.portal-user-menu.is-open {
  display: block !important;
}

.portal-rtl .portal-user-menu,
[dir="rtl"] .portal-user-menu {
  right: auto !important;
  left: 0 !important;
}

/* User Menu Header Card */
.portal-user-menu-header {
  padding: 12px 16px !important;
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
  text-align: start !important;
}

.portal-user-menu-name {
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  color: #0f172a !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.3 !important;
}

.portal-user-menu-role {
  display: inline-block !important;
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  color: #0284c7 !important;
  background: #e0f2fe !important;
  padding: 2px 8px !important;
  border-radius: 9999px !important;
  margin-top: 4px !important;
}

.portal-user-menu-divider {
  height: 1px !important;
  background: #f1f5f9 !important;
  margin: 4px 0 !important;
}

/* Menu items override any #header and #user-tools a rules */
body.portal-shell #header #user-tools .portal-user-menu a.portal-user-menu-item,
body.portal-shell #header #user-tools .portal-user-menu a.portal-user-menu-item:link,
body.portal-shell #header #user-tools .portal-user-menu a.portal-user-menu-item:visited,
body.portal-shell #user-tools .portal-user-menu a.portal-user-menu-item,
body.portal-shell #user-tools .portal-user-menu a.portal-user-menu-item:link,
body.portal-shell #user-tools .portal-user-menu a.portal-user-menu-item:visited,
body #user-tools .portal-user-menu a.portal-user-menu-item,
body #user-tools .portal-user-menu a.portal-user-menu-item:link,
body #user-tools .portal-user-menu a.portal-user-menu-item:visited,
#user-tools .portal-user-menu a.portal-user-menu-item,
#user-tools .portal-user-menu a.portal-user-menu-item:link,
#user-tools .portal-user-menu a.portal-user-menu-item:visited,
#user-tools .portal-user-menu button.portal-user-menu-item,
body.portal-shell #user-tools .portal-user-menu button.portal-user-menu-item {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
  padding: 10px 16px !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: #1e293b !important;
  text-decoration: none !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  text-align: start !important;
  box-sizing: border-box !important;
  transition: all 0.15s ease !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
}

body.portal-shell #header #user-tools .portal-user-menu a.portal-user-menu-item:hover,
body.portal-shell #header #user-tools .portal-user-menu a.portal-user-menu-item:focus-visible,
body.portal-shell #user-tools .portal-user-menu a.portal-user-menu-item:hover,
body.portal-shell #user-tools .portal-user-menu a.portal-user-menu-item:focus-visible,
body #user-tools .portal-user-menu a.portal-user-menu-item:hover,
body #user-tools .portal-user-menu a.portal-user-menu-item:focus-visible,
#user-tools .portal-user-menu a.portal-user-menu-item:hover,
#user-tools .portal-user-menu a.portal-user-menu-item:focus-visible,
#user-tools .portal-user-menu button.portal-user-menu-item:hover,
#user-tools .portal-user-menu button.portal-user-menu-item:focus-visible {
  background: #f1f5f9 !important;
  color: #0284c7 !important;
  outline: none !important;
  padding-inline-start: 18px !important;
}

.portal-menu-icon {
  width: 18px !important;
  height: 18px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  color: var(--portal-slate-500, #64748b) !important;
}

.portal-user-menu-item:hover .portal-menu-icon,
.portal-user-menu-item:focus-visible .portal-menu-icon {
  color: #0284c7 !important;
}

.portal-user-logout-btn .portal-menu-icon {
  color: #ef4444 !important;
}


/* Logout Item styling */
body.portal-shell #header #user-tools .portal-user-menu .portal-user-logout-btn,
body.portal-shell #user-tools .portal-user-menu .portal-user-logout-btn,
body #user-tools .portal-user-menu .portal-user-logout-btn,
#user-tools .portal-user-menu .portal-user-logout-btn {
  color: #ef4444 !important;
}

body.portal-shell #header #user-tools .portal-user-menu .portal-user-logout-btn:hover,
body.portal-shell #header #user-tools .portal-user-menu .portal-user-logout-btn:focus-visible,
body.portal-shell #user-tools .portal-user-menu .portal-user-logout-btn:hover,
body.portal-shell #user-tools .portal-user-menu .portal-user-logout-btn:focus-visible,
body #user-tools .portal-user-menu .portal-user-logout-btn:hover,
body #user-tools .portal-user-menu .portal-user-logout-btn:focus-visible,
#user-tools .portal-user-menu .portal-user-logout-btn:hover,
#user-tools .portal-user-menu .portal-user-logout-btn:focus-visible {
  background: #fef2f2 !important;
  color: #dc2626 !important;
}

.portal-profile-avatar-large {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--portal-accent-blue);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.portal-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 840px) {
  .portal-profile-grid {
    grid-template-columns: 1fr;
  }
}

.portal-card-box {
  background: #ffffff;
  border: 1px solid var(--portal-slate-200);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.portal-card-header {
  padding: 1rem 1.25rem;
  background: var(--portal-slate-50);
  border-bottom: 1px solid var(--portal-slate-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.portal-readonly-field {
  margin-bottom: 1rem;
}

.portal-readonly-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--portal-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.portal-readonly-field .readonly-value {
  font-size: 0.95rem;
  color: var(--portal-navy-900);
}

.portal-role-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--portal-accent-blue-light);
  color: var(--portal-accent-blue-hover);
  border: 1px solid #bae6fd;
}

.portal-badge-active {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--portal-success-bg);
  color: var(--portal-success);
  border: 1px solid var(--portal-success-border);
}

.portal-badge-inactive {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--portal-danger-bg);
  color: var(--portal-danger);
  border: 1px solid var(--portal-danger-border);
}

.portal-badge-warning {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--portal-warning-bg);
  color: var(--portal-warning);
  border: 1px solid var(--portal-warning-border);
}

.portal-badge-superuser {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: #faf5ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

/* Module Access Badges */
.portal-badge-module {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  line-height: 1.25;
}

.portal-badge-module.both {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #d8b4fe;
}

.portal-badge-module.crm {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.portal-badge-module.attendance {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.portal-badge-module.disabled {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.portal-badge-module.none {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

/* Kanban Board Canonical Styles */
.pipeline-kanban-board,
.portal-kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1.5rem;
  align-items: start;
}

.pipeline-column,
.portal-kanban-col {
  background: var(--portal-slate-50);
  border: 1px solid var(--portal-slate-200);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  overflow: hidden;
}

.pipeline-column-header,
.portal-kanban-header {
  padding: 0.85rem 1rem;
  background: #ffffff;
  border-bottom: 1px solid var(--portal-slate-200);
  position: sticky;
  top: 0;
  z-index: 2;
}

.portal-kanban-cards {
  padding: 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.portal-kanban-card {
  background: #ffffff;
  border: 1px solid var(--portal-slate-200);
  border-radius: 6px;
  padding: 0.85rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.portal-kanban-card:hover {
  border-color: var(--portal-slate-300);
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.08);
}

/* RTL Refinements */
[dir="rtl"] .portal-sidebar,
body.portal-rtl .portal-sidebar {
  border-right: none !important;
  border-left: 1px solid var(--portal-slate-200) !important;
}

[dir="rtl"] .portal-user-trigger .portal-user-chevron,
body.portal-rtl .portal-user-trigger .portal-user-chevron {
  margin-left: 0;
  margin-right: 2px;
}

[dir="rtl"] .portal-toolbar,
body.portal-rtl .portal-toolbar {
  text-align: right;
}

[dir="rtl"] .portal-table th,
[dir="rtl"] .portal-table td,
body.portal-rtl .portal-table th,
body.portal-rtl .portal-table td {
  text-align: right;
}

/* Accessible focus ring for buttons & inputs */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--portal-accent-blue) !important;
  outline-offset: 2px !important;
}

/* ==========================================================================
   TM Madar Themed Unsaved Changes Modal
   ========================================================================== */
.tm-unsaved-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
}

.tm-unsaved-modal-backdrop.tm-unsaved-modal-open {
  opacity: 1;
  visibility: visible;
}

.tm-unsaved-modal-card {
  background: #ffffff;
  border: 1px solid var(--portal-slate-200, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.25), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
  transform: scale(0.96) translateY(6px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tm-unsaved-modal-backdrop.tm-unsaved-modal-open .tm-unsaved-modal-card {
  transform: scale(1) translateY(0);
}

.tm-unsaved-modal-body {
  display: flex;
  gap: 1.125rem;
  padding: 1.5rem 1.5rem 1.25rem 1.5rem;
  align-items: flex-start;
}

.tm-unsaved-modal-icon-wrap {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--portal-warning-bg, #fffbeb);
  border: 1px solid var(--portal-warning-border, #fde68a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--portal-warning, #d97706);
}

.tm-unsaved-modal-icon {
  width: 24px;
  height: 24px;
  display: block;
}

.tm-unsaved-modal-content {
  flex: 1;
  min-width: 0;
}

.tm-unsaved-modal-title {
  margin: 0 0 0.4rem 0 !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: var(--portal-navy-900, #0f172a) !important;
  line-height: 1.35 !important;
}

.tm-unsaved-modal-desc {
  margin: 0 !important;
  font-size: 0.92rem !important;
  color: var(--portal-slate-600, #475569) !important;
  line-height: 1.5 !important;
}

.tm-unsaved-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--portal-slate-50, #f8fafc);
  border-top: 1px solid var(--portal-slate-200, #e2e8f0);
}

.tm-unsaved-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none !important;
  line-height: 1.25;
}

.tm-unsaved-btn-stay {
  background: var(--portal-accent-blue, #0284c7);
  color: #ffffff !important;
  border: 1px solid var(--portal-accent-blue, #0284c7);
}

.tm-unsaved-btn-stay:hover,
.tm-unsaved-btn-stay:focus-visible {
  background: var(--portal-accent-blue-hover, #0369a1);
  border-color: var(--portal-accent-blue-hover, #0369a1);
  outline: 2px solid var(--portal-accent-blue, #0284c7);
  outline-offset: 2px;
}

.tm-unsaved-btn-leave {
  background: #ffffff;
  color: var(--portal-danger, #dc2626) !important;
  border: 1px solid #fca5a5;
}

.tm-unsaved-btn-leave:hover,
.tm-unsaved-btn-leave:focus-visible {
  background: var(--portal-danger-bg, #fef2f2);
  border-color: #ef4444;
  color: #b91c1c !important;
  outline: 2px solid var(--portal-danger, #dc2626);
  outline-offset: 2px;
}

/* RTL Support */
[dir="rtl"] .tm-unsaved-modal-card,
body.portal-rtl .tm-unsaved-modal-card {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .tm-unsaved-modal-actions,
body.portal-rtl .tm-unsaved-modal-actions {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--portal-accent-blue) !important;
  outline-offset: 2px !important;
}


