/* ============================================================
   nFlux Design System — Notion-inspired warm refresh
   Pair with Bootstrap 5 + Bootstrap Icons + Inter (Google Fonts).
   Drop into your Django static/ folder and reference once.
   ============================================================ */

:root {
  /* Surfaces (warm light) */
  --canvas:        #FAFAF7;   /* page background */
  --surface:       #FFFFFF;   /* cards */
  --subtle:        #F5F3EC;   /* hover, table head, chips */
  --soft:          #EFEDE5;   /* dividers as fills */
  --border:        #E8E4D8;   /* hairlines */
  --border-strong: #D8D3C4;

  /* Ink */
  --ink:           #1B1B18;
  --ink-2:         #3D3C36;
  --ink-3:         #6F6E68;
  --ink-4:         #9A988F;
  --ink-5:         #B8B5A8;

  /* Brand — refined navy + warm orange */
  --primary:       #3D5A80;        /* refined navy */
  --primary-2:     #2E4664;
  --primary-soft:  #E8EEF5;
  --accent:        #E87722;        /* original brand orange */
  --accent-2:      #C9621A;
  --accent-soft:   #FCEEDF;

  /* Semantic */
  --success:       #3F8A5F;
  --success-soft:  #E5F1EA;
  --warning:       #C7841E;
  --warning-soft:  #FBEFD7;
  --danger:        #C2410C;
  --danger-soft:   #FBE5DA;
  --info:          #4F7CAC;
  --info-soft:     #E5EDF5;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Inter', sans-serif;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Shadows — layered & soft */
  --sh-1: 0 1px 2px rgba(20, 20, 18, 0.04);
  --sh-2: 0 1px 2px rgba(20, 20, 18, 0.04), 0 4px 16px rgba(20, 20, 18, 0.04);
  --sh-3: 0 1px 2px rgba(20, 20, 18, 0.05), 0 8px 24px rgba(20, 20, 18, 0.06);
  --sh-pop: 0 4px 12px rgba(20, 20, 18, 0.08), 0 16px 48px rgba(20, 20, 18, 0.10);

  /* Layout */
  --sidebar-width: 256px;
  --topbar-h: 60px;
  --tabbar-h: 64px;

  /* Theme-aware controls */
  --btn-primary-bg:    var(--ink);
  --btn-primary-hover: var(--ink-2);
  --btn-primary-text:  #FFFFFF;
  --native-scheme:     light;
}

/* Dark theme */
[data-theme="dark"] {
  --canvas:        #1B1B18;
  --surface:       #232320;
  --subtle:        #2B2B27;
  --soft:          #34332E;
  --border:        #3A3933;
  --border-strong: #4A4943;

  --ink:           #F5F3EC;
  --ink-2:         #E5E2D8;
  --ink-3:         #B8B5A8;
  --ink-4:         #8A8880;
  --ink-5:         #6F6E68;

  --primary:       #8AAACE;
  --primary-2:     #B0C7E2;
  --primary-soft:  #2A3849;
  --accent:        #F19A52;
  --accent-2:      #FFB477;
  --accent-soft:   #3E2D1B;

  --success:       #6EBA8B;
  --success-soft:  #1F3528;
  --warning:       #E2B265;
  --warning-soft:  #3D2F18;
  --danger:        #E08566;
  --danger-soft:   #3D2018;
  --info:          #8FB3D6;
  --info-soft:     #1F2D3D;

  --sh-1: 0 1px 2px rgba(0,0,0,0.3);
  --sh-2: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --sh-3: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.25);
  --sh-pop: 0 4px 12px rgba(0,0,0,0.4), 0 16px 48px rgba(0,0,0,0.5);

  --btn-primary-bg:    var(--accent);
  --btn-primary-hover: var(--accent-2);
  --btn-primary-text:  #1B1B18;
  --native-scheme:     dark;

  --bs-body-bg: var(--canvas);
  --bs-body-color: var(--ink);
  --bs-secondary-color: var(--ink-3);
  --bs-tertiary-bg: var(--subtle);
  --bs-border-color: var(--border);
  --bs-card-bg: var(--surface);
  --bs-card-color: var(--ink);
  --bs-table-bg: var(--surface);
  --bs-table-color: var(--ink-2);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--subtle);
  --bs-table-hover-color: var(--ink);
}

