/* ── Global Typography Scaling ───────────────────────────────── */
:root {
  font-size: 16px;
  /* Default desktop base */
}

@media (max-width: 1200px) {
  :root {
    font-size: 15px;
  }

  /* Tablet Scaling */
}

@media (max-width: 768px) {
  :root {
    font-size: 14px;
  }

  /* Mobile/Small Tablet Scaling */
}

/* ── Premium UI Variables ────────────────────────────────────── */
:root {
  /* Layout Colors */
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --muted: #64748b;
  --line: #e2e8f0;

  /* Primary & Accents (Black in Light, Blue in Dark) */
  --primary: #0f172a;
  --primary-dark: #1e293b;
  --primary-light: #f1f5f9;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --topbar-h: 70px;

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --shadow-focus: 0 0 0 4px rgba(14, 165, 233, 0.15);

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography Scale (Responsive) */
  --font-xs: 0.75rem;
  /* 12px */
  --font-sm: 0.875rem;
  /* 14px */
  --font-base: 1rem;
  /* 16px */
  --font-lg: 1.125rem;
  /* 18px */
  --font-xl: 1.25rem;
  /* 20px */
  --font-2xl: clamp(1.5rem, 4vw, 2.5rem);
  /* Fluid Heading 24px - 40px */
  --font-3xl: clamp(2rem, 5vw, 3.5rem);
  /* Massive Fluid Heading */

  /* Action Accents (Mirrors Primary) */
  --accent-action: var(--primary);
  --accent-action-hov: var(--primary-dark);
  --accent-action-text: #ffffff;
}

/* ── Dark Mode Overrides ────────────────────────────────────── */
body.dark-mode {
  --bg: #0f172a !important;
  --card: #1e293b !important;
  --text: #f8fafc !important;
  --text-muted: #94a3b8 !important;
  --muted: #94a3b8 !important;
  --line: #334155 !important;

  /* Sidebar dark deepens */
  --sidebar-bg: #020617 !important;
  --sidebar-text: #f1f5f9 !important;

  /* Topbar deepens */
  --topbar-bg: rgba(15, 23, 42, 0.9) !important;

  /* Switch Primary to Blue in Dark mode */
  --primary: #4a7ef7 !important;
  --primary-dark: #60a5fa !important;
  --primary-light: rgba(74, 126, 247, 0.1) !important;

  /* Action Accents switch to Blue in Dark Mode */
  --accent-action: var(--primary) !important;
  --accent-action-hov: var(--primary-dark) !important;
}

