/* =========================================================
   AccessPro — Central Stylesheet
   World-class Time & Attendance + Access Control System
   ========================================================= */

/* ===== 1. CSS RESET ===== */
@import url('field-borders.css');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; color: var(--color-text); background-color: var(--color-bg); min-height: 100vh; }
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* ===== 2. DESIGN TOKENS ===== */
:root {
  /* Brand Colors */
  --color-primary:        #2563eb;
  --color-primary-dark:   #1d4ed8;
  --color-primary-darker: #1e40af;
  --color-primary-light:  #dbeafe;
  --color-primary-lighter:#eff6ff;

  /* Semantic Colors */
  --color-success:        #059669;
  --color-success-light:  #d1fae5;
  --color-warning:        #d97706;
  --color-warning-light:  #fef3c7;
  --color-danger:         #dc2626;
  --color-danger-light:   #fee2e2;
  --color-info:           #0284c7;
  --color-info-light:     #e0f2fe;
  --color-purple:         #7c3aed;
  --color-purple-light:   #ede9fe;

  /* Neutral Palette */
  --color-gray-50:  #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;

  /* Theme (Light Mode) */
  --color-bg:           #f3f4f6;
  --color-surface:      #ffffff;
  --color-border:       #e5e7eb;
  --color-input-border: #64748b;
  --color-border-focus: #2563eb;
  --color-text:         #111827;
  --color-text-secondary: #4b5563;
  --color-text-muted:   #9ca3af;

  /* Sidebar */
  --sidebar-bg:           #1e293b;
  --sidebar-text:         #94a3b8;
  --sidebar-text-hover:   #f1f5f9;
  --sidebar-active-bg:    #2563eb;
  --sidebar-active-text:  #ffffff;
  --sidebar-width:        300px;
  --sidebar-collapsed:    72px;

  /* Spacing */
  --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem;  --sp-8: 2rem;    --sp-10: 2.5rem;
  --sp-12: 3rem;   --sp-16: 4rem;   --sp-20: 5rem;

  /* Border Radius */
  --r-sm: 0.25rem; --r: 0.375rem; --r-md: 0.5rem;
  --r-lg: 0.75rem; --r-xl: 1rem;  --r-2xl: 1.5rem; --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  --shadow-2xl:0 25px 50px -12px rgba(0,0,0,.25);

  /* Font Sizes */
  --fs-xs: .75rem; --fs-sm: .875rem; --fs-base: 1rem;
  --fs-lg: 1.125rem; --fs-xl: 1.25rem; --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem; --fs-4xl: 2.25rem;

  /* Transitions */
  --t-fast: 150ms ease; --t-base: 200ms ease; --t-slow: 300ms ease;

  /* Z-index */
  --z-raised: 10; --z-dropdown: 100; --z-sticky: 200;
  --z-overlay: 300; --z-modal: 400; --z-toast: 500;
}

/* Dark Mode — opt-in only (via the sidebar toggle, body.dark).
   Deliberately NOT tied to @media (prefers-color-scheme: dark): that
   made every page silently go dark on any device/browser set to dark
   mode, with no way to turn it off on pages that don't load the
   toggle, and made the app look broken on screenshots and demos. */
body.dark {
  --color-bg: #0f172a; --color-surface: #1e293b;
  --color-border: #334155; --color-text: #f1f5f9; --color-input-border: #94a3b8;
  --color-text-secondary: #94a3b8; --color-text-muted: #64748b;
  --sidebar-bg: #0f172a;
}

/* ===== 3. TYPOGRAPHY ===== */
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.25; color: var(--color-text); }
h1 { font-size: var(--fs-4xl); } h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); } h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }  h6 { font-size: var(--fs-base); }
p  { color: var(--color-text-secondary); }
.text-xs   { font-size: var(--fs-xs); }   .text-sm  { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); } .text-lg  { font-size: var(--fs-lg); }
.text-xl   { font-size: var(--fs-xl); }   .text-2xl { font-size: var(--fs-2xl); }
.text-3xl  { font-size: var(--fs-3xl); }  .text-4xl { font-size: var(--fs-4xl); }
.font-normal  { font-weight: 400; } .font-medium { font-weight: 500; }
.font-semibold{ font-weight: 600; } .font-bold   { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.text-primary   { color: var(--color-primary); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-danger    { color: var(--color-danger); }
.text-muted     { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-center  { text-align: center; } .text-right { text-align: right; }
.text-left    { text-align: left; }

/* ===== 4. LAYOUT ===== */
.app-layout   { display: flex; min-height: 100vh; }
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left var(--t-slow); }
.main-content.collapsed { margin-left: var(--sidebar-collapsed); }
.page-container { flex: 1; padding: var(--sp-8); max-width: 1440px; width: 100%; }
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-8); flex-wrap: wrap; gap: var(--sp-4); }
.page-title   { font-size: var(--fs-2xl); font-weight: 700; color: var(--color-text); }
.page-subtitle{ font-size: var(--fs-sm); color: var(--color-text-muted); margin-top: var(--sp-1); }

.grid   { display: grid; gap: var(--sp-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.flex  { display: flex; } .flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; }
.items-center  { align-items: center; }    .items-start { align-items: flex-start; }
.justify-center{ justify-content: center; } .justify-between { justify-content: space-between; }
.justify-end   { justify-content: flex-end; }
.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-6 { gap: var(--sp-6); } .gap-8 { gap: var(--sp-8); }
.mt-2 { margin-top: var(--sp-2); }   .mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }   .mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }.mb-8 { margin-bottom: var(--sp-8); }
.p-4  { padding: var(--sp-4); } .p-6 { padding: var(--sp-6); } .p-8 { padding: var(--sp-8); }
.w-full { width: 100%; } .h-full { height: 100%; }

