/* ==========================================================================
   LABTECH24 — Admin & Management Portal
   Core design system
   ========================================================================== */

:root {
  /* Brand — matched to LABTECH24 logo (navy + signal red + sky) */
  --primary: #1A428A;
  --primary-600: #15366F;
  --primary-700: #102A56;
  --primary-050: #EEF3FB;
  --primary-100: #D5E1F4;
  --brand-red: #E31B23;
  --brand-red-600: #C4161D;
  --brand-sky: #EAF2F9;

  /* Sidebar — deep navy from logo wordmark */
  --sidebar-bg: #102A56;
  --sidebar-bg-alt: #1A428A;
  --sidebar-border: #243F72;
  --sidebar-text: #C5D3E8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-muted: #8FA3C4;
  --sidebar-width: 264px;
  --sidebar-width-collapsed: 76px;
  --header-height: 64px;

  /* Surfaces — soft sky wash like the logo background */
  --bg: #EAF2F9;
  --surface: #FFFFFF;
  --surface-sunken: #F5F9FC;
  --surface-hover: #EEF4FA;

  /* Text */
  --text: #0F1F3D;
  --text-secondary: #3D4F6F;
  --text-muted: #6B7C99;
  --text-inverse: #FFFFFF;

  /* Lines */
  --border: #D5E0EE;
  --border-strong: #B8C7DC;

  /* Status — danger locked to brand red */
  --success: #067647;
  --success-bg: #ECFDF3;
  --success-border: #ABEFC6;
  --warning: #B54708;
  --warning-bg: #FFFAEB;
  --warning-border: #FEDF89;
  --danger: #E31B23;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --info: #1A428A;
  --info-bg: #EEF3FB;
  --info-border: #B8C9E8;
  --neutral: #3D4F6F;
  --neutral-bg: #EEF2F7;
  --neutral-border: #D5E0EE;
  --violet: #2F5BAF;
  --violet-bg: #EEF3FB;
  --violet-border: #C5D4EE;

  /* Shape */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .12), 0 4px 8px -4px rgba(16, 24, 40, .06);

  /* Type */
  --font-display: 'Manrope', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02', 'cv03', 'cv11';
}

/* Prevent shell flash while sidebar/topbar mount between page navigations */
body:not(.is-auth-page):not(.is-ready) {
  visibility: hidden;
}
body.is-ready,
body.is-auth-page {
  visibility: visible;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text);
  letter-spacing: -.015em;
  margin: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-700); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

::selection { background: var(--primary-100); }

/* Scrollbars */
.scroll-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-thin::-webkit-scrollbar-thumb { background: #C9D1DA; border-radius: 8px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   Typographic utilities
   -------------------------------------------------------------------------- */

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.text-secondary-ui { color: var(--text-secondary) !important; }
.text-muted-ui { color: var(--text-muted) !important; }
.fs-13 { font-size: 13px; }
.fs-12 { font-size: 12px; }
.fs-11 { font-size: 11px; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1045;
  transition: transform .24s var(--ease), width .24s var(--ease);
}

.sidebar__brand {
  height: auto;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 14px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--sidebar-border);
  flex: 0 0 auto;
  text-decoration: none;
}

.sidebar__brand:hover { color: inherit; }

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 52px;
  object-fit: contain;
  object-position: left center;
}