/* ── Reset & Typography ─────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: var(--font-sm);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color var(--transition);
}

img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
div,
td,
th {
  word-break: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

h1 {
  font-size: var(--font-3xl);
}

h2 {
  font-size: var(--font-2xl);
}

h3 {
  font-size: var(--font-xl);
}

h4 {
  font-size: var(--font-lg);
}

h5 {
  font-size: var(--font-base);
}

h6 {
  font-size: var(--font-sm);
}

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.guest-main {
  width: 100%;
  max-width: 100vw;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  color: #e5edf8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  overflow: hidden;
  z-index: 200;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px
}

.brand-icon {
  font-size: var(--font-xl);
  flex-shrink: 0
}

.brand-name {
  font-weight: 800;
  font-size: var(--font-base);
  letter-spacing: -.4px;
  white-space: nowrap
}

.brand-sub {
  font-size: var(--font-xs);
  color: #8896a8;
  font-weight: 500;
  white-space: nowrap
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: #8896a8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1
}

.sidebar-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08)
}

/* Nav */
.sidebar-nav {
  padding: 12px 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: #2d3748;
  border-radius: 4px;
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  color: #5d718a;
  padding: 18px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
  transition: background 0.2s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 700;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: #3b82f6;
  /* Bright blue indicator */
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.nav-icon {
  font-size: var(--font-base);
  flex-shrink: 0;
  width: 20px;
  text-align: center
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis
}

.nav-logout {
  color: #f87171 !important
}

.nav-logout:hover {
  background: rgba(248, 113, 113, .12) !important
}

/* ── Collapsed sidebar (icon-only) ─ desktop ──────────────── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed)
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 10px 8px
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 20px 8px 16px
}

.sidebar.collapsed .brand {
  gap: 0
}

/* ── Toggle button (desktop collapse) ─────────────────────── */
.sidebar-toggle {
  position: fixed;
  top: 18px;
  left: 12px;
  z-index: 300;
  display: none;
  /* shown only on mobile via media query */
  flex-direction: column;
  gap: 5px;
  background: var(--sidebar-bg);
  border: none;
  border-radius: 8px;
  padding: 12px 10px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #e5edf8;
  border-radius: 2px;
  transition: var(--transition)
}

/* Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  height: var(--topbar-h);
}

.topbar-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: var(--font-base);
}

.topbar-action:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: var(--font-xs);
  font-weight: 700;
  padding: 2px 5px;
  min-width: 18px;
  text-align: center;
  border: 2px solid var(--card);
}

.profile-img {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.profile-dd {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 1000;
  padding: 8px 0;
  animation: ddFadeIn 0.2s ease-out;
}

@keyframes ddFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition);
}

.dd-item:hover {
  background: #f8fafc;
}

.topbar h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.topbar .muted {
  font-size: 12px;
  margin-top: 2px
}

.page-body {
  padding: 20px 24px 32px;
  flex: 1
}

/* ═══════════════════════════════════════════════════════════
   CARDS & LAYOUT
═══════════════════════════════════════════════════════════ */
.auth-card,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.auth-card {
  max-width: 440px;
  margin: 60px auto;
  padding: 32px 40px;
}

.auth-card.wide {
  max-width: 860px;
}

.card {
  padding: 24px;
  background: var(--card);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h3 {
  margin-top: 0;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.cards,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px
}

.stat p,
.stat-value {
  font-size: 34px;
  font-weight: 700;
  margin: 8px 0 0
}

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.split>.card.form-card {
  flex: 0 0 360px;
}

.split>.card.table-card {
  flex: 1;
  min-width: 0;
  /* Prevents flex-child from overflowing */
}

@media (max-width: 991px) {

  .split>.card.form-card,
  .split>.card.table-card {
    flex: 1 1 100%;
  }
}

.table-responsive-view {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.form-card {
  align-self: start
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.grid-form .full {
  grid-column: 1/-1
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px
}

.three-col {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))
}

.split.triple {
  grid-template-columns: repeat(3, minmax(0, 1fr))
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0 18px
}

.kpi-strip .card {
  padding: 16px
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 16px 0
}

.table-card {
  overflow: auto
}

/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: 0.01em;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--text);
  font-size: 14px;
  transition: all var(--transition);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

input:hover,
select:hover,
textarea:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.compact-form input,
.compact-form select,
.compact-form textarea {
  min-height: 40px;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--primary) !important;
  color: #ffffff !important;
}

.btn.success {
  background: var(--success);
}

.btn.success:hover {
  background: #059669;
}

.btn.danger,
.btn-danger {
  background: var(--danger);
}

.btn.danger:hover,
.btn-danger:hover {
  background: #dc2626;
}

.btn.small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-light {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.btn-light:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════════════ */
.table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.table th,
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

.table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--line);
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-muted {
  background: #f1f5f9;
  color: #475569;
}

/* ═══════════════════════════════════════════════════════════
   FLASH MESSAGES
═══════════════════════════════════════════════════════════ */
.flash {
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.flash.success {
  background: #ecfdf5;
  color: #064e3b;
  border-left: 4px solid var(--success);
}

.flash.error {
  background: #fef2f2;
  color: #7f1d1d;
  border-left: 4px solid var(--danger);
}

/* ═══════════════════════════════════════════════════════════
   TOOLBAR & MISC
═══════════════════════════════════════════════════════════ */
.toolbar,
.toolbar-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 12px;
  flex-wrap: wrap
}

.table-search {
  max-width: 240px
}

.actions-inline {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center
}

.actions-inline .btn {
  white-space: nowrap
}

.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap
}

.page-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800
}

.page-header p {
  margin: 4px 0 0;
  color: var(--muted)
}

.toolbar-between h1 {
  margin: 0
}

.muted {
  color: var(--muted)
}

.error-text {
  color: var(--danger);
  font-size: 13px
}

.subtle {
  font-size: 12px;
  color: var(--muted)
}

.empty-state {
  padding: 40px 28px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  text-align: center
}

.empty-note {
  padding: 16px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted)
}

.mt-16 {
  margin-top: 16px
}

.mb-16 {
  margin-bottom: 16px
}

.list {
  padding-left: 18px
}

.list li {
  margin-bottom: 8px
}

.list-plain {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px
}

.list-plain li {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  color: var(--muted)
}

.module-shell {
  display: grid;
  gap: 16px
}

.page-subtitle {
  color: var(--muted);
  margin-top: 4px
}

