:root {
  --primary: #6366f1;
  --nav-bg: linear-gradient(90deg, #e9e2fb 0%, #dfe7fb 55%, #d9edfb 100%);
  --nav-text: #475569;
  --topbar-height: 56px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #eef2f7;
  color: #1e293b;
}

/* ── Main layout ── */
#main-wrapper {
  min-height: 100vh;
}

/* ── Horizontal top nav ── */
#topbar {
  min-height: var(--topbar-height);
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(49, 46, 129, 0.10);
  position: sticky;
  top: 0;
  z-index: 1030;
}

#topbar .brand {
  color: #312e81;
  white-space: nowrap;
}

#topbar .brand i { font-size: 1.25rem; }

#topbar .brand .brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

#topbar #nav-toggle {
  background: rgba(49, 46, 129, 0.08);
  color: #312e81;
}

#topbar .main-nav {
  flex-direction: row;
  gap: 0.25rem;
  margin: 0 0 0 1.5rem;
}

#topbar .main-nav .nav-link {
  color: var(--nav-text);
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  border-radius: 6px;
  border-bottom: 3px solid transparent;
  transition: background 0.18s, color 0.18s;
}

#topbar .main-nav .nav-link:hover {
  background: rgba(49, 46, 129, 0.06);
  color: #312e81;
}

#topbar .main-nav .nav-link.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border-bottom-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

#topbar .main-nav .nav-link i { font-size: 1.05rem; }

/* keep all topbar text readable on the pastel bar */
#topbar #user-name { color: #334155; }

#topbar .btn-outline-secondary,
#topbar .btn-outline-primary {
  color: #4338ca;
  border-color: rgba(49, 46, 129, 0.25);
}

#topbar .btn-outline-secondary:hover,
#topbar .btn-outline-primary:hover {
  background: rgba(49, 46, 129, 0.08);
  border-color: rgba(49, 46, 129, 0.4);
  color: #312e81;
}

/* ── Top-right cluster — cohesive glass style on the pastel bar ── */
#topbar .topbar-actions { gap: 0.5rem; }

/* Online status pill */
#topbar .status-online {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(49, 46, 129, 0.12);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
}
#topbar .status-online .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

/* Portal button */
#topbar .btn-portal {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #312e81;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(49, 46, 129, 0.16);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
#topbar .btn-portal:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(49, 46, 129, 0.3);
  color: #312e81;
}

/* User chip — avatar + name + logout grouped */
#topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(49, 46, 129, 0.12);
  border-radius: 999px;
  padding: 0.18rem 0.4rem 0.18rem 0.22rem;
}
#topbar #user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
#topbar #user-name {
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#topbar .user-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #64748b;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
#topbar .user-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

#page-content {
  padding: 1.75rem;
}

/* ── Dashboard ── */
/* Staggered entrance — replays each time the Dashboard is opened
   (navigating in toggles .active from display:none, restarting the animation). */
#section-home.active > .row {
  animation: dashRowIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#section-home.active > .row:nth-child(1) { animation-delay: 0.05s; }
#section-home.active > .row:nth-child(2) { animation-delay: 0.14s; }
#section-home.active > .row:nth-child(3) { animation-delay: 0.23s; }
#section-home.active > .row:nth-child(4) { animation-delay: 0.32s; }
#section-home.active > .row:nth-child(5) { animation-delay: 0.41s; }
#section-home.active > .row:nth-child(6) { animation-delay: 0.50s; }

@keyframes dashRowIn {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  #section-home.active > .row { animation: none; }
}