/* ─────────── Base ─────────── */
* { box-sizing: border-box; }
html { overflow-x: hidden; }
html, body { background: var(--canvas); color: var(--ink); }
body {
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  overflow-x: hidden; /* prevent wide tables from expanding the page; .table-soft handles its own scroll */
}
h1,h2,h3,h4,h5,h6 { font-family: var(--font-display); letter-spacing: -0.015em; color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); text-decoration: underline; }

/* ─────────── App layout ─────────── */
.app { min-height: 100vh; }

#sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 1000;
  transition: width 0.2s ease, transform 0.25s ease;
}
#sidebar .brand {
  padding: 18px 18px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
#sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem; letter-spacing: -0.04em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1), var(--sh-1);
}
#sidebar .brand .brand-text { line-height: 1.1; }
#sidebar .brand h1 { font-size: 0.95rem; font-weight: 700; margin: 0; color: var(--ink); }
#sidebar .brand small { font-size: 0.68rem; color: var(--ink-4); }
.sidebar-collapse-btn {
  width: 32px; height: 32px; margin-left: auto; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: none;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.sidebar-collapse-btn:hover {
  background: var(--primary-soft); border-color: var(--primary-soft); color: var(--accent);
}
.sidebar-collapse-btn i { font-size: 1rem; line-height: 1; }
.sidebar-collapse-btn .compact-logo { display: none; }
#sidebar .sidebar-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 12px;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
#sidebar .sidebar-scroll::-webkit-scrollbar { width: 6px; }
#sidebar .sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
#sidebar .nav-section {
  padding: 14px 18px 4px; color: var(--ink-4);
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
}
#sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; margin: 1px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 0.875rem; font-weight: 500;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
#sidebar .nav-link:hover { background: var(--subtle); color: var(--ink); text-decoration: none; }
#sidebar .nav-link.active {
  background: var(--primary-soft); color: var(--ink); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
#sidebar .nav-link.active i { color: var(--accent); }
#sidebar .nav-link i {
  font-size: 1rem; width: 18px; text-align: center; color: var(--ink-3); flex-shrink: 0;
}
#sidebar .nav-link .nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 0.65rem; font-weight: 700; padding: 1px 6px; border-radius: var(--r-pill); min-width: 18px; text-align: center;
}
#sidebar .sidebar-footer {
  padding: 10px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--accent-soft), var(--primary-soft));
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; flex-shrink: 0; border: 1px solid var(--border);
}
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar.xl { width: 64px; height: 64px; font-size: 1.3rem; }
#sidebar .user-name { font-size: 0.82rem; font-weight: 600; color: var(--ink); line-height: 1.15; }
#sidebar .user-role { font-size: 0.7rem; color: var(--ink-4); line-height: 1.15; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999; }

#main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left 0.2s ease; }

@media (min-width: 901px) {
  [data-sidebar="compact"] #sidebar {
    width: 66px;
    background: var(--surface);
    border-right-color: var(--border);
    box-shadow: none;
  }
  [data-sidebar="compact"] #main { margin-left: 66px; }
  [data-sidebar="compact"] #sidebar .brand {
    min-height: 54px;
    padding: 10px 0;
    justify-content: center;
    gap: 0;
    position: relative;
    border-bottom-color: var(--border);
    background: var(--surface);
  }
  [data-sidebar="compact"] #sidebar .brand > img {
    display: none !important;
  }
  [data-sidebar="compact"] #sidebar .brand-text,
  [data-sidebar="compact"] #sidebar .nav-section,
  [data-sidebar="compact"] #sidebar .nav-link .nav-badge,
  [data-sidebar="compact"] #sidebar .sidebar-footer > div:not(.avatar),
  [data-sidebar="compact"] #sidebar .sidebar-footer form {
    display: none !important;
  }
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn {
    position: static;
    width: 42px;
    height: 40px;
    margin-left: 0;
    background: transparent;
    border-color: transparent;
    color: var(--accent);
    box-shadow: none;
    overflow: hidden;
  }
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn .compact-logo {
    display: block !important;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    transition: opacity 0.12s ease, transform 0.12s ease;
  }
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn i {
    position: absolute;
    opacity: 0;
    transform: scale(0.88);
    color: currentColor;
    font-size: 1.08rem;
    transition: opacity 0.12s ease, transform 0.12s ease, color 0.12s ease;
  }
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn:hover .compact-logo,
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn:focus-visible .compact-logo {
    opacity: 0;
    transform: scale(0.92);
  }
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn:hover i,
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn:focus-visible i {
    opacity: 1;
    transform: scale(1);
  }
  [data-sidebar="compact"] #sidebar .sidebar-collapse-btn:hover {
    background: var(--subtle);
    border-color: transparent;
    color: var(--accent);
  }
  [data-sidebar="compact"] #sidebar .nav-link {
    width: 42px; height: 40px; margin: 6px auto; padding: 0;
    justify-content: center; gap: 0;
    font-size: 0; overflow: hidden;
    color: var(--ink-3);
    border-radius: var(--r-sm);
  }
  [data-sidebar="compact"] #sidebar .nav-link i {
    width: auto; font-size: 1.08rem; color: currentColor;
  }
  [data-sidebar="compact"] #sidebar .nav-link:hover {
    background: var(--subtle);
    color: var(--ink);
  }
  [data-sidebar="compact"] #sidebar .nav-link.active {
    background: var(--primary-soft);
    color: var(--ink);
    box-shadow: inset 3px 0 0 var(--accent);
  }
  [data-sidebar="compact"] #sidebar .nav-link.active i { color: var(--accent); }
  [data-sidebar="compact"] #sidebar .sidebar-footer {
    justify-content: center;
    padding: 10px 0;
    border-top-color: var(--border);
    background: var(--surface);
  }
  [data-sidebar="compact"] #sidebar .avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-soft), var(--primary-soft));
    border-color: var(--border);
    color: var(--ink);
  }
}