.kpi-mini {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.kpi-mini strong {
  font-size: 22px
}

.stat-label {
  color: var(--muted);
  font-size: 13px
}

.card.compact {
  padding: 16px
}

.form-grid {
  display: grid;
  gap: 1rem
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid #d9dee8;
  border-radius: var(--radius);
  background: #fff
}

.report-grid .card {
  min-height: 280px
}

/* ═══════════════════════════════════════════════════════════
   ANNOUNCEMENT
═══════════════════════════════════════════════════════════ */
.announcement {
  padding: 14px 0;
  border-bottom: 1px solid var(--line)
}

.announcement.pinned h3::after {
  content: '📌';
  margin-left: 8px
}

/* ═══════════════════════════════════════════════════════════
   CHAT — WhatsApp Style
═══════════════════════════════════════════════════════════ */
/* Legacy (kept for compat) */
.chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start
}

.chat-sidebar {
  min-height: 520px
}

.chat-main {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  height: 600px
}

.chat-channel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background var(--transition)
}

.chat-channel.active {
  border-color: var(--primary);
  background: #eef4ff
}

.chat-channel span {
  font-size: 12px;
  color: var(--muted)
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  min-height: 0;
  background: #f0f2f5
}

.chat-bubble {
  max-width: 65%;
  padding: 8px 12px 6px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
  background: #fff;
  border-radius: 0 8px 8px 8px
}

.chat-bubble.self {
  align-self: flex-end;
  background: #d9fdd3;
  border-radius: 8px 0 8px 8px
}

.chat-bubble .meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
  align-items: center;
  flex-wrap: wrap
}

.chat-form {
  display: grid;
  gap: 8px
}

/* ── WA Container ─────────────────── */
.wa-wrap {
  display: flex;
  height: calc(100vh - var(--topbar-h) - 52px);
  min-height: 480px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow)
}

/* ── WA Sidebar ───────────────────── */
.wa-sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--card)
}

.wa-sidebar-hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: var(--card)
}

.wa-search-bar {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 999px;
  padding: 7px 13px;
  gap: 8px;
  border: 1px solid var(--line)
}

.wa-search-bar input {
  background: none;
  border: none;
  outline: none;
  flex: 1;
  font-size: 13.5px;
  color: var(--text);
  padding: 0;
  width: auto;
  box-shadow: none
}

.wa-chan-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent
}

.wa-chan-list::-webkit-scrollbar {
  width: 4px
}

.wa-chan-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px
}

.wa-chan-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text)
}

.wa-chan-item:hover {
  background: var(--bg)
}

.wa-chan-item.active {
  background: #eef4ff
}

.wa-avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -.5px;
  font-size: 16px;
  width: 46px;
  height: 46px
}

.wa-chan-info {
  flex: 1;
  min-width: 0
}

.wa-chan-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.wa-chan-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px
}

.wa-chan-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0
}

.wa-unread {
  background: #25d366;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center
}

.wa-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 18px;
  transition: background var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0
}

.wa-icon-btn:hover {
  background: var(--bg);
  color: var(--text)
}

/* ── WA Main ──────────────────────── */
.wa-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f0f2f5
}

.wa-chat-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0
}

.wa-hd-info {
  flex: 1;
  min-width: 0
}

.wa-hd-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.wa-hd-sub {
  font-size: 12px;
  color: var(--muted)
}

.wa-hd-actions {
  display: flex;
  gap: 2px
}

.wa-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  scrollbar-width: thin
}

.wa-msgs::-webkit-scrollbar {
  width: 5px
}

.wa-msgs::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .15);
  border-radius: 4px
}

.wa-date-div {
  display: flex;
  justify-content: center;
  margin: 10px 0
}

.wa-date-div span {
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: #555
}

/* ── WA Bubbles ───────────────────── */
.wa-msg {
  display: flex;
  flex-direction: column;
  max-width: 65%;
  margin-bottom: 1px
}

.wa-msg.self {
  align-self: flex-end;
  align-items: flex-end
}

.wa-msg.other {
  align-self: flex-start;
  align-items: flex-start
}

.wa-bub {
  padding: 7px 11px 5px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
  max-width: 100%
}

.wa-msg.self .wa-bub {
  background: #d9fdd3;
  border-radius: 8px 0 8px 8px;
  color: #111
}

.wa-msg.other .wa-bub {
  background: #fff;
  border-radius: 0 8px 8px 8px;
  color: #111
}

.wa-bub.pinned {
  border-left: 3px solid #f6ad55
}

.wa-bub-sender {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px
}

.wa-bub-text {
  white-space: pre-wrap;
  word-break: break-word
}

.wa-attach a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .05)
}

.wa-attach a:hover {
  background: rgba(0, 0, 0, .1)
}

