:root {
    --bg: #0b1220;
    --surface: #111a2e;
    --surface-2: #16223d;
    --border: #1f2c4a;
    --text: #e6ecf5;
    --muted: #95a3bd;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --sidebar: #0e1729;
    --active-bg: #2563eb;
    --active-text: #ffffff;
    --shadow: 0 4px 16px rgba(0,0,0,.35);
  }
  body.light-theme {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f1f4fa;
    --border: #e5e9f2;
    --text: #0f172a;
    --muted: #64748b;
    --sidebar: #ffffff;
    --shadow: 0 4px 16px rgba(15,23,42,.06);
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    transition: background .2s, color .2s;
  }
  a { text-decoration: none; color: inherit; }

  /* Layout */
  .app { display: flex; min-height: 100vh; }
  .sidebar {
    width: 240px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .sidebar::-webkit-scrollbar { width: 6px; }
  .sidebar::-webkit-scrollbar-track { background: transparent; }
  .sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  .sidebar::-webkit-scrollbar-thumb:hover { background: var(--muted); }
  .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
  .brand-logo {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg,#2563eb,#3b82f6);
    display: grid; place-items: center; color: #fff;
  }
  .brand-name { font-weight: 700; font-size: 1.05rem; }
  .nav-link-custom {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 500; font-size: .92rem;
    margin-bottom: 4px; cursor: pointer;
    transition: background .15s, color .15s;
  }
  .nav-link-custom i { width: 18px; text-align: center; }
  .nav-link-custom:hover { background: var(--surface-2); color: var(--text); }
  .nav-link-custom.active { background: var(--active-bg); color: var(--active-text); }
  .sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

  .main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
  }
  .topbar-left { display: flex; align-items: center; gap: 12px; }
  .hamburger { background: transparent; border: 0; color: var(--text); font-size: 1.2rem; display: none; }
  .topbar-right { display: flex; align-items: center; gap: 14px; }
  .theme-toggle {
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); padding: 8px 14px; border-radius: 10px;
    font-size: .88rem; display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer; transition: background .15s;
  }
  .theme-toggle:hover { background: var(--border); }
  .profile { display: flex; align-items: center; gap: 10px; }
  .avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg,#8b5cf6,#2563eb);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  }
  .profile-name { font-size: .88rem; font-weight: 600; line-height: 1.1; }
  .profile-role { font-size: .75rem; color: var(--muted); }

  .content { padding: 24px; }
  .welcome h2 { font-weight: 700; font-size: 1.5rem; margin: 0 0 4px; }
  .welcome p { color: var(--muted); margin: 0; font-size: .9rem; }

  .card-x {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: var(--shadow);
    height: 100%;
  }
  .card-title-x {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
  }
  .card-title-x h6 {
    margin: 0; font-size: .78rem; letter-spacing: .08em;
    color: var(--muted); text-transform: uppercase; font-weight: 700;
  }
  .view-all { font-size: .82rem; color: var(--primary); font-weight: 600; }
  .view-all:hover { color: var(--primary-hover); }

  /* Continue learning */
  .cl-row { display: flex; gap: 14px; align-items: center; }
  .cl-thumb {
    width: 72px; height: 72px; border-radius: 12px;
    background: var(--surface-2); display: grid; place-items: center;
    color: var(--primary); font-size: 1.6rem; flex-shrink: 0;
  }
  .cl-body { flex: 1; min-width: 0; }
  .cl-title { font-weight: 600; margin: 0 0 2px; }
  .cl-sub { color: var(--muted); font-size: .82rem; margin-bottom: 8px; }
  .progress { background: var(--surface-2); height: 6px; border-radius: 99px; }
  .progress-bar { background: var(--primary); border-radius: 99px; }
  .btn-primary-x {
    background: var(--primary); color: #fff; border: 0;
    padding: 8px 18px; border-radius: 8px; font-weight: 600; font-size: .85rem;
    transition: background .15s;
  }
  .btn-primary-x:hover { background: var(--primary-hover); color: #fff; }

  /* Module card */
  .module {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px; padding: 16px;
    height: 100%;
    transition: transform .15s, border-color .15s;
    cursor: pointer;
  }
  .module:hover { transform: translateY(-2px); border-color: var(--primary); }
  .module-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: grid; place-items: center; font-size: 1.1rem;
    margin-bottom: 10px;
  }
  .ic-blue { background: rgba(37,99,235,.15); color: #3b82f6; }
  .ic-orange { background: rgba(245,158,11,.15); color: #f59e0b; }
  .ic-purple { background: rgba(139,92,246,.15); color: #a78bfa; }
  .ic-green { background: rgba(34,197,94,.15); color: #22c55e; }
  .module h6 { margin: 0 0 4px; font-weight: 700; font-size: .95rem; }
  .module p { color: var(--muted); font-size: .78rem; margin: 0 0 10px; min-height: 32px; }
  .module .pct { font-size: .78rem; color: var(--muted); margin-top: 6px; }

  /* Donut */
  .donut-wrap { display: flex; align-items: center; gap: 18px; }
  .donut { position: relative; width: 130px; height: 130px; flex-shrink: 0; }
  .donut-label {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
  }
  .donut-label strong { font-size: 1.4rem; }
  .donut-label span { font-size: .7rem; color: var(--muted); }
  .legend { font-size: .82rem; }
  .legend div { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .dot { width: 10px; height: 10px; border-radius: 50%; }
  .legend small { color: var(--muted); font-size: .72rem; display: block; }

  /* Achievements */
  .ach { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .ach:last-child { border-bottom: 0; }
  .ach-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
  .ach-body { flex: 1; min-width: 0; }
  .ach-body h6 { margin: 0; font-size: .88rem; font-weight: 600; }
  .ach-body small { color: var(--muted); font-size: .75rem; }
  .xp { color: var(--success); font-weight: 700; font-size: .85rem; }

  /* Chart */
  .chart-svg { width: 100%; height: 200px; }
  .chart-grid { stroke: var(--border); stroke-width: 1; }
  .chart-axis { fill: var(--muted); font-size: 10px; }

  /* Nested dropdown */
  .nav-group { margin-bottom: 4px; }
  .nav-toggle {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 500; font-size: .92rem;
    background: transparent; border: 0; cursor: pointer; text-align: left;
    transition: background .15s, color .15s;
  }
  .nav-toggle i.lead-icon { width: 18px; text-align: center; }
  .nav-toggle .chev { margin-left: auto; font-size: .7rem; transition: transform .2s; }
  .nav-toggle:not(.collapsed) .chev { transform: rotate(90deg); }
  .nav-toggle:hover { background: var(--surface-2); color: var(--text); }

  /* Status dot */
  .status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
    position: relative;
    vertical-align: middle;
    transform: translateY(-1px);
    z-index: 1;
  }
  .status-dot::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.25);
    filter: blur(4px);
    z-index: -1;
    animation: glow-pulse 2.5s ease-in-out infinite;
  }
  .status-dot.valid {
    background: #22c55e;
    box-shadow:
      0 0 2px 1px rgba(34, 197, 94, 0.6),
      0 0 8px 2px rgba(34, 197, 94, 0.35),
      0 0 16px 4px rgba(34, 197, 94, 0.15),
      inset 0 0 3px 1px rgba(255, 255, 255, 0.4);
    animation: breathe 2.5s ease-in-out infinite;
  }
  @keyframes breathe {
    0%, 100% {
      transform: translateY(-1px) scale(1);
      opacity: 1;
    }
    50% {
      transform: translateY(-1px) scale(1.15);
      opacity: 0.85;
    }
  }
  @keyframes glow-pulse {
    0%, 100% {
      opacity: 0.5;
      transform: scale(1);
    }
    50% {
      opacity: 1;
      transform: scale(1.4);
    }
  }
  .submenu { list-style: none; padding: 4px 0 4px 10px; margin: 0; border-left: 1px solid var(--border); margin-left: 18px; }
  .submenu .nav-toggle, .submenu .sub-link {
    font-size: .85rem; padding: 8px 10px; border-radius: 8px;
    color: var(--muted); display: flex; align-items: center; gap: 10px;
    cursor: pointer; transition: background .15s, color .15s;
  }
  .submenu .sub-link { text-decoration: none; }
  .submenu .nav-toggle:hover, .submenu .sub-link:hover { background: var(--surface-2); color: var(--text); }
  .submenu .sub-link.active { background: var(--active-bg); color: var(--active-text); }
  .submenu .sub-link i { width: 14px; font-size: .55rem; text-align: center; }
  .submenu .submenu { margin-left: 12px; }

  /* Mobile */
  @media (max-width: 991.98px) {
    .sidebar {
      position: fixed; left: -260px; top: 0; z-index: 100;
      transition: left .25s;
      overflow-y: auto;
    }
    .sidebar.open { left: 0; }
    .hamburger { display: inline-block; }
    .profile-text { display: none; }
  }
  .backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99;
  }
  .backdrop.show { display: block; }