#topbar {
  height: var(--topbar-h);
  background: var(--canvas);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
#topbar .page-title { font-size: 0.95rem; font-weight: 600; color: var(--ink); }
#topbar .topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid transparent;
  background: transparent; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer; transition: 0.12s; text-decoration: none;
}
.icon-btn:hover { background: var(--subtle); color: var(--ink); text-decoration: none; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  background: var(--accent); color: #fff;
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px; border-radius: var(--r-pill);
  min-width: 16px; text-align: center; border: 2px solid var(--canvas);
}
.icon-btn .dot.danger { background: var(--danger); }

#content { padding: 28px 24px 40px; flex: 1; max-width: 1400px; width: 100%; }

/* ─────────── Cards ─────────── */
.card-soft {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-soft.elevated { box-shadow: var(--sh-2); }
.card-pad { padding: 20px; }
.card-pad-lg { padding: 24px; }

.card-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title-row h3 {
  font-size: 0.95rem; font-weight: 700; margin: 0; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.card-title-row h3 i { color: var(--ink-4); font-size: 1rem; }

/* Legacy Bootstrap/template compatibility */
.card,
.form-section,
.data-table {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.data-table {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.form-section {
  padding: 20px;
  margin-bottom: 16px;
}
.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}
.form-section-title i {
  color: var(--accent);
}
.form-section form.row {
  row-gap: 14px;
}
.form-section .form-control,
.form-section .form-select {
  min-height: 40px;
}
.form-section textarea.form-control {
  min-height: 84px;
}
.card-header,
.card-footer,
.list-group-item {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.table {
  --bs-table-bg: var(--surface);
  --bs-table-color: var(--ink-2);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--subtle);
  --bs-table-hover-color: var(--ink);
  color: var(--ink-2);
  border-color: var(--border);
}
.table > :not(caption) > * > * {
  background-color: var(--bs-table-bg);
  color: var(--bs-table-color);
  border-color: var(--bs-table-border-color);
}
.table-hover > tbody > tr:hover > * {
  background-color: var(--subtle);
  color: var(--ink);
}
.table-light,
.table thead,
.table > thead,
.bg-light,
.bulk-upload-empty {
  --bs-table-bg: var(--subtle) !important;
  --bs-table-color: var(--ink-2) !important;
  --bs-table-border-color: var(--border) !important;
  background-color: var(--subtle) !important;
  color: var(--ink-2) !important;
}
.table thead th,
.table thead td,
.table > :not(caption) > thead > tr > *,
.table > thead > tr > *,
thead.table-light > tr > *,
.table-light > tr > *,
.table-light > * > * {
  --bs-table-bg: var(--subtle) !important;
  --bs-table-color: var(--ink-2) !important;
  --bs-table-border-color: var(--border) !important;
  background-color: var(--subtle) !important;
  color: var(--ink-2) !important;
  border-color: var(--border) !important;
}
.table tbody tr {
  border-color: var(--border);
}
.bg-white {
  background-color: var(--surface) !important;
  color: var(--ink) !important;
}
.text-dark {
  color: var(--ink) !important;
}
.text-muted {
  color: var(--ink-3) !important;
}
.text-primary,
.link-primary {
  color: var(--primary) !important;
}
.badge.bg-light,
.badge.bg-secondary,
.badge.bg-success,
.badge.bg-primary,
.badge.bg-warning,
.badge.bg-danger,
.badge.bg-info {
  border: 1px solid transparent;
}
.badge.bg-light {
  background: var(--subtle) !important;
  color: var(--ink-2) !important;
  border-color: var(--border);
}
.badge.bg-secondary {
  background: var(--subtle) !important;
  color: var(--ink-2) !important;
  border-color: var(--border);
}
.badge.bg-success {
  background: var(--success-soft) !important;
  color: var(--success) !important;
}
.badge.bg-primary {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
}
.badge.bg-warning {
  background: var(--warning-soft) !important;
  color: var(--warning) !important;
}
.badge.bg-danger {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
}
.badge.bg-info {
  background: var(--info-soft) !important;
  color: var(--info) !important;
}
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-dark,
.btn-outline-warning,
.btn-outline-danger,
.btn-outline-success {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-dark:hover,
.btn-outline-warning:hover,
.btn-outline-danger:hover,
.btn-outline-success:hover {
  background: var(--subtle);
  border-color: var(--border-strong);
  color: var(--ink);
}
i[class^="bi-"],
i[class*=" bi-"] {
  color: inherit;
}

/* Stat tile (Notion-flat) */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
  transition: 0.15s;
}
.stat-tile:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }
.stat-tile .stat-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-4);
  display: flex; align-items: center; gap: 6px;
}
.stat-tile .stat-label i { font-size: 0.85rem; color: var(--ink-4); }
.stat-tile .stat-value {
  font-size: 1.6rem; font-weight: 700; color: var(--ink);
  letter-spacing: -0.02em; line-height: 1.1;
}
.stat-tile .stat-meta { font-size: 0.78rem; color: var(--ink-3); }
.stat-tile .stat-trend { font-size: 0.78rem; font-weight: 600; }
.stat-tile .stat-trend.up { color: var(--success); }
.stat-tile .stat-trend.down { color: var(--danger); }