.wa-bub-ft {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  justify-content: flex-end
}

.wa-bub-time {
  font-size: 11px;
  color: #888;
  white-space: nowrap
}

.wa-bub-tick {
  font-size: 12px;
  line-height: 1
}

.wa-bub-tick.read {
  color: #53bdeb
}

.wa-bub-tick.sent {
  color: #aaa
}

/* ── WA Compose ───────────────────── */
.wa-compose {
  padding: 8px 14px;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0
}

.wa-compose-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 22px;
  border: 1px solid var(--line);
  padding: 7px 13px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  min-height: 42px
}

.wa-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  color: var(--text);
  max-height: 120px;
  min-height: 22px;
  line-height: 1.6;
  padding: 0;
  width: auto;
  overflow-y: auto;
  box-shadow: none
}

.wa-textarea::placeholder {
  color: var(--muted)
}

.wa-textarea:focus {
  border: none;
  box-shadow: none
}

.wa-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #25d366;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 19px;
  flex-shrink: 0;
  transition: background var(--transition), transform .15s;
  box-shadow: 0 2px 8px rgba(37, 211, 102, .3)
}

.wa-send:hover {
  background: #1da851;
  transform: scale(1.06)
}

.wa-send:active {
  transform: scale(.95)
}

/* ── WA Slide panels ──────────────── */
.wa-slide-panel {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  animation: slideDown .2s ease
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* ── Dark mode ────────────────────── */
body.dark-mode .wa-wrap {
  border-color: #2d3748
}

body.dark-mode .wa-sidebar {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode .wa-sidebar-hd {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode .wa-search-bar {
  background: #0f1117;
  border-color: #2d3748
}

body.dark-mode .wa-chan-item {
  border-color: #2d3748
}

body.dark-mode .wa-chan-item:hover {
  background: #232a3b
}

body.dark-mode .wa-chan-item.active {
  background: #1e2d4f
}

body.dark-mode .wa-chat-hd {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode .wa-compose {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode .wa-compose-wrap {
  background: #0f1117;
  border-color: #2d3748
}

body.dark-mode .wa-main {
  background: #0d1117
}

body.dark-mode .wa-msg.self .wa-bub {
  background: #025c4c;
  color: #e5edf8
}

body.dark-mode .wa-msg.other .wa-bub {
  background: #1a1f2e;
  color: #e5edf8
}

body.dark-mode .wa-date-div span {
  background: rgba(30, 40, 60, .9);
  color: #aaa;
  border-color: rgba(255, 255, 255, .08)
}

body.dark-mode .wa-icon-btn:hover {
  background: #232a3b;
  color: #e5edf8
}

body.dark-mode .wa-slide-panel {
  background: #0f1117;
  border-color: #2d3748
}

/* ── Responsive ───────────────────── */
@media(max-width:768px) {
  .wa-wrap {
    position: relative;
    height: calc(100vh - var(--topbar-h) - 26px);
    border-radius: 10px
  }

  .wa-sidebar {
    position: absolute;
    inset: 0;
    z-index: 10;
    width: 100%
  }

  .wa-sidebar.wa-hidden {
    display: none
  }

  .wa-main {
    position: absolute;
    inset: 0;
    z-index: 10;
    width: 100%
  }

  .wa-main.wa-hidden {
    display: none
  }

  .wa-back-btn {
    display: inline-flex !important
  }

  .wa-msg {
    max-width: 85%
  }
}

@media(max-width:480px) {
  .wa-msg {
    max-width: 92%
  }
}

/* ═══════════════════════════════════════════════════════════
   ORG CHART
═══════════════════════════════════════════════════════════ */
.org-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px
}

.org-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 4px
}

.org-list span {
  font-size: 12px;
  color: var(--muted)
}

/* ═══════════════════════════════════════════════════════════
   RAISE REQUEST
═══════════════════════════════════════════════════════════ */
.request-type-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center
}

.request-type-card:hover,
.request-type-card.selected {
  border-color: var(--primary);
  background: #eef4ff
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════════ */
body.dark-mode {
  --bg: #0f1117;
  --card: #1a1f2e;
  --text: #e5edf8;
  --muted: #8896a8;
  --line: #2d3748;
  --primary: #4a7ef7
}

body.dark-mode .sidebar {
  background: #0a0e17
}

body.dark-mode .topbar {
  background: #1a1f2e
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #232a3b;
  color: #e5edf8;
  border-color: #2d3748
}

body.dark-mode .table th {
  background: #1a1f2e
}

body.dark-mode .kanban-col {
  background: #151a25
}

body.dark-mode .kanban-card {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode .flash.success {
  background: #14532d;
  color: #bbf7d0
}

body.dark-mode .flash.error {
  background: #7f1d1d;
  color: #fecaca
}

body.dark-mode .btn-light {
  background: #232a3b;
  color: #e5edf8;
  border-color: #2d3748
}

body.dark-mode .card {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  border-color: var(--primary)
}

body.dark-mode .empty-state {
  background: #1a1f2e;
  border-color: #2d3748
}

body.dark-mode .table tbody tr:hover {
  background: #1e2538
}

body.dark-mode .nav-section {
  color: #2d3f55
}

body.dark-mode .topbar h2 {
  color: #e5edf8
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤1024px)
═══════════════════════════════════════════════════════════ */
@media (max-width:1024px) {
  :root {
    --sidebar-w: 210px
  }

  .split.triple {
    grid-template-columns: 1fr 1fr
  }

  .page-body {
    padding: 16px 18px 28px
  }

  .topbar {
    padding: 12px 18px
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤768px)
═══════════════════════════════════════════════════════════ */
@media (max-width:768px) {

  /* Show hamburger */
  .sidebar-toggle {
    display: flex
  }

  .sidebar-close {
    display: block
  }

  /* Sidebar slides in from left as overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4, 0, .2, 1);
    z-index: 400;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .3);
  }

  .sidebar.open {
    transform: translateX(0)
  }

  .sidebar-backdrop.open {
    display: block
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0 !important
  }

  .page-body {
    padding: 12px 14px 24px
  }

  .topbar {
    padding: 10px 14px;
    padding-left: 52px;
    min-height: 56px
  }

  .topbar h2 {
    font-size: 16px
  }

  /* Flatten grids */
  .split,
  .chat-layout,
  .grid-two,
  .split.triple,
  .section-grid,
  .kpi-strip {
    grid-template-columns: 1fr
  }

  .grid-form {
    grid-template-columns: 1fr
  }

  .cards,
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr))
  }

  .chart-grid {
    grid-template-columns: 1fr
  }

  .permission-grid {
    grid-template-columns: 1fr
  }

  /* Table scroll */
  .table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .table-responsive-view {
    width: 100%;
    margin-bottom: 0;
  }

  .table {
    min-width: 600px
  }

  /* Toolbar stacks */
  .toolbar,
  .toolbar-between {
    flex-direction: column;
    align-items: flex-start
  }

  .table-search {
    max-width: 100%;
    width: 100%
  }

  /* Hide secondary columns in tables on tiny screens */
  .hide-mobile {
    display: none !important;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start
  }

  .page-header h1 {
    font-size: 22px
  }

  .actions-inline {
    flex-wrap: wrap
  }

  .btn {
    font-size: 12px;
    padding: 8px 12px
  }

  .auth-card {
    margin: 20px auto;
    padding: 20px;
    max-width: calc(100% - 28px)
  }

  .auth-card.wide {
    max-width: calc(100% - 28px)
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Small Mobile (≤480px)
═══════════════════════════════════════════════════════════ */
@media (max-width:480px) {

  .cards,
  .stats-grid {
    grid-template-columns: 1fr 1fr
  }

  .stat p,
  .stat-value {
    font-size: 26px
  }

  .btn.small {
    padding: 5px 8px;
    font-size: 11px
  }

  .badge {
    font-size: 10.5px;
    padding: 2px 7px
  }
}

/* ═══════════════════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════════════════ */
@media print {

  .sidebar,
  .sidebar-toggle,
  .topbar,
  .sidebar-backdrop,
  .btn,
  .flash {
    display: none !important
  }

  .main-content {
    margin: 0 !important
  }

  .page-body {
    padding: 0
  }

  .table {
    font-size: 11px
  }
}

/* ═══════════════════════════════════════════════════════════
   PATCH — Missing classes (bugfix pass)
═══════════════════════════════════════════════════════════ */

/* ── stat-card — used on dashboard KPI and automation stats ── */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
}

.stat-card span,
.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.stat-card strong,
.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

/* ── grid-2 — two equal columns (payroll create/approve row) ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ── toolbar-actions — button group in page toolbar/topbar ── */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── btn-secondary — secondary action button style ─────── */
.btn-secondary {
  background: #e5e7eb;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover {
  background: #d1d5db;
  opacity: 1;
}

body.dark-mode .btn-secondary {
  background: #2d3748;
  color: #e5edf8;
  border-color: #4a5568;
}

/* ── full-row — spans full width inside a grid-form ─────── */
.full-row {
  grid-column: 1 / -1;
}

.full-row.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

/* ── two-col — alias for grid-form two-column layout ─────── */
.two-col {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ── stack-form — vertical stacked form layout ──────────── */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── grid-cards — auto-fill card grid (org chart etc.) ──── */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

/* ── alert / alert-danger — inline form error banner ─────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 12px;
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

body.dark-mode .alert-danger {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #991b1b;
}

/* ── Kanban board base styles ────────────────────────────── */
.kanban-col {
  min-height: 200px;
  background: #f0f4f8;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

.kanban-card:active {
  cursor: grabbing;
}

/* ── Chat emoji reactions ────────────────────────────────── */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: rgba(35, 89, 212, .08);
  border: 1px solid rgba(35, 89, 212, .2);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  color: var(--text);
}

.reaction-btn:hover,
.reaction-btn.reacted {
  background: rgba(35, 89, 212, .18);
  border-color: var(--primary);
}

.add-reaction-btn {
  background: none;
  border: 1px dashed var(--muted);
  border-radius: 999px;
  padding: 1px 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  transition: border-color var(--transition), color var(--transition);
}

.add-reaction-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.emoji-opt {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background var(--transition);
  line-height: 1;
}

.emoji-opt:hover {
  background: var(--bg);
}

/* ── Dark mode patches for new classes ──────────────────── */
body.dark-mode .kanban-col {
  background: #151a25;
  border-color: #2d3748;
}

body.dark-mode .kanban-card {
  background: #1a1f2e;
  border-color: #2d3748;
}

body.dark-mode .reaction-btn {
  background: rgba(74, 126, 247, .1);
  border-color: rgba(74, 126, 247, .25);
}

body.dark-mode .reaction-btn:hover,
body.dark-mode .reaction-btn.reacted {
  background: rgba(74, 126, 247, .22);
}

body.dark-mode .emoji-opt:hover {
  background: #232a3b;
}

body.dark-mode .stat-card strong,
body.dark-mode .stat-card .stat-value {
  color: #e5edf8;
}

/* ── SUPER RESPONSIVE STYLES ─────────────────────────────── */

/* Desktop & Large Tablet (1024px and below) */
@media (max-width: 1024px) {
  body {
    overflow: auto; /* Restore body scroll for mobile */
    height: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    overflow: visible;
  }

  /* Sidebar overlay mode */
  .sidebar {
    position: fixed;
    top: 0;
    left: calc(var(--sidebar-w) * -1.2);
    /* hidden fully */
    height: 100vh;
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transition: left var(--transition) cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    left: 0;
  }

  /* Show close button in sidebar header */
  .sidebar-close {
    display: block;
  }

  /* Show toggle button fixed on screen */
  .sidebar-toggle {
    display: flex;
  }

  /* Show backdrop when sidebar open */
  .sidebar-backdrop.open {
    display: block;
  }

  /* Main content no longer needs left padding/margin */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    height: auto;
    overflow: visible;
  }

  /* Adjust topbar padding so toggle button doesn't overlap text */
  .topbar {
    padding-left: 56px;
  }
}

/* Tablet & Mobile (768px and below) */
@media (max-width: 768px) {

  /* General grid collapsing (cards, stats, dashboard bits) */
  .grid-cards,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* Two-column layout in forms -> stack to 1 column */
  .form-row,
  .split-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Forms: Make every form-group take full width */
  .form-group-half {
    width: 100%;
  }

  /* Toolbar actions: stack search and buttons */
  .toolbar-actions,
  .table-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .toolbar-actions .btn,
  .table-header .btn {
    width: 100%;
    justify-content: center;
  }

  .table-search {
    width: 100%;
  }

  /* Page body padding reduction for screen real estate */
  .page-body {
    padding: 16px 12px 24px;
  }

  /* Login / Guest layout container */
  .auth-box,
  .login-box {
    width: 90%;
    margin: 20px auto;
    padding: 24px;
  }

  /* Topbar resizing */
  .topbar {
    padding: 10px 14px 10px 50px;
  }

  .topbar h2 {
    font-size: 16px;
  }

  /* Full row form actions */
  .full-row.actions,
  .form-actions {
    flex-direction: column;
    gap: 10px;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* Modal boxes on mobile */
  .modal-box {
    width: 95%;
    margin: 20px;
    max-height: 90vh;
  }

  .modal-body {
    padding: 16px;
  }
}

/* Extra small devices (480px and below) */
@media (max-width: 480px) {
  .page-body {
    padding: 12px 8px 16px;
  }

  .stat-card {
    padding: 16px 12px;
  }

  .stat-card .icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  /* Tables */
  .table th,
  .table td {
    padding: 8px 6px;
    font-size: 13px;
  }

  .sys-card {
    padding: 16px;
  }

  .sys-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .sys-card-header .sys-btn,
  .sys-card-header .btn {
    width: 100%;
    margin-top: 8px;
  }
}


/* ── Profile dropdown items (moved from inline style in topbar.php) ── */
.dd-item {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  font-size: 13.5px;
  transition: background .15s;
  white-space: nowrap;
}

.dd-item:hover {
  background: var(--bg);
}

body.dark-mode .dd-item:hover {
  background: #232a3b;
}

/* ── alert-success — green inline banner (employee/intern/user lists) ── */
.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

body.dark-mode .alert-success {
  background: #14532d;
  color: #bbf7d0;
  border-color: #166534;
}

/* ── btn-small — alias for .btn.small (used in employee/intern/user tables) ── */
.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-small.btn-danger,
.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD REDESIGN START
═══════════════════════════════════════════════════════════ */
.dash-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.dash-stat-card {
  padding: 24px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--line);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.dash-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.dash-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.dash-stat-card.border-primary::before {
  background: var(--primary);
}

.dash-stat-card.border-info::before {
  background: var(--info);
}

.dash-stat-card.border-warn::before {
  background: var(--warn);
}

.dash-stat-card.border-danger::before {
  background: var(--danger);
}

.dash-stat-card.border-success::before {
  background: var(--success);
}

.dash-stat-card.border-purple::before {
  background: #8b5cf6;
}

.dash-stat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dash-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f1f5f9;
  font-size: 20px;
}

.dash-stat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.dash-alerts-section {
  margin-bottom: 30px;
}

.dash-alert-card {
  background: #fffbfa;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.05);
}

.dash-alert-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid #ffe4e6;
  background: #fff1f2;
}

.dash-alert-icon {
  font-size: 20px;
}

.dash-alert-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #9f1239;
}

.dash-alert-body {
  padding: 16px 24px;
}

.dash-alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed #fecdd3;
}