/* Pastel badges (priority / status) — scoped to .badge so buttons are unaffected */
.badge.bg-danger    { background-color: #F5A9A9 !important; color: #7f1d1d !important; }
.badge.bg-warning   { background-color: #FDE3A7 !important; color: #6b4e00 !important; }
.badge.bg-success   { background-color: #A7E0C0 !important; color: #14532d !important; }
.badge.bg-primary   { background-color: #9EC5FE !important; color: #1e3a8a !important; }
.badge.bg-info      { background-color: #A0E7E5 !important; color: #134e52 !important; }
.badge.bg-secondary { background-color: #CBD5E1 !important; color: #334155 !important; }
.badge.bg-dark      { background-color: #B8C0E0 !important; color: #1e293b !important; }
.badge.bg-upcoming  { background-color: #FFD8A8 !important; color: #7a4a00 !important; }
/* Thicker text for priority / status chips only */
.badge.badge-strong { font-weight: 750 !important; }

/* Chart filter bar */
.dash-filters {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.55rem 0.85rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}
.dash-filters .df-label { color: #475569; }
.dash-filters .df-toggle {
  min-width: 120px;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}
.dash-filters .df-toggle:hover { border-color: #cbd5e1; }
.dash-filters .df-toggle:focus,
.dash-filters .df-toggle.show {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.dash-filters .df-menu {
  max-height: 264px;
  overflow-y: auto;
  padding: 0.25rem;
  font-size: 0.85rem;
  border-color: #e2e8f0;
}
.dash-filters .df-check {
  display: flex;
  align-items: center;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.32rem 0.5rem;
  margin: 0;
}
.dash-filters .df-check:hover { background: #f1f5f9; }
.dash-filters .df-check input { cursor: pointer; }

/* Stat cards */
.stat-card {
  border: none;
  border-radius: 16px;
  padding: 1.35rem 1.5rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(79, 70, 229, 0.05);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12) !important;
}

.stat-card .fs-3 {
  font-size: 1.95rem !important;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: #0f172a;
}

.stat-card .text-muted {
  text-transform: uppercase;
  font-size: 0.68rem !important;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-card .icon-box {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff !important;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}

/* Solid gradient icon tiles (override Bootstrap translucent bg utilities) */
.stat-card .icon-box.text-info    { background: linear-gradient(135deg, #38bdf8, #0ea5e9) !important; }
.stat-card .icon-box.text-success { background: linear-gradient(135deg, #34d399, #059669) !important; }
.stat-card .icon-box.text-danger  { background: linear-gradient(135deg, #fb7185, #e11d48) !important; }
.stat-card .icon-box.text-warning { background: linear-gradient(135deg, #fbbf24, #f59e0b) !important; }

/* Dashboard section cards — lifted off the page so they stand out */
#section-home .card {
  border: 1px solid #dde4ed;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05) !important;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}

#section-home .card:hover {
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.13) !important;
  transform: translateY(-2px);
}

#section-home .card-header {
  background: #f8fafc !important;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e9eef4;
  border-left: 4px solid #94a3b8;
}

/* per-panel colour identity — keyed off the header icon colour,
   so each table reads as a distinct block instead of blending in */
#section-home .card-header:has(> i.text-danger)  { border-left-color: #e11d48; background: #fff1f2 !important; }
#section-home .card-header:has(> i.text-warning) { border-left-color: #f59e0b; background: #fffbeb !important; }
#section-home .card-header:has(> i.text-success) { border-left-color: #059669; background: #f0fdf4 !important; }

#section-home .card-header .badge {
  font-size: 0.7rem;
  border-radius: 20px;
}

#section-home .table thead th {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
}

#section-home .table tbody tr { transition: background 0.12s ease; }
#section-home .table tbody tr:hover td { background: #f8fafc; }
#section-home .table td { border-color: #f1f5f9; }

/* ── Tables ── */
.table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 600;
}

.table td { vertical-align: middle; }

/* ── ToDoList toolbar ── */
.todo-toolbar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  position: sticky;
  top: var(--topbar-height);
  z-index: 1020;
}

.todo-toolbar .input-group-text {
  background: #fff;
  border-right: none;
  color: #94a3b8;
}

.todo-toolbar .form-control {
  border-left: none;
  background: #fff;
}

.todo-toolbar .form-control:focus {
  box-shadow: none;
  border-color: #cbd5e1;
}

.btn-clear-filters {
  color: #ef4444;
  background: #fff;
  border: 1px solid #fecaca;
  white-space: nowrap;
}

.btn-clear-filters:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
}

/* ── ToDoList table — content-sized columns, single-line headers (the clean look) ── */
#section-todos .table {
  font-size: 0.82rem;
  table-layout: auto;
  width: 100%;
}

#section-todos .table th,
#section-todos .table td {
  padding: 0.32rem 0.28rem;   /* tighter horizontal gap so all columns + 3 action buttons fit */
}

#section-todos .table th {
  letter-spacing: 0;
  font-size: 0.75rem;
}

/* cells: single line with ellipsis (no wrapping clutter) */
#section-todos .table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* keep the sort label + arrow icon together on ONE line */
.xf-sort {
  min-width: 0;
  white-space: nowrap;
}
#section-todos .table thead .xf-header { flex-wrap: nowrap; gap: 4px; align-items: center; }

#section-todos .table-responsive {
  max-height: calc(100vh - var(--topbar-height) - 6.5rem);
  overflow-y: auto;
  overflow-x: hidden;          /* desktop: fits, no horizontal scroll */
}

/* Mobile/tablet: re-enable horizontal scroll so the wide table isn't crushed */
@media (max-width: 991.98px) {
  #section-todos .table-responsive { overflow-x: auto; }
  #section-todos .table { min-width: 900px; }   /* keep columns readable; swipe sideways */
}

#section-todos .table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #e8edf3;
  box-shadow: 0 2px 0 #cbd5e1;
}

/* card polish — exclude the Add/Edit form panel so its dropdowns aren't clipped */
#section-todos > .card:not(#todo-form-panel) {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
  overflow: hidden;
}

/* zebra striping + soft hover for easier scanning */
#section-todos .table tbody tr:nth-child(even) td { background: #f9fafc; }
#section-todos .table tbody tr:hover td { background: #eef2ff; }

/* Task Title may wrap so long names aren't cut off */
#section-todos .table td.todo-title-cell { white-space: normal; }

/* Assignee column — auto-sizes to fit the names (no clipping); names stack vertically */
#section-todos .table th.assignee-col,
#section-todos .table td.todo-assignee-cell {
  min-width: 96px;           /* sensible minimum; column grows to fit longer names */
}
#section-todos .table td.todo-assignee-cell {
  white-space: normal;       /* multiple names wrap onto new lines */
  line-height: 1.35;
}
#section-todos .table td.todo-assignee-cell .badge {
  display: inline-block;
  white-space: nowrap;       /* keep each full name (e.g. "Sumanth Kumar") on one line */
}

/* Actions — compact buttons so Edit + Copy + Delete all fit */
#section-todos .table td.todo-actions-cell {
  overflow: visible;
  white-space: nowrap;
}
#section-todos .table td.todo-actions-cell .btn {
  padding: 1px 5px;
  margin: 0 2px 0 0 !important;
  line-height: 1.1;
}
#section-todos .table td.todo-actions-cell .btn i { font-size: 0.78rem; }

/* ── Badges ── */
.badge { font-weight: 500; font-size: 0.76rem; }

/* Outline (no-fill) tag badges — used for Category & Assignee */
.badge.tag-outline {
  background: transparent !important;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-weight: 600;
}
.badge.tag-outline-info {
  background: transparent !important;
  border: 1px solid #7dd3fc;
  color: #0369a1;
  font-weight: 600;
}

/* ── Modals ── */
.modal-header {
  background: var(--primary);
  color: #fff;
  border-radius: 0.5rem 0.5rem 0 0;
}

.modal-header .btn-close { filter: invert(1); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
}

/* ── Responsive: collapse nav into dropdown ── */
@media (max-width: 991.98px) {
  #topbar {
    flex-wrap: wrap;
    align-items: center;
  }

  #nav-collapse {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    border-top: 1px solid rgba(49, 46, 129, 0.10);
    padding-bottom: 0.5rem;
  }

  #nav-collapse.show { display: flex; }

  #topbar .main-nav {
    flex-direction: column;
    margin: 0.5rem 0 0 0;
  }

  #topbar .main-nav .nav-link {
    border-bottom: none;
    border-left: 3px solid transparent;
  }

  #topbar .main-nav .nav-link.active {
    border-left-color: var(--primary);
  }
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}