.stat-tile.accent { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); border-color: var(--accent-soft); }
.stat-tile.primary { background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%); border-color: var(--primary-soft); }
.stat-tile.success { background: linear-gradient(135deg, var(--success-soft), var(--surface) 70%); border-color: var(--success-soft); }

/* ─────────── Buttons ─────────── */
.btn { font-family: var(--font-sans); font-weight: 500; border-radius: var(--r-md); padding: 8px 14px; font-size: 0.875rem; transition: 0.12s; }
.btn:focus, .btn:focus-visible { box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-weight: 600;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
  color: var(--btn-primary-text);
}
.btn-primary:disabled,
.btn-primary.disabled {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  opacity: 0.55;
}
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-soft {
  background: var(--surface); border: 1px solid var(--border); color: var(--ink);
}
.btn-soft:hover { background: var(--subtle); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--subtle); color: var(--ink); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #347049; border-color: #347049; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--ink-2); }
.btn-outline:hover { background: var(--subtle); border-color: var(--border-strong); color: var(--ink); }
.btn-lg-pill { padding: 12px 20px; border-radius: var(--r-pill); font-weight: 600; }
.btn-xs { padding: 4px 10px; font-size: 0.78rem; border-radius: var(--r-sm); }

/* ─────────── Quick action chip (used on dashboard) ─────────── */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.qa-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  text-align: left; color: var(--ink); text-decoration: none; transition: 0.15s; cursor: pointer;
  font-family: var(--font-sans); font-size: 0.85rem; font-weight: 500;
}
.qa-tile:hover { background: var(--subtle); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--sh-2); text-decoration: none; color: var(--ink); }
.qa-tile .qa-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
  background: var(--subtle); color: var(--ink-2);
}
.qa-tile.accent .qa-icon { background: var(--accent-soft); color: var(--accent-2); }
.qa-tile.primary .qa-icon { background: var(--primary-soft); color: var(--primary); }
.qa-tile.success .qa-icon { background: var(--success-soft); color: var(--success); }
.qa-tile.warning .qa-icon { background: var(--warning-soft); color: var(--warning); }
.qa-tile.danger .qa-icon { background: var(--danger-soft); color: var(--danger); }
.qa-tile .qa-label { font-weight: 600; line-height: 1.2; }
.qa-tile .qa-sub { font-size: 0.74rem; color: var(--ink-4); font-weight: 400; }