/* ===== 5. SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: var(--z-sticky);
  transition: width var(--t-slow), transform var(--t-slow);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 52px;
}
.sidebar-logo { display: flex; align-items: center; gap: var(--sp-3); color: white; overflow: hidden; flex: 1; min-width: 0; }
.logo-icon {
  width: 36px; height: 36px; background: var(--color-primary);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: var(--fs-lg); flex-shrink: 0;
}
.logo-text { font-size: var(--fs-md, 1rem); font-weight: 700; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; white-space: normal; transition: opacity var(--t-slow), width var(--t-slow); }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; overflow: hidden; }
.sidebar-toggle {
  background: none; border: none; color: var(--sidebar-text); cursor: pointer;
  padding: var(--sp-2); border-radius: var(--r); display: flex; align-items: center;
  transition: background var(--t-fast), color var(--t-fast); flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); color: white; }

.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-4) 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto; scrollbar-color: rgba(255,255,255,.9) rgba(255,255,255,.12);
}
.sidebar-nav::-webkit-scrollbar { width: 12px; }
.sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,.12); }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.9); border-radius: var(--r-full);
  border: 3px solid transparent; background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: #fff; background-clip: padding-box; }

.nav-section { margin-bottom: var(--sp-2); }
.nav-section-label {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  width: 100%; background: none; border: none; font: inherit; text-align: left; cursor: pointer;
  font-size: var(--fs-xs); font-weight: 600; color: var(--sidebar-text);
  text-transform: uppercase; letter-spacing: .07em;
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--t-slow), color var(--t-fast);
}
.nav-section-label:hover { color: var(--sidebar-text-hover); }
.nav-section-label-text { overflow: hidden; text-overflow: ellipsis; }
.nav-section-chevron { width: 14px; height: 14px; flex-shrink: 0; opacity: .6; transition: transform var(--t-fast); }
.nav-section.closed .nav-section-chevron { transform: rotate(-90deg); }
.sidebar.collapsed .nav-section-label { opacity: 0; pointer-events: none; }

.nav-section-items {
  overflow: hidden;
  max-height: 4000px;   /* was 800px: long sections (Admin) were clipped, cutting off their last item */
  transition: max-height var(--t-slow), opacity var(--t-fast);
}
.nav-section.closed .nav-section-items { max-height: 0; opacity: 0; }
.sidebar.collapsed .nav-section-items { max-height: none !important; opacity: 1 !important; }

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); margin: 2px var(--sp-3);
  border-radius: var(--r-md); color: var(--sidebar-text);
  text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
  white-space: normal; overflow: hidden; line-height: 1.25;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer; position: relative;
}
.nav-item:hover  { background: rgba(255,255,255,.07); color: var(--sidebar-text-hover); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-item svg   { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item-text  { transition: opacity var(--t-slow); overflow: hidden; min-width: 0; overflow-wrap: anywhere; }
.sidebar:not(.collapsed) { max-width: 86vw; }
.sidebar.collapsed .nav-item-text { opacity: 0; width: 0; }

.nav-badge { margin-left: auto; background: var(--color-danger); color: white; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: var(--r-full); transition: opacity var(--t-slow); }
.sidebar.collapsed .nav-badge { opacity: 0; }

/* Collapsed tooltip */
.sidebar.collapsed .nav-item::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: var(--color-gray-900); color: white;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r);
  font-size: var(--fs-sm); white-space: nowrap; z-index: var(--z-toast);
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-footer { padding: var(--sp-4); border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-ver { padding: .45rem var(--sp-4); font-size: .68rem; color: var(--sidebar-text); opacity: .85; text-align: center; border-top: 1px solid rgba(255,255,255,.06); letter-spacing: .01em; }
.btn-logout {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-3) var(--sp-4); margin: 0;
  border-radius: var(--r-md); border: none; background: transparent;
  color: var(--sidebar-text); font-size: var(--fs-sm); font-weight: 500;
  white-space: nowrap; overflow: hidden; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
}
.btn-logout:hover { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn-logout svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-logout span { transition: opacity var(--t-slow); overflow: hidden; }
.sidebar.collapsed .btn-logout span { opacity: 0; width: 0; }
.sidebar-user {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  cursor: pointer; overflow: hidden;
  transition: background var(--t-fast);
}
.sidebar-user:hover { background: rgba(255,255,255,.07); }
.sidebar-user-info { flex: 1; min-width: 0; overflow: hidden; transition: opacity var(--t-slow); }
.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }
.sidebar-user-name { font-size: var(--fs-sm); font-weight: 600; color: white; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: var(--fs-xs); color: var(--sidebar-text); }

.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: calc(var(--z-sticky) - 1); display: none; }
.sidebar-overlay.visible { display: block; }

/* ===== 6. TOPBAR ===== */
.topbar {
  height: 64px; background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-8); position: sticky; top: 0;
  z-index: var(--z-raised); gap: var(--sp-4);
}
.topbar-left  { display: flex; align-items: center; gap: var(--sp-4); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); }
.mobile-menu-btn { display: none; background: none; border: none; cursor: pointer; padding: var(--sp-2); color: var(--color-text); border-radius: var(--r); }
.topbar-search { position: relative; max-width: 360px; width: 100%; }
.topbar-search input {
  width: 100%; padding: .5rem var(--sp-4) .5rem 2.25rem;
  border: 1px solid var(--color-border); border-radius: var(--r-full);
  background: var(--color-bg); color: var(--color-text);
  font-size: var(--fs-sm); outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.topbar-search input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; width: 16px; height: 16px; }
.topbar-btn {
  background: none; border: none; cursor: pointer; padding: var(--sp-2);
  color: var(--color-text-secondary); border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar-btn:hover { background: var(--color-gray-100); color: var(--color-text); }
.notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: var(--color-danger); border-radius: 50%; border: 2px solid var(--color-surface); }
.topbar-clock { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text); background: var(--color-bg); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-full); white-space: nowrap; }

/* ===== 7. CARDS ===== */
.card { background: var(--color-surface); border-radius: var(--r-xl); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--color-border); gap: var(--sp-4); }
.card-title  { font-size: var(--fs-base); font-weight: 600; color: var(--color-text); }
.card-subtitle { font-size: var(--fs-sm); color: var(--color-text-muted); margin-top: 2px; }
.card-body   { padding: var(--sp-6); }
.card-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--color-border); background: var(--color-bg); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }

