:root {
  --brand-primary: #5d3be3;
  --brand-secondary: #22c55e;
  --bg-main: #f0f2f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text-primary: #1e1b4b;
  --text-secondary: #64748b;
  --muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.15);

  --sidebar-grad: linear-gradient(180deg, #4c1d95 0%, #1e1b4b 100%);

  --metric-purple: #7c3aed;
  --metric-blue: #3b82f6;
  --metric-teal: #0ea5e9;
  --metric-cyan: #22d3ee;

  --bar-yellow: #fde68a;
  --bar-orange: #ffcc80;
  --bar-blue: #90caf9;
  --bar-green: #a5d6a7;
  --bar-purple: #ce93d8;
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
}

.full-gradient {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at -10% -10%, rgba(255,255,255,0.08), transparent 60%),
    radial-gradient(1200px 600px at 110% 10%, rgba(255,255,255,0.08), transparent 60%),
    linear-gradient(135deg, #5d3be3 0%, #7c3aed 50%, #0ea5e9 100%);
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.btn {
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  box-shadow: 0 10px 20px rgba(93, 59, 227, 0.35);
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface-2);
}

.input::placeholder { color: var(--muted); }

.top-userbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.top-userbar-left {
  flex: 1;
  min-width: 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: 10px;
  color: var(--text-secondary);
  max-width: 520px;
}

.search-input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
}

.search-input::placeholder {
  color: #94a3b8;
}

.top-userbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.divider-vertical {
  width: 1px;
  height: 22px;
  background: var(--border-color);
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--text-primary);
}

.profile-btn:hover {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(226, 232, 240, 0.9);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  font-weight: 700;
  font-size: 12px;
  color: #334155;
}

.profile-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.profile-caret {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
}