.brand-mark {
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  display: none;
  place-items: center;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.brand-sub {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 12px 20px;
}
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: #2A4A7A; border-radius: 6px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0 10px;
  margin: 18px 0 7px;
}
.nav-group-label:first-child { margin-top: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
  white-space: nowrap;
}
.nav-item i { font-size: 16px; width: 18px; text-align: center; flex: 0 0 18px; opacity: .9; }
.nav-item:hover { background: var(--sidebar-bg-alt); color: #fff; }
.nav-item.active { background: var(--sidebar-bg-alt); color: var(--sidebar-text-active); font-weight: 600; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-red);
}
.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, .08);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
}
.nav-item.active .nav-count { color: #FFE2E3; background: rgba(227, 27, 35, .28); }

.sidebar__footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--sidebar-border);
  padding: 12px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius);
}
.sidebar-user:hover { background: rgba(255, 255, 255, .08); }
.sidebar-user .avatar { background: rgba(227, 27, 35, .18); color: #FFD3D5; }
.sidebar-user__name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-user__role { color: var(--sidebar-muted); font-size: 11.5px; }
.sidebar-user__actions { margin-left: auto; display: flex; gap: 2px; }
.icon-ghost-dark {
  width: 28px; height: 28px; border: 0; background: transparent;
  color: var(--sidebar-muted); border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 15px;
  transition: background .15s, color .15s;
}
.icon-ghost-dark:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* Main column — original shell model (margin only; width is auto) */
.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .24s var(--ease);
}

.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--header-height);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  min-width: 0;
  box-sizing: border-box;
}
.topbar__title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.breadcrumb-line { font-size: 12px; color: var(--text-muted); }
.breadcrumb-line a { color: var(--text-muted); }
.breadcrumb-line a:hover { color: var(--primary); }
.breadcrumb-line .sep { margin: 0 6px; color: var(--border-strong); }

.search-global {
  position: relative;
  width: 320px;
  margin-left: auto;
  min-width: 0;
  flex: 0 1 320px;
}
.search-global i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px;
}
.search-global input {
  width: 100%; height: 36px;
  padding: 0 46px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  font-size: 13px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-global input:focus {
  outline: none; background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-050);
}
.search-global kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-body); font-size: 10.5px; color: var(--text-muted);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: var(--radius-sm); padding: 1px 5px; background: #fff;
}

.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  color: var(--text-secondary);
  display: grid; place-items: center;
  font-size: 17px;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.icon-btn .dot-badge {
  position: absolute; top: 6px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); border: 1.5px solid #fff;
}

.topbar__divider { width: 1px; height: 26px; background: var(--border); }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  transition: background .15s, border-color .15s;
}
.user-chip:hover { background: var(--surface-hover); border-color: var(--border); }
.user-chip__name { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--text); }
.user-chip__role { font-size: 11px; color: var(--text-muted); line-height: 1.25; }