.empty-state i { font-size: 3rem; margin-bottom: 0.75rem; display: block; }

/* ── Section pages hidden by default ── */
.page-section { display: none; }
.page-section.active { display: block; }

/* ── Completed todo ── */
.todo-done td:not(:last-child) {
  opacity: 0.5;
  text-decoration: line-through;
}

/* ── Cancelled todo ── */
.todo-cancelled td {
  opacity: 0.45;
  text-decoration: line-through;
  color: #999 !important;
}
.todo-cancelled td .badge {
  opacity: 0.6;
}

/* ── Excel-style column filters ── */
.xf-th {
  position: relative;
  white-space: nowrap;
}

.xf-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.xf-sort {
  cursor: pointer;
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.xf-sort i { flex-shrink: 0; }

.xf-btn {
  background: none;
  border: none;
  padding: 1px 5px;
  cursor: pointer;
  color: #64748b;
  font-size: 0.78rem;
  border-radius: 3px;
  line-height: 1.4;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.xf-btn:hover { color: var(--primary); background: rgba(79,70,229,0.08); }
.xf-btn.active { color: var(--primary); }

.xf-dropdown {
  display: none;
  position: fixed;
  z-index: 1060;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.13);
  min-width: 210px;
  font-size: 0.83rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #1e293b;
}

.xf-dropdown.open {
  display: flex;
  flex-direction: column;
}

.xf-dd-head {
  padding: 7px 12px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
  border-radius: 6px 6px 0 0;
}

.xf-dd-body { padding: 8px 12px; }

.xf-date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.xf-date-row label {
  width: 32px;
  font-size: 0.78rem;
  color: #64748b;
  margin: 0;
  flex-shrink: 0;
}

.xf-date-row input[type="date"] {
  flex: 1;
  font-size: 0.8rem;
  padding: 3px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  min-width: 0;
}

.xf-dd-search {
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
}

.xf-dd-search input {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  outline: none;
}

.xf-dd-search input:focus { border-color: var(--primary); }

.xf-dd-selall {
  padding: 5px 10px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

.xf-dd-selall label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-weight: 600;
  color: #374151;
}

.xf-dd-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 3px 0;
}