/* Stat Cards */
.stat-card {
  background: var(--color-surface); border-radius: var(--r-xl);
  border: 1px solid var(--color-border); padding: var(--sp-6);
  display: flex; align-items: flex-start; gap: var(--sp-4);
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue   { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon.green  { background: var(--color-success-light); color: var(--color-success); }
.stat-icon.yellow { background: var(--color-warning-light); color: var(--color-warning); }
.stat-icon.red    { background: var(--color-danger-light);  color: var(--color-danger); }
.stat-icon.purple { background: var(--color-purple-light);  color: var(--color-purple); }
.stat-content  { flex: 1; min-width: 0; }
.stat-label    { font-size: var(--fs-sm); color: var(--color-text-muted); font-weight: 500; margin-bottom: var(--sp-1); }
.stat-value    { font-size: var(--fs-3xl); font-weight: 700; color: var(--color-text); line-height: 1; margin-bottom: var(--sp-2); }
.stat-trend    { display: flex; align-items: center; justify-content: center; gap: var(--sp-1); font-size: var(--fs-xs); font-weight: 500; }
.stat-trend.up      { color: var(--color-success); }
.stat-trend.down    { color: var(--color-danger); }
.stat-trend.neutral { color: var(--color-text-muted); }

/* ===== 8. BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: .625rem var(--sp-4); border: 1px solid transparent;
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all var(--t-fast); outline: none; line-height: 1.25; user-select: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--color-primary-light); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary  { background: var(--color-primary);  color: white; border-color: var(--color-primary); }
.btn-primary:hover:not(:disabled)  { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-success  { background: var(--color-success);  color: white; border-color: var(--color-success); }
.btn-success:hover:not(:disabled)  { background: #047857; border-color: #047857; }
.btn-danger   { background: var(--color-danger);   color: white; border-color: var(--color-danger); }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; border-color: #b91c1c; }
.btn-warning  { background: var(--color-warning);  color: white; border-color: var(--color-warning); }
.btn-secondary{ background: var(--color-surface);  color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled){ background: var(--color-bg); border-color: var(--color-gray-400); }
.btn-ghost    { background: transparent; color: var(--color-text-secondary); border-color: transparent; }
.btn-ghost:hover:not(:disabled)    { background: var(--color-bg); color: var(--color-text); }
.btn-outline  { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover:not(:disabled)  { background: var(--color-primary); color: white; }

.btn-sm  { padding: .375rem var(--sp-3); font-size: var(--fs-xs); }
.btn-lg  { padding: var(--sp-3) var(--sp-8); font-size: var(--fs-base); }
.btn-xl  { padding: var(--sp-4) var(--sp-10); font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-icon{ padding: var(--sp-2); width: 36px; height: 36px; }
.btn-icon-sm { padding: var(--sp-1); width: 28px; height: 28px; }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: ''; position: absolute;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: white;
  border-radius: 50%; animation: spin .6s linear infinite;
}

/* ===== 9. FORMS ===== */
.form-group  { margin-bottom: var(--sp-5); }
.form-label  { display: block; font-size: var(--fs-sm); font-weight: 500; color: var(--color-text); margin-bottom: var(--sp-2); }
.form-label.required::after { content: ' *'; color: var(--color-danger); }
.form-control {
  display: block; width: 100%;
  padding: .625rem var(--sp-3); border: 1.5px solid var(--color-input-border, #64748b);
  border-radius: var(--r-md); background: var(--color-surface);
  color: var(--color-text); font-size: var(--fs-sm); outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast); appearance: none;
}
.form-control:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-control:disabled { background: var(--color-bg); color: var(--color-text-muted); cursor: not-allowed; }
.form-control.invalid { border-color: var(--color-danger); }
.form-control.invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.25rem;
}
.form-hint  { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: var(--sp-1); }
.form-error { font-size: var(--fs-xs); color: var(--color-danger); margin-top: var(--sp-1); display: flex; align-items: center; gap: var(--sp-1); }
.form-row   { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }

.form-check { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.form-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }
.form-check label { font-size: var(--fs-sm); color: var(--color-text); cursor: pointer; }

.input-group { position: relative; }
.input-group .form-control { padding-left: 2.5rem; }
.input-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; width: 16px; height: 16px; }