.content {
  flex: 1 1 auto;
  padding: 24px 24px 48px;
  max-width: 1560px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.page-head { margin-bottom: 22px; display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13.5px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.section-title { font-size: 15px; font-weight: 700; }

/* --------------------------------------------------------------------------
   Avatars & status dots
   -------------------------------------------------------------------------- */

.avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-050);
  color: var(--primary-700);
  font-size: 12px; font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: .01em;
}
.avatar-sm { width: 28px; height: 28px; flex-basis: 28px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; flex-basis: 56px; font-size: 18px; border-radius: 12px; }
.avatar-xl { width: 76px; height: 76px; flex-basis: 76px; font-size: 24px; border-radius: 14px; }
.avatar--slate { background: #EEF1F5; color: #475467; }
.avatar--violet { background: var(--violet-bg); color: var(--violet); }
.avatar--green { background: var(--success-bg); color: var(--success); }
.avatar--amber { background: var(--warning-bg); color: var(--warning); }

.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid #fff; margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 7px; }
.dot--success { background: var(--success); }
.dot--warning { background: var(--warning); }
.dot--danger { background: var(--danger); }
.dot--info { background: var(--info); }
.dot--neutral { background: #98A2B3; }
.dot--pulse { box-shadow: 0 0 0 0 rgba(6, 118, 71, .45); animation: pulse 2.4s infinite; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 6px rgba(6, 118, 71, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 118, 71, 0); }
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card-ui {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  max-width: 100%;
  min-width: 0;
}
.card-ui__head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-ui__head h2, .card-ui__head h3 { font-size: 14.5px; font-weight: 700; }
.card-ui__head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.card-ui__head .head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-ui__body { padding: 18px; }
.card-ui__body--flush { padding: 0; }
.card-ui__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

/* KPI */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  height: 100%;
  transition: box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.kpi:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.kpi__top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.kpi__icon {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 8px; display: grid; place-items: center;
  font-size: 15px;
  background: var(--neutral-bg); color: var(--text-secondary);
}
.kpi__icon--primary { background: var(--primary-050); color: var(--primary); }
.kpi__icon--success { background: var(--success-bg); color: var(--success); }
.kpi__icon--warning { background: var(--warning-bg); color: var(--warning); }
.kpi__icon--danger { background: var(--danger-bg); color: var(--danger); }
.kpi__icon--violet { background: var(--violet-bg); color: var(--violet); }
.kpi__label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.kpi__value {
  font-family: var(--font-display);
  font-size: 27px; font-weight: 700; letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi__meta { margin-top: 8px; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; }
.delta--up { color: var(--success); }
.delta--down { color: var(--danger); }
.delta--flat { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Badges & pills
   -------------------------------------------------------------------------- */

.badge-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11.5px; font-weight: 600;
  line-height: 1.6;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-status--success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-status--warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge-status--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-status--info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge-status--violet { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-border); }
.badge-status--neutral { background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-border); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; color: var(--text-secondary);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  --bs-btn-font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.btn i { font-size: 14px; }

.btn-primary,
.btn-primary:focus {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(26, 66, 138, .22);
}
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-primary:active { background: var(--primary-700) !important; border-color: var(--primary-700) !important; }

.btn-accent,
.btn-accent:focus {
  background: var(--brand-red); border-color: var(--brand-red); color: #fff;
  box-shadow: 0 1px 2px rgba(227, 27, 35, .25);
}
.btn-accent:hover { background: var(--brand-red-600); border-color: var(--brand-red-600); color: #fff; }

.btn-outline-neutral {
  background: #fff; border: 1px solid var(--border); color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}
.btn-outline-neutral:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }

.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger-soft { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }
.btn-danger-soft:hover { background: #FEE4E2; color: var(--danger); }

.btn-sm { font-size: 12.5px; padding: 4px 10px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }

.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::before {
  content: ''; width: 13px; height: 13px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group-seg { display: inline-flex; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.btn-group-seg button {
  border: 0; background: transparent; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  padding: 4px 12px; transition: background .15s, color .15s;
}
.btn-group-seg button:hover { color: var(--text); }
.btn-group-seg button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-label {
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 11px;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.form-control::placeholder { color: #9AA4B5; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-050);
}
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.invalid-feedback { font-size: 12px; color: var(--danger); }
.form-text { font-size: 12px; color: var(--text-muted); }

.form-section { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.form-section__title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.form-section__hint { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }

.input-icon { position: relative; }
.input-icon > i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.input-icon .form-control { padding-left: 31px; }

.form-switch .form-check-input { width: 36px; height: 20px; margin-top: 1px; background-color: #D3D8DF; border: 0; box-shadow: none; }
.form-switch .form-check-input:checked { background-color: var(--primary); }
.form-switch .form-check-input:focus { box-shadow: 0 0 0 3px var(--primary-050); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-label { font-size: 13.5px; }

.setting-row {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row__text { flex: 1 1 auto; }
.setting-row__text strong { font-size: 13.5px; font-weight: 600; display: block; }
.setting-row__text span { font-size: 12.5px; color: var(--text-muted); }

/* Filter bar */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.filter-bar .form-select, .filter-bar .form-control { height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.filter-bar .search-wrap { flex: 1 1 240px; max-width: 320px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-ui { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.table-ui thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-sunken);
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.table-ui tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-secondary);
  vertical-align: middle;
  white-space: nowrap;
}
.table-ui tbody tr { transition: background .12s var(--ease); }
.table-ui tbody tr:hover { background: var(--surface-hover); }
.table-ui tbody tr:last-child td { border-bottom: 0; }
.table-ui .cell-strong { color: var(--text); font-weight: 600; }
.table-ui .cell-id { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.table-ui td.text-end, .table-ui th.text-end { text-align: right; }
.table-ui .row-actions { width: 44px; }

.person-cell { display: flex; align-items: center; gap: 10px; }
.person-cell__name { color: var(--text); font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.person-cell__sub { font-size: 12px; color: var(--text-muted); line-height: 1.3; }

.table-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.table-foot__count { font-size: 12.5px; color: var(--text-muted); }

.pagination-ui { display: flex; gap: 4px; margin-left: auto; }
.pagination-ui button {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius); font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  transition: background .15s, color .15s, border-color .15s;
}
.pagination-ui button:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.pagination-ui button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-ui button:disabled { opacity: .45; cursor: not-allowed; }

/* Dropdowns */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  font-size: 13.5px;
  min-width: 190px;
}
.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px;
}
.dropdown-item i { font-size: 15px; color: var(--text-muted); width: 16px; }
.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-item:hover i { color: var(--text-secondary); }
.dropdown-item.text-danger, .dropdown-item.text-danger i { color: var(--danger); }
.dropdown-item.text-danger:hover { background: var(--danger-bg); color: var(--danger); }
.dropdown-header {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 10px 4px;
}
.dropdown-divider { margin: 5px 0; border-color: var(--border); }

/* --------------------------------------------------------------------------
   Schedule list / timeline
   -------------------------------------------------------------------------- */

.schedule-item {
  display: flex; gap: 14px; padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .12s var(--ease);
}
.schedule-item:last-child { border-bottom: 0; }
.schedule-item:hover { background: var(--surface-hover); }
.schedule-item__time {
  flex: 0 0 66px;
  font-size: 13px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.schedule-item__time span { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); }
.schedule-item__rail { flex: 0 0 3px; border-radius: 3px; background: var(--border-strong); }
.schedule-item__rail--success { background: var(--success); }
.schedule-item__rail--warning { background: var(--warning); }
.schedule-item__rail--info { background: var(--info); }
.schedule-item__rail--danger { background: var(--danger); }
.schedule-item__body { flex: 1 1 auto; min-width: 0; }
.schedule-item__title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.schedule-item__meta { font-size: 12.5px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 2px; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline__item { position: relative; padding-bottom: 18px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: ''; position: absolute; left: -23px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border-strong);
}
.timeline__item--primary::before { border-color: var(--primary); }
.timeline__item--success::before { border-color: var(--success); }
.timeline__item--warning::before { border-color: var(--warning); }
.timeline__item--danger::before { border-color: var(--danger); }
.timeline__text { font-size: 13.5px; color: var(--text); }
.timeline__text strong { font-weight: 600; }
.timeline__time { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Availability */
.availability-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 18px; border-bottom: 1px solid var(--border);
}
.availability-row:last-child { border-bottom: 0; }
.availability-row__name { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.availability-row__role { font-size: 12px; color: var(--text-muted); }
.availability-row__hours { margin-left: auto; text-align: right; }
.availability-row__hours strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Capacity meter */
.meter { height: 6px; border-radius: 3px; background: var(--neutral-bg); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 3px; background: var(--primary); transition: width .5s var(--ease); }
.meter__fill--success { background: var(--success); }
.meter__fill--warning { background: var(--warning); }
.meter__fill--danger { background: var(--danger); }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */

.chart-box { position: relative; height: 268px; }
.chart-box--sm { height: 200px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tabs-ui {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tabs-ui button {
  border: 0; background: transparent;
  padding: 11px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.tabs-ui button:hover { color: var(--text); background: var(--surface-hover); }
.tabs-ui button:focus-visible { outline-offset: -2px; }
.tabs-ui button.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.tabs-ui button[hidden] { display: none !important; }

.tab-panels { position: relative; }
.tab-panel {
  display: none;
  animation: tab-in .18s var(--ease);
}
.tab-panel.active { display: block; }
.tab-panel[hidden] { display: none !important; animation: none; }

@keyframes tab-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Definition list
   -------------------------------------------------------------------------- */

.dl-ui { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 0; margin: 0; }
.dl-ui dt {
  font-size: 12.5px; color: var(--text-muted); font-weight: 500;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.dl-ui dd {
  font-size: 13.5px; color: var(--text); font-weight: 500; margin: 0;
  padding: 8px 0; border-bottom: 1px solid var(--border); text-align: right;
}
.dl-ui dt:last-of-type, .dl-ui dd:last-of-type { border-bottom: 0; }

/* --------------------------------------------------------------------------
   Modals, toasts, empty & loading states
   -------------------------------------------------------------------------- */

.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-header p { margin: 3px 0 0; font-size: 13px; color: var(--text-muted); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-sunken); border-radius: 0 0 var(--radius-lg) var(--radius-lg); gap: 8px; }
.modal-backdrop.show { opacity: .35; }

.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 1090;
  display: flex; flex-direction: column; gap: 10px;
  width: 340px; max-width: calc(100vw - 32px);
}
.toast-ui {
  display: flex; gap: 11px; align-items: flex-start;
  background: #fff; border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s var(--ease);
}
.toast-ui.hide { animation: toast-out .18s var(--ease) forwards; }
.toast-ui--success { border-left-color: var(--success); }
.toast-ui--danger { border-left-color: var(--danger); }
.toast-ui--warning { border-left-color: var(--warning); }
.toast-ui i.lead-icon { font-size: 17px; line-height: 1.2; }
.toast-ui--success i.lead-icon { color: var(--success); }
.toast-ui--danger i.lead-icon { color: var(--danger); }
.toast-ui--warning i.lead-icon { color: var(--warning); }
.toast-ui--info i.lead-icon { color: var(--primary); }
.toast-ui strong { font-size: 13.5px; display: block; }
.toast-ui p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-muted); }
.toast-ui button { margin-left: auto; border: 0; background: transparent; color: var(--text-muted); font-size: 15px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

.empty-state { text-align: center; padding: 44px 24px; }
.empty-state__icon {
  width: 44px; height: 44px; margin: 0 auto 14px;
  border-radius: 10px; display: grid; place-items: center;
  background: var(--neutral-bg); color: var(--text-muted); font-size: 20px;
}
.empty-state h3 { font-size: 14.5px; font-weight: 700; }
.empty-state p { font-size: 13px; color: var(--text-muted); margin: 4px auto 16px; max-width: 340px; }

.skeleton {
  background: linear-gradient(90deg, #EEF1F4 25%, #F6F8FA 37%, #EEF1F4 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s var(--ease) infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-line { height: 10px; margin-bottom: 9px; }

.tooltip-inner { font-size: 12px; padding: 5px 9px; border-radius: var(--radius-sm); background: #101828; }
.tooltip.show { opacity: 1; }

/* Notification dropdown */
.notif-menu { width: 372px; padding: 0; max-width: calc(100vw - 24px); }
.notif-menu__head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.notif-menu__head strong { font-size: 13.5px; }
.notif-list { max-height: 344px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 11px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.notif-item:hover { background: var(--surface-hover); }
.notif-item__icon {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 7px;
  display: grid; place-items: center; font-size: 14px;
}
.notif-item__title { font-size: 13px; font-weight: 600; color: var(--text); }
.notif-item__desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.notif-item__time { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.notif-item--unread { background: var(--primary-050); }
.notif-item--unread:hover { background: var(--primary-100); }
.notif-menu__foot { padding: 10px 16px; text-align: center; }
.notif-menu__foot a { font-size: 13px; font-weight: 600; }

/* Role switcher */
.role-switch {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3px 3px 3px 10px;
}
.role-switch__label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.role-switch select {
  border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  color: var(--text); padding: 3px 24px 3px 8px; height: 28px;
}
.demo-note {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}

/* Calendar */
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.fc { --fc-border-color: var(--border); --fc-today-bg-color: var(--primary-050); font-size: 13px; }
.fc .fc-toolbar-title { font-family: var(--font-display); font-size: 16px !important; font-weight: 700; }
.fc .fc-col-header-cell-cushion { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 8px 4px; }
.fc .fc-daygrid-day-number { font-size: 12px; color: var(--text-secondary); font-weight: 600; padding: 6px 8px; }
.fc .fc-button { background: #fff !important; border: 1px solid var(--border) !important; color: var(--text-secondary) !important; font-size: 12.5px !important; font-weight: 600 !important; box-shadow: none !important; text-transform: capitalize; padding: 5px 11px !important; border-radius: var(--radius) !important; }
.fc .fc-button:hover { background: var(--surface-hover) !important; color: var(--text) !important; }
.fc .fc-button-active { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
.fc .fc-event { border: 0; border-radius: var(--radius-sm); padding: 0; background: transparent; }
.fc-event-main { padding: 0; }
.cal-event {
  border-left: 3px solid var(--primary);
  background: var(--primary-050);
  border-radius: 3px;
  padding: 3px 6px;
  overflow: hidden;
}
.cal-event strong { display: block; font-size: 11.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event span { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.cal-event--success { border-left-color: var(--success); background: var(--success-bg); }
.cal-event--warning { border-left-color: var(--warning); background: var(--warning-bg); }
.cal-event--danger { border-left-color: var(--danger); background: var(--danger-bg); }
.cal-event--neutral { border-left-color: #98A2B3; background: var(--neutral-bg); }

/* Message bubble preview */
.sms-preview {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.char-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-count.over { color: var(--danger); font-weight: 600; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 480px);
  background: var(--bg);
}

.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(16, 42, 86, .94) 0%, rgba(26, 66, 138, .88) 52%, rgba(227, 27, 35, .55) 100%),
    radial-gradient(1100px 560px at 12% 0%, #3B6BC0 0%, transparent 58%),
    #102A56;
  overflow: hidden;
}

.login-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, #000 20%, transparent 90%);
  pointer-events: none;
}

.login-visual__content { position: relative; z-index: 1; max-width: 460px; }
.login-visual__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.72);
  margin-bottom: 14px;
}
.login-visual__eyebrow::before {
  content: '';
  width: 18px; height: 2px;
  background: var(--brand-red);
  border-radius: 2px;
}
.login-visual h1 {
  color: #fff;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.15;
  margin-bottom: 12px;
}
.login-visual p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255,255,255,.78);
  max-width: 38ch;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background:
    radial-gradient(800px 400px at 100% 0%, rgba(26, 66, 138, .10), transparent 60%),
    var(--brand-sky);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px 28px;
}

.login-card__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.login-card__brand img {
  display: block;
  width: min(100%, 260px);
  height: auto;
}

.login-card h2 {
  font-size: 20px;
  margin-bottom: 6px;
  text-align: center;
}
.login-card__lead {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 22px;
}

.login-card .form-label { font-weight: 600; font-size: 12.5px; color: var(--text-secondary); }
.login-card .form-control {
  border-radius: var(--radius);
  border-color: var(--border-strong);
  padding: 10px 12px;
  font-size: 14px;
}
.login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 66, 138, .16);
}

.login-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 18px;
  font-size: 13px;
}
.login-meta a { font-weight: 600; }

.login-error {
  display: none;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
}
.login-error.is-visible { display: flex; }

.login-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--primary-050);
  border: 1px solid var(--primary-100);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.login-hint strong { color: var(--text); font-weight: 600; }
.login-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.login-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.login-footer a {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.login-success {
  text-align: center;
  padding-top: 4px;
}
.login-success__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-050);
  color: var(--primary);
  font-size: 24px;
  border: 1px solid var(--primary-100);
}
.login-success h2 { margin-bottom: 8px; }

@media (max-width: 991.98px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { min-height: 220px; padding: 28px 24px; }
  .login-visual h1 { font-size: 28px; }
  .login-panel { padding: 28px 18px 40px; }
}

/* Utility */
.stack-divider > * + * { border-top: 1px solid var(--border); }
.hairline { height: 1px; background: var(--border); border: 0; margin: 0; }
.no-wrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