/* ─────────── Badges & status pills ─────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 0.72rem; font-weight: 600; line-height: 1.4;
  background: var(--subtle); color: var(--ink-2);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.danger  { background: var(--danger-soft);  color: var(--danger);  }
.pill.info    { background: var(--info-soft);    color: var(--info);    }
.pill.accent  { background: var(--accent-soft);  color: var(--accent-2);}
.pill.neutral { background: var(--subtle);       color: var(--ink-2);   }

/* ─────────── Tables ─────────── */
.table-soft {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.table-soft::-webkit-scrollbar,
.data-table::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar { height: 8px; background: var(--subtle); }
.table-soft::-webkit-scrollbar-thumb,
.data-table::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--ink-4);
  border-radius: var(--r-pill);
}
.table-soft::-webkit-scrollbar-thumb:hover,
.data-table::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
}
.table-soft table { width: 100%; min-width: max-content; margin: 0; border-collapse: collapse; }
.table-soft thead th {
  background: var(--subtle); color: var(--ink-3);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border);
}
.table-soft tbody td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.86rem; color: var(--ink-2); vertical-align: middle;
}
.table-soft tbody tr:last-child td { border-bottom: 0; }
.table-soft tbody tr:hover td { background: var(--subtle); }

/* Employee directory is a daily-work screen, so keep every column visible instead of
   making the user horizontally drag the whole table to reach profile/actions. */
.employee-directory-card {
  max-width: 100%;
  min-width: 0;
}
.employee-directory-table-wrap {
  max-width: 100%;
}
.employee-directory-table-wrap table.employee-directory-table {
  width: 100%;
  min-width: 620px;
  table-layout: fixed;
}
.employee-directory-table .col-id { width: 7%; }
.employee-directory-table .col-employee { width: 14%; }
.employee-directory-table .col-designation { width: 13.5%; }
.employee-directory-table .col-site { width: 13.5%; }
.employee-directory-table .col-phone { width: 8.5%; }
.employee-directory-table .col-joined { width: 8.5%; }
.employee-directory-table .col-status { width: 12%; }
.employee-directory-table .col-profile { width: 8.5%; }
.employee-directory-table .col-face { width: 7.5%; }
.employee-directory-table .col-actions { width: 7%; }
.employee-directory-table th,
.employee-directory-table td {
  padding-left: 12px;
  padding-right: 12px;
}
.employee-directory-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}
.employee-directory-table .badge,
.employee-directory-table .btn {
  justify-self: start;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  display: inline-block;
}
.employee-directory-table .employee-id-badge,
.employee-directory-table .employee-payroll-badge {
  font-size: 0.68rem;
}
.employee-directory-table .employee-status-badge {
  border: 1px solid transparent;
}
.employee-directory-table .employee-status-badge.badge-active {
  background: var(--success-soft) !important;
  color: var(--success) !important;
}
.employee-directory-table .employee-status-badge.badge-pending {
  background: var(--warning-soft) !important;
  color: var(--warning) !important;
}
.employee-directory-table .employee-status-badge.badge-rejected {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
}
.employee-directory-table .employee-status-badge.badge-draft {
  background: var(--subtle) !important;
  color: var(--ink-2) !important;
  border-color: var(--border);
}
.employee-directory-table td > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.employee-directory-table td:last-child .d-flex {
  gap: 4px !important;
  overflow: visible;
  white-space: normal;
}
.employee-directory-table td:last-child .btn {
  padding-left: 8px !important;
  padding-right: 8px !important;
  white-space: nowrap;
  overflow: visible;
}