/* ===== 10. BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 2px var(--sp-2); border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-light);    color: var(--color-info); }
.badge-gray    { background: var(--color-gray-100);      color: var(--color-gray-600); }
.badge-purple  { background: var(--color-purple-light);  color: var(--color-purple); }
.role-admin    { background: #fce7f3; color: #9d174d; }
.role-staff    { background: #dbeafe; color: #1e40af; }
.role-visitor  { background: #d1fae5; color: #065f46; }
.status-present    { background: var(--color-success-light); color: var(--color-success); }
.status-absent     { background: var(--color-danger-light);  color: var(--color-danger); }
.status-late       { background: var(--color-warning-light); color: var(--color-warning); }
.status-on-break   { background: var(--color-info-light);    color: var(--color-info); }
.status-checked-in { background: var(--color-success-light); color: var(--color-success); }
.status-checked-out{ background: var(--color-gray-100);      color: var(--color-gray-500); }
.status-active     { background: var(--color-success-light); color: var(--color-success); }
.status-inactive   { background: var(--color-gray-100);      color: var(--color-gray-500); }

/* ===== 11. TABLES ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--r-xl); border: 1px solid var(--color-border); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { background: var(--color-bg); color: var(--color-text-muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; padding: var(--sp-3) var(--sp-4); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--color-border); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--color-text); }
.table td { padding: var(--sp-4); border-bottom: 1px solid var(--color-border); color: var(--color-text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--color-bg); }
.table-user   { display: flex; align-items: center; gap: var(--sp-3); }
.table-actions{ display: flex; align-items: center; gap: var(--sp-2); }

/* ===== 12. AVATARS ===== */
.avatar { border-radius: 50%; overflow: hidden; background: var(--color-primary-light); color: var(--color-primary); font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.av-xs  { width: 24px;  height: 24px;  font-size: 10px; }
.av-sm  { width: 32px;  height: 32px;  font-size: var(--fs-xs); }
.av-md  { width: 40px;  height: 40px;  font-size: var(--fs-sm); }
.av-lg  { width: 52px;  height: 52px;  font-size: var(--fs-base); }
.av-xl  { width: 80px;  height: 80px;  font-size: var(--fs-xl); }
.av-2xl { width: 120px; height: 120px; font-size: var(--fs-3xl); }

/* ===== 13. MODALS ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: var(--z-overlay); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity var(--t-base); pointer-events: none; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal { background: var(--color-surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0; width: 100%; max-height: 90vh; overflow-y: auto; transform: translateY(100%); transition: transform var(--t-slow); box-shadow: var(--shadow-2xl); }
@media (min-width: 640px) {
  .modal { border-radius: var(--r-2xl); max-width: 560px; transform: scale(.95) translateY(0); opacity: 0; transition: transform var(--t-base), opacity var(--t-base); }
  .modal-overlay.open .modal { transform: scale(1); opacity: 1; }
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-sm  { max-width: 420px; }
.modal-lg  { max-width: 720px; }
.modal-xl  { max-width: 920px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: var(--color-surface); z-index: 1; }
.modal-title  { font-size: var(--fs-lg); font-weight: 600; color: var(--color-text); }
.modal-close  { background: none; border: none; cursor: pointer; padding: var(--sp-2); color: var(--color-text-muted); border-radius: var(--r); display: flex; align-items: center; transition: background var(--t-fast), color var(--t-fast); }
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body   { padding: var(--sp-6); }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6); border-top: 1px solid var(--color-border); position: sticky; bottom: 0; background: var(--color-surface); }

/* ===== 14. TOASTS ===== */
.toast-container { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); pointer-events: none; }
.toast { background: var(--color-gray-900); color: white; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); box-shadow: var(--shadow-xl); pointer-events: all; transform: translateX(110%); transition: transform var(--t-slow); max-width: 360px; min-width: 280px; }
.toast.show   { transform: translateX(0); }
.toast.hiding { transform: translateX(110%); }
.toast-success{ background: var(--color-success); }
.toast-error  { background: var(--color-danger); }
.toast-warning{ background: var(--color-warning); }
.toast-info   { background: var(--color-primary); }
.toast svg    { width: 18px; height: 18px; flex-shrink: 0; }
.toast-msg    { flex: 1; }
.toast-close  { background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer; padding: var(--sp-1); border-radius: var(--r-sm); display: flex; align-items: center; }
.toast-close:hover { color: white; }

/* ===== 15. LOADING ===== */
.spinner    { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 16px; height: 16px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
.spinner-xl { width: 48px; height: 48px; border-width: 4px; }
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; z-index: var(--z-modal); flex-direction: column; gap: var(--sp-4); }
.skeleton { background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-border) 50%, var(--color-bg) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: var(--r); }
.skeleton-text   { height: 14px; margin-bottom: var(--sp-2); border-radius: var(--r-sm); }
.skeleton-title  { height: 24px; width: 60%; margin-bottom: var(--sp-3); }
.skeleton-circle { border-radius: 50%; }
.skeleton-stat   { height: 80px; }

/* ===== 16. CAMERA ===== */
.camera-box { border: 2px dashed var(--color-border); border-radius: var(--r-xl); overflow: hidden; background: var(--color-bg); position: relative; }
.camera-feed { width: 100%; height: 260px; object-fit: cover; display: block; }
.camera-canvas { display: none; }
.camera-placeholder { width: 100%; height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3); color: var(--color-text-muted); }
.camera-placeholder svg { width: 48px; height: 48px; opacity: .4; }
.camera-photo { width: 100%; height: 260px; object-fit: cover; display: block; }
.camera-controls { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); padding: var(--sp-4); background: var(--color-surface); border-top: 1px solid var(--color-border); }
.capture-btn { width: 64px; height: 64px; border-radius: 50%; background: var(--color-danger); border: 4px solid var(--color-surface); box-shadow: 0 0 0 2px var(--color-danger); cursor: pointer; transition: transform var(--t-fast); }
.capture-btn:hover  { transform: scale(1.08); }
.capture-btn:active { transform: scale(.95); }

/* ===== 17. VISITOR BADGE ===== */
.visitor-badge { width: 320px; background: white; border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--shadow-xl); border: 1px solid var(--color-border); font-family: inherit; }
.vbadge-header { background: linear-gradient(135deg, var(--color-primary-darker), var(--color-primary)); color: white; padding: var(--sp-4) var(--sp-5); text-align: center; }
.vbadge-company{ font-size: var(--fs-xl); font-weight: 700; }
.vbadge-type   { font-size: var(--fs-xs); opacity: .9; text-transform: uppercase; letter-spacing: .1em; margin-top: 2px; }
.vbadge-body   { padding: var(--sp-5); display: flex; gap: var(--sp-4); align-items: flex-start; }
.vbadge-photo  { width: 80px; height: 80px; border-radius: var(--r-lg); object-fit: cover; border: 2px solid var(--color-border); flex-shrink: 0; background: var(--color-bg); }
.vbadge-info   { flex: 1; }
.vbadge-name   { font-size: var(--fs-lg); font-weight: 700; color: var(--color-text); }
.vbadge-company-name { font-size: var(--fs-sm); color: var(--color-text-secondary); margin-bottom: var(--sp-3); }
.vbadge-detail { font-size: var(--fs-xs); color: var(--color-text-muted); line-height: 2; }
.vbadge-detail strong { color: var(--color-text); font-weight: 500; }
.vbadge-footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; background: var(--color-bg); }
.vbadge-number { font-size: var(--fs-2xl); font-weight: 700; color: var(--color-primary); font-family: monospace; }
.vbadge-qr     { width: 60px; height: 60px; }

/* ===== 18. ATTENDANCE CLOCK ===== */
.clock-widget { text-align: center; padding: var(--sp-8); }
.clock-time   { font-size: 4rem; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; letter-spacing: -2px; line-height: 1; margin-bottom: var(--sp-2); }
.clock-date   { font-size: var(--fs-base); color: var(--color-text-muted); margin-bottom: var(--sp-6); }
.clock-status { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-6); border-radius: var(--r-full); font-weight: 600; margin-bottom: var(--sp-6); }
.clock-btns   { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 280px; margin: 0 auto; }
.work-hours-display { font-size: var(--fs-3xl); font-weight: 700; color: var(--color-primary); }