.layout {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

.sidebar {
  width: 260px;
  background: var(--sidebar-grad);
  padding: 24px 16px;
  flex-shrink: 0;
  color: white;
  display: flex;
  flex-direction: column;
}

.content {
  flex-grow: 1;
  padding: 24px 32px;
  overflow-y: auto;
  min-width: 0;    /* prevent flex children from overflowing */
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: flex-start;
}

.metric {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  color: white;
  box-shadow: var(--shadow-sm);
}

.metric .icon-box {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.metric .label {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.metric .value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.metric.purple { background: #8b5cf6; }
.metric.blue { background: #3b82f6; }
.metric.teal { background: #0ea5e9; }
.metric.cyan { background: #2dd4bf; }

.main-panel {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

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

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-select {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 500;
}

.date-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--text-primary);
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 12px 20px;
  border-top: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.month-item {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
}

.month-item.active {
  font-weight: 600;
  color: var(--text-primary);
}

.year-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.timeline-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.timeline-grid {
  display: flex;
  flex-direction: column;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  overflow: hidden;
  background-image: linear-gradient(to right, #f1f5f9 1px, transparent 1px);
  background-size: 40px 100%;
}

.timeline-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  border-bottom: 1px solid #f1f5f9;
  background: white;
}

.row-info {
  padding: 12px 16px;
  border-right: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fafafa;
}

.row-title {
  font-weight: 700;
  font-size: 14px;
}

.row-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

.row-content {
  padding: 6px 0;
  position: relative;
  min-height: 60px;
  display: flex;
  align-items: center;
}

.timeline-bar {
  cursor: pointer;
  height: 40px;
  border-radius: 4px;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  margin: 0 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.timeline-bar .bar-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-bar .bar-dates {
  font-size: 10px;
  opacity: 0.7;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-right: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f43f5e;
}

.badge-active {
  background: #2dd4bf;
  color: white;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.aside-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chart-section, .activities-section {
  background: white;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border-color);
}

.section-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 16px;
}

.section-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-tools .divider {
  opacity: 0.3;
}

.section-tools .tool-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.section-tools .tool-icon svg {
  opacity: 0.8;
}

/* ── Responsive: Tablet ─────────────────────────────────── */
@media (max-width: 1100px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ── Responsive: Mobile (≤768px) ───────────────────────── */
@media (max-width: 768px) {
  /* Sidebar: off-screen by default, overlay on toggle */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 24px 16px !important;
  }
  html.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }
  /* Override ALL desktop collapsed rules on mobile */
  html.sidebar-is-collapsed .sidebar {
    width: 280px !important;
    padding: 24px 16px !important;
    transform: translateX(-100%);
  }
  html.sidebar-mobile-open.sidebar-is-collapsed .sidebar {
    transform: translateX(0);
  }
  html.sidebar-is-collapsed .sidebar .sidebar-client-selector,
  html.sidebar-is-collapsed .sidebar .nav-group-toggle .nav-group-label,
  html.sidebar-is-collapsed .sidebar .nav-group-toggle .nav-chevron,
  html.sidebar-is-collapsed .sidebar .menu-item .item-content span:not(.icon),
  html.sidebar-is-collapsed .sidebar .logout-btn span:not(.icon),
  html.sidebar-is-collapsed .sidebar .version-badge { display: revert !important; }
  html.sidebar-is-collapsed .sidebar .menu-item .item-content,
  html.sidebar-is-collapsed .sidebar .logout-btn,
  html.sidebar-is-collapsed .sidebar .nav-group-toggle { justify-content: flex-start !important; }
  /* Sidebar desktop toggle hidden */
  .sidebar-toggle { display: none !important; }

  /* Overlay behind sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
  }
  html.sidebar-mobile-open .sidebar-overlay {
    display: block;
  }

  /* Hamburger button visible */
  .mobile-hamburger {
    display: flex !important;
  }

  /* Content fills full width */
  .content {
    padding: 12px 14px;
    width: 100%;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Top userbar: hamburger left, icons right, single row */
  .top-userbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .top-userbar-left {
    flex: 0 0 auto;
    min-width: 0;
  }
  .top-userbar-right {
    flex: 1;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  /* Hide non-essential icons on mobile */
  .top-userbar-right .divider-vertical {
    display: none;
  }
  /* Hide profile name on mobile */
  .profile-name {
    display: none;
  }
  .profile-caret {
    display: none;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  /* Stat cards: 2 per row */
  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .metric {
    padding: 12px;
    gap: 8px;
  }
  .metric .value {
    font-size: 16px;
  }
  .metric .label {
    font-size: 10px;
  }
  .metric .icon-box {
    width: 28px;
    height: 28px;
  }

  /* Grid: single column */
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Tables: horizontal scroll */
  .table-responsive,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Form grid: single column */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Month selector / calendar header */
  .month-selector,
  .calendar-header {
    gap: 6px;
    flex-wrap: wrap;
  }

  /* Timeline: allow horizontal scroll */
  .timeline-grid {
    min-width: 720px;
  }
  .timeline-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Search */
  .search {
    max-width: 100%;
  }

  /* Filter dropdowns stack */
  .filter-select {
    font-size: 12px;
    padding: 6px 8px;
    min-width: 0;
    width: auto;
    flex: 1;
    max-width: 140px;
  }

  /* Breadcrumbs: smaller */
  .breadcrumbs {
    font-size: 11px;
  }
  .bc-current {
    max-width: 180px;
  }
}

/* ── Responsive: Small phone (≤480px) ──────────────────── */
@media (max-width: 480px) {
  .content {
    padding: 10px;
  }

  /* Stat cards: stack */
  .cards {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .metric .value {
    font-size: 14px;
  }

  .top-userbar-right .icon-btn {
    width: 32px;
    height: 32px;
  }

  .divider-vertical {
    display: none;
  }
}

/* ── Hamburger button (hidden on desktop) ──────────────── */
.mobile-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--brand-primary);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 10;
}

/* ── Sidebar overlay (hidden on desktop) ───────────────── */
.sidebar-overlay {
  display: none;
}


