:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #101828;
  --muted: #667085;
  --primary: #6366f1;
  --primary-soft: #eef0ff;
  --border: #e8ebf2;
  --success-soft: #ecfdf3;
  --danger-soft: #fef3f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell { display: flex; min-height: 100vh; transition: all 0.25s ease; }

.app-sidebar {
  width: 270px;
  background: #fff;
  color: var(--text);
  padding: 16px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.25s ease;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

.app-nav-link {
  color: #4b5563;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-nav-link:hover { background: #f5f7ff; color: #1f2937; }
.app-nav-link.active { background: linear-gradient(90deg, #6366f1, #7c83ff); color: #fff; }

.sidebar-upgrade-card {
  margin-top: auto;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  padding: 12px;
}

.app-main { flex: 1; padding: 14px 16px 20px; transition: all 0.25s ease; }
.content-wrap { background: transparent; border: 0; border-radius: 0; padding: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.topbar-right { flex-wrap: nowrap; }
.topbar-search-wrap { position: relative; }
.topbar-search-wrap i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: #98a2b3; font-size: 12px;
}
.topbar-search { width: 280px; padding-left: 30px; font-size: 13px; }
.topbar-user-pill {
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px; font-size: 12px;
}

.card, .table, .alert, .nav-tabs, .form-control, .form-select { border-radius: 14px !important; }
.card {
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 20px rgba(16, 24, 40, 0.04);
}
.table { border-color: var(--border); }
.table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  /* Tinted from page/canvas bg so branded theme applies (overridden in header when branding active) */
  background: color-mix(in srgb, var(--bg) 72%, var(--surface));
}

.badge-soft-success { background: var(--success-soft); color: #067647; padding: 6px 10px; border-radius: 999px; }
.badge-soft-danger { background: var(--danger-soft); color: #b42318; padding: 6px 10px; border-radius: 999px; }

.badge.badge-status-muted {
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 500;
  border: 1px solid var(--border);
}

.section-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 30px; font-weight: 700; margin-top: 6px; }

.auth-main { max-width: 1080px; margin: 0 auto; padding-top: 34px; }
.login-shell { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; }
.login-panel {
  border-radius: 20px; padding: 30px; min-height: 540px;
  border: 1px solid var(--border);
}
.login-brand-panel {
  color: #fff;
  background: linear-gradient(160deg, #1f3bc8 0%, #5c2ad5 55%, #0f79b2 100%);
  box-shadow: 0 30px 60px rgba(47, 64, 181, 0.35);
}
.login-feature {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px; padding: 10px 12px;
}
.login-form-panel { background: var(--surface); display: flex; flex-direction: column; justify-content: center; }

.nav-tabs .nav-link { color: var(--muted); border: 0 !important; }
.nav-tabs .nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.weekend-day { background: #f1f5f9 !important; color: #94a3b8 !important; border-radius: 50%; font-style: italic; }

.profile-header {
  display: flex; align-items: center; gap: 16px; padding: 18px;
  border-radius: 18px; border: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.03));
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.profile-header-info { min-width: 260px; }
.profile-side-card { background: linear-gradient(180deg, rgba(99, 102, 241, 0.06), rgba(255, 255, 255, 0.9)); }
.profile-checklist { display: grid; gap: 8px; }
.profile-check-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; color: var(--muted);
}
.profile-check-item.done { background: var(--success-soft); color: #067647; border-color: #b7ebcd; }
.profile-tabs .nav-link { white-space: nowrap; border-radius: 999px !important; padding: 8px 14px; margin-right: 8px; }
.profile-tab-content { box-shadow: 0 8px 28px rgba(16, 24, 40, 0.06); }
.profile-tab-content .form-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px;
}
.profile-section-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.repeatable-container .repeatable-row { position: relative; }
.repeatable-container .repeatable-row .remove-row-btn { min-width: 34px; }

.employee-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.employee-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
}

.employee-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.topbar-user-btn {
  padding-left: 12px;
  padding-right: 12px;
}

.topbar-user-menu {
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(16, 24, 40, 0.12);
  padding: 8px;
  min-width: 220px;
}

.topbar-user-menu .dropdown-item {
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 500;
}

.topbar-user-menu .dropdown-item:hover {
  background: #f5f7ff;
}

.profile-photo-preview {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  background-repeat: no-repeat;
}

.theme-dark {
  --bg: #0b1020;
  --surface: #121a2b;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #8aa2ff;
  --primary-soft: #1f2b4d;
  --border: #24314a;
  --success-soft: #0f2e23;
  --danger-soft: #3b1c1c;
}
body.theme-dark { background: radial-gradient(circle at top right, #1a2340 0%, #0b1020 50%); }
body.theme-dark .content-wrap { background: transparent; }
body.theme-dark .topbar,
body.theme-dark .card,
body.theme-dark .kpi-card,
body.theme-dark .table,
body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .app-sidebar { background-color: var(--surface); color: var(--text); border-color: var(--border) !important; }
body.theme-dark .table thead th { background: #172238; }
body.theme-dark .app-nav-link { color: #c7d2fe; }
body.theme-dark .app-nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

body.theme-dark .text-muted { color: var(--muted) !important; }
body.theme-dark .section-title { color: var(--muted); }
body.theme-dark .list-group-item { color: var(--text); border-color: var(--border); }
body.theme-dark .topbar-search { background: #0f172a; color: var(--text); border-color: var(--border); }
body.theme-dark .topbar-search::placeholder { color: #94a3b8; }
body.theme-dark .topbar-search-wrap i { color: #94a3b8; }
body.theme-dark .dropdown-menu { background: var(--surface); border-color: var(--border); }
body.theme-dark .dropdown-item { color: var(--text); }
body.theme-dark .dropdown-item:hover { background: rgba(255,255,255,0.06); }
body.theme-dark .badge.bg-light { background: #172238 !important; color: var(--text) !important; border-color: var(--border) !important; }

body.theme-dark .badge-soft-success {
  background: rgba(34, 197, 94, 0.16) !important;
  color: #86efac !important;
  border: 1px solid rgba(34, 197, 94, 0.35);
}
body.theme-dark .badge-soft-danger {
  background: rgba(248, 113, 113, 0.14) !important;
  color: #fecaca !important;
  border: 1px solid rgba(248, 113, 113, 0.35);
}
body.theme-dark .badge.badge-status-muted {
  background: rgba(148, 163, 184, 0.12) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
body.theme-dark .btn-light {
  background: #1e293b !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
body.theme-dark .btn-light:hover {
  background: #334155 !important;
  color: #fff !important;
}
body.theme-dark .nav-tabs .nav-link {
  color: var(--muted);
}
body.theme-dark .nav-tabs .nav-link.active {
  background: rgba(138, 162, 255, 0.18) !important;
  color: #e0e7ff !important;
  border: 1px solid rgba(138, 162, 255, 0.35) !important;
}
body.theme-dark .profile-check-item.done {
  background: rgba(34, 197, 94, 0.12) !important;
  color: #86efac !important;
  border-color: rgba(34, 197, 94, 0.35) !important;
}
body.theme-dark .btn-outline-secondary {
  color: var(--text) !important;
  border-color: var(--border) !important;
}
body.theme-dark .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #fff !important;
}

.app-shell.sidebar-collapsed .app-sidebar { width: 86px; }
.app-shell.sidebar-collapsed .sidebar-brand strong,
.app-shell.sidebar-collapsed .sidebar-brand small,
.app-shell.sidebar-collapsed .app-nav-link span,
.app-shell.sidebar-collapsed .sidebar-upgrade-card { display: none; }
.app-shell.sidebar-collapsed .app-nav-link { justify-content: center; }

@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
  .app-main { padding: 10px; }
  .content-wrap { padding: 0; }
  .topbar-search { width: 150px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-panel { min-height: auto; }
  .profile-header { flex-direction: column; align-items: flex-start; }
}

/* ── Holiday day highlight in flatpickr ── */
.flatpickr-day.holiday-day {
    background: #fff3cd !important;
    color: #856404 !important;
    border-color: #ffc107 !important;
    font-weight: 600;
}
.flatpickr-day.holiday-day:hover {
    background: #ffc107 !important;
    color: #000 !important;
}

/* ── Sidebar section labels ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem;
}
.nav-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-secondary-color, #6c757d);
    padding: 0.4rem 0.75rem 0.2rem;
    opacity: 0.7;
}

/* ── Sidebar scrollable nav area ── */
.sidebar-scroll {
  flex: 1;
  min-height: 0;          /* allows flex child to shrink below content size */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 2px;         /* room for the scrollbar thumb */
}

/* thin, modern scrollbar (Webkit/Blink) */
.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}
.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.25);
  border-radius: 99px;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.55);
}

/* Firefox */
.sidebar-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,.3) transparent;
}

/* Section labels */
.sidebar-section-label {
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #9ca3af;
  padding: 0 .5rem;
  margin-bottom: .25rem;
}

/* ═══════════════════════════════════════════════════════
   DASHBOARD — Professional redesign
   ═══════════════════════════════════════════════════════ */

/* Welcome banner */
.dashboard-welcome {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #7c3aed 100%);
  border-radius: 18px;
  padding: 22px 24px;
  color: #fff;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.dashboard-welcome::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.dashboard-welcome::after {
  content: '';
  position: absolute;
  bottom: -60px; right: 60px;
  width: 240px; height: 240px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.dashboard-welcome .welcome-title { font-size: 1.35rem; font-weight: 700; margin: 0 0 4px; }
.dashboard-welcome .welcome-sub   { opacity: .8; font-size: .9rem; margin: 0; }
.dashboard-welcome .welcome-date  { font-size: .78rem; opacity: .65; margin-top: 8px; }

/* KPI cards — refined */
.kpi-card {
  border-radius: 16px !important;
  padding: 18px !important;
  transition: transform .2s ease, box-shadow .2s ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,24,40,.09) !important; }
.kpi-value { font-size: 28px !important; font-weight: 800 !important; line-height: 1.1; }
.kpi-icon-wrap { width: 44px !important; height: 44px !important; border-radius: 14px !important; font-size: 20px !important; }

/* KPI trend badge */
.kpi-trend {
  font-size: 11px;
  font-weight: 600;
  border-radius: 99px;
  padding: 2px 8px;
  margin-top: 6px;
  display: inline-block;
}
.kpi-trend.up   { background: #ecfdf5; color: #059669; }
.kpi-trend.down { background: #fef2f2; color: #dc2626; }
.kpi-trend.flat { background: #f1f5f9; color: #64748b; }

/* Dashboard section headers */
.dash-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.dash-section-header h6 { font-size: .95rem; font-weight: 700; margin: 0 0 2px; }
.dash-section-header small { color: var(--muted); font-size: .78rem; }

/* Stat bar (mini horizontal bar) */
.stat-bar-wrap { margin-top: 10px; }
.stat-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-bar-track { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.stat-bar-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6366f1, #8b5cf6); }

/* Quick-action buttons */
.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, box-shadow .15s, transform .15s;
}
.quick-action-btn:hover {
  background: #f5f7ff;
  box-shadow: 0 3px 10px rgba(99,102,241,.1);
  transform: translateX(2px);
  color: #6366f1;
  text-decoration: none;
}
.quick-action-btn .qa-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

/* Table polish on dashboard */
.dash-table th { font-size: 11px !important; text-transform: uppercase; letter-spacing: .06em; }
.dash-table td { font-size: .85rem; vertical-align: middle; }

/* ═══════════════════════════════════════════════════════
   PROFILE PAGE — Full-screen fit + responsive tabs
   ═══════════════════════════════════════════════════════ */

/* Profile header — full responsive */
.profile-header {
  flex-wrap: wrap !important;
  gap: 12px !important;
  padding: 16px !important;
}
.profile-header-info {
  min-width: 0 !important;   /* was 260px — breaks narrow screens */
  flex: 1 1 200px;
}
.profile-header-info h4 { font-size: clamp(1rem, 3vw, 1.35rem); }
.profile-header-info .d-flex.flex-wrap { gap: 6px !important; }

/* Profile tabs — horizontally scrollable, no wrap */
.profile-tabs {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  flex-wrap: nowrap !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0 !important;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0 !important;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tabs .nav-item { flex-shrink: 0; }
.profile-tabs .nav-link {
  white-space: nowrap !important;
  border-radius: 0 !important;
  padding: 10px 14px !important;
  margin-right: 0 !important;
  border-bottom: 2px solid transparent !important;
  font-size: .84rem;
  color: var(--muted);
}
.profile-tabs .nav-link.active {
  border-bottom-color: var(--primary) !important;
  color: var(--primary) !important;
  background: transparent !important;
  border-radius: 0 !important;
}
.profile-tabs .nav-link:hover:not(.active) {
  background: #f5f7ff;
  color: var(--text);
}

/* Profile tab content */
.profile-tab-content {
  border-radius: 0 0 16px 16px !important;
  border-top: 0 !important;
}

/* Tab section header */
.tab-section-header { border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

/* Compact KPI cards inside profile */
.profile-kpi-row .kpi-card { padding: 12px !important; }
.profile-kpi-row .kpi-value { font-size: 1rem !important; font-weight: 700 !important; }
.profile-kpi-row .kpi-label { font-size: 11px; }

/* Address icon badge */
.addr-icon-badge {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 16px; flex-shrink: 0;
}
.current-badge   { background: #eef0ff; color: #6366f1; }
.permanent-badge { background: #ecfdf5; color: #059669; }

/* Profile overflow fix for overall page */
.app-main { overflow-x: hidden; }
.content-wrap { max-width: 100%; }

/* ═══════════════════════════════════════════════════════
   IMPORT CSV — sample data section
   ═══════════════════════════════════════════════════════ */
.import-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.import-feature-item {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: .82rem;
}
.import-feature-item i { color: var(--primary); margin-top: 1px; flex-shrink: 0; }

/* Dark mode overrides for new elements */
body.theme-dark .quick-action-btn { background: var(--surface); border-color: var(--border); }
body.theme-dark .quick-action-btn:hover { background: rgba(255,255,255,.06); color: #c7d2fe; }
body.theme-dark .dashboard-welcome { box-shadow: 0 8px 32px rgba(99,102,241,.35); }
body.theme-dark .import-feature-item { background: var(--surface); border-color: var(--border); color: var(--text); }
body.theme-dark .stat-bar-track { background: var(--border); }

@media (max-width: 767.98px) {
  .profile-header { flex-direction: column !important; }
  .profile-avatar { align-self: flex-start; }
  .dashboard-welcome { padding: 16px; }
  .dashboard-welcome .welcome-title { font-size: 1.1rem; }
  .kpi-value { font-size: 22px !important; }
}

/* ── Notification dropdown items ── */
.notif-item { color: var(--text); transition: background .12s; }
.notif-item:hover { background: #f5f7ff; color: var(--text); }
.notif-dropdown-menu { border-radius: 14px !important; border: 1px solid var(--border); box-shadow: 0 16px 48px rgba(16,24,40,.14); }

body.theme-dark .notif-item:hover { background: rgba(255,255,255,.05); }
body.theme-dark .notif-dropdown-menu { background: var(--surface); border-color: var(--border); }
body.theme-dark .notif-item .text-body { color: var(--text) !important; }

/* ── Notification read/unread states ── */
.notif-item-read { opacity: .55; }
.notif-item-read .notif-icon-wrap { filter: grayscale(.6); }
body.theme-dark .notif-item-read { opacity: .4; }