/* ===== 19. AUTH PAGES ===== */
.auth-page { min-height: 100vh; display: flex; }
.auth-hero {
  flex: 1; background: linear-gradient(135deg, #050505, #121212 55%, #3a1214);
  padding: var(--sp-12); display: flex; flex-direction: column; justify-content: center;
  color: white; position: relative; overflow: hidden;
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23fff' fill-opacity='.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
}
.auth-hero-inner  { position: relative; z-index: 1; max-width: 460px; }
.auth-logo        { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-12); }
.auth-logo-icon   { width: 48px; height: 48px; background: rgba(255,255,255,.2); border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-size: var(--fs-2xl); font-weight: 700; }
.auth-logo-name   { font-size: var(--fs-2xl); font-weight: 700; }
.auth-hero-title  { font-size: var(--fs-4xl); font-weight: 800; line-height: 1.2; margin-bottom: var(--sp-4); }
.auth-hero-sub    { font-size: var(--fs-lg); opacity: .85; margin-bottom: var(--sp-8); line-height: 1.7; }
.auth-features    { display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-feat        { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-base); opacity: .9; }
.auth-feat-icon   { width: 32px; height: 32px; background: rgba(255,255,255,.15); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auth-feat-icon svg { width: 16px; height: 16px; }
.auth-panel       { width: 100%; max-width: 480px; padding: var(--sp-12) var(--sp-8); display: flex; flex-direction: column; justify-content: center; background: var(--color-surface); }
.auth-panel-title { font-size: var(--fs-2xl); font-weight: 700; color: var(--color-text); margin-bottom: var(--sp-2); }
.auth-panel-sub   { font-size: var(--fs-base); color: var(--color-text-muted); margin-bottom: var(--sp-8); }

/* ===== 20. STEPPER ===== */
.stepper { display: flex; align-items: center; margin-bottom: var(--sp-8); }
.step    { display: flex; align-items: center; flex: 1; }
.step:last-child { flex: none; }
.step-num { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: var(--fs-sm); font-weight: 600; flex-shrink: 0; transition: all var(--t-base); }
.step.done .step-num   { background: var(--color-success); color: white; }
.step.active .step-num { background: var(--color-primary); color: white; }
.step.todo .step-num   { background: var(--color-bg); color: var(--color-text-muted); border: 2px solid var(--color-border); }
.step-label      { font-size: var(--fs-xs); margin-left: var(--sp-2); white-space: nowrap; }
.step.active .step-label { color: var(--color-primary); font-weight: 600; }
.step.done .step-label   { color: var(--color-success); }
.step.todo .step-label   { color: var(--color-text-muted); }
.step-line { flex: 1; height: 2px; background: var(--color-border); margin: 0 var(--sp-2); transition: background var(--t-base); }
.step-line.done { background: var(--color-success); }

/* ===== 21. TABS ===== */
.tabs { border-bottom: 1px solid var(--color-border); display: flex; overflow-x: auto; }
.tab  { padding: var(--sp-3) var(--sp-5); font-size: var(--fs-sm); font-weight: 500; color: var(--color-text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: color var(--t-fast), border-color var(--t-fast); text-decoration: none; }
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ===== 22. DROPDOWN ===== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; top: calc(100% + 4px); right: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-1); min-width: 180px; z-index: var(--z-dropdown); opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast); }
.dropdown-menu.open { opacity: 1; transform: translateY(0); pointer-events: all; }
.dropdown-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r); font-size: var(--fs-sm); color: var(--color-text); cursor: pointer; border: none; background: none; width: 100%; text-align: left; transition: background var(--t-fast); }
.dropdown-item:hover { background: var(--color-bg); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: var(--color-danger-light); }
.dropdown-item svg { width: 15px; height: 15px; }
.dropdown-divider { height: 1px; background: var(--color-border); margin: var(--sp-1) 0; }

/* ===== 23. PROGRESS ===== */
.progress     { height: 8px; background: var(--color-border); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--color-primary); border-radius: var(--r-full); transition: width var(--t-slow); }
.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.danger  { background: var(--color-danger); }