.xf-item {
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.xf-item:hover { background: #f1f5f9; }

.xf-item label {
  cursor: pointer;
  margin: 0;
  user-select: none;
}

.xf-dd-foot {
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  border-radius: 0 0 6px 6px;
}

/* ── Assignee multi-select (chips + checkbox dropdown) ── */
.ms-multi { position: relative; }

.ms-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: calc(1.5em + 0.5rem + 2px);
  height: auto;
  cursor: pointer;
  padding-right: 1.5rem;
}

.ms-control.is-invalid { border-color: #dc3545; }

.ms-placeholder { color: #6c757d; }

.ms-chips { display: contents; }

.ms-chip {
  background: #6c757d;
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1.5;
}

.ms-chip-x { cursor: pointer; opacity: 0.85; font-weight: 700; }
.ms-chip-x:hover { opacity: 1; }

.ms-caret {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.8rem;
  pointer-events: none;
}

.ms-dropdown {
  display: none;
  position: absolute;
  z-index: 1065;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.13);
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.ms-dropdown.open { display: block; }

.ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.ms-option:hover { background: #f1f5f9; }
.ms-option input { cursor: pointer; }
.ms-option label { cursor: pointer; margin: 0; flex: 1; }

.ms-option.ms-selectall {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #374151;
}

.ms-option.ms-selectall:hover { background: #eef2f7; }