.dash-alert-item:last-child {
  border-bottom: none;
}

.dash-alert-text {
  font-size: 14px;
  color: #881337;
  font-weight: 500;
}

.dash-alert-footer {
  padding: 16px 24px;
  background: #fff;
  border-top: 1px solid #ffe4e6;
}

.dash-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.dash-chart-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.dash-chart-header {
  margin-bottom: 20px;
}

.dash-chart-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.dash-chart-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 280px;
  max-height: 320px;
}

.dash-canvas-container {
  flex: 1;
  position: relative;
  height: 100%;
  width: 100%;
  min-height: 280px;
}

.dash-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 280px;
  background: #f8fafc;
  border: 2px dashed #e2e8f0;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.dash-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.dash-empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.dash-empty-subtitle {
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD DESIGN END
═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   GLOBAL UI DESIGN SYSTEM (.sys-)
═══════════════════════════════════════════════════════════ */
/* Layout & Grid System */
.sys-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}

.sys-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sys-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sys-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sys-grid-split {
  grid-template-columns: 3fr 7fr;
}

.sys-grid-split-rev {
  grid-template-columns: 7fr 3fr;
}

@media (max-width: 1024px) {

  .sys-grid-4,
  .sys-grid-3,
  .sys-grid-2,
  .sys-grid-split,
  .sys-grid-split-rev {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .sys-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Card System */
.sys-card {
  background: var(--card, #ffffff);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line, #f1f5f9);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

.sys-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  /* interior responsiveness */
}

.sys-card-header h3,
.sys-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #1e293b);
}

.sys-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* fixes flex wrap blowout */
}

.sys-card-actions {
  margin-top: 16px;
}

/* Typography elements */
.sys-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted, #64748b);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: block;
}