@media (max-width: 1180px) {
  .employee-directory-table .col-id { width: 8%; }
  .employee-directory-table .col-employee { width: 15%; }
  .employee-directory-table .col-designation { width: 13%; }
  .employee-directory-table .col-site { width: 13%; }
  .employee-directory-table .col-phone { width: 9%; }
  .employee-directory-table .col-joined { width: 9%; }
  .employee-directory-table .col-status { width: 12%; }
  .employee-directory-table .col-profile { width: 8%; }
  .employee-directory-table .col-face { width: 6%; }
  .employee-directory-table .col-actions { width: 7%; }
  .employee-directory-table th,
  .employee-directory-table td {
    padding-left: 9px;
    padding-right: 9px;
  }
  .employee-directory-table .col-face,
  .employee-directory-table th:nth-child(9),
  .employee-directory-table td:nth-child(9) {
    display: none;
  }
}

@media (max-width: 900px) {
  /* Horizontal-scroll table — same as onboarding cockpit */
  .employee-directory-table .col-joined,
  .employee-directory-table th:nth-child(6),
  .employee-directory-table td:nth-child(6),
  .employee-directory-table .col-profile,
  .employee-directory-table th:nth-child(8),
  .employee-directory-table td:nth-child(8),
  .employee-directory-table .col-face,
  .employee-directory-table th:nth-child(9),
  .employee-directory-table td:nth-child(9) {
    display: none;
  }
}

/* ─────────── Forms ─────────── */
.form-control, .form-select {
  background: var(--surface); border: 1px solid var(--border); color: var(--ink);
  border-radius: var(--r-md); padding: 9px 12px; font-size: 0.9rem;
  transition: border-color 0.12s, box-shadow 0.12s;
  color-scheme: var(--native-scheme);
}
.form-control:focus, .form-select:focus {
  background: var(--surface); color: var(--ink);
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

.form-control::placeholder {
  color: var(--ink-5);
  opacity: 1;
}
.form-control[type="file"]::file-selector-button {
  background: var(--subtle);
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--ink);
  margin: -9px 12px -9px -12px;
  padding: 9px 12px;
}
.form-control[type="file"]::file-selector-button:hover {
  background: var(--soft);
}

input[type="date"],
input[type="time"],
input[type="month"],
input[type="week"],
input[type="datetime-local"] {
  color-scheme: var(--native-scheme);
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="week"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='4' y='5' width='16' height='15' rx='2' stroke='%23B8B5A8' stroke-width='2'/%3E%3Cpath d='M8 3v4M16 3v4M4 10h16' stroke='%23B8B5A8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 16px 16px !important;
  color: transparent !important;
  filter: none !important;
  opacity: 1;
  cursor: pointer;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-left: 8px;
}

/* Bulk upload has page-local legacy colors; keep it synced with the theme. */
.bulk-upload-card,
.bulk-upload-head,
.bulk-upload-form,
.bulk-upload-note,
.bulk-upload-table,
.bulk-upload-empty {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--ink) !important;
}
.bulk-upload-head,
.bulk-upload-table thead th {
  background: var(--subtle) !important;
}
.bulk-upload-head p,
.bulk-upload-form .form-text,
.bulk-upload-note-grid,
.bulk-upload-count,
.bulk-upload-table thead th,
.bulk-upload-table tbody td {
  color: var(--ink-3) !important;
}
.bulk-upload-head h5,
.bulk-upload-section-head h6,
.bulk-upload-note-title,
.bulk-upload-batch {
  color: var(--primary) !important;
}
.bulk-upload-note code {
  background: var(--accent-soft) !important;
  color: var(--accent-2) !important;
}

/* ─────────── Mobile bottom tab bar ─────────── */
#bottom-tabs {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--tabbar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 90;
  box-shadow: 0 -4px 24px rgba(20,20,18,0.04);
}
#bottom-tabs .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-4); font-size: 0.65rem; font-weight: 600;
  text-decoration: none; padding: 4px; border-radius: var(--r-sm); position: relative;
  min-height: 52px;
}
#bottom-tabs .tab i { font-size: 1.25rem; line-height: 1; }
#bottom-tabs .tab.active { color: var(--ink); }
#bottom-tabs .tab.active i { color: var(--accent); }
#bottom-tabs .tab.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
#bottom-tabs .tab .tab-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: var(--danger); color: #fff;
  font-size: 0.55rem; font-weight: 700; padding: 1px 4px; border-radius: var(--r-pill); min-width: 14px;
}