/* ===== 24. EMPTY STATE ===== */
.empty-state { text-align: center; padding: var(--sp-16) var(--sp-8); color: var(--color-text-muted); }
.empty-icon  { width: 64px; height: 64px; margin: 0 auto var(--sp-4); background: var(--color-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.empty-icon svg { width: 28px; height: 28px; opacity: .5; }
.empty-title { font-size: var(--fs-lg); font-weight: 600; color: var(--color-text); margin-bottom: var(--sp-2); }
.empty-text  { font-size: var(--fs-sm); max-width: 300px; margin: 0 auto var(--sp-6); }

/* ===== 25. ALERTS ===== */
.alert { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-lg); border: 1px solid transparent; }
.alert svg   { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--color-info-light);    border-color: #bae6fd; color: #0c4a6e; }
.alert-success { background: var(--color-success-light); border-color: #a7f3d0; color: #064e3b; }
.alert-warning { background: var(--color-warning-light); border-color: #fcd34d; color: #78350f; }
.alert-danger  { background: var(--color-danger-light);  border-color: #fca5a5; color: #7f1d1d; }
.alert-title { font-weight: 600; margin-bottom: var(--sp-1); }

/* ===== 26. FILTERS BAR ===== */
.filters-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.filter-select { min-width: 140px; padding: .5rem var(--sp-3); padding-right: 2.25rem; border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-surface); color: var(--color-text); font-size: var(--fs-sm); appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; cursor: pointer; outline: none; transition: border-color var(--t-fast); }
.filter-select:focus { border-color: var(--color-primary); }

/* ===== 27. PRINT ===== */
@media print {
  .sidebar, .topbar, .btn, .toast-container, .filters-bar { display: none !important; }
  .main-content { margin-left: 0; }
  .visitor-badge { box-shadow: none; border: 1px solid #000; }
  body { background: white; color: black; }
}

/* ===== 28. RESPONSIVE ===== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; z-index: var(--z-overlay); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .mobile-menu-btn { display: flex; }
  .page-container { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { max-width: 100%; padding: var(--sp-8) var(--sp-6); }
  .clock-time { font-size: 3rem; }
  .stat-value { font-size: var(--fs-2xl); }
  .topbar-search { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar-clock { display: none; }
  /* The desktop icon-rail collapse toggle has nothing to do on mobile —
     the sidebar there opens/closes via the hamburger + overlay, and this
     button only ever un-labels the nav (collapsed forces width:72px on
     desktop, but mobile forces full width !important), leaving a
     confusing icon-only menu stuck open at full width. */
  .sidebar-toggle { display: none; }
  /* iOS Safari auto-zooms the whole page when a focused input's
     font-size is under 16px — every .form-control was 14px (--fs-sm),
     so tapping any field on an iPhone/iPad jolted the view. 16px on
     mobile only; the desktop size is untouched. */
  .form-control { font-size: 16px; }
}
@media (max-width: 480px) {
  .clock-time { font-size: 2.5rem; }
  .visitor-badge { width: 100%; max-width: 320px; }
  .page-container { padding: var(--sp-3); }
  .card-body { padding: var(--sp-4); }
  .stat-card { padding: var(--sp-4); }
}

/* ===== 29. ANIMATIONS ===== */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes shimmer  { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes fadeIn   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn  { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes bounceIn { 0% { transform: scale(.8); opacity: 0; } 60% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.anim-fade-in   { animation: fadeIn .3s ease forwards; }
.anim-bounce-in { animation: bounceIn .4s ease forwards; }
.anim-pulse     { animation: pulse 2s ease-in-out infinite; }

/* ===== 30. UTILITIES ===== */
.hidden      { display: none !important; }
.invisible   { visibility: hidden; }
.sr-only     { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded-full{ border-radius: var(--r-full); }
.shadow-md   { box-shadow: var(--shadow-md); }
.border      { border: 1px solid var(--color-border); }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.overflow-hidden { overflow: hidden; }
.relative    { position: relative; }
.absolute    { position: absolute; }
.divider     { height: 1px; background: var(--color-border); margin: var(--sp-4) 0; }
.spacer      { flex: 1; }

/* ===== 31. CHART CONTAINER ===== */
.chart-container { position: relative; height: 260px; width: 100%; }

/* ===== 32. TIMELINE ===== */
.timeline { position: relative; padding-left: var(--sp-8); }
.timeline::before { content: ''; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: var(--color-border); }
.tl-item  { position: relative; margin-bottom: var(--sp-6); }
.tl-dot   { position: absolute; left: -2rem; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--color-primary); border: 2px solid var(--color-surface); box-shadow: 0 0 0 2px var(--color-primary); }
.tl-dot.success { background: var(--color-success); box-shadow: 0 0 0 2px var(--color-success); }
.tl-dot.warning { background: var(--color-warning); box-shadow: 0 0 0 2px var(--color-warning); }
.tl-dot.danger  { background: var(--color-danger);  box-shadow: 0 0 0 2px var(--color-danger); }
.tl-time  { font-size: var(--fs-xs); color: var(--color-text-muted); margin-bottom: 2px; }
.tl-text  { font-size: var(--fs-sm); color: var(--color-text); }

/* ── Force white text on auth hero panel ── */
.auth-hero,
.auth-hero *,
.auth-hero h1,
.auth-hero p,
.auth-hero li,
.auth-hero .auth-hero-title,
.auth-hero .auth-hero-sub,
.auth-hero .auth-logo-name,
.auth-feat {
  color: #ffffff !important;
}
.auth-feat-icon {
  background: rgba(255,255,255,0.2) !important;
  color: #ffffff !important;
}

/* ================================================================
   STAT / KPI / TILE CARDS — everything centred.
   Icon on top, then label, figure and trend, all centred beneath it.
   The doubled selector (.stat-card.stat-card) outranks any page-level
   <style> rule of the same name, and the .app-layout form outranks
   it again on pages that use the standard shell.
   Present in BOTH copies of main.css (root and Access Control) —
   keep them identical.
   ================================================================ */
.stat-card.stat-card,
.app-layout .stat-card{
  flex-direction:column; align-items:center; justify-content:center;
  text-align:center; gap:var(--sp-3);
}
button.stat-card{ width:100%; font:inherit; color:inherit; cursor:pointer; }
a.stat-card{ text-decoration:none; color:inherit; }
.stat-card .stat-icon{ margin-left:auto; margin-right:auto; }
.stat-card .stat-content{ width:100%; text-align:center; }
.stat-card .stat-label,
.stat-card .stat-value,
.stat-card .stat-trend,
.stat-card .stat-meta,
.stat-card .drill-hint{ text-align:center; margin-left:auto; margin-right:auto; width:100%; }
.stat-card .stat-trend{ display:flex; justify-content:center; }
.stat-card .stat-meta{ font-size:var(--fs-xs); color:var(--color-text-muted); margin-top:var(--sp-1); }

/* KPI strips inside drill-through popups (both implementations) */
.drill-kpi, .drill-stat,
.drill-kpi-label, .drill-kpi-value,
.drill-stat .label, .drill-stat .value, .drill-stat *{ text-align:center; }
/* ── Cards and popups are LEFT-aligned (only KPI number tiles stay centred) ──────────────
   Data grids and form controls stay left-aligned so columns and
   inputs remain readable. */
.card, .modal { text-align: left; }
.stat-card { text-align: center; }
.card :is(table, th, td, input, select, textarea, pre, code),
.modal :is(table, th, td, input, select, textarea, pre, code) { text-align: left; }
.card-header, .modal-header { justify-content: space-between; text-align: left; position: relative; }
.modal-header .modal-close { position: absolute; right: var(--sp-4); top: 50%; transform: translateY(-50%); }
.modal-footer { justify-content: flex-end; }

/* ── Centred text in every stat / KPI tile (site-wide) ─────────
   Each page named its tiles differently (rc-kpi, st-kpi, qp-stat, ...),
   so they are listed here once. Add a new tile class to this list and
   its text is centred too. */
:is(.stat-card, .kpi, .rc-kpi, .st-kpi, .bx-kpi, .bg-kpi, .bs-kpi, .qp-stat, .hist-stat,
    .sp-stat, .sd-stat, .hr-stat, .dstat, .og-stat, .wa-stat, .drill-tile, .drill-stat),
:is(.stat-card, .kpi, .rc-kpi, .st-kpi, .bx-kpi, .bg-kpi, .bs-kpi, .qp-stat, .hist-stat,
    .sp-stat, .sd-stat, .hr-stat, .dstat, .og-stat, .wa-stat, .drill-tile, .drill-stat) *:not(table, th, td, input, select, textarea, pre, code) {
  text-align: center !important;
}

/* ===== TEXT ON DARK-BLUE BANNERS =====
   The global h1–h6 / p colours above are dark, so a heading placed on a navy
   hero banner inherits dark text and is unreadable. Headings on these banners
   are always white and bold; paragraphs are a soft white. */
:is(.rq-hero, .ps-hero, .pt-hero, .hist-hero, .vision-hero, .hist-quote-banner,
    .greeting-banner, .profile-banner, .auth-hero, .vbadge-header)
  :is(h1, h2, h3, h4, h5, h6) { color: #fff !important; font-weight: 800; }
:is(.rq-hero, .ps-hero, .pt-hero, .hist-hero, .vision-hero, .hist-quote-banner,
    .greeting-banner, .auth-hero, .vbadge-header)
  p { color: rgba(255,255,255,.88); }

/* ================================================================
   POLISH LAYER (Oct 2026): one consistent look for controls, tables, focus and motion.
   Kept at the END of main.css so it refines every page without touching their markup.
   ================================================================ */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]):not([type=hidden]),
textarea, select {
  border: 1.5px solid #cbd5e1 !important; border-radius: 8px !important; font-size: .9rem; background-color: var(--color-surface, #fff);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]):not([type=hidden]):hover,
textarea:hover, select:hover { border-color: #64748b !important; }
input:not([type=checkbox]):not([type=radio]):focus, textarea:focus, select:focus {
  border-color: var(--color-primary, #1f3a68) !important; box-shadow: 0 0 0 3px rgba(31,58,104,.16) !important; outline: none;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=hidden]):not(.vi-skip), select { min-height: 38px; }
select { padding-right: 2rem; }
textarea { line-height: 1.5; }
::placeholder { color: #94a3b8; opacity: 1; }

/* keyboard users always see where they are */
:where(a, button, [role=button], summary, .tab, .dh-li, .pf-card):focus-visible { outline: 2px solid var(--color-primary, #1f3a68); outline-offset: 2px; border-radius: 6px; }

/* buttons */
.btn { transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* cards: a touch of depth, and they lift when they are clickable */
.card { box-shadow: 0 1px 2px rgba(15,23,42,.05); }
a.card, button.card, .card[onclick], .pf-card, .dh-li[onclick] { transition: box-shadow .15s ease, transform .15s ease, background-color .15s ease; }
a.card:hover, button.card:hover, .card[onclick]:hover, .pf-card:hover { box-shadow: 0 6px 18px rgba(15,23,42,.10); transform: translateY(-1px); }

/* tables: readable rows, sticky headers inside scrolling wrappers, gentle hover */
.table th { position: sticky; top: 0; z-index: 2; white-space: nowrap; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: rgba(31,58,104,.045); }
.table td, .table th { vertical-align: middle; }
.table-wrapper { border-radius: var(--r-lg, 12px); }

/* badges and links */
.badge { font-weight: 650; letter-spacing: .01em; }
main a:not(.btn):not(.card):not([class*=nav]):hover { text-decoration: underline; text-underline-offset: 2px; }

/* the page headline block, left-aligned and with breathing room */
.page-head, .page-header { text-align: left; }
.page-title { letter-spacing: -.01em; }

/* long text never overflows its box */
.card-body, .modal-body, td { overflow-wrap: anywhere; }

/* thinner, quieter scrollbars */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
html { scroll-behavior: smooth; }

/* respect people who turn animation off */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }

/* phones: comfortable touch targets and no sideways scrolling */
@media (max-width: 640px) {
  .btn { min-height: 42px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; }   /* stops iPhones zooming into a box */
  .page-container { padding-left: var(--sp-3, .75rem); padding-right: var(--sp-3, .75rem); }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media print { .sidebar, .topbar, .toast-container, #vi-layer { display: none !important; } .card { box-shadow: none; } }

/* ================================================================
   DESIGN SYSTEM v2 (Oct 2026): the "world-class" finish.
   Everything is expressed with tokens, so each customer's colours and dark mode flow through.
   ================================================================ */
:root {
  --ctl-border: #000; --ctl-border-hover: #000;
  --surface-2: #f8fafc; --hairline: #e9edf3;
  --ring: color-mix(in srgb, var(--color-primary) 22%, transparent);
  --shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lift: 0 8px 24px rgba(16,24,40,.10), 0 2px 6px rgba(16,24,40,.05);
  --font-ui: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.dark { --ctl-border: #fff; --ctl-border-hover: #fff; --surface-2: #17213a; --hairline: #2a3650; --shadow-card: 0 1px 2px rgba(0,0,0,.35); --shadow-lift: 0 10px 28px rgba(0,0,0,.45); }

/* typography: crisper, calmer hierarchy */
body { font-family: var(--font-ui); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; line-height: 1.55; background: var(--color-bg); }
h1, h2, h3, h4 { letter-spacing: -.012em; }
.page-title { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.page-subtitle { font-size: .92rem; color: var(--color-text-secondary); margin-top: .35rem; max-width: 70ch; }
.page-header { margin-bottom: var(--sp-6); }
.page-container { padding: clamp(1rem, .5rem + 2vw, 2rem); }
.card-title { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.card-subtitle { font-size: .82rem; color: var(--color-text-muted); }
.stat-value, .kpi b, .table td, .badge { font-variant-numeric: tabular-nums; }
.stat-value, .kpi b { letter-spacing: -.02em; }

/* surfaces */
.card, .table-wrapper, .modal, .dh-card { border-color: var(--hairline); box-shadow: var(--shadow-card); }
.card { border-radius: 14px; }
.card-header { border-bottom: 1px solid var(--hairline); padding-block: var(--sp-4); }
a.card:hover, button.card:hover, .card[onclick]:hover, .pf-card:hover { box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--color-primary) 30%, var(--hairline)); }
.modal-overlay { backdrop-filter: blur(3px); background: rgba(15,23,42,.45); }
.modal { border-radius: 18px; box-shadow: 0 30px 80px rgba(15,23,42,.30); }
.modal-title { font-weight: 750; letter-spacing: -.01em; }

/* controls: one finish everywhere */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]):not([type=hidden]), textarea, select {
  border: 2px solid var(--field-border, #000) !important; border-radius: 10px !important; background-color: var(--color-surface); color: var(--color-text);
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]):not([type=hidden]):hover, textarea:hover, select:hover { border-color: var(--ctl-border-hover) !important; }
input:not([type=checkbox]):not([type=radio]):focus, textarea:focus, select:focus { border-color: var(--field-border, #000) !important; box-shadow: 0 0 0 4px var(--ring) !important; outline: 3px solid var(--field-focus, #1d4ed8); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { accent-color: var(--color-primary); }
.form-label { font-weight: 600; font-size: .84rem; color: var(--color-text); }

/* buttons */
.btn { border-radius: 10px; font-weight: 600; min-height: 38px; }
.btn-sm { min-height: 32px; border-radius: 8px; }
.btn-lg { min-height: 46px; border-radius: 12px; }
.btn-primary { background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 92%, #fff), var(--color-primary)); box-shadow: 0 1px 2px rgba(16,24,40,.18), inset 0 1px 0 rgba(255,255,255,.14); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 35%, transparent); }
.btn-outline { border-color: var(--ctl-border); color: var(--color-text); background: var(--color-surface); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); color: var(--color-primary); border-color: var(--color-primary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

/* tables: quiet header, generous rows */
.table-wrapper { border-radius: 14px; background: var(--color-surface); }
.table th { background: var(--surface-2); color: var(--color-text-secondary); font-size: .72rem; letter-spacing: .06em; border-bottom: 1px solid var(--hairline); padding: .7rem var(--sp-4); }
.table td { border-bottom: 1px solid var(--hairline); padding: .8rem var(--sp-4); }
.table tbody tr:hover { background: color-mix(in srgb, var(--color-primary) 4%, transparent); }

/* badges: soft, with a hairline */
.badge { padding: .18rem .6rem; font-size: .72rem; border: 1px solid transparent; }
.badge-success { border-color: color-mix(in srgb, var(--color-success) 22%, transparent); }
.badge-danger  { border-color: color-mix(in srgb, var(--color-danger) 22%, transparent); }
.badge-warning { border-color: color-mix(in srgb, var(--color-warning) 28%, transparent); }
.badge-primary, .badge-info { border-color: color-mix(in srgb, var(--color-primary) 22%, transparent); }

/* tabs */
.tabs { border-bottom: 1px solid var(--hairline); }
.tab { font-weight: 600; transition: color .15s ease, border-color .15s ease; }

/* sidebar: calmer, with a clear active state */
.sidebar { box-shadow: 6px 0 24px rgba(15,23,42,.10); }
.nav-item { border-radius: 10px; font-weight: 550; transition: background-color .15s ease, color .15s ease; }
.nav-item:hover:not(.active) { background: rgba(255,255,255,.07); color: var(--sidebar-text-hover); }
.nav-item.active { font-weight: 650; box-shadow: 0 6px 16px rgba(0,0,0,.22); }
.nav-section-label { letter-spacing: .1em; font-size: .68rem; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }

/* top bar: glassy and sticky */
.topbar { background: color-mix(in srgb, var(--color-surface) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--hairline); position: sticky; top: 0; z-index: var(--z-sticky, 200); }

/* loading */
.spinner { border-color: var(--hairline); border-top-color: var(--color-primary); }
@keyframes ds-shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--hairline) 37%, var(--surface-2) 63%); background-size: 800px 100%; animation: ds-shimmer 1.3s infinite linear; border-radius: 8px; min-height: 1rem; }

/* toasts */
.toast { border-radius: 12px; box-shadow: var(--shadow-lift); font-weight: 550; }
::selection { background: color-mix(in srgb, var(--color-primary) 22%, transparent); }

/* ================================================================
   RESPONSIVE SAFETY NET (every screen from a small phone to a large monitor)
   A flex child will not shrink below its content unless told it may, so one wide table or
   long line used to stretch the whole page past the screen. These rules let the page shrink,
   make wide tables and code scroll inside their own box, and centre the page on big screens.
   ================================================================ */
html, body { max-width: 100%; overflow-x: clip; }
.app-layout { width: 100%; }
.main-content { min-width: 0; max-width: 100%; }
.page-container { min-width: 0; margin-left: auto; margin-right: auto; }
.card, .card-body, .card-header, .modal, .table-wrapper { min-width: 0; max-width: 100%; }
img, video, canvas, iframe { max-width: 100%; }
pre, code, .wf-mono { overflow-wrap: anywhere; }
h1, h2, h3, .page-title, .page-subtitle, .card-title { overflow-wrap: anywhere; }
.topbar { min-width: 0; }
.topbar-right { min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.page-header, .page-head, .filter-bar, .btn-group, .actions { flex-wrap: wrap; }
@media (max-width: 900px) {
  .page-container table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .page-container .table-wrapper table { display: table; }
  .modal { max-width: calc(100vw - 1.5rem); }
  .page-header > div, .page-head > div { min-width: 0; }
  .topbar-right { gap: var(--sp-2); }
}
@media (max-width: 480px) {
  .btn { white-space: normal; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1600px) {
  .page-container { max-width: 1680px; }
}

/* top bar: on narrower screens it may grow to a second row instead of squashing the title or pushing buttons off the screen */
@media (max-width: 1280px) {
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; padding-top: .35rem; padding-bottom: .35rem; row-gap: .35rem; }
  .topbar-left { flex: 1 1 160px; min-width: 0; }
  .topbar-right { flex: 0 1 auto; }
}
@media (max-width: 768px) {
  .sidebar:not(.mobile-open) { box-shadow: none; }   /* the closed menu's shadow used to show as a grey strip at the left edge */
}
@media (max-width: 768px) {
  .card-header, .modal-header { flex-wrap: wrap; row-gap: var(--sp-2); }
  .card-header > *, .modal-header > * { min-width: 0; }
}