.sys-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text, #0f172a);
  margin: 8px 0;
  line-height: 1.1;
}

.sys-subtext {
  font-size: 13px;
  color: var(--muted, #94a3b8);
  margin: 0;
}

/* Buttons */
.sys-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.sys-btn-primary {
  background: var(--accent-action);
  color: var(--accent-action-text);
}

.sys-btn-primary:hover {
  background: var(--accent-action-hov);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sys-btn-success {
  background: #16a34a;
  color: #fff;
}

.sys-btn-success:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.2);
}

.sys-btn-warning {
  background: #d97706;
  color: #fff;
}

.sys-btn-warning:hover {
  background: #b45309;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.2);
}

.sys-btn-danger {
  background: #dc2626;
  color: #fff;
}

.sys-btn-danger:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);
}

.sys-btn-outline {
  background: transparent;
  border: 1px solid var(--line, #cbd5e1);
  color: var(--text, #334155);
}

.sys-btn-outline:hover {
  background: var(--bg, #f8fafc);
  border-color: var(--muted, #94a3b8);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.sys-btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

/* V3 UI Components */
.sys-card {
  background: var(--card, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
  /* Clips the internal scrolling wrapper */
  transition: box-shadow var(--transition), transform var(--transition);
}

.sys-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: rgba(0, 0, 0, 0.015);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.sys-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #0f172a);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Table System */
.sys-table-wrapper {
  overflow-x: auto;
  /* interior responsiveness */
  -webkit-overflow-scrolling: touch;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line, #f1f5f9);
}

.sys-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.sys-table th,
.sys-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line, #f1f5f9);
  font-size: 13.5px;
}

.sys-table th {
  background: var(--bg, #f8fafc);
  font-weight: 600;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.sys-table tr:hover {
  background: var(--bg, #f8fafc);
}

.sys-table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Badges */
.sys-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.sys-badge-blue {
  background: #dbeafe;
  color: #1e40af;
}

.sys-badge-green {
  background: #dcfce7;
  color: #166534;
}

.sys-badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

.sys-badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.sys-badge-gray {
  background: #f1f5f9;
  color: #475569;
}

.sys-badge-purple {
  background: #ede9fe;
  color: #6d28d9;
}

.sys-badge-amber {
  background: #fef3c7;
  color: #92400e;
}

/* Filter Block inside cards */
.sys-filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.sys-filter-bar input,
.sys-filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--line, #cbd5e1);
  border-radius: 6px;
  font-size: 13px;
  background: var(--card, #fff);
  color: var(--text, #0f172a);
}

/* Empty State */
.sys-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  border: 2px dashed var(--line, #e2e8f0);
  border-radius: 8px;
  background: var(--bg, #f8fafc);
}

.sys-empty-icon {
  font-size: 40px;
  color: var(--muted, #94a3b8);
  margin-bottom: 16px;
  opacity: 0.5;
}

.sys-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #1e293b);
  margin: 0 0 8px 0;
}

.sys-empty-desc {
  font-size: 13px;
  color: var(--muted, #64748b);
  margin: 0;
}

/* List System */
.sys-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.sys-list-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line, #f1f5f9);
}

.sys-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sys-list-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg, #f1f5f9);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sys-list-content {
  flex: 1;
  min-width: 0;
}

.sys-list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #0f172a);
  margin: 0 0 4px 0;
}

.sys-list-desc {
  font-size: 13px;
  color: var(--muted, #64748b);
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.sys-list-meta {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  font-weight: 500;
  text-transform: uppercase;
}

/* Forms Structure */
.sys-form-group {
  margin-bottom: 16px;
}

.sys-form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text, #1e293b);
}

.sys-form-input {
  width: 100%;
  border: 1px solid var(--line, #cbd5e1);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--card, #fff);
  color: var(--text, #0f172a);
}

/* Global Dark Mode Support overlay */
body.dark-mode .sys-card,
body.dark-mode .sys-table-wrapper {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .sys-table th,
body.dark-mode .sys-table tr:hover {
  background: #0f172a;
}

body.dark-mode .sys-table th,
body.dark-mode .sys-table td {
  border-color: #334155;
}

body.dark-mode .sys-btn-outline {
  color: #cbd5e1;
  border-color: #475569;
}

body.dark-mode .sys-btn-outline:hover {
  background: #334155;
}

body.dark-mode .sys-list-item {
  border-color: #334155;
}

body.dark-mode .sys-empty-state {
  background: #0f172a;
  border-color: #334155;
}

body.dark-mode .sys-filter-bar input,
body.dark-mode .sys-filter-bar select,
body.dark-mode .sys-form-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

body.dark-mode .sys-badge-blue {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
}

body.dark-mode .sys-badge-green {
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
}

body.dark-mode .sys-badge-yellow {
  background: rgba(217, 119, 6, 0.2);
  color: #fde047;
}

body.dark-mode .sys-badge-red {
  background: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
}

body.dark-mode .sys-badge-gray {
  background: #334155;
  color: #cbd5e1;
}

body.dark-mode .sys-badge-purple {
  background: rgba(109, 40, 217, 0.25);
  color: #c4b5fd;
}

body.dark-mode .sys-badge-amber {
  background: rgba(146, 64, 14, 0.25);
  color: #fcd34d;
}