/* ─────────── Mobile responsiveness ─────────── */
@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: var(--sh-pop); }
  #sidebar-overlay.active { display: block; }
  #main { margin-left: 0; padding-bottom: var(--tabbar-h); }
  #topbar { padding: 0 14px; }
  #content { padding: 16px 14px 24px; }
  .table-responsive {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
  .table-responsive > table,
  .table-responsive > .table {
    width: max-content;
    min-width: 100%;
  }
  .table-soft table,
  .data-table table {
    width: max-content;
    min-width: 100%;
  }
  #bottom-tabs { display: flex; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 901px) {
  .hide-desktop { display: none !important; }
}

/* ─────────── Utility / misc ─────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted-2 { color: var(--ink-3); }
.text-muted-3 { color: var(--ink-4); }
.bg-subtle { background: var(--subtle); }

.section-title {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-4); margin: 0 0 12px;
}

.greeting-card {
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
  border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px 24px;
  position: relative; overflow: hidden;
}
[data-theme="dark"] .greeting-card {
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
}
.greeting-card h2 {
  font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -0.02em;
}
.greeting-card .greeting-sub { color: var(--ink-2); margin-top: 4px; font-size: 0.9rem; }

/* Check-in widget */
.checkin-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.checkin-card .clock {
  font-family: var(--font-display); font-weight: 700; font-size: 2.4rem;
  letter-spacing: -0.03em; color: var(--ink); line-height: 1;
}
.checkin-card .clock-meta { font-size: 0.85rem; color: var(--ink-3); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline .t-item { display: flex; gap: 12px; align-items: flex-start; }
.timeline .t-dot {
  width: 28px; height: 28px; border-radius: var(--r-pill); flex-shrink: 0;
  background: var(--subtle); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}
.timeline .t-item.success .t-dot { background: var(--success-soft); color: var(--success); }
.timeline .t-item.accent  .t-dot { background: var(--accent-soft); color: var(--accent-2); }
.timeline .t-item.danger  .t-dot { background: var(--danger-soft); color: var(--danger); }
.timeline .t-item.info    .t-dot { background: var(--info-soft); color: var(--info); }
.timeline .t-content { flex: 1; }
.timeline .t-title { font-size: 0.86rem; font-weight: 600; color: var(--ink); }
.timeline .t-meta { font-size: 0.74rem; color: var(--ink-4); }

/* Calendar mini */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: var(--r-sm); background: var(--subtle);
  display: flex; align-items: center; justify-content: center; font-size: 0.72rem;
  color: var(--ink-3); position: relative; font-weight: 500;
}
.cal-cell.present { background: var(--success-soft); color: var(--success); font-weight: 700; }
.cal-cell.absent  { background: var(--danger-soft);  color: var(--danger);  font-weight: 700; }
.cal-cell.leave   { background: var(--info-soft);    color: var(--info);    font-weight: 700; }
.cal-cell.holiday { background: var(--accent-soft);  color: var(--accent-2);font-weight: 700; }
.cal-cell.weekend { background: transparent; color: var(--ink-5); }
.cal-cell.today   { box-shadow: 0 0 0 2px var(--ink); }
.cal-cell.future  { background: transparent; color: var(--ink-5); }
.cal-dow {
  font-size: 0.62rem; font-weight: 700; color: var(--ink-4); text-align: center; padding: 4px 0;
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* Progress bar */
.progress-bar-soft {
  height: 6px; background: var(--soft); border-radius: var(--r-pill); overflow: hidden;
}
.progress-bar-soft > span {
  display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill);
  transition: width 0.4s ease;
}

/* Theme toggle */
.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--ink-2);
}
.theme-toggle:hover { background: var(--subtle); color: var(--ink); }
[data-theme="light"] .theme-toggle .moon,
[data-theme="dark"]  .theme-toggle .sun { display: none; }
[data-theme="dark"]  .theme-toggle .moon,
[data-theme="light"] .theme-toggle .sun { display: inline; }

/* Bootstrap overrides for visual harmony */
.alert { border-radius: var(--r-md); border: 1px solid var(--border); font-size: 0.88rem; }
.modal-content { border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.dropdown-menu { border-radius: var(--r-md); border: 1px solid var(--border); box-shadow: var(--sh-3); padding: 6px; background: var(--surface); }
.dropdown-item { border-radius: var(--r-sm); font-size: 0.86rem; color: var(--ink-2); padding: 8px 10px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--subtle); color: var(--ink); }
.dropdown-divider { border-color: var(--border); }

/* Print */
@media print {
  #sidebar, #topbar, #bottom-tabs, #sidebar-overlay { display: none !important; }
  #main { margin: 0; }
